From e82eb76abaa79cb8e6e6a2a82feedbd75b5bbb7e Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 21 Apr 2022 15:25:57 +0800 Subject: [PATCH] Update holograms if height changes --- .../java/net/citizensnpcs/editor/GenericEquipperGUI.java | 4 ++-- .../src/main/java/net/citizensnpcs/trait/HologramTrait.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/editor/GenericEquipperGUI.java b/main/src/main/java/net/citizensnpcs/editor/GenericEquipperGUI.java index 26c1a1095..54b4c4904 100644 --- a/main/src/main/java/net/citizensnpcs/editor/GenericEquipperGUI.java +++ b/main/src/main/java/net/citizensnpcs/editor/GenericEquipperGUI.java @@ -21,15 +21,15 @@ import net.citizensnpcs.api.trait.trait.Equipment; import net.citizensnpcs.api.trait.trait.Equipment.EquipmentSlot; @Menu(title = "NPC Equipment", type = InventoryType.CHEST, dimensions = { 2, 5 }) -@MenuSlot(slot = { 0, 2 }, material = Material.DIAMOND_HELMET, amount = 1, lore = "Place a helmet below") -@MenuSlot(slot = { 0, 4 }, material = Material.DIAMOND_LEGGINGS, lore = "Place leggings below", amount = 1) @MenuSlot( slot = { 0, 1 }, compatMaterial = { "SHIELD", "BARRIER", "FIRE" }, lore = "Place offhand item below", amount = 1) @MenuSlot(slot = { 0, 0 }, material = Material.DIAMOND_SWORD, lore = "Place in hand item below", amount = 1) +@MenuSlot(slot = { 0, 2 }, material = Material.DIAMOND_HELMET, lore = "Place helmet below", amount = 1) @MenuSlot(slot = { 0, 3 }, material = Material.DIAMOND_CHESTPLATE, lore = "Place chestplate below", amount = 1) +@MenuSlot(slot = { 0, 4 }, material = Material.DIAMOND_LEGGINGS, lore = "Place leggings below", amount = 1) @MenuSlot(slot = { 0, 5 }, material = Material.DIAMOND_BOOTS, lore = "Place boots below", amount = 1) @MenuPattern( offset = { 0, 6 }, diff --git a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java index 5bebd79b5..a00d13d8b 100644 --- a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java @@ -37,6 +37,7 @@ public class HologramTrait extends Trait { private Location currentLoc; @Persist private HologramDirection direction = HologramDirection.BOTTOM_UP; + private double lastEntityHeight = 0; private boolean lastNameplateVisible; @Persist private double lineHeight = -1; @@ -93,6 +94,7 @@ public class HologramTrait extends Trait { } }); } + lastEntityHeight = getEntityHeight(); return hologramNPC; } @@ -209,11 +211,13 @@ public class HologramTrait extends Trait { } } boolean update = currentLoc.getWorld() != npc.getStoredLocation().getWorld() - || currentLoc.distance(npc.getStoredLocation()) >= 0.001 || lastNameplateVisible != nameplateVisible; + || currentLoc.distance(npc.getStoredLocation()) >= 0.001 || lastNameplateVisible != nameplateVisible + || (lastEntityHeight - getEntityHeight()) >= 0.05; lastNameplateVisible = nameplateVisible; if (update) { currentLoc = npc.getStoredLocation(); + lastEntityHeight = getEntityHeight(); } if (nameNPC != null && nameNPC.isSpawned()) { if (update) {