From 6c176039053ac35af10b03a9289987db0d4feac1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 1 Jul 2021 09:40:22 +1200 Subject: [PATCH] Don't modify the destroy packet and just send our own --- .../PacketListenerEntityDestroy.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java index e175e4c2..bca5c82c 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerEntityDestroy.java @@ -71,26 +71,21 @@ public class PacketListenerEntityDestroy extends PacketAdapter { public void onPre17Packet(PacketEvent event) { int[] entityIds = event.getPacket().getIntegerArrays().read(0); - int[] newEntityIds = entityIds; for (int entityId : entityIds) { - int[] toAdd = getToRemove(event.getPlayer(), entityId); + int[] toRemove = getToRemove(event.getPlayer(), entityId); - if (toAdd == null) { + if (toRemove == null) { continue; } - newEntityIds = Arrays.copyOf(entityIds, entityIds.length + toAdd.length); - - for (int a = 0; a < toAdd.length; a++) { - newEntityIds[newEntityIds.length - (a + 1)] = toAdd[a]; + try { + for (PacketContainer container : DisguiseUtilities.getDestroyPackets(toRemove)) { + ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), container); + } + } catch (InvocationTargetException e) { + e.printStackTrace(); } } - - if (entityIds.length == newEntityIds.length) { - return; - } - - event.getPacket().getIntegerArrays().write(0, newEntityIds); } }