From bba628a511c8c96547842edfd1e5be34f4eff463 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 10 Jul 2021 19:26:44 +1200 Subject: [PATCH] Fix item wrong field --- .../PacketListenerInventory.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java index a3b9c3cc..27a8f7a0 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java @@ -13,6 +13,7 @@ import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -87,7 +88,7 @@ public class PacketListenerInventory extends PacketAdapter { mods.write(0, 0); mods.write(1, slot); - mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR))); + packet.getItemModifier().write(0, new ItemStack(Material.AIR)); try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); @@ -109,7 +110,7 @@ public class PacketListenerInventory extends PacketAdapter { StructureModifier mods = packet.getModifier(); mods.write(0, 0); mods.write(1, slot); - mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR))); + packet.getItemModifier().write(0, new ItemStack(Material.AIR)); try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); @@ -137,7 +138,7 @@ public class PacketListenerInventory extends PacketAdapter { mods.write(0, 0); mods.write(1, player.getInventory().getHeldItemSlot() + 36); - mods.write(2, ReflectionManager.getNmsItem(currentlyHeld)); + packet.getItemModifier().write(0, currentlyHeld); try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); @@ -156,7 +157,7 @@ public class PacketListenerInventory extends PacketAdapter { mods.write(0, 0); mods.write(1, event.getPacket().getIntegers().read(0) + 36); - mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR))); + packet.getItemModifier().write(0, new ItemStack(Material.AIR)); try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); @@ -205,7 +206,7 @@ public class PacketListenerInventory extends PacketAdapter { mods.write(0, 0); mods.write(1, slot); - mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR))); + packet.getItemModifier().write(0, new ItemStack(Material.AIR)); try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); @@ -225,7 +226,7 @@ public class PacketListenerInventory extends PacketAdapter { StructureModifier mods = packet.getModifier(); mods.write(0, 0); mods.write(1, slot); - mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR))); + packet.getItemModifier().write(0, new ItemStack(Material.AIR)); try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); @@ -281,7 +282,7 @@ public class PacketListenerInventory extends PacketAdapter { if (item != null && item.getType() != Material.AIR && item.getType() != Material.ELYTRA) { event.setPacket(event.getPacket().shallowClone()); - event.getPacket().getModifier().write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR))); + event.getPacket().getItemModifier().write(0, new ItemStack(Material.AIR)); } } // Else if its a hotbar slot @@ -295,7 +296,8 @@ public class PacketListenerInventory extends PacketAdapter { if (item != null && item.getType() != Material.AIR) { event.setPacket(event.getPacket().shallowClone()); - event.getPacket().getModifier().write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR))); + + event.getPacket().getItemModifier().write(0, new ItemStack(Material.AIR)); } } }