added armadillo npc and wolf variant property

This commit is contained in:
D3v1s0m 2024-05-29 23:15:21 +05:30
parent 1e80b0b217
commit 3a4baaf1dc
No known key found for this signature in database
GPG Key ID: FA1F770C7B1D40C1
6 changed files with 55 additions and 1 deletions

@ -0,0 +1,8 @@
package lol.pyr.znpcsplus.util;
public enum ArmadilloState {
IDLE,
ROLLING,
SCARED,
UNROLLING
}

@ -0,0 +1,23 @@
package lol.pyr.znpcsplus.util;
public enum WoldVariant {
PALE(3),
SPOTTED(6),
SNOWY(5),
BLACK(1),
ASHEN(0),
RUSTY(4),
WOODS(8),
CHESTNUT(2),
STRIPED(7);
private final int id;
WoldVariant(int id) {
this.id = id;
}
public int getId() {
return id;
}
}

@ -276,6 +276,8 @@ public class ZNpcsPlus {
registerEnumParser(manager, RabbitType.class, incorrectUsageMessage); registerEnumParser(manager, RabbitType.class, incorrectUsageMessage);
registerEnumParser(manager, AttachDirection.class, incorrectUsageMessage); registerEnumParser(manager, AttachDirection.class, incorrectUsageMessage);
registerEnumParser(manager, Sound.class, incorrectUsageMessage); registerEnumParser(manager, Sound.class, incorrectUsageMessage);
registerEnumParser(manager, ArmadilloState.class, incorrectUsageMessage);
registerEnumParser(manager, WoldVariant.class, incorrectUsageMessage);
manager.registerCommand("npc", new MultiCommand(bootstrap.loadHelpMessage("root")) manager.registerCommand("npc", new MultiCommand(bootstrap.loadHelpMessage("root"))
.addSubcommand("center", new CenterCommand(npcRegistry)) .addSubcommand("center", new CenterCommand(npcRegistry))

@ -86,6 +86,8 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
registerEnumSerializer(RabbitType.class); registerEnumSerializer(RabbitType.class);
registerEnumSerializer(AttachDirection.class); registerEnumSerializer(AttachDirection.class);
registerEnumSerializer(Sound.class); registerEnumSerializer(Sound.class);
registerEnumSerializer(ArmadilloState.class);
registerEnumSerializer(WoldVariant.class);
registerPrimitiveSerializers(Integer.class, Boolean.class, Double.class, Float.class, Long.class, Short.class, Byte.class, String.class); registerPrimitiveSerializers(Integer.class, Boolean.class, Double.class, Float.class, Long.class, Short.class, Byte.class, String.class);
@ -411,7 +413,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
register(new EncodedByteProperty<>("wolf_collar", DyeColor.BLUE, wolfIndex++, DyeColor::getDyeData)); register(new EncodedByteProperty<>("wolf_collar", DyeColor.BLUE, wolfIndex++, DyeColor::getDyeData));
} else register(new EncodedIntegerProperty<>("wolf_collar", DyeColor.RED, wolfIndex++, Enum::ordinal)); } else register(new EncodedIntegerProperty<>("wolf_collar", DyeColor.RED, wolfIndex++, Enum::ordinal));
if (ver.isNewerThanOrEquals(ServerVersion.V_1_16)) { if (ver.isNewerThanOrEquals(ServerVersion.V_1_16)) {
register(new EncodedIntegerProperty<>("wolf_angry", false, wolfIndex, b -> b ? 1 : 0)); register(new EncodedIntegerProperty<>("wolf_angry", false, wolfIndex++, b -> b ? 1 : 0));
linkProperties("tamed", "sitting"); linkProperties("tamed", "sitting");
} }
else { else {
@ -643,6 +645,14 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
// Sniffer // Sniffer
register(new CustomTypeProperty<>("sniffer_state", 17, SnifferState.IDLING, EntityDataTypes.SNIFFER_STATE, state -> com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState.valueOf(state.name()))); register(new CustomTypeProperty<>("sniffer_state", 17, SnifferState.IDLING, EntityDataTypes.SNIFFER_STATE, state -> com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState.valueOf(state.name())));
if (!ver.isNewerThanOrEquals(ServerVersion.V_1_20_5)) return;
// Armadillo
register(new CustomTypeProperty<>("armadillo_state", 17, ArmadilloState.IDLE, EntityDataTypes.ARMADILLO_STATE, state ->
com.github.retrooper.packetevents.protocol.entity.armadillo.ArmadilloState.valueOf(state.name())));
// Wolf
register(new EncodedIntegerProperty<>("wolf_variant", WoldVariant.PALE, wolfIndex, WoldVariant::getId, EntityDataTypes.WOLF_VARIANT));
} }
private void registerSerializer(PropertySerializer<?> serializer) { private void registerSerializer(PropertySerializer<?> serializer) {

@ -170,6 +170,11 @@ public class NpcTypeImpl implements NpcType {
if (EntityTypes.isTypeInstanceOf(type, EntityTypes.GUARDIAN)) { if (EntityTypes.isTypeInstanceOf(type, EntityTypes.GUARDIAN)) {
addProperties("is_retracting_spikes"); addProperties("is_retracting_spikes");
} }
if (version.isNewerThanOrEquals(ServerVersion.V_1_20_5)) {
if (EntityTypes.isTypeInstanceOf(type, EntityTypes.WOLF)) {
addProperties("wolf_variant");
}
}
return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties), defaultProperties); return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties), defaultProperties);
} }
} }

@ -368,6 +368,12 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
register(builder(p, "camel", EntityTypes.CAMEL) register(builder(p, "camel", EntityTypes.CAMEL)
.setHologramOffset(0.25) .setHologramOffset(0.25)
.addProperties("bashing", "camel_sitting")); .addProperties("bashing", "camel_sitting"));
if (!version.isNewerThanOrEquals(ServerVersion.V_1_20_5)) return;
register(builder(p, "armadillo", EntityTypes.ARMADILLO)
.setHologramOffset(-1.475)
.addProperties("armadillo_state"));
} }
public Collection<NpcType> getAll() { public Collection<NpcType> getAll() {