mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-25 18:47:40 +01:00
Update holograms if height changes
This commit is contained in:
parent
96ba80edd8
commit
e82eb76aba
@ -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 },
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user