From c9c71ba80d972a7e57aa8778c59cbcb473d8dce9 Mon Sep 17 00:00:00 2001 From: Jitse Boonstra Date: Sat, 14 Mar 2020 23:29:07 +0100 Subject: [PATCH] Patch for hologram glitch in 1.15 R1. --- api/pom.xml | 2 +- .../main/java/net/jitse/npclib/hologram/Hologram.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index a1a75b9..e0bef4e 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -28,7 +28,7 @@ org.spigotmc spigot-api - 1.14.4-R0.1-SNAPSHOT + 1.15.2-R0.1-SNAPSHOT provided diff --git a/api/src/main/java/net/jitse/npclib/hologram/Hologram.java b/api/src/main/java/net/jitse/npclib/hologram/Hologram.java index 1493e18..3cad652 100644 --- a/api/src/main/java/net/jitse/npclib/hologram/Hologram.java +++ b/api/src/main/java/net/jitse/npclib/hologram/Hologram.java @@ -18,6 +18,7 @@ public class Hologram { private final List armorStands = new ArrayList<>(); private final List showPackets = new ArrayList<>(); private final List hidePackets = new ArrayList<>(); + private final List metaPackets = new ArrayList<>(); private static final double DELTA = 0.3; @@ -89,6 +90,8 @@ public class Hologram { .invoke(CRAFT_BUKKIT_CLASS.cast(location.getWorld())); createPackets(); + // Create update packets so we can send the metadata packet for V1.15 R1 and up. + getUpdatePackets(text); } private void createPackets() { @@ -139,6 +142,11 @@ public class Hologram { showPackets.add(PACKET_PLAY_OUT_SPAWN_ENTITY_LIVING_CONSTRUCTOR.invoke(entityArmorStand)); hidePackets.add(PACKET_PLAY_OUT_ENTITY_DESTROY_CONSTRUCTOR .invoke(new int[]{(int) GET_ID_METHOD.invoke(entityArmorStand)})); + // For 1.15 R1 and up. + metaPackets.add(PACKET_PLAY_OUT_ENTITY_METADATA_CONSTRUCTOR.invoke( + GET_ID_METHOD.invoke(entityArmorStand), + GET_DATAWATCHER_METHOD.invoke(entityArmorStand), + true)); location.subtract(0, DELTA, 0); } @@ -199,6 +207,9 @@ public class Hologram { for (int i = 0; i < text.size(); i++) { if (text.get(i).isEmpty()) continue; // No need to spawn the line. SEND_PACKET_METHOD.invoke(playerConnection, showPackets.get(i)); + if (version.isAboveOrEqual(MinecraftVersion.V1_15_R1)) { + SEND_PACKET_METHOD.invoke(playerConnection, metaPackets.get(i)); + } } }