Skip to content

Commit

Permalink
Give item holograms the same tracking range as the base hologram
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 27, 2024
1 parent 3210887 commit 8cf37b0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main/src/main/java/net/citizensnpcs/trait/HologramTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ private NPC createHologram(String line, double heightOffset) {
if (itemMatcher.matches()) {
Material item = SpigotUtil.isUsing1_13API() ? Material.matchMaterial(itemMatcher.group(1), false)
: Material.matchMaterial(itemMatcher.group(1));
if (item == null) {
hologramNPC.destroy();
throw new IllegalStateException("Unknown material " + line);
}
ItemStack itemStack = new ItemStack(item, 1);
NPC itemNPC = registry.createNPCUsingItem(EntityType.DROPPED_ITEM, "", itemStack);
itemNPC.data().setPersistent(NPC.Metadata.NAMEPLATE_VISIBLE, false);
Expand All @@ -138,6 +142,10 @@ private NPC createHologram(String line, double heightOffset) {
.setColor(Util.matchEnum(ChatColor.values(), itemMatcher.group(2).substring(1)));
}
}
if (hologramNPC.data().has(NPC.Metadata.TRACKING_RANGE)) {
itemNPC.data().setPersistent(NPC.Metadata.TRACKING_RANGE,
hologramNPC.data().get(NPC.Metadata.TRACKING_RANGE));
}
itemNPC.getOrAddTrait(MountTrait.class).setMountedOn(hologramNPC.getUniqueId());
itemNPC.spawn(currentLoc);
NPC hn = hologramNPC;
Expand Down

0 comments on commit 8cf37b0

Please sign in to comment.