2023-09-11 04:03:35 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Nassim Jahnke <nassim@njahnke.dev>
|
|
|
|
Date: Mon, 11 Sep 2023 12:01:57 +1000
|
|
|
|
Subject: [PATCH] Add slot sanity checks in container clicks
|
|
|
|
|
|
|
|
|
2023-11-04 16:07:48 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2023-12-06 18:47:45 +01:00
|
|
|
index f5f9af9bd3189c3455bce76d56a12503a8d87c35..9a94249834f8b0b8d3f6aeaf0c859ba875079250 100644
|
2023-11-04 16:07:48 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2023-12-06 18:47:45 +01:00
|
|
|
@@ -2989,6 +2989,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2023-11-04 16:07:48 +01:00
|
|
|
break;
|
|
|
|
case SWAP:
|
|
|
|
if ((packet.getButtonNum() >= 0 && packet.getButtonNum() < 9) || packet.getButtonNum() == 40) {
|
|
|
|
+ // Paper start
|
|
|
|
+ if (packet.getSlotNum() < 0) {
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
click = (packet.getButtonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY;
|
|
|
|
Slot clickedSlot = this.player.containerMenu.getSlot(packet.getSlotNum());
|
|
|
|
if (clickedSlot.mayPickup(this.player)) {
|
2023-09-11 04:03:35 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
|
2023-12-06 17:34:54 +01:00
|
|
|
index 9ee3c2e0dcfaa4280be4973479c6490ded33809c..96a2d06e8da8bf0f0a3b0af813bf79d448940a3a 100644
|
2023-09-11 04:03:35 +02:00
|
|
|
--- 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
|
|
|
|
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)) {
|