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 013e2cc..b7eef77 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java @@ -612,7 +612,9 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { if (!ver.isNewerThanOrEquals(ServerVersion.V_1_20)) return; // Camel - register(new BooleanProperty("bashing", 18, false, legacyBooleans)); + int camelIndex = 18; + register(new BooleanProperty("bashing", camelIndex++, false, legacyBooleans)); + register(new CamelSittingProperty(6, camelIndex)); // Sniffer register(new CustomTypeProperty<>("sniffer_state", 17, SnifferState.IDLING, EntityDataTypes.SNIFFER_STATE, state -> com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState.valueOf(state.name()))); diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/CamelSittingProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/CamelSittingProperty.java new file mode 100644 index 0000000..2732c21 --- /dev/null +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/CamelSittingProperty.java @@ -0,0 +1,33 @@ +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 com.github.retrooper.packetevents.protocol.entity.pose.EntityPose; +import lol.pyr.znpcsplus.entity.EntityPropertyImpl; +import lol.pyr.znpcsplus.entity.PacketEntity; +import org.bukkit.entity.Player; + +import java.util.Map; + +public class CamelSittingProperty extends EntityPropertyImpl { + private final int poseIndex; + private final int lastPoseTickIndex; + + public CamelSittingProperty(int poseIndex, int lastPoseTickIndex) { + super("camel_sitting", false, Boolean.class); + this.poseIndex = poseIndex; + this.lastPoseTickIndex = lastPoseTickIndex; + } + + @Override + public void apply(Player player, PacketEntity entity, boolean isSpawned, Map properties) { + boolean value = entity.getProperty(this); + if (value) { + properties.put(poseIndex, newEntityData(poseIndex, EntityDataTypes.ENTITY_POSE, EntityPose.SITTING)); + properties.put(lastPoseTickIndex, newEntityData(lastPoseTickIndex, EntityDataTypes.LONG, -1L)); + } else { + properties.put(poseIndex, newEntityData(poseIndex, EntityDataTypes.ENTITY_POSE, EntityPose.STANDING)); + properties.put(lastPoseTickIndex, newEntityData(lastPoseTickIndex, EntityDataTypes.LONG, 0L)); + } + } +} 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 2cc382f..1d197f3 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcTypeRegistryImpl.java @@ -367,7 +367,7 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry { register(builder(p, "camel", EntityTypes.CAMEL) .setHologramOffset(0.25) - .addProperties("bashing")); + .addProperties("bashing", "camel_sitting")); } public Collection getAll() {