Patch for hologram glitch in 1.15 R1.

This commit is contained in:
Jitse Boonstra 2020-03-14 23:29:07 +01:00
parent 9bf3095a56
commit c9c71ba80d
2 changed files with 12 additions and 1 deletions

View File

@ -28,7 +28,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -18,6 +18,7 @@ public class Hologram {
private final List<Object> armorStands = new ArrayList<>();
private final List<Object> showPackets = new ArrayList<>();
private final List<Object> hidePackets = new ArrayList<>();
private final List<Object> 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));
}
}
}