diff --git a/api/src/main/java/lol/pyr/znpcsplus/util/SkeletonType.java b/api/src/main/java/lol/pyr/znpcsplus/util/SkeletonType.java new file mode 100644 index 0000000..ba3f05f --- /dev/null +++ b/api/src/main/java/lol/pyr/znpcsplus/util/SkeletonType.java @@ -0,0 +1,11 @@ +package lol.pyr.znpcsplus.util; + +public enum SkeletonType { + NORMAL, + WITHER, + STRAY; + + public byte getLegacyId() { + return (byte) ordinal(); + } +} diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java b/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java index c4d1f9a..383d84f 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java @@ -296,6 +296,7 @@ public class ZNpcsPlus { registerEnumParser(manager, ArmadilloState.class, incorrectUsageMessage); registerEnumParser(manager, WoldVariant.class, incorrectUsageMessage); registerEnumParser(manager, NpcStorageType.class, incorrectUsageMessage); + registerEnumParser(manager, SkeletonType.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 a10ce9f..024a28a 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java @@ -91,6 +91,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { registerEnumSerializer(Sound.class); registerEnumSerializer(ArmadilloState.class); registerEnumSerializer(WoldVariant.class); + registerEnumSerializer(SkeletonType.class); registerPrimitiveSerializers(Integer.class, Boolean.class, Double.class, Float.class, Long.class, Short.class, Byte.class, String.class); @@ -439,6 +440,12 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { witherIndex += 3; // skip the first 3 indexes, will be used for the other properties later register(new IntegerProperty("invulnerable_time", witherIndex, 0, false)); + // Skeleton + if (ver.isOlderThan(ServerVersion.V_1_11)) { + if (legacyBooleans) register(new EncodedByteProperty<>("skeleton_type", SkeletonType.NORMAL, 13, SkeletonType::getLegacyId)); + else register(new EncodedIntegerProperty<>("skeleton_type", SkeletonType.NORMAL, ver.isOlderThan(ServerVersion.V_1_10) ? 11 : 12, Enum::ordinal)); + } + if (!ver.isNewerThanOrEquals(ServerVersion.V_1_9)) return; // Shulker int shulkerIndex; 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 bfb259e..f62adb8 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java @@ -143,6 +143,9 @@ public class NpcTypeImpl implements NpcType { } else if (version.isOlderThan(ServerVersion.V_1_11) && type.equals(EntityTypes.HORSE)) { addProperties("has_chest"); } + if (version.isOlderThan(ServerVersion.V_1_11) && EntityTypes.isTypeInstanceOf(type, EntityTypes.SKELETON)) { + addProperties("skeleton_type"); + } if (EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_EVO_ILLU_ILLAGER)) { addProperties("spell"); }