From 5bec816d02ba2b32c63e2c403dd4bc4d90ec7e18 Mon Sep 17 00:00:00 2001 From: Pyrbu Date: Thu, 30 Nov 2023 20:18:00 +0100 Subject: [PATCH] expose entity id in api --- api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java | 5 +++++ plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java b/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java index cf20af2..00c3efe 100644 --- a/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java +++ b/api/src/main/java/lol/pyr/znpcsplus/api/npc/Npc.java @@ -113,4 +113,9 @@ public interface Npc extends PropertyHolder { * @param pitch The pitch to set */ void setHeadRotation(float yaw, float pitch); + + /** + * @return The entity id of the packet entity that this npc object represents + */ + int getPacketEntityId(); } diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java index 8ee3a58..93672e7 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java @@ -49,7 +49,6 @@ public class NpcImpl extends Viewable implements Npc { hologram = new HologramImpl(propertyRegistry, configManager, packetFactory, textSerializer, location.withY(location.getY() + type.getHologramOffset())); } - public void setType(NpcTypeImpl type) { UNSAFE_hideAll(); this.type = type; @@ -134,7 +133,7 @@ public class NpcImpl extends Viewable implements Npc { private void UNSAFE_refreshProperty(EntityPropertyImpl property) { for (Player viewer : getViewers()) { List data = property.applyStandalone(viewer, entity, true); - if (data.size() > 0) packetFactory.sendMetadata(viewer, entity, data); + if (!data.isEmpty()) packetFactory.sendMetadata(viewer, entity, data); } } @@ -192,4 +191,9 @@ public class NpcImpl extends Viewable implements Npc { public void editAction(int index, InteractionActionImpl action) { actions.set(index, action); } + + @Override + public int getPacketEntityId() { + return entity.getEntityId(); + } }