From 5d8f5d485a058c25f2b1239d76755bdd83c03122 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 10 Oct 2023 18:28:29 +0100 Subject: [PATCH] Fixed crash without trinkets --- .../unicopia/entity/player/Pony.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) 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 54f0e46d..bfd22bb3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -96,8 +96,7 @@ public class Pony extends Living implements Copyable, Update private final Interpolator interpolator = new LinearInterpolator(); - @Nullable - private Race.Composite compositeRace; + private Race.Composite compositeRace = Race.UNSET.composite(); private Race respawnRace = Race.UNSET; private boolean dirty; @@ -222,19 +221,6 @@ public class Pony extends Living implements Copyable, Update */ @Override public Race.Composite getCompositeRace() { - if (compositeRace == null || entity.age % 2 == 0) { - compositeRace = getSpellSlot() - .get(SpellPredicate.IS_MIMIC, true) - .map(AbstractDisguiseSpell::getDisguise) - .map(EntityAppearance::getAppearance) - .flatMap(Pony::of) - .map(Pony::getSpecies) - .orElseGet(this::getSpecies).composite( - AmuletSelectors.UNICORN_AMULET.test(entity) ? Race.UNICORN - : AmuletSelectors.ALICORN_AMULET.test(entity) ? Race.ALICORN - : null - ); - } return compositeRace; } @@ -354,6 +340,20 @@ public class Pony extends Living implements Copyable, Update @Override public boolean beforeUpdate() { + if (compositeRace.includes(Race.UNSET) || entity.age % 2 == 0) { + compositeRace = getSpellSlot() + .get(SpellPredicate.IS_MIMIC, true) + .map(AbstractDisguiseSpell::getDisguise) + .map(EntityAppearance::getAppearance) + .flatMap(Pony::of) + .map(Pony::getSpecies) + .orElseGet(this::getSpecies).composite( + AmuletSelectors.UNICORN_AMULET.test(entity) ? Race.UNICORN + : AmuletSelectors.ALICORN_AMULET.test(entity) ? Race.ALICORN + : null + ); + } + if (isClient()) { if (entity.hasVehicle() && entity.isSneaking()) {