From 3a4baaf1dc5ae58253a2ccbf0598a8fae6fca515 Mon Sep 17 00:00:00 2001 From: D3v1s0m Date: Wed, 29 May 2024 23:15:21 +0530 Subject: [PATCH] added armadillo npc and wolf variant property --- .../pyr/znpcsplus/util/ArmadilloState.java | 8 +++++++ .../lol/pyr/znpcsplus/util/WoldVariant.java | 23 +++++++++++++++++++ .../java/lol/pyr/znpcsplus/ZNpcsPlus.java | 2 ++ .../entity/EntityPropertyRegistryImpl.java | 12 +++++++++- .../lol/pyr/znpcsplus/npc/NpcTypeImpl.java | 5 ++++ .../znpcsplus/npc/NpcTypeRegistryImpl.java | 6 +++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 api/src/main/java/lol/pyr/znpcsplus/util/ArmadilloState.java create mode 100644 api/src/main/java/lol/pyr/znpcsplus/util/WoldVariant.java diff --git a/api/src/main/java/lol/pyr/znpcsplus/util/ArmadilloState.java b/api/src/main/java/lol/pyr/znpcsplus/util/ArmadilloState.java new file mode 100644 index 0000000..bdea88f --- /dev/null +++ b/api/src/main/java/lol/pyr/znpcsplus/util/ArmadilloState.java @@ -0,0 +1,8 @@ +package lol.pyr.znpcsplus.util; + +public enum ArmadilloState { + IDLE, + ROLLING, + SCARED, + UNROLLING +} diff --git a/api/src/main/java/lol/pyr/znpcsplus/util/WoldVariant.java b/api/src/main/java/lol/pyr/znpcsplus/util/WoldVariant.java new file mode 100644 index 0000000..fed5d66 --- /dev/null +++ b/api/src/main/java/lol/pyr/znpcsplus/util/WoldVariant.java @@ -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; + } +} diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java b/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java index 67ac5b9..21b879c 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java @@ -276,6 +276,8 @@ public class ZNpcsPlus { registerEnumParser(manager, RabbitType.class, incorrectUsageMessage); registerEnumParser(manager, AttachDirection.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")) .addSubcommand("center", new CenterCommand(npcRegistry)) diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java index 64b43a5..9565719 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java @@ -86,6 +86,8 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { registerEnumSerializer(RabbitType.class); registerEnumSerializer(AttachDirection.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); @@ -411,7 +413,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { register(new EncodedByteProperty<>("wolf_collar", DyeColor.BLUE, wolfIndex++, DyeColor::getDyeData)); } else register(new EncodedIntegerProperty<>("wolf_collar", DyeColor.RED, wolfIndex++, Enum::ordinal)); 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"); } else { @@ -643,6 +645,14 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { // Sniffer 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) { diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java index 565493f..c2b8cb1 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java @@ -170,6 +170,11 @@ public class NpcTypeImpl implements NpcType { if (EntityTypes.isTypeInstanceOf(type, EntityTypes.GUARDIAN)) { 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); } } diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java index 1d197f3..336c286 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java @@ -368,6 +368,12 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry { register(builder(p, "camel", EntityTypes.CAMEL) .setHologramOffset(0.25) .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 getAll() {