diff --git a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java index 4b39a073d..5e3019d7c 100644 --- a/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/HologramTrait.java @@ -120,7 +120,7 @@ public class HologramTrait extends Trait { if (!SUPPORTS_DISPLAY || hologramSetting.equalsIgnoreCase("armorstand")) return new ArmorstandRenderer(); return hologramSetting.equalsIgnoreCase("interaction") ? new InteractionVehicleRenderer() - : new TextDisplayVehicleRenderer(); + : new TextDisplayRenderer(); } private HologramRenderer createNameRenderer() { @@ -654,6 +654,44 @@ public class HologramTrait extends Trait { private static Set LINE_ARGS = ImmutableSet.of("set", "remove", "margintop", "marginbottom"); } + public class TextDisplayRenderer extends SingleEntityHologramRenderer { + private Color color; + + @Override + protected NPC createNPC(Entity base, String name, Vector3d offset) { + NPC hologram = registry.createNPC(EntityType.TEXT_DISPLAY, ""); + hologram.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, false); + hologram.data().set(NPC.Metadata.TEXT_DISPLAY_COMPONENT, Messaging.minecraftComponentFromRawMessage(name)); + return hologram; + } + + @Override + public void render0(NPC base, Vector3d offset) { + TextDisplay disp = (TextDisplay) hologram.getEntity(); + disp.setInterpolationDelay(0); + disp.setInterpolationDuration(0); + disp.setBillboard(Billboard.CENTER); + if (color != null) { + disp.setBackgroundColor(color); + } + hologram.getEntity().teleport( + npc.getStoredLocation().clone().add(offset.x, offset.y + getEntityBbHeight(), offset.z), + TeleportCause.PLUGIN); + } + + public void setBackgroundColor(Color color) { + this.color = color; + } + + @Override + public void updateText(NPC npc, String raw) { + this.text = Placeholders.replace(raw, null, npc); + if (hologram == null) + return; + hologram.data().set(NPC.Metadata.TEXT_DISPLAY_COMPONENT, Messaging.minecraftComponentFromRawMessage(text)); + } + } + public class TextDisplayVehicleRenderer extends SingleEntityHologramRenderer { private Color color; @@ -672,7 +710,7 @@ public class HologramTrait extends Trait { disp.setInterpolationDuration(0); disp.setBillboard(Billboard.CENTER); Transformation tf = disp.getTransformation(); - tf.getTranslation().y = (float) offset.y + 0.2f; + tf.getTranslation().y = (float) offset.y + 0.7f; disp.setTransformation(tf); if (color != null) { disp.setBackgroundColor(color); diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java index e75733a49..50cf711e7 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java @@ -935,7 +935,7 @@ public class NMSImpl implements NMSBridge { @Override public void linkTextInteraction(org.bukkit.entity.Player player, org.bukkit.entity.Entity entity, org.bukkit.entity.Entity mount, double offset) { - offset += -0.5 + getHandle(mount).getPassengersRidingOffset(); + offset += -0.9 + getHandle(mount).getPassengersRidingOffset(); sendPacket(player, new ClientboundBundlePacket(List.of( new ClientboundSetEntityDataPacket(entity.getEntityId(),