Fixed race change advancement criterion. Fixes #230

This commit is contained in:
Sollace 2024-01-17 19:28:27 +00:00
parent 54381cf673
commit 5ac68a3df9
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -239,8 +239,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, 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<PlayerEntity> implements Copyable<Pony>, 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<PlayerEntity> implements Copyable<Pony>, 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<BlockPos> chooseClimbingPos() {
if (getObservedSpecies() == Race.CHANGELING && getSpellSlot().get(SpellPredicate.IS_DISGUISE, false).isEmpty()) {