From 12ea0eab22a6bbf27c4492429fdc82edc8f04713 Mon Sep 17 00:00:00 2001 From: D3v1s0m Date: Mon, 21 Aug 2023 20:17:30 +0530 Subject: [PATCH] added baby property --- .../znpcsplus/entity/EntityPropertyRegistryImpl.java | 11 +++++++++-- .../main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) 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 3ceeed8..9ffcbb4 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java @@ -62,8 +62,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { /* registerType("using_item", false); // TODO: fix it for 1.8 and add new property to use offhand item and riptide animation - registerType("baby", false); // TODO - // Player registerType("shoulder_entity_left", ParrotVariant.NONE); registerType("shoulder_entity_right", ParrotVariant.NONE); @@ -210,6 +208,15 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { register(new EncodedIntegerProperty<>("potion_color", Color.class, potionIndex++, Color::asRGB)); register(new BooleanProperty("potion_ambient", potionIndex, false, legacyBooleans)); + int babyIndex; + if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) babyIndex = 16; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) babyIndex = 15; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_14)) babyIndex = 14; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_10)) babyIndex = 12; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_9)) babyIndex = 11; + else babyIndex = 12; + register(new BooleanProperty("baby", babyIndex, false, legacyBooleans)); + // Player register(new DummyProperty<>("skin", SkinDescriptor.class, false)); final int skinLayersIndex; 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 4d406c0..2c8f05c 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeImpl.java @@ -3,6 +3,7 @@ package lol.pyr.znpcsplus.npc; import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.manager.server.ServerVersion; import com.github.retrooper.packetevents.protocol.entity.type.EntityType; +import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes; import lol.pyr.znpcsplus.api.entity.EntityProperty; import lol.pyr.znpcsplus.api.npc.NpcType; import lol.pyr.znpcsplus.entity.EntityPropertyImpl; @@ -92,6 +93,9 @@ public class NpcTypeImpl implements NpcType { if (version.isNewerThanOrEquals(ServerVersion.V_1_9)) addProperties("glow"); if (version.isNewerThanOrEquals(ServerVersion.V_1_14)) addProperties("pose"); if (version.isNewerThanOrEquals(ServerVersion.V_1_17)) addProperties("shaking"); + if (EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_AGEABLE)) { + addProperties("baby"); + } return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties)); } }