Fixed crash without trinkets

This commit is contained in:
Sollace 2023-10-10 18:28:29 +01:00
parent 442186978d
commit 5d8f5d485a
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -96,8 +96,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
private final Interpolator interpolator = new LinearInterpolator(); private final Interpolator interpolator = new LinearInterpolator();
@Nullable private Race.Composite compositeRace = Race.UNSET.composite();
private Race.Composite compositeRace;
private Race respawnRace = Race.UNSET; private Race respawnRace = Race.UNSET;
private boolean dirty; private boolean dirty;
@ -222,19 +221,6 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
*/ */
@Override @Override
public Race.Composite getCompositeRace() { 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; return compositeRace;
} }
@ -354,6 +340,20 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
@Override @Override
public boolean beforeUpdate() { 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 (isClient()) {
if (entity.hasVehicle() && entity.isSneaking()) { if (entity.hasVehicle() && entity.isSneaking()) {