Fix bug and add a method to simplify name showing

This commit is contained in:
fullwall 2022-04-17 14:51:05 +08:00
parent da76924041
commit f4e3786514
2 changed files with 6 additions and 2 deletions

View File

@ -135,6 +135,11 @@ public class ArmorStandTrait extends Trait {
npc.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
}
public void setAsPointEntityWithName() {
setAsPointEntity();
npc.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, true);
}
/**
* @see ArmorStand#setGravity(boolean)
*/

View File

@ -73,8 +73,7 @@ public class HologramTrait extends Trait {
private NPC createHologram(String line, double heightOffset) {
NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line);
hologramNPC.addTrait(new ClickRedirectTrait(npc));
hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsPointEntity();
npc.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, true);
hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsPointEntityWithName();
hologramNPC.spawn(currentLoc.clone().add(0,
getEntityHeight()
+ (direction == HologramDirection.BOTTOM_UP ? heightOffset : getMaxHeight() - heightOffset),