expose entity id in api

This commit is contained in:
Pyrbu 2023-11-30 20:18:00 +01:00
parent caea8eaca2
commit 5bec816d02
2 changed files with 11 additions and 2 deletions

@ -113,4 +113,9 @@ public interface Npc extends PropertyHolder {
* @param pitch The pitch to set * @param pitch The pitch to set
*/ */
void setHeadRotation(float yaw, float pitch); void setHeadRotation(float yaw, float pitch);
/**
* @return The entity id of the packet entity that this npc object represents
*/
int getPacketEntityId();
} }

@ -49,7 +49,6 @@ public class NpcImpl extends Viewable implements Npc {
hologram = new HologramImpl(propertyRegistry, configManager, packetFactory, textSerializer, location.withY(location.getY() + type.getHologramOffset())); hologram = new HologramImpl(propertyRegistry, configManager, packetFactory, textSerializer, location.withY(location.getY() + type.getHologramOffset()));
} }
public void setType(NpcTypeImpl type) { public void setType(NpcTypeImpl type) {
UNSAFE_hideAll(); UNSAFE_hideAll();
this.type = type; this.type = type;
@ -134,7 +133,7 @@ public class NpcImpl extends Viewable implements Npc {
private <T> void UNSAFE_refreshProperty(EntityPropertyImpl<T> property) { private <T> void UNSAFE_refreshProperty(EntityPropertyImpl<T> property) {
for (Player viewer : getViewers()) { for (Player viewer : getViewers()) {
List<EntityData> data = property.applyStandalone(viewer, entity, true); List<EntityData> 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) { public void editAction(int index, InteractionActionImpl action) {
actions.set(index, action); actions.set(index, action);
} }
@Override
public int getPacketEntityId() {
return entity.getEntityId();
}
} }