1.18-pre -> 1.18.2

This commit is contained in:
Sollace 2022-03-26 21:34:15 +02:00
parent ddbf75a44f
commit 9f46fe9270
37 changed files with 187 additions and 121 deletions

View file

@ -2,11 +2,11 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.18-pre8
yarn_mappings=1.18-pre8+build.2
loader_version=0.12.5
fabric_version=0.43.0+1.18
# check these on https://fabricmc.net/develop
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.1
loader_version=0.13.3
fabric_version=0.47.8+1.18.2
# Mod Properties
group=com.minelittlepony
@ -15,6 +15,6 @@ org.gradle.daemon=false
description=Magical Abilities for Mine Little Pony!
# Dependencies
modmenu_version=2.0.0-beta.7
minelp_version=4.4.1
modmenu_version=3.1.0
minelp_version=4.4.4
kirin_version=1.10.0

View file

@ -2,41 +2,41 @@ package com.minelittlepony.unicopia;
import com.minelittlepony.unicopia.item.toxin.Toxics;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public interface UTags {
Tag<Item> APPLES = item("apples");
Tag<Item> FRESH_APPLES = item("fresh_apples");
TagKey<Item> APPLES = item("apples");
TagKey<Item> FRESH_APPLES = item("fresh_apples");
Tag<Item> FALLS_SLOWLY = item("falls_slowly");
TagKey<Item> FALLS_SLOWLY = item("falls_slowly");
Tag<Item> MAGIC_FEATHERS = item("magic_feathers");
TagKey<Item> MAGIC_FEATHERS = item("magic_feathers");
Tag<Item> SHADES = item("shades");
TagKey<Item> SHADES = item("shades");
Tag<Block> FRAGILE = block("fragile");
Tag<Block> INTERESTING = block("interesting");
TagKey<Block> FRAGILE = block("fragile");
TagKey<Block> INTERESTING = block("interesting");
Tag<Block> CRYSTAL_HEART_BASE = block("crystal_heart_base");
Tag<Block> CRYSTAL_HEART_ORNAMENT = block("crystal_heart_ornament");
TagKey<Block> CRYSTAL_HEART_BASE = block("crystal_heart_base");
TagKey<Block> CRYSTAL_HEART_ORNAMENT = block("crystal_heart_ornament");
Tag<EntityType<?>> TRANSFORMABLE_ENTITIES = entity("transformable");
TagKey<EntityType<?>> TRANSFORMABLE_ENTITIES = entity("transformable");
static Tag<Item> item(String name) {
return TagFactory.ITEM.create(new Identifier("unicopia", name));
static TagKey<Item> item(String name) {
return TagKey.of(Registry.ITEM_KEY, new Identifier("unicopia", name));
}
static Tag<Block> block(String name) {
return TagFactory.BLOCK.create(new Identifier("unicopia", name));
static TagKey<Block> block(String name) {
return TagKey.of(Registry.BLOCK_KEY, new Identifier("unicopia", name));
}
static Tag<EntityType<?>> entity(String name) {
return TagFactory.ENTITY_TYPE.create(new Identifier("unicopia", name));
static TagKey<EntityType<?>> entity(String name) {
return TagKey.of(Registry.ENTITY_TYPE_KEY, new Identifier("unicopia", name));
}
static void bootstrap() {

View file

@ -2,6 +2,7 @@ package com.minelittlepony.unicopia;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.PersistentState;
import net.minecraft.world.dimension.DimensionType;
@ -29,12 +30,14 @@ public class WorldTribeManager extends PersistentState {
return tag;
}
@SuppressWarnings("deprecation")
public static String nameFor(DimensionType dimension) {
return "unicopia:tribes" + dimension.getSuffix();
public static String nameFor(RegistryEntry<DimensionType> dimension) {
if (dimension.matchesKey(DimensionType.THE_END_REGISTRY_KEY)) {
return "unicopia:tribes_end";
}
return "unicopia:tribes";
}
public static WorldTribeManager forWorld(ServerWorld world) {
return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.getDimension()));
return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.method_40134()));
}
}

View file

@ -10,10 +10,10 @@ import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.RayTraceHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -53,7 +53,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
.orElse(e) : e;
}).orElseGet(() -> trace.getBlockPos().map(pos -> {
if (!iplayer.getWorld().isAir(pos)) {
return new FallingBlockEntity(player.getEntityWorld(), 0, 0, 0, iplayer.getWorld().getBlockState(pos));
return MixinFallingBlockEntity.createInstance(player.getEntityWorld(), 0, 0, 0, iplayer.getWorld().getBlockState(pos));
}
return null;
}).orElse(null));

View file

@ -154,7 +154,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
public static void spawnEffectAround(Entity source, BlockPos center, double radius, double range) {
BlockPos.iterate(center.add(-radius, -radius, -radius), center.add(radius, radius, radius)).forEach(i -> {
double dist = Math.sqrt(i.getSquaredDistance(source.getX(), source.getY(), source.getZ(), true));
double dist = Math.sqrt(i.getSquaredDistance(source.getX(), source.getY(), source.getZ()));
if (dist <= radius) {
spawnEffect(source.world, i, dist, range);

View file

@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.util.RayTraceHelper;
@ -105,7 +106,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
}
Vec3d pos = Vec3d.ofBottomCenter(bpos);
FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos));
FallingBlockEntity e = MixinFallingBlockEntity.createInstance(world, pos.x, pos.y, pos.z, world.getBlockState(bpos));
world.removeBlock(bpos, true);
e.setOnGround(false);
e.timeFalling = Integer.MIN_VALUE;
@ -115,5 +116,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
apply.accept(e);
}
world.spawnEntity(e);
e.updateVelocity(HORIZONTAL_VARIANCE, pos);
}
}

View file

@ -1,10 +1,9 @@
package com.minelittlepony.unicopia.ability.magic.spell.effect;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.UTags;
@ -15,12 +14,15 @@ import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.Util;
import net.minecraft.world.World;
/**
* Transforms whatever entity it strikes into a random other entity.
@ -40,7 +42,7 @@ public class TransformationSpell extends AbstractSpell implements ProjectileSpel
if (projectile.world.isClient) {
return;
}
pickType(entity.getType(), entity.world.random).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> {
pickType(entity.getType(), entity.world).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> {
entity.playSound(USounds.SPELL_TRANSFORM_TRANSMUTE_ENTITY, 1, 1);
}, () -> {
ParticleUtils.spawnParticles(ParticleTypes.SMOKE, entity, 20);
@ -62,8 +64,8 @@ public class TransformationSpell extends AbstractSpell implements ProjectileSpel
}
@SuppressWarnings("unchecked")
private <T extends MobEntity> Optional<EntityType<T>> pickType(EntityType<?> except, Random random) {
Set<EntityType<?>> options = new HashSet<>(UTags.TRANSFORMABLE_ENTITIES.values());
private <T extends MobEntity> Optional<EntityType<T>> pickType(EntityType<?> except, World world) {
Set<EntityType<?>> options = Registries.valuesForTag(world, UTags.TRANSFORMABLE_ENTITIES).collect(Collectors.toSet());
if (except.getSpawnGroup() == SpawnGroup.MONSTER) {
options.removeIf(t -> t.getSpawnGroup() == SpawnGroup.MONSTER);
} else {
@ -72,6 +74,6 @@ public class TransformationSpell extends AbstractSpell implements ProjectileSpel
if (options.size() <= 1) {
return options.stream().findFirst().map(t -> (EntityType<T>)t);
}
return Optional.ofNullable((EntityType<T>)Util.getRandom(new ArrayList<>(options), random));
return Optional.ofNullable((EntityType<T>)Util.getRandom(new ArrayList<>(options), world.random));
}
}

View file

@ -11,7 +11,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.state.property.Property;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.world.World;
/**
@ -66,7 +66,7 @@ class BlockStateMap implements BlockStateConverter {
return add(StateMapping.replaceBlock(from, to));
}
public Builder replaceBlock(Tag<Block> from, Block to) {
public Builder replaceBlock(TagKey<Block> from, Block to) {
return add(StateMapping.replaceBlock(from, to));
}

View file

@ -6,13 +6,15 @@ import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Property;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.world.World;
interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockState, BlockState> {
@ -49,13 +51,13 @@ interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockSta
(w, s) -> Blocks.AIR.getDefaultState());
}
static StateMapping replaceBlock(Tag<Block> tag, Block to) {
static StateMapping replaceBlock(TagKey<Block> tag, Block to) {
return build(
s -> s.isIn(tag),
(w, s) -> to.getDefaultState(),
s -> build(
p -> p.isOf(to),
(w, p) -> tag.getRandom(w.random).getDefaultState()
(w, p) -> Registries.entriesForTag(w, tag).getRandom(w.random).get().value().getDefaultState()
)
);
}

View file

@ -78,7 +78,7 @@ public class KeyBindingsHandler {
} else {
for (Binding i : keys.keySet()) {
AbilitySlot slot = keys.get(i);
if (slot == AbilitySlot.PRIMARY && client.options.keySneak.isPressed() && abilities.isFilled(AbilitySlot.PASSIVE)) {
if (slot == AbilitySlot.PRIMARY && client.options.sneakKey.isPressed() && abilities.isFilled(AbilitySlot.PASSIVE)) {
slot = AbilitySlot.PASSIVE;
}
if (slot == AbilitySlot.PRIMARY && !abilities.isFilled(slot)) {

View file

@ -78,7 +78,7 @@ public class DismissSpellScreen extends GameGui {
}
@Override
public boolean isPauseScreen() {
public boolean shouldPause() {
return false;
}

View file

@ -96,7 +96,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
@Override
public void finish() {
finished = true;
onClose();
close();
}
@Override

View file

@ -113,7 +113,7 @@ public class UHud extends DrawableHelper {
RenderSystem.enableBlend();
RenderSystem.setShaderTexture(0, HUD_TEXTURE);
boolean swap = client.options.keySneak.isPressed();
boolean swap = client.options.sneakKey.isPressed();
slots.forEach(slot -> slot.renderBackground(matrices, abilities, swap, tickDelta));
slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta));
@ -271,7 +271,7 @@ public class UHud extends DrawableHelper {
void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) {
stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> {
RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player), client.options.keySneak.isPressed()));
RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player), client.options.sneakKey.isPressed()));
drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v);
RenderSystem.setShaderTexture(0, HUD_TEXTURE);
});

View file

@ -27,10 +27,10 @@ public abstract class AbstractGeometryBasedParticle extends Particle {
int light = getBrightness(tickDelta);
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT);
buffer.vertex(corners[0].getX(), corners[0].getY(), corners[0].getZ()).texture(0, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
buffer.vertex(corners[1].getX(), corners[1].getY(), corners[1].getZ()).texture(1, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
buffer.vertex(corners[2].getX(), corners[2].getY(), corners[2].getZ()).texture(1, 1).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
buffer.vertex(corners[3].getX(), corners[3].getY(), corners[3].getZ()).texture(0, 1).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
buffer.vertex(corners[0].getX(), corners[0].getY(), corners[0].getZ()).texture(0, 0).color(red, green, blue, alpha).light(light).next();
buffer.vertex(corners[1].getX(), corners[1].getY(), corners[1].getZ()).texture(1, 0).color(red, green, blue, alpha).light(light).next();
buffer.vertex(corners[2].getX(), corners[2].getY(), corners[2].getZ()).texture(1, 1).color(red, green, blue, alpha).light(light).next();
buffer.vertex(corners[3].getX(), corners[3].getY(), corners[3].getZ()).texture(0, 1).color(red, green, blue, alpha).light(light).next();
te.draw();
}
@ -39,7 +39,7 @@ public abstract class AbstractGeometryBasedParticle extends Particle {
int light = getBrightness(tickDelta);
for (Vec3f corner : corners) {
buffer.vertex(corner.getX(), corner.getY(), corner.getZ()).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
buffer.vertex(corner.getX(), corner.getY(), corner.getZ()).color(red, green, blue, alpha).light(light).next();
}
}

View file

@ -27,10 +27,10 @@ public class MagicParticle extends SpriteBillboardParticle {
scale = random.nextFloat() * 0.12F;
maxAge = (int)(Math.random() * 10) + 20;
colorRed = color.getX();
colorGreen = color.getY();
colorBlue = color.getZ();
colorAlpha = alpha;
red = color.getX();
green = color.getY();
blue = color.getZ();
this.alpha = alpha;
}
public MagicParticle(MagicParticleEffect effect, SpriteProvider provider, ClientWorld w, double x, double y, double z, double vX, double vY, double vZ) {

View file

@ -50,7 +50,7 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl
corner.add(x, y, z);
}
float alpha = colorAlpha * (1 - ((float)age / maxAge));
float alpha = this.alpha * (1 - ((float)age / maxAge));
renderQuad(te, buffer, corners, alpha, tickDelta);
}

View file

@ -120,7 +120,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
}
float getAlpha() {
return colorAlpha * (1 - ((float)age / maxAge));
return alpha * (1 - ((float)age / maxAge));
}
boolean tick() {

View file

@ -43,9 +43,9 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
super(effect, world, x, y, z, velocityX, velocityY, velocityZ);
setMaxAge(70);
colorRed = world.random.nextFloat();
colorGreen = world.random.nextFloat();
colorBlue = world.random.nextFloat();
red = world.random.nextFloat();
green = world.random.nextFloat();
blue = world.random.nextFloat();
}
@Override
@ -72,9 +72,9 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
public void setAttribute(int key, Object value) {
if (key == 1) {
int tint = (int)value;
colorRed = Color.r(tint);
colorGreen = Color.g(tint);
colorBlue = Color.b(tint);
red = Color.r(tint);
green = Color.g(tint);
blue = Color.b(tint);
}
}
@Override
@ -100,13 +100,13 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
@Override
protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) {
float alpha = colorAlpha * getAlphaScale();
float alpha = this.alpha * getAlphaScale();
float angle = MathHelper.lerp(tickDelta, prevRotationAngle, rotationAngle);
for (int i = 0; i < TEXTURES.length; i++) {
RenderSystem.setShaderTexture(0, TEXTURES[i]);
RenderSystem.setShaderColor(colorRed, colorGreen, colorBlue, alpha);
RenderSystem.setShaderColor(red, green, blue, alpha);
Vec3f[] corners = new Vec3f[]{
new Vec3f(-1, -1, 0),

View file

@ -49,10 +49,10 @@ public class SphereParticle extends Particle implements Attachment {
super(w, x, y, z);
this.parameters = parameters;
this.radius = parameters.getRadius();
this.colorRed = parameters.getColor().getX() / 255F;
this.colorGreen = parameters.getColor().getY() / 255F;
this.colorBlue = parameters.getColor().getZ() / 255F;
this.colorAlpha = parameters.getAlpha();
this.red = parameters.getColor().getX() / 255F;
this.green = parameters.getColor().getY() / 255F;
this.blue = parameters.getColor().getZ() / 255F;
this.alpha = parameters.getAlpha();
setMaxAge(10);
}
@ -82,12 +82,12 @@ public class SphereParticle extends Particle implements Attachment {
}
if (key == 1) {
int tint = (int)value;
colorRed = Color.r(tint);
colorGreen = Color.g(tint);
colorBlue = Color.b(tint);
red = Color.r(tint);
green = Color.g(tint);
blue = Color.b(tint);
}
if (key == 2) {
colorAlpha = (float)value;
alpha = (float)value;
}
}
@ -121,12 +121,12 @@ public class SphereParticle extends Particle implements Attachment {
@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
if (colorAlpha <= 0 || radius <= 0) {
if (alpha <= 0 || radius <= 0) {
return;
}
float[] color = ColorHelper.changeSaturation(colorRed, colorGreen, colorBlue, 4);
RenderSystem.setShaderColor(color[0], color[1], color[2], colorAlpha / 3F);
float[] color = ColorHelper.changeSaturation(red, green, blue, 4);
RenderSystem.setShaderColor(color[0], color[1], color[2], alpha / 3F);
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
VertexConsumer buffer = immediate.getBuffer(RenderLayers.getMagicNoColor());

View file

@ -26,7 +26,7 @@ import net.minecraft.world.World;
public class CastSpellEntity extends LightEmittingEntity implements Caster<LivingEntity>, WeaklyOwned<LivingEntity> {
private static final TrackedData<Float> GRAVITY = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private static final LevelStore LEVELS = Levelled.fixed(0);

View file

@ -38,8 +38,8 @@ import net.minecraft.nbt.NbtElement;
import net.minecraft.world.World;
public class Creature extends Living<LivingEntity> implements WeaklyOwned<LivingEntity> {
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<NbtCompound> MASTER = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private static final TrackedData<NbtCompound> MASTER = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
public static final TrackedData<Float> GRAVITY = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final LevelStore LEVELS = Levelled.fixed(0);

View file

@ -6,7 +6,9 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
public interface DynamicLightSource {
int getLightLevel();
default int getLightLevel() {
return 0;
}
static final class LightEmitter<T extends Entity & DynamicLightSource> {
@Nullable

View file

@ -209,12 +209,6 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource,
return false;
}
@Override
public void setRemoved(RemovalReason reason) {
super.setRemoved(reason);
emitter.remove();
}
@Override
public void onRemoved() {
super.onRemoved();

View file

@ -17,12 +17,6 @@ public abstract class LightEmittingEntity extends Entity implements DynamicLight
emitter.tick();
}
@Override
public void setRemoved(RemovalReason reason) {
super.setRemoved(reason);
emitter.remove();
}
@Override
public void onRemoved() {
super.onRemoved();

View file

@ -8,13 +8,15 @@ import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.item.GemstoneItem;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.util.Registries;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.tag.ItemTags;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Util;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
@ -36,7 +38,7 @@ public interface UTradeOffers {
TradeOfferHelper.registerWanderingTraderOffers(1, factories -> {
factories.add(buyTiered(UItems.GEMSTONE, 30, UItems.GOLDEN_FEATHER, 1, UItems.GOLDEN_WING, 1, 30, 2, 0.05F));
factories.add((e, rng) -> new TradeOffer(new ItemStack(UItems.GEMSTONE, 3), GemstoneItem.enchant(UItems.GEMSTONE.getDefaultStack(), SpellType.REGISTRY.getRandom(rng)), 20, 1, 0.05F));
factories.add((e, rng) -> new TradeOffer(new ItemStack(UItems.GEMSTONE, 3), GemstoneItem.enchant(UItems.GEMSTONE.getDefaultStack(), SpellType.REGISTRY.getRandom(rng).get().value()), 20, 1, 0.05F));
factories.add(buy(UItems.GEMSTONE, 20, UItems.HAY_FRIES, 5, 50, 3, 0.06F));
factories.add(buy(Items.WHEAT, 17, UItems.HAY_BURGER, 1, 10, 6, 0.08F));
factories.add(buy(ItemTags.SMALL_FLOWERS, 2, UItems.DAFFODIL_DAISY_SANDWICH, 1, 10, 6, 0.08F));
@ -64,17 +66,21 @@ public interface UTradeOffers {
return (e, rng) -> new TradeOffer(new ItemStack(item, count), new ItemStack(intermediate, intermediatCount), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange);
}
private static TradeOffers.Factory buy(Tag<Item> item, int count, Item returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange);
private static TradeOffers.Factory buy(TagKey<Item> item, int count, Item returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(random(e, item, rng), count), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange);
}
@SuppressWarnings("unused")
private static TradeOffers.Factory buy(Tag<Item> item, int count, Tag<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem.getRandom(rng), returnCount), maxUses, experience, priceChange);
private static TradeOffers.Factory buy(TagKey<Item> item, int count, TagKey<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(random(e, item, rng), count), new ItemStack(random(e, returnItem, rng), returnCount), maxUses, experience, priceChange);
}
private static TradeOffers.Factory buy(Item item, int count, Tag<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item, count), new ItemStack(returnItem.getRandom(rng), returnCount), maxUses, experience, priceChange);
private static TradeOffers.Factory buy(Item item, int count, TagKey<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item, count), new ItemStack(random(e, returnItem, rng), returnCount), maxUses, experience, priceChange);
}
private static Item random(Entity e, TagKey<Item> item, Random rng) {
return Registries.entriesForTag(e.world, item).getRandom(rng).get().value();
}
static class JarredItemTradeOfferFactory implements TradeOffers.Factory {

View file

@ -6,6 +6,7 @@ import java.util.Optional;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinFallingBlock;
import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.block.Block;
@ -71,9 +72,9 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
BlockState lowerState = state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER);
BlockState upperState = state.with(DoorBlock.HALF, DoubleBlockHalf.UPPER);
context.attachExtraEntity(configure(new FallingBlockEntity(entity.world, entity.getX(), entity.getY(), entity.getZ(), upperState), block));
context.attachExtraEntity(configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), upperState), block));
return configure(new FallingBlockEntity(entity.world, entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block);
return configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block);
}
if (block instanceof BlockEntityProvider) {
@ -91,7 +92,7 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
boolean logged = entity.world.isWater(entity.getBlockPos());
if (state.get(Properties.WATERLOGGED) != logged) {
entity = new FallingBlockEntity(entity.world, entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged));
entity = MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged));
spell.getDisguise().setAppearance(entity);
return;
}

View file

@ -78,7 +78,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
static final TrackedData<Float> MANA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
static final TrackedData<Float> XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private final AbilityDispatcher powers = new AbilityDispatcher(this);
private final PlayerPhysics gravity = new PlayerPhysics(this);
@ -323,7 +323,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
public boolean canHangAt(BlockPos pos) {
BlockState state = getWorld().getBlockState(pos);
return state.hasSolidTopSurface(getWorld(), pos, getEntity(), Direction.DOWN);
return state.isSolidSurface(getWorld(), pos, getEntity(), Direction.DOWN);
}
private BlockPos getHangingPos() {

View file

@ -3,12 +3,16 @@ package com.minelittlepony.unicopia.item;
import java.util.Optional;
import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.toxin.Toxicity;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.RayTraceHelper;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
@ -107,12 +111,13 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem {
public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> items) {
super.appendStacks(tab, items);
if (isIn(tab)) {
UTags.APPLES.values().forEach(item -> {
if (item != this) {
ItemStack stack = new ItemStack(this);
stack.getOrCreateNbt().putString("appearance", Registry.ITEM.getId(item).toString());
items.add(stack);
}
Unicopia.SIDE.getPony().map(Pony::getWorld)
.stream()
.flatMap(world -> Registries.valuesForTag(world, UTags.APPLES))
.filter(a -> a != this).forEach(item -> {
ItemStack stack = new ItemStack(this);
stack.getOrCreateNbt().putString("appearance", Registry.ITEM.getId(item).toString());
items.add(stack);
});
}
}

View file

@ -13,7 +13,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
@ -27,9 +27,9 @@ public class Toxic {
private final Ailment defaultAilment;
private final Map<Race, Ailment> ailments;
private final Tag<Item> tag;
private final TagKey<Item> tag;
Toxic(UseAction action, Optional<FoodComponent> component, Tag<Item> tag, Ailment defaultAilment, Map<Race, Ailment> ailments) {
Toxic(UseAction action, Optional<FoodComponent> component, TagKey<Item> tag, Ailment defaultAilment, Map<Race, Ailment> ailments) {
this.action = action;
this.component = component;
this.tag = tag;
@ -37,8 +37,9 @@ public class Toxic {
this.ailments = ailments;
}
@SuppressWarnings("deprecation")
public boolean matches(Item item) {
return tag.contains(item);
return item.getRegistryEntry().isIn(tag);
}
public Optional<FoodComponent> getFoodComponent() {

View file

@ -14,7 +14,7 @@ import net.minecraft.world.World;
@Mixin(BlockItem.class)
abstract class MixinBlockItem extends Item implements ToxicHolder {
public MixinBlockItem() {super(null); }
MixinBlockItem() {super(null); }
@Override
public UseAction getUseAction(ItemStack stack) {

View file

@ -0,0 +1,16 @@
package com.minelittlepony.unicopia.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.block.BlockState;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.world.World;
@Mixin(FallingBlockEntity.class)
public interface MixinFallingBlockEntity {
@Invoker("<init>")
static FallingBlockEntity createInstance(World world, double x, double y, double z, BlockState state) {
return null;
}
}

View file

@ -1,6 +1,11 @@
package com.minelittlepony.unicopia.mixin;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
import org.jetbrains.annotations.Nullable;
@ -10,6 +15,7 @@ import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.unicopia.item.toxin.Toxic;

View file

@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.item.VanillaOverrides;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@Mixin(Items.class)
abstract class MixinItems {
@ -18,8 +19,10 @@ abstract class MixinItems {
argsOnly = true)
private static Item modifyItem(Item item, Identifier id, Item itemAlso) {
// Registry#containsId is client-only :thonkjang:
// TODO: Move onGroundTick() event to MixinItem and make it a registerable event so we don't have to do this
Item replacement = VanillaOverrides.REGISTRY.get(id);
if (replacement != null) {
Registry.register(Registry.ITEM, new Identifier("unicopia_overriden", id.getPath()), item);
return replacement;
}
return item;

View file

@ -54,7 +54,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster<Li
private static final TrackedData<Float> DAMAGE = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<Float> GRAVITY = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<Boolean> HYDROPHOBIC = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private static final LevelStore LEVELS = Levelled.fixed(1);
public static final byte PROJECTILE_COLLISSION = 3;

View file

@ -0,0 +1,13 @@
package com.minelittlepony.unicopia.util;
import java.util.HashSet;
import java.util.Set;
public final class ItemTrace {
private static final Set<Class<?>> noticedClasses = new HashSet<>();
public static void traceItem(Class<?> c) {
if (noticedClasses.add(c)) {
System.out.println(c.getCanonicalName());
}
}
}

View file

@ -1,15 +1,29 @@
package com.minelittlepony.unicopia.util;
import java.util.stream.Stream;
import com.mojang.serialization.Lifecycle;
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryEntryList;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.world.World;
public interface Registries {
static <T> Registry<T> createSimple(Identifier id) {
return FabricRegistryBuilder.from(new SimpleRegistry<T>(RegistryKey.ofRegistry(id), Lifecycle.stable())).buildAndRegister();
return FabricRegistryBuilder.from(new SimpleRegistry<T>(RegistryKey.ofRegistry(id), Lifecycle.stable(), null)).buildAndRegister();
}
static <T> RegistryEntryList<T> entriesForTag(World world, TagKey<T> key) {
return world.getRegistryManager().get(key.registry()).getOrCreateEntryList(key);
}
static <T> Stream<T> valuesForTag(World world, TagKey<T> key) {
return entriesForTag(world, key).stream().map(RegistryEntry::value);
}
}

View file

@ -13,6 +13,7 @@
"MixinDamageSource",
"MixinEntity",
"MixinFallingBlock",
"MixinFallingBlockEntity",
"MixinItem",
"MixinItemEntity",
"MixinItems",