From 78fd8f931baed7ccc42b283f583282d60b9a9378 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Thu, 28 Nov 2024 14:02:35 -0800 Subject: [PATCH] Copy items when constructing ClientboundSetCursorItemPacket Unlike ClientboundContainerSetSlotPacket, the constructor itself does not copy the item. Thus, we need to pass a copy of the item to the constructor. --- patches/server/1059-Correct-update-cursor.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/server/1059-Correct-update-cursor.patch b/patches/server/1059-Correct-update-cursor.patch index 77c0c52550..5a1e3ce282 100644 --- a/patches/server/1059-Correct-update-cursor.patch +++ b/patches/server/1059-Correct-update-cursor.patch @@ -10,7 +10,7 @@ now leads to an IOOB. patch uses instead. diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index d7ac001d53a083e9881f2320eb7fd5dcbd20416e..b5d5dbc50a7b8c40739a15f164ffd08fdc534f9c 100644 +index d7ac001d53a083e9881f2320eb7fd5dcbd20416e..cd1b6b539a62fa5237d6dab2d1c09a2e631d9941 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -3287,7 +3287,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -18,7 +18,7 @@ index d7ac001d53a083e9881f2320eb7fd5dcbd20416e..b5d5dbc50a7b8c40739a15f164ffd08f case PLACE_ONE: case SWAP_WITH_CURSOR: - this.player.connection.send(new ClientboundContainerSetSlotPacket(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); -+ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(this.player.containerMenu.getCarried())); // Paper - correctly set cursor ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(this.player.containerMenu.getCarried().copy())); // Paper - correctly set cursor this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.getSlotNum(), this.player.containerMenu.getSlot(packet.getSlotNum()).getItem())); break; // Modified clicked only @@ -27,7 +27,7 @@ index d7ac001d53a083e9881f2320eb7fd5dcbd20416e..b5d5dbc50a7b8c40739a15f164ffd08f case DROP_ONE_CURSOR: case CLONE_STACK: - this.player.connection.send(new ClientboundContainerSetSlotPacket(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); -+ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(this.player.containerMenu.getCarried())); // Paper - correctly set cursor ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(this.player.containerMenu.getCarried().copy())); // Paper - correctly set cursor break; // Nothing case NOTHING: @@ -36,7 +36,7 @@ index d7ac001d53a083e9881f2320eb7fd5dcbd20416e..b5d5dbc50a7b8c40739a15f164ffd08f if (packet.slotNum() >= 0) { this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.slotNum(), this.player.inventoryMenu.getSlot(packet.slotNum()).getItem())); - this.player.connection.send(new ClientboundContainerSetSlotPacket(-1, this.player.inventoryMenu.incrementStateId(), -1, ItemStack.EMPTY)); -+ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(ItemStack.EMPTY)); // Paper - correctly set cursor ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(ItemStack.EMPTY.copy())); // Paper - correctly set cursor } return; }