From 5ac68a3df9ff16b8f96c4d03b3a49376dd0ffadf Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 17 Jan 2024 19:28:27 +0000 Subject: [PATCH] Fixed race change advancement criterion. Fixes #230 --- .../unicopia/entity/player/Pony.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 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 6a12cabe..666ca9c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -239,8 +239,7 @@ public class Pony extends Living implements Copyable, Update gravity.updateFlightState(); entity.sendAbilitiesUpdate(); - - UCriteria.PLAYER_CHANGE_RACE.trigger(entity); + recalculateCompositeRace(); } public void setSuppressedRace(Race race) { @@ -377,20 +376,7 @@ public class Pony extends Living implements Copyable, Update @Override public boolean beforeUpdate() { if (compositeRace.includes(Race.UNSET) || entity.age % 2 == 0) { - Race intrinsicRace = getSpecies(); - Race suppressedRace = getSuppressedRace(); - compositeRace = getSpellSlot() - .get(SpellPredicate.IS_MIMIC, true) - .map(AbstractDisguiseSpell::getDisguise) - .map(EntityAppearance::getAppearance) - .flatMap(Pony::of) - .map(Pony::getSpecies) - .orElse(intrinsicRace).composite( - AmuletSelectors.UNICORN_AMULET.test(entity) ? Race.UNICORN - : AmuletSelectors.ALICORN_AMULET.test(entity) ? Race.ALICORN - : null, - AmuletSelectors.PEARL_NECKLACE.test(entity) ? suppressedRace.or(Race.SEAPONY) : null - ); + recalculateCompositeRace(); } if (ticksInvulnerable > 0) { @@ -482,6 +468,24 @@ public class Pony extends Living implements Copyable, Update return super.beforeUpdate(); } + private void recalculateCompositeRace() { + Race intrinsicRace = getSpecies(); + Race suppressedRace = getSuppressedRace(); + compositeRace = getSpellSlot() + .get(SpellPredicate.IS_MIMIC, true) + .map(AbstractDisguiseSpell::getDisguise) + .map(EntityAppearance::getAppearance) + .flatMap(Pony::of) + .map(Pony::getSpecies) + .orElse(intrinsicRace).composite( + AmuletSelectors.UNICORN_AMULET.test(entity) ? Race.UNICORN + : AmuletSelectors.ALICORN_AMULET.test(entity) ? Race.ALICORN + : null, + AmuletSelectors.PEARL_NECKLACE.test(entity) ? suppressedRace.or(Race.SEAPONY) : null + ); + UCriteria.PLAYER_CHANGE_RACE.trigger(entity); + } + @Override public Optional chooseClimbingPos() { if (getObservedSpecies() == Race.CHANGELING && getSpellSlot().get(SpellPredicate.IS_DISGUISE, false).isEmpty()) {