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 b62db66..ff582ba 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java @@ -72,14 +72,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { registerType("beam_target", null); // TODO: Make a block pos class for this registerType("show_base", true); // TODO - // Armor Stand - registerType("head_rotation", Vector3f.zero()); - registerType("body_rotation", Vector3f.zero()); - registerType("left_arm_rotation", new Vector3f(-10, 0, -10)); - registerType("right_arm_rotation", new Vector3f(-15, 0, 10)); - registerType("left_leg_rotation", new Vector3f(-1 , 0, -1)); - registerType("right_leg_rotation", new Vector3f(1, 0, 1)); - // Axolotl registerType("axolotl_variant", 0); registerType("playing_dead", false); // TODO fix disabling @@ -266,6 +258,19 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { linkProperties("skin_cape", "skin_jacket", "skin_left_sleeve", "skin_right_sleeve", "skin_left_leg", "skin_right_leg", "skin_hat"); + int armorStandRotationIndex; + if (ver.isNewerThanOrEquals(ServerVersion.V_1_17)) armorStandRotationIndex = 16; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_15)) armorStandRotationIndex = 15; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_14)) armorStandRotationIndex = 14; + else if (ver.isNewerThanOrEquals(ServerVersion.V_1_10)) armorStandRotationIndex = 12; + else armorStandRotationIndex = 11; + register(new RotationProperty("head_rotation", armorStandRotationIndex++, Vector3f.zero())); + register(new RotationProperty("body_rotation", armorStandRotationIndex++, Vector3f.zero())); + register(new RotationProperty("left_arm_rotation", armorStandRotationIndex++, new Vector3f(-10, 0, -10))); + register(new RotationProperty("right_arm_rotation", armorStandRotationIndex++, new Vector3f(-15, 0, 10))); + register(new RotationProperty("left_leg_rotation", armorStandRotationIndex++, new Vector3f(-1, 0, -1))); + register(new RotationProperty("right_leg_rotation", armorStandRotationIndex, new Vector3f(1, 0, 1))); + } private void registerSerializer(PropertySerializer serializer) { diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/RotationProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/RotationProperty.java new file mode 100644 index 0000000..412197d --- /dev/null +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/RotationProperty.java @@ -0,0 +1,25 @@ +package lol.pyr.znpcsplus.entity.properties; + +import com.github.retrooper.packetevents.protocol.entity.data.EntityData; +import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; +import lol.pyr.znpcsplus.entity.EntityPropertyImpl; +import lol.pyr.znpcsplus.entity.PacketEntity; +import lol.pyr.znpcsplus.util.Vector3f; +import org.bukkit.entity.Player; + +import java.util.Map; + +public class RotationProperty extends EntityPropertyImpl { + private final int index; + + public RotationProperty(String name, int index, Vector3f defaultValue) { + super(name, defaultValue, Vector3f.class); + this.index = index; + } + + @Override + public void apply(Player player, PacketEntity entity, boolean isSpawned, Map properties) { + Vector3f vec = entity.getProperty(this); + properties.put(index, newEntityData(index, EntityDataTypes.ROTATION, new com.github.retrooper.packetevents.util.Vector3f(vec.getX(), vec.getY(), vec.getZ()))); + } +}