Give item holograms the same tracking range as the base hologram

This commit is contained in:
fullwall 2024-03-27 16:18:11 +08:00
parent 321088784c
commit 8cf37b0ecc

View File

@ -126,6 +126,10 @@ public class HologramTrait extends Trait {
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);
@ -138,6 +142,10 @@ public class HologramTrait extends Trait {
.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;