mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-13 11:41:26 +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;
|
import net.citizensnpcs.api.trait.trait.Equipment.EquipmentSlot;
|
||||||
|
|
||||||
@Menu(title = "NPC Equipment", type = InventoryType.CHEST, dimensions = { 2, 5 })
|
@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(
|
@MenuSlot(
|
||||||
slot = { 0, 1 },
|
slot = { 0, 1 },
|
||||||
compatMaterial = { "SHIELD", "BARRIER", "FIRE" },
|
compatMaterial = { "SHIELD", "BARRIER", "FIRE" },
|
||||||
lore = "Place offhand item below",
|
lore = "Place offhand item below",
|
||||||
amount = 1)
|
amount = 1)
|
||||||
@MenuSlot(slot = { 0, 0 }, material = Material.DIAMOND_SWORD, lore = "Place in hand 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, 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)
|
@MenuSlot(slot = { 0, 5 }, material = Material.DIAMOND_BOOTS, lore = "Place boots below", amount = 1)
|
||||||
@MenuPattern(
|
@MenuPattern(
|
||||||
offset = { 0, 6 },
|
offset = { 0, 6 },
|
||||||
|
@ -37,6 +37,7 @@ public class HologramTrait extends Trait {
|
|||||||
private Location currentLoc;
|
private Location currentLoc;
|
||||||
@Persist
|
@Persist
|
||||||
private HologramDirection direction = HologramDirection.BOTTOM_UP;
|
private HologramDirection direction = HologramDirection.BOTTOM_UP;
|
||||||
|
private double lastEntityHeight = 0;
|
||||||
private boolean lastNameplateVisible;
|
private boolean lastNameplateVisible;
|
||||||
@Persist
|
@Persist
|
||||||
private double lineHeight = -1;
|
private double lineHeight = -1;
|
||||||
@ -93,6 +94,7 @@ public class HologramTrait extends Trait {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
lastEntityHeight = getEntityHeight();
|
||||||
return hologramNPC;
|
return hologramNPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,11 +211,13 @@ public class HologramTrait extends Trait {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean update = currentLoc.getWorld() != npc.getStoredLocation().getWorld()
|
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;
|
lastNameplateVisible = nameplateVisible;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
currentLoc = npc.getStoredLocation();
|
currentLoc = npc.getStoredLocation();
|
||||||
|
lastEntityHeight = getEntityHeight();
|
||||||
}
|
}
|
||||||
if (nameNPC != null && nameNPC.isSpawned()) {
|
if (nameNPC != null && nameNPC.isSpawned()) {
|
||||||
if (update) {
|
if (update) {
|
||||||
|
Loading…
Reference in New Issue
Block a user