From 914f149667f64b35d39fc6e7b949f86c0a7d9145 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 19 Nov 2024 16:25:24 +0000 Subject: [PATCH] More 1.21.2/3 updates --- .../render/entity/AirBalloonEntityModel.java | 3 +- .../entity/AirBalloonEntityRenderer.java | 115 ++++++++++++------ .../effect/ButterfingersStatusEffect.java | 9 +- .../effect/CorruptInfluenceStatusEffect.java | 22 ++-- .../effect/FoodPoisoningStatusEffect.java | 17 ++- .../entity/effect/RaceChangeStatusEffect.java | 9 +- .../entity/effect/SimpleStatusEffect.java | 2 +- .../effect/SunBlindnessStatusEffect.java | 5 +- .../unicopia/entity/mob/AirBalloonEntity.java | 45 ++++--- .../unicopia/server/world/UTreeGen.java | 2 +- 10 files changed, 135 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityModel.java index 96588b3c0..ba0ab80fe 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityModel.java @@ -13,7 +13,7 @@ import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.util.math.MathHelper; -public class AirBalloonEntityModel extends EntityModel { +public class AirBalloonEntityModel extends EntityModel { private final ModelPart root; private ModelPart main; @@ -29,6 +29,7 @@ public class AirBalloonEntityModel extends EntityModel { private final List sandbags; public AirBalloonEntityModel(ModelPart root) { + super(root); this.root = root; isBurner = root.hasChild("burner"); isSandbags = root.hasChild("sandbag_ne"); diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityRenderer.java index c4bb76d09..3d6269b93 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/entity/AirBalloonEntityRenderer.java @@ -7,14 +7,17 @@ import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.entity.collision.MultiBox; import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity; +import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity.BalloonDesign; +import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity.BasketType; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.VertexRendering; import net.minecraft.client.render.entity.*; import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; +import net.minecraft.client.render.entity.state.LivingEntityRenderState; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.Items; import net.minecraft.util.Colors; @@ -22,66 +25,109 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RotationAxis; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; -public class AirBalloonEntityRenderer extends MobEntityRenderer { +public class AirBalloonEntityRenderer extends MobEntityRenderer { public AirBalloonEntityRenderer(EntityRendererFactory.Context context) { super(context, new AirBalloonEntityModel(AirBalloonEntityModel.getBasketModelData().createModel()), 0); addFeature(new BalloonFeature(new AirBalloonEntityModel(AirBalloonEntityModel.getBurnerModelData().createModel()), this, - AirBalloonEntity::hasBurner, e -> { - return getComponentTexture(e.getStackInHand(Hand.MAIN_HAND).isOf(Items.SOUL_LANTERN) ? "soul_burner" : "burner"); - }, (light, entity) -> entity.isAscending() ? 0xFF00FF : light)); + i -> i.hasBurner, e -> { + return getComponentTexture(e.hasSoulFlame ? "soul_burner" : "burner"); + }, (light, entity) -> entity.isAscending ? 0xFF00FF : light)); addFeature(new BalloonFeature(new AirBalloonEntityModel(AirBalloonEntityModel.getCanopyModelData().createModel()), this, - AirBalloonEntity::hasBalloon, - e -> getComponentTexture("canopy/" + e.getDesign().asString()), - (light, entity) -> entity.hasBurner() && entity.isAscending() ? light | 0x00005F : light) + i -> i.hasBalloon, + e -> getComponentTexture("canopy/" + e.design.asString()), + (light, entity) -> entity.hasBurner && entity.isAscending ? light | 0x00005F : light) ); addFeature(new BalloonFeature(new AirBalloonEntityModel(AirBalloonEntityModel.getSandbagsModelData().createModel()), - this, e -> e.hasBalloon() && e.getInflation(1) >= 1, e -> getComponentTexture("sandbags"), - (light, entity) -> entity.hasBurner() && entity.isAscending() ? light | 0x00003F : light)); + this, e -> e.hasBalloon && e.inflation >= 1, e -> getComponentTexture("sandbags"), + (light, entity) -> entity.hasBurner && entity.isAscending ? light | 0x00003F : light)); } @Override - public void render(AirBalloonEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light) { + public void render(State entity, MatrixStack matrices, VertexConsumerProvider vertices, int light) { matrices.push(); - if (entity.hurtTime > 0) { - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(entity.age + tickDelta) * 3)); + if (entity.hurt) { + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(entity.age) * 3)); } - super.render(entity, yaw, tickDelta, matrices, vertices, light); + super.render(entity, matrices, vertices, light); matrices.pop(); - if (MinecraftClient.getInstance().getEntityRenderDispatcher().shouldRenderHitboxes() && !entity.isInvisible() && !MinecraftClient.getInstance().hasReducedDebugInfo()) { - MultiBox.forEach(entity.getBoundingBox(), box -> { - WorldRenderer.drawBox(matrices, vertices.getBuffer(RenderLayer.getLines()), box.offset(entity.getPos().multiply(-1)), 1, 1, 1, 1); + if (MinecraftClient.getInstance().getEntityRenderDispatcher().shouldRenderHitboxes() && !entity.invisible && !MinecraftClient.getInstance().hasReducedDebugInfo()) { + MultiBox.forEach(entity.boundingBox, box -> { + VertexRendering.drawBox(matrices, vertices.getBuffer(RenderLayer.getLines()), box.offset(entity.pos.multiply(-1)), 1, 1, 1, 1); }); } } + + @Override + public State createRenderState() { + return new State(); + } + @Override - public Identifier getTexture(AirBalloonEntity entity) { - return getComponentTexture("basket/" + entity.getBasketType().id().getPath()); + public void updateRenderState(AirBalloonEntity entity, State state, float tickDelta) { + super.updateRenderState(entity, state, tickDelta); + state.design = entity.getDesign(); + state.basket = entity.getBasketType(); + state.inflation = entity.getInflation(tickDelta); + state.hasBurner = entity.hasBurner(); + state.hasBalloon = entity.hasBalloon(); + state.isAscending = entity.isAscending(); + state.boundingBox = entity.getBoundingBox(); + state.hasSoulFlame = entity.getStackInHand(Hand.MAIN_HAND).isOf(Items.SOUL_LANTERN); + state.pos = entity.getPos(); + } + + public static class State extends LivingEntityRenderState { + public BalloonDesign design; + public BasketType basket; + + public float inflation; + public boolean hasBurner; + public boolean hasBalloon; + public boolean isAscending; + public boolean hasSoulFlame; + public Box boundingBox; + public Vec3d pos; } @Override - protected float getLyingAngle(AirBalloonEntity entity) { - return 0; + protected Box getBoundingBox(AirBalloonEntity entity) { + if (entity.hasBalloon()) { + return entity.getBalloonBoundingBox().withMinY(entity.getY()); + } + return entity.getInteriorBoundingBox(); + } + + @Override + public Identifier getTexture(State entity) { + return getComponentTexture("basket/" + entity.basket.id().getPath()); + } + + @Override + protected float method_3919() { + return 90.0F; } private Identifier getComponentTexture(String componentName) { return Unicopia.id("textures/entity/air_balloon/" + componentName + ".png"); } - final class BalloonFeature extends FeatureRenderer { + final class BalloonFeature extends FeatureRenderer { private final AirBalloonEntityModel model; - private final Predicate visibilityTest; - private final Function textureFunc; - private final BiFunction lightFunc; + private final Predicate visibilityTest; + private final Function textureFunc; + private final BiFunction lightFunc; public BalloonFeature(AirBalloonEntityModel model, - FeatureRendererContext context, - Predicate visibilityTest, - Function textureFunc, - BiFunction lightFunc) { + FeatureRendererContext context, + Predicate visibilityTest, + Function textureFunc, + BiFunction lightFunc) { super(context); this.model = model; this.visibilityTest = visibilityTest; @@ -90,16 +136,11 @@ public BalloonFeature(AirBalloonEntityModel model, } @Override - public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, AirBalloonEntity entity, - float limbAngle, float limbDistance, float tickDelta, float animationProgress, float yaw, float pitch) { + public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, State entity, float limbDistance, float limbAngle) { if (visibilityTest.test(entity)) { - Identifier texture = textureFunc.apply(entity); - var model = this.model; - if (texture.getPath().indexOf("sandbags") != -1) { - model = new AirBalloonEntityModel(AirBalloonEntityModel.getSandbagsModelData().createModel()); - } - render(getModel(), model, texture, matrices, vertices, lightFunc.apply(light, entity), entity, limbAngle, limbDistance, 0, yaw, pitch, tickDelta, Colors.WHITE); + render(model, textureFunc.apply(entity), matrices, vertices, lightFunc.apply(light, entity), entity, Colors.WHITE); } } } + } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java index e0134649d..478b8e041 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Hand; import net.minecraft.util.math.MathHelper; @@ -22,18 +23,18 @@ public class ButterfingersStatusEffect extends StatusEffect { } @Override - public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { + public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) { amplifier = MathHelper.clamp(amplifier, 0, 5); final int scale = 500 + (int)(((5 - amplifier) / 5F) * 900); if (entity.getWorld().random.nextInt(scale / 4) == 0) { - applyInstantEffect(null, null, entity, amplifier, entity.getWorld().random.nextInt(scale)); + applyInstantEffect(world, null, null, entity, amplifier, entity.getWorld().random.nextInt(scale)); } return true; } @Override - public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { + public void applyInstantEffect(ServerWorld world, @Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { if (target.getWorld().isClient) { return; @@ -49,7 +50,7 @@ public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacke ItemStack stack = target.getMainHandStack(); if (!stack.isEmpty()) { target.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY); - target.dropStack(stack); + target.dropStack(world, stack); target.getWorld().playSound(null, target.getBlockPos(), USounds.ENTITY_GENERIC_BUTTER_FINGERS, target.getSoundCategory()); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java index a62848fe2..479556f57 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.entity.damage.UDamageTypes; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.effect.StatusEffectCategory; @@ -14,6 +15,7 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.mob.HostileEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; import net.minecraft.world.WorldEvents; @@ -22,12 +24,12 @@ public class CorruptInfluenceStatusEffect extends SimpleStatusEffect { CorruptInfluenceStatusEffect(int color) { super(StatusEffectCategory.NEUTRAL, color, false); - addAttributeModifier(EntityAttributes.GENERIC_ATTACK_DAMAGE, CORRUPTION_MODIFIER_ID, 15, EntityAttributeModifier.Operation.ADD_VALUE); - addAttributeModifier(EntityAttributes.GENERIC_ATTACK_SPEED, CORRUPTION_MODIFIER_ID, 10, EntityAttributeModifier.Operation.ADD_VALUE); + addAttributeModifier(EntityAttributes.ATTACK_DAMAGE, CORRUPTION_MODIFIER_ID, 15, EntityAttributeModifier.Operation.ADD_VALUE); + addAttributeModifier(EntityAttributes.ATTACK_SPEED, CORRUPTION_MODIFIER_ID, 10, EntityAttributeModifier.Operation.ADD_VALUE); } @Override - public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { + public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) { if (entity.getWorld().isClient) { return true; @@ -53,7 +55,7 @@ public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { } else if (entity.age % 2000 == 0) { - entity.damage(Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2); + entity.damage(world, Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2); } return true; @@ -65,22 +67,22 @@ public boolean canApplyUpdateEffect(int duration, int amplifier) { } public static void reproduce(HostileEntity mob) { - HostileEntity clone = (HostileEntity)mob.getType().create(mob.getWorld()); + HostileEntity clone = (HostileEntity)mob.getType().create(mob.getWorld(), SpawnReason.BREEDING); clone.copyPositionAndRotation(mob); clone.takeKnockback(0.1, 0.5, 0.5); mob.takeKnockback(0.1, -0.5, -0.5); if (mob.getRandom().nextInt(4) != 0) { mob.clearStatusEffects(); } else { - if (clone.getAttributes().hasAttribute(EntityAttributes.GENERIC_MAX_HEALTH)) { + if (clone.getAttributes().hasAttribute(EntityAttributes.MAX_HEALTH)) { float maxHealthDifference = mob.getMaxHealth() - clone.getMaxHealth(); clone.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 900000, 2)); - clone.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH) + clone.getAttributeInstance(EntityAttributes.MAX_HEALTH) .addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, maxHealthDifference + 1, EntityAttributeModifier.Operation.ADD_VALUE)); } - if (clone.getAttributes().hasAttribute(EntityAttributes.GENERIC_ATTACK_DAMAGE)) { - clone.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE) - .addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, mob.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADD_VALUE)); + if (clone.getAttributes().hasAttribute(EntityAttributes.ATTACK_DAMAGE)) { + clone.getAttributeInstance(EntityAttributes.ATTACK_DAMAGE) + .addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, mob.getAttributeValue(EntityAttributes.ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADD_VALUE)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/FoodPoisoningStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/FoodPoisoningStatusEffect.java index e3e6c97c1..49fbc928f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/FoodPoisoningStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/FoodPoisoningStatusEffect.java @@ -3,6 +3,7 @@ import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.USounds; +import com.minelittlepony.unicopia.util.TypedActionResult; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.FoodComponent; @@ -15,8 +16,8 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.registry.RegistryKeys; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; -import net.minecraft.util.TypedActionResult; public class FoodPoisoningStatusEffect extends StatusEffect { @@ -25,12 +26,8 @@ public class FoodPoisoningStatusEffect extends StatusEffect { } @Override - public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { - if (entity.getWorld().isClient) { - return true; - } - - boolean showParticles = entity.getStatusEffect(entity.getRegistryManager().get(RegistryKeys.STATUS_EFFECT).getEntry(this)).shouldShowParticles(); + public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) { + boolean showParticles = entity.getStatusEffect(entity.getRegistryManager().getOrThrow(RegistryKeys.STATUS_EFFECT).getEntry(this)).shouldShowParticles(); if (!entity.hasStatusEffect(StatusEffects.NAUSEA) && entity.getRandom().nextInt(12) == 0) { entity.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 1, true, showParticles, false)); @@ -41,15 +38,15 @@ public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { } if (EffectUtils.isPoisoned(entity) && entity.getRandom().nextInt(12) == 0 && !entity.hasStatusEffect(StatusEffects.POISON)) { - StatusEffects.POISON.value().applyUpdateEffect(entity, 1); + StatusEffects.POISON.value().applyUpdateEffect(world, entity, 1); } return true; } @Override - public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { - applyUpdateEffect(target, amplifier); + public void applyInstantEffect(ServerWorld world, @Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { + applyUpdateEffect(world, target, amplifier); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java index 075279187..9dd02988e 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java @@ -26,6 +26,7 @@ import net.minecraft.world.World.ExplosionSourceType; import net.minecraft.registry.Registry; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.server.world.ServerWorld; import net.minecraft.registry.Registries; public class RaceChangeStatusEffect extends StatusEffect { @@ -74,7 +75,7 @@ private void resetTicks(LivingEntity entity) { } @Override - public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { + public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) { StatusEffectInstance state = entity.getStatusEffect(forRace(race)); if (state == null || entity.isDead()) { @@ -158,7 +159,7 @@ public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { } pony.setSpecies(race); } else if (!pony.asEntity().isCreative()) { - if (!entity.damage(Living.living(entity).damageOf(UDamageTypes.TRIBE_SWAP), Float.MAX_VALUE)) { + if (!entity.damage(world, Living.living(entity).damageOf(UDamageTypes.TRIBE_SWAP), Float.MAX_VALUE)) { entity.setHealth(0); pony.setRespawnRace(Race.UNSET); pony.setSpecies(race); @@ -177,8 +178,8 @@ public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { } @Override - public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { - applyUpdateEffect(target, amplifier); + public void applyInstantEffect(ServerWorld world, @Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { + applyUpdateEffect(world, target, amplifier); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/SimpleStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/SimpleStatusEffect.java index f6a0fa1c6..9c1191282 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/SimpleStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/SimpleStatusEffect.java @@ -16,7 +16,7 @@ public SimpleStatusEffect(StatusEffectCategory category, int color, boolean inst } protected RegistryEntry getEntry(Entity entity) { - return entity.getRegistryManager().get(RegistryKeys.STATUS_EFFECT).getEntry(this); + return entity.getRegistryManager().getOrThrow(RegistryKeys.STATUS_EFFECT).getEntry(this); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java index f30752d4c..1d3e09789 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java @@ -12,6 +12,7 @@ import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectCategory; import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.server.world.ServerWorld; public class SunBlindnessStatusEffect extends SimpleStatusEffect { public static final int MAX_DURATION = 250; @@ -21,7 +22,7 @@ public class SunBlindnessStatusEffect extends SimpleStatusEffect { } @Override - public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { + public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) { StatusEffectInstance state = entity.getStatusEffect(getEntry(entity)); if (state == null || isSunImmune(entity)) { @@ -32,7 +33,7 @@ public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { if (!hasSunExposure(entity)) { entity.setStatusEffect(new StatusEffectInstance(getEntry(entity), (int)(state.getDuration() * 0.8F), Math.max(1, amplifier - 1), true, false), entity); } else { - entity.damage(Living.living(entity).damageOf(amplifier == 2 ? UDamageTypes.SUN : UDamageTypes.SUNLIGHT), amplifier / 5F); + entity.damage(world, Living.living(entity).damageOf(amplifier == 2 ? UDamageTypes.SUN : UDamageTypes.SUNLIGHT), amplifier / 5F); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/mob/AirBalloonEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/mob/AirBalloonEntity.java index 3b8f7e9c7..056880c20 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/mob/AirBalloonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/mob/AirBalloonEntity.java @@ -21,6 +21,7 @@ import net.minecraft.particle.ParticleTypes; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.registry.RegistryKey; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.ActionResult; @@ -228,8 +229,10 @@ public void tick() { setInflation(inflation); } - if (activeFuel <= 0 && !fuelItems.isEmpty()) { - activeFuel = FurnaceBlockEntity.createFuelTimeMap().getOrDefault(fuelItems.remove(0).getItem(), 0); + if (getWorld() instanceof ServerWorld sw) { + if (activeFuel <= 0 && !fuelItems.isEmpty()) { + activeFuel = sw.getFuelRegistry().getFuelTicks(fuelItems.remove(0)); + } } if (activeFuel > -6 && age % 2 == 0) { @@ -329,13 +332,13 @@ public void tick() { } @Override - public boolean damage(DamageSource source, float amount) { + public boolean damage(ServerWorld world, DamageSource source, float amount) { if (source.getAttacker() instanceof PlayerEntity player && player.getAbilities().creativeMode) { - dropInventory(); + dropInventory(world); remove(RemovalReason.KILLED); return true; } - if (super.damage(source, amount)) { + if (super.damage(world, source, amount)) { hurtTime = 0; maxHurtTime = 0; return true; @@ -432,7 +435,9 @@ protected ActionResult interactMob(PlayerEntity player, Hand hand) { if (stack.isIn(ConventionalItemTags.SHEAR_TOOLS) && hasBalloon()) { stack.damage(1, player, getSlotForHand(hand)); - dropStack(BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true))); + if (getWorld() instanceof ServerWorld sw) { + dropStack(sw, BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true))); + } setDesign(BalloonDesign.NONE); playSound(USounds.ENTITY_HOT_AIR_BALLOON_EQUIP_CANOPY.value(), 1, 1); if (!player.isSneaky()) { @@ -456,8 +461,8 @@ protected ActionResult interactMob(PlayerEntity player, Hand hand) { return ActionResult.SUCCESS; } - if (hasBurner()) { - int fuel = FurnaceBlockEntity.createFuelTimeMap().getOrDefault(stack.getItem(), 0); + if (hasBurner() && getWorld() instanceof ServerWorld sw) { + int fuel = sw.getFuelRegistry().getFuelTicks(stack); if (fuel > 0) { if (fuelItems.size() < 64) { fuelItems.add(stack.splitUnlessCreative(1, player)); @@ -473,17 +478,17 @@ protected ActionResult interactMob(PlayerEntity player, Hand hand) { } @Override - protected void dropInventory() { - dropStack(getPickBlockStack()); - if (getWorld().getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { + protected void dropInventory(ServerWorld world) { + dropStack(world, getPickBlockStack()); + if (world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { ItemStack lantern = getStackInHand(Hand.MAIN_HAND); setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY); - dropStack(lantern); + dropStack(world, lantern); if (hasBalloon()) { - dropStack(BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true))); + dropStack(world, BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true))); setDesign(BalloonDesign.NONE); } - fuelItems.forEach(this::dropStack); + fuelItems.forEach(s -> dropStack(world, s)); fuelItems.clear(); } } @@ -612,20 +617,12 @@ protected Box calculateBoundingBox() { return MultiBox.of(box, boxes); } - @Override - public Box getVisibilityBoundingBox() { - if (hasBalloon()) { - return getBalloonBoundingBox().withMinY(getY()); - } - return getInteriorBoundingBox(); - } - - protected Box getInteriorBoundingBox() { + public Box getInteriorBoundingBox() { Box box = MultiBox.unbox(getBoundingBox()); return box.withMinY(box.minY - 0.05).contract(0.15, 0, 0.15); } - protected Box getBalloonBoundingBox() { + public Box getBalloonBoundingBox() { float inflation = getInflation(1); return MultiBox.unbox(getBoundingBox()) .offset(0.125, 7.3 * inflation, 0.125) diff --git a/src/main/java/com/minelittlepony/unicopia/server/world/UTreeGen.java b/src/main/java/com/minelittlepony/unicopia/server/world/UTreeGen.java index 77f43a340..ec61fb6cd 100644 --- a/src/main/java/com/minelittlepony/unicopia/server/world/UTreeGen.java +++ b/src/main/java/com/minelittlepony/unicopia/server/world/UTreeGen.java @@ -30,7 +30,7 @@ public interface UTreeGen { UniformIntProvider.create(3, 6), 0.3f, UniformIntProvider.create(1, 3), - Registries.BLOCK.getOrCreateEntryList(BlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH) + Registries.BLOCK.getOrThrow(BlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH) ), new JungleFoliagePlacer( ConstantIntProvider.create(3), ConstantIntProvider.create(2),