diff options
author | Newwind <[email protected]> | 2024-08-31 19:29:50 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-08-31 20:29:50 +0200 |
commit | 509ea2fd17fa03ce04f86046098607733b8767ba (patch) | |
tree | 3f7c9a29481fafbb6ad9f846839ec8f4863d2363 /patches/server/0882-Add-slot-sanity-checks-in-container-clicks.patch | |
parent | e01ddf46279fbb68d157749a906b7a2ecc60da1a (diff) | |
download | Paper-509ea2fd17fa03ce04f86046098607733b8767ba.tar.gz Paper-509ea2fd17fa03ce04f86046098607733b8767ba.zip |
Fix horse armor desync (#11341)
Diffstat (limited to 'patches/server/0882-Add-slot-sanity-checks-in-container-clicks.patch')
-rw-r--r-- | patches/server/0882-Add-slot-sanity-checks-in-container-clicks.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/patches/server/0882-Add-slot-sanity-checks-in-container-clicks.patch b/patches/server/0882-Add-slot-sanity-checks-in-container-clicks.patch new file mode 100644 index 0000000000..a0cde98097 --- /dev/null +++ b/patches/server/0882-Add-slot-sanity-checks-in-container-clicks.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nassim Jahnke <[email protected]> +Date: Mon, 11 Sep 2023 12:01:57 +1000 +Subject: [PATCH] Add slot sanity checks in container clicks + + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 5541de6364b9982ae95e0a952167ae09084f65cf..e0983cfdfddaf59b29d2b8106c3c34b14191cfa8 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -2986,6 +2986,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + break; + case SWAP: + if ((packet.getButtonNum() >= 0 && packet.getButtonNum() < 9) || packet.getButtonNum() == 40) { ++ // Paper start - Add slot sanity checks to container clicks ++ if (packet.getSlotNum() < 0) { ++ action = InventoryAction.NOTHING; ++ break; ++ } ++ // Paper end - Add slot sanity checks to container clicks + click = (packet.getButtonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; + Slot clickedSlot = this.player.containerMenu.getSlot(packet.getSlotNum()); + if (clickedSlot.mayPickup(this.player)) { +diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +index 0e380151b038e2133013eb7d73621cf247b5b954..afd8f48bd41d2cac413c292f7988c903da1dc700 100644 +--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java ++++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +@@ -423,6 +423,7 @@ public abstract class AbstractContainerMenu { + this.resetQuickCraft(); + } + } else if (this.quickcraftStatus == 1) { ++ if (slotIndex < 0) return; // Paper - Add slot sanity checks to container clicks + slot = (Slot) this.slots.get(slotIndex); + itemstack = this.getCarried(); + if (AbstractContainerMenu.canItemQuickReplace(slot, itemstack, true) && slot.mayPlace(itemstack) && (this.quickcraftType == 2 || itemstack.getCount() > this.quickcraftSlots.size()) && this.canDragTo(slot)) { +@@ -597,6 +598,7 @@ public abstract class AbstractContainerMenu { + int j2; + + if (actionType == ClickType.SWAP && (button >= 0 && button < 9 || button == 40)) { ++ if (slotIndex < 0) return; // Paper - Add slot sanity checks to container clicks + ItemStack itemstack4 = playerinventory.getItem(button); + + slot = (Slot) this.slots.get(slotIndex); |