From 96261af9f82af925c67c4d41e8057d3acba103ce Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Wed, 7 Jul 2021 20:12:38 +0200 Subject: [PATCH] Fix de-spawn packet implementation to support 1.17.1 --- .../w1zzrd/spigot/wizcompat/packet/EntityCreator.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dev/w1zzrd/spigot/wizcompat/packet/EntityCreator.java b/src/dev/w1zzrd/spigot/wizcompat/packet/EntityCreator.java index d103c2b..79f1857 100644 --- a/src/dev/w1zzrd/spigot/wizcompat/packet/EntityCreator.java +++ b/src/dev/w1zzrd/spigot/wizcompat/packet/EntityCreator.java @@ -69,8 +69,17 @@ public final class EntityCreator { } public static void sendEntityDespawnPacket(final Player target, final int entityID) { + sendEntityDespawnPackets(target, entityID); + } + + public static void sendEntityDespawnPackets(final Player target, final int... entityIDs) { final Package versionPackage = getNativePacketPackage(target); - Packets.sendPacket(target, reflectConstruct(loadClass(versionPackage, "PacketPlayOutEntityDestroy", "game.PacketPlayOutEntityDestroy"), entityID)); + try { + Packets.sendPacket(target, reflectConstruct(loadClass(versionPackage, "PacketPlayOutEntityDestroy", "game.PacketPlayOutEntityDestroy"), new Object[]{ entityIDs })); + } catch (Throwable t) { + for (int entityID : entityIDs) + Packets.sendPacket(target, reflectConstruct(loadClass(versionPackage, "PacketPlayOutEntityDestroy", "game.PacketPlayOutEntityDestroy"), entityID)); + } } public static int getEntityID(final Object entity) {