From bf5649a966caff3206fa730793272951ed1ff098 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 19 Dec 2022 16:10:09 +0100 Subject: [PATCH] Apply the same to Living --- .../unicopia/client/render/WorldRenderDelegate.java | 4 ++-- .../unicopia/client/sound/MagicAuraSoundInstance.java | 2 +- .../com/minelittlepony/unicopia/entity/Creature.java | 6 ------ .../minelittlepony/unicopia/entity/ItemTracker.java | 6 +++--- .../com/minelittlepony/unicopia/entity/Living.java | 11 ++++++++++- .../minelittlepony/unicopia/entity/player/Pony.java | 9 --------- .../unicopia/item/AlicornAmuletItem.java | 2 +- .../item/enchantment/GemFindingEnchantment.java | 2 +- .../item/enchantment/PoisonedJokeEnchantment.java | 4 ++-- .../item/enchantment/WantItNeedItEnchantment.java | 2 +- 10 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java index c928509c..96814854 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java @@ -75,7 +75,7 @@ public class WorldRenderDelegate { if (!recurseMinion && pony instanceof Creature creature && creature.isMinion()) { recurseMinion = true; - dispatcher.render(creature.getEntity(), x, y, z, yaw, tickDelta, matrices, layer -> { + dispatcher.render(creature.asEntity(), x, y, z, yaw, tickDelta, matrices, layer -> { return PassThroughVertexConsumer.of(vertices.getBuffer(layer), MINION_OVERLAY); }, light); recurseMinion = false; @@ -106,7 +106,7 @@ public class WorldRenderDelegate { matrices.push(); - Entity owner = pony.getEntity(); + Entity owner = pony.asEntity(); boolean negative = pony.getPhysics().isGravityNegative(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java b/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java index d01b9504..c13c30dd 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java @@ -29,7 +29,7 @@ public class MagicAuraSoundInstance extends FadeOutSoundInstance { y = pos.y; z = pos.z; - if (!living.getEntity().isRemoved() && data.isPresent()) { + if (!living.asEntity().isRemoved() && data.isPresent()) { float level = data.get().level; if (level != targetVolume) { setTargetVolume(level); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java index 95ff0cfe..c76490b8 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java @@ -17,7 +17,6 @@ import com.minelittlepony.unicopia.entity.ai.DynamicTargetGoal; import com.minelittlepony.unicopia.entity.ai.EatMuffinGoal; import com.minelittlepony.unicopia.entity.ai.WantItTakeItGoal; -import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.ai.goal.*; @@ -94,11 +93,6 @@ public class Creature extends Living implements WeaklyOwned getTargets() { return Optional.ofNullable(targets); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemTracker.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemTracker.java index 5c8474d6..f074de21 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemTracker.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemTracker.java @@ -4,11 +4,11 @@ import java.util.*; import java.util.function.Predicate; import java.util.stream.Stream; +import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.util.Copyable; import com.minelittlepony.unicopia.util.NbtSerialisable; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; @@ -72,10 +72,10 @@ public class ItemTracker implements NbtSerialisable, Copyable { return false; }); - if (!(living.getEntity() instanceof PlayerEntity)) { + if (!(living instanceof Pony)) { foundStacks.forEach(stack -> { if (getTicks((Trackable)stack.getItem()) == 1) { - stack.inventoryTick(living.getReferenceWorld(), living.getEntity(), 0, false); + stack.inventoryTick(living.getReferenceWorld(), living.asEntity(), 0, false); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index 1e4346f0..4806e3bd 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -109,6 +109,15 @@ public abstract class Living implements Equine, Caste return asEntity(); } + /** + * @deprecated use asEntity() + */ + @Deprecated(forRemoval = true) + @Override + public final Entity getEntity() { + return asEntity(); + } + @Override public final T asEntity() { return entity; @@ -121,7 +130,7 @@ public abstract class Living implements Equine, Caste try { getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.world.isClient); } catch (Exception e) { - Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", getEntity(), e); + Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", entity, e); } if (invinsibilityTicks > 0) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index 72290752..6c012c7f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -288,15 +288,6 @@ public class Pony extends Living implements Copyable, Update return interpolator; } - /** - * @deprecated use asEntity() - */ - @Deprecated(forRemoval = true) - @Override - public final Entity getEntity() { - return asEntity(); - } - /** * @deprecated use asEntity() */ diff --git a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java index b304a2c8..915618fb 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java @@ -110,7 +110,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab @Override public void onEquipped(Living wearer) { - wearer.getReferenceWorld().playSound(null, wearer.getOrigin(), USounds.ITEM_ALICORN_AMULET_CURSE, wearer.getEntity().getSoundCategory(), 3, 1); + wearer.playSound(USounds.ITEM_ALICORN_AMULET_CURSE, 3, 1); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java index 6adf346e..4b934ff6 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java @@ -37,7 +37,7 @@ public class GemFindingEnchantment extends SimpleEnchantment { @Override public void onEquipped(Living user) { if (user.isClient()) { - MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.getEntity().getSoundCategory(), user, user.getReferenceWorld().getRandom())); + MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.asEntity().getSoundCategory(), user, user.getReferenceWorld().getRandom())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java index cd83b2fc..6fc9c05b 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java @@ -40,7 +40,7 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi return; } - int light = user.getReferenceWorld().getLightLevel(user.getEntity().getRootVehicle().getBlockPos()); + int light = user.getReferenceWorld().getLightLevel(user.asEntity().getRootVehicle().getBlockPos()); Random rng = user.getReferenceWorld().random; Data data = user.getEnchants().computeIfAbsent(this, Data::new); @@ -50,7 +50,7 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi user.getReferenceWorld().playSoundFromEntity( null, - user.getEntity(), + user.asEntity(), sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE, 0.5F + rng.nextFloat() * 0.5F, 0.5F + rng.nextFloat() * 0.5F diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java index 9d0dbc0a..71688e6c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java @@ -17,7 +17,7 @@ public class WantItNeedItEnchantment extends SimpleEnchantment { @Override public void onUserTick(Living user, int level) { if (user instanceof Creature && user.getReferenceWorld().random.nextInt(10) == 0) { - ParticleUtils.spawnParticles(new FollowingParticleEffect(UParticles.HEALTH_DRAIN, user.getEntity(), 0.2F), user.getEntity(), 1); + ParticleUtils.spawnParticles(new FollowingParticleEffect(UParticles.HEALTH_DRAIN, user.asEntity(), 0.2F), user.asEntity(), 1); } } }