Adjust hologram mount strategy

This commit is contained in:
fullwall 2023-11-01 00:58:28 +08:00
parent 401e34a4a3
commit 483b6565cd
1 changed files with 8 additions and 1 deletions

View File

@ -106,7 +106,6 @@ public class HologramTrait extends Trait {
hologramNPC = registry.createNPC(EntityType.INTERACTION, line); hologramNPC = registry.createNPC(EntityType.INTERACTION, line);
hologramNPC.addTrait(new ClickRedirectTrait(npc)); hologramNPC.addTrait(new ClickRedirectTrait(npc));
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, true); hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, true);
hologramNPC.getOrAddTrait(MountTrait.class).setMountedOn(npc.getUniqueId());
} else { } else {
hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line); hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line);
hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsHelperEntityWithName(npc); hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsHelperEntityWithName(npc);
@ -339,6 +338,10 @@ public class HologramTrait extends Trait {
if (updateName) { if (updateName) {
nameLine.setText(npc.getRawName()); nameLine.setText(npc.getRawName());
} }
if (useDisplayEntities && nameLine.hologram.getEntity().getVehicle() == null) {
npc.getEntity().addPassenger(nameLine.hologram.getEntity());
}
} }
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
@ -359,6 +362,10 @@ public class HologramTrait extends Trait {
hologramNPC.teleport(tp, TeleportCause.PLUGIN); hologramNPC.teleport(tp, TeleportCause.PLUGIN);
} }
if (useDisplayEntities && hologramNPC.getEntity().getVehicle() == null) {
npc.getEntity().addPassenger(hologramNPC.getEntity());
}
String text = line.text; String text = line.text;
if (ITEM_MATCHER.matcher(text).matches()) { if (ITEM_MATCHER.matcher(text).matches()) {
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, false); hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, false);