make interaction detection also treat holograms as part of the npc (fixes #76)

This commit is contained in:
Pyrbu 2023-07-24 02:51:40 +02:00
parent c8abf4f3fb
commit 32b588807a
2 changed files with 7 additions and 1 deletions

@ -51,6 +51,10 @@ public class HologramLine implements PropertyHolder {
armorStand.setLocation(location, viewers);
}
public int getEntityId() {
return armorStand.getEntityId();
}
@SuppressWarnings("unchecked")
@Override
public <T> T getProperty(EntityProperty<T> key) {

@ -103,7 +103,9 @@ public class NpcRegistryImpl implements NpcRegistry {
}
public NpcEntryImpl getByEntityId(int id) {
return npcList.stream().filter(entry -> entry.getNpc().getEntity().getEntityId() == id).findFirst().orElse(null);
return npcList.stream().filter(entry -> entry.getNpc().getEntity().getEntityId() == id ||
entry.getNpc().getHologram().getLines().stream().anyMatch(line -> line.getEntityId() == id)) // Also match the holograms of npcs
.findFirst().orElse(null);
}
public Collection<String> getAllIds() {