Prep for a future feature

This commit is contained in:
Sollace 2022-09-30 10:21:18 +02:00
parent 1d5bd75d6a
commit 5fff677f79
9 changed files with 15 additions and 15 deletions

View file

@ -83,7 +83,7 @@ public class CustomEventCriterion extends AbstractCriterion<CustomEventCriterion
public boolean test(String event, int count, ServerPlayerEntity player) { public boolean test(String event, int count, ServerPlayerEntity player) {
return this.event.equalsIgnoreCase(event) return this.event.equalsIgnoreCase(event)
&& (races.isEmpty() || races.contains(Pony.of(player).getSpecies())) && (races.isEmpty() || races.contains(Pony.of(player).getActualSpecies()))
&& (flying == null || flying == Pony.of(player).getPhysics().isFlying()) && (flying == null || flying == Pony.of(player).getPhysics().isFlying())
&& (repeatCount <= 0 || (count > 0 && count % repeatCount == 0)); && (repeatCount <= 0 || (count > 0 && count % repeatCount == 0));
} }

View file

@ -44,7 +44,7 @@ public class RaceChangeCriterion extends AbstractCriterion<RaceChangeCriterion.C
} }
public boolean test(ServerPlayerEntity player) { public boolean test(ServerPlayerEntity player) {
return Pony.of(player).getSpecies() == race; return Pony.of(player).getActualSpecies() == race;
} }
@Override @Override

View file

@ -84,7 +84,7 @@ public class DismissSpellScreen extends GameGui {
DrawableUtil.drawArc(matrices, 160, 1600, 0, DrawableUtil.TAU, 0x00000020, false); DrawableUtil.drawArc(matrices, 160, 1600, 0, DrawableUtil.TAU, 0x00000020, false);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
DrawableUtil.renderRaceIcon(matrices, pony.getSpecies(), 0, 0, 16); DrawableUtil.renderRaceIcon(matrices, pony.getActualSpecies(), 0, 0, 16);
matrices.pop(); matrices.pop();
DrawableUtil.drawLine(matrices, mouseX, mouseY - 4, mouseX, mouseY + 4, 0xFFAAFF99); DrawableUtil.drawLine(matrices, mouseX, mouseY - 4, mouseX, mouseY + 4, 0xFFAAFF99);

View file

@ -36,7 +36,7 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell
screen.addDrawable(new SpellbookScreen.ImageButton(x, y, size, size)) screen.addDrawable(new SpellbookScreen.ImageButton(x, y, size, size))
.getStyle() .getStyle()
.setIcon(TribeButton.createSprite(pony.getSpecies(), 0, 0, size)) .setIcon(TribeButton.createSprite(pony.getActualSpecies(), 0, 0, size))
.setTooltip(ProfileTooltip.get(pony)); .setTooltip(ProfileTooltip.get(pony));

View file

@ -70,7 +70,7 @@ class SpeciesCommand {
} }
static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) { static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) {
Race spec = Pony.of(player).getSpecies(); Race spec = Pony.of(player).getActualSpecies();
String name = "commands.race.tell."; String name = "commands.race.tell.";
name += isSelf ? "self" : "other"; name += isSelf ? "self" : "other";

View file

@ -75,7 +75,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
int progression = ticks % (stage.ordinal() * STAGE_DURATION); int progression = ticks % (stage.ordinal() * STAGE_DURATION);
if (eq.getSpecies() == race || !race.isPermitted(entity instanceof PlayerEntity ? (PlayerEntity)entity : null)) { if ((eq instanceof Pony pony ? pony.getActualSpecies() : eq.getSpecies()) == race || !race.isPermitted(entity instanceof PlayerEntity ? (PlayerEntity)entity : null)) {
if (progression == 0 && entity instanceof PlayerEntity && stage == Stage.CRAWLING) { if (progression == 0 && entity instanceof PlayerEntity && stage == Stage.CRAWLING) {
((PlayerEntity)entity).sendMessage(Stage.INITIAL.getMessage(race), true); ((PlayerEntity)entity).sendMessage(Stage.INITIAL.getMessage(race), true);
} }

View file

@ -166,11 +166,11 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
@Override @Override
public Race getSpecies() { public Race getSpecies() {
if (getMaster() == null) { return getActualSpecies();
return Race.HUMAN;
} }
return Race.fromName(getMaster().getDataTracker().get(RACE), Race.HUMAN); public Race getActualSpecies() {
return Race.fromName(entity.getDataTracker().get(RACE), Race.HUMAN);
} }
@Override @Override
@ -285,7 +285,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
if (race != clientPreferredRace) { if (race != clientPreferredRace) {
clientPreferredRace = race; clientPreferredRace = race;
if (race != getSpecies()) { if (race != getActualSpecies()) {
Channel.CLIENT_REQUEST_SPECIES_CHANGE.send(new MsgRequestSpeciesChange(race)); Channel.CLIENT_REQUEST_SPECIES_CHANGE.send(new MsgRequestSpeciesChange(race));
} }
} }
@ -552,7 +552,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
@Override @Override
public void toNBT(NbtCompound compound) { public void toNBT(NbtCompound compound) {
super.toNBT(compound); super.toNBT(compound);
compound.putString("playerSpecies", Race.REGISTRY.getId(getSpecies()).toString()); compound.putString("playerSpecies", Race.REGISTRY.getId(getActualSpecies()).toString());
compound.putFloat("magicExhaustion", magicExhaustion); compound.putFloat("magicExhaustion", magicExhaustion);
compound.putInt("ticksHanging", ticksHanging); compound.putInt("ticksHanging", ticksHanging);
NbtSerialisable.writeBlockPos("hangingPosition", hangingPosition, compound); NbtSerialisable.writeBlockPos("hangingPosition", hangingPosition, compound);
@ -616,7 +616,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
oldPlayer.getSpellSlot().stream(true).filter(SpellPredicate.IS_PLACED).forEach(getSpellSlot()::put); oldPlayer.getSpellSlot().stream(true).filter(SpellPredicate.IS_PLACED).forEach(getSpellSlot()::put);
} }
oldPlayer.getSpellSlot().put(null); oldPlayer.getSpellSlot().put(null);
setSpecies(oldPlayer.getSpecies()); setSpecies(oldPlayer.getActualSpecies());
getDiscoveries().copyFrom(oldPlayer.getDiscoveries()); getDiscoveries().copyFrom(oldPlayer.getDiscoveries());
getCharms().equipSpell(Hand.MAIN_HAND, oldPlayer.getCharms().getEquippedSpell(Hand.MAIN_HAND)); getCharms().equipSpell(Hand.MAIN_HAND, oldPlayer.getCharms().getEquippedSpell(Hand.MAIN_HAND));
getCharms().equipSpell(Hand.OFF_HAND, oldPlayer.getCharms().getEquippedSpell(Hand.OFF_HAND)); getCharms().equipSpell(Hand.OFF_HAND, oldPlayer.getCharms().getEquippedSpell(Hand.OFF_HAND));

View file

@ -42,7 +42,7 @@ public class MsgPlayerCapabilities implements Packet<PlayerEntity> {
public MsgPlayerCapabilities(boolean full, Pony player) { public MsgPlayerCapabilities(boolean full, Pony player) {
playerId = player.getMaster().getUuid(); playerId = player.getMaster().getUuid();
newRace = player.getSpecies(); newRace = player.getActualSpecies();
compoundTag = full ? player.toNBT() : new NbtCompound(); compoundTag = full ? player.toNBT() : new NbtCompound();
} }

View file

@ -45,7 +45,7 @@ public class MsgRequestSpeciesChange implements Packet<ServerPlayerEntity> {
Race worldDefaultRace = WorldTribeManager.forWorld((ServerWorld)player.getReferenceWorld()).getDefaultRace(); Race worldDefaultRace = WorldTribeManager.forWorld((ServerWorld)player.getReferenceWorld()).getDefaultRace();
if (force || player.getSpecies().isDefault() || (player.getSpecies() == worldDefaultRace && !player.isSpeciesPersisted())) { if (force || player.getActualSpecies().isDefault() || (player.getActualSpecies() == worldDefaultRace && !player.isSpeciesPersisted())) {
player.setSpecies(newRace.isPermitted(sender) ? newRace : worldDefaultRace); player.setSpecies(newRace.isPermitted(sender) ? newRace : worldDefaultRace);
} }