aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTamion <[email protected]>2024-08-17 23:31:38 +0200
committerGitHub <[email protected]>2024-08-17 23:31:38 +0200
commit44017487a81534067fd17e2d5e8669e61e19d719 (patch)
treea75aaa77fbbe52a3df1b8a9e4e23d673e4091406
parent8c3018a4b177aa0f7658d510bf7d19c5fa8e5b65 (diff)
downloadPaper-44017487a81534067fd17e2d5e8669e61e19d719.tar.gz
Paper-44017487a81534067fd17e2d5e8669e61e19d719.zip
Fix CraftBukkit drag system (#10703)
-rw-r--r--patches/server/1050-Fix-CraftBukkit-drag-system.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/patches/server/1050-Fix-CraftBukkit-drag-system.patch b/patches/server/1050-Fix-CraftBukkit-drag-system.patch
new file mode 100644
index 0000000000..eec68004e0
--- /dev/null
+++ b/patches/server/1050-Fix-CraftBukkit-drag-system.patch
@@ -0,0 +1,54 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tamion <[email protected]>
+Date: Sun, 26 May 2024 22:20:21 +0200
+Subject: [PATCH] Fix CraftBukkit drag system
+
+== AT ==
+public net.minecraft.world.inventory.AbstractContainerMenu quickcraftSlots
+public net.minecraft.world.inventory.AbstractContainerMenu quickcraftStatus
+public net.minecraft.world.inventory.AbstractContainerMenu quickcraftType
+public net.minecraft.world.inventory.AbstractContainerMenu resetQuickCraft()V
+
+diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+index bb74747ba19e882c820e2dac8d2f34166acb530b..238114d295df0508be6b47b94f478b9906384be0 100644
+--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+@@ -3123,6 +3123,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
+ }
+ break;
+ case QUICK_CRAFT:
++ // Paper start - Fix CraftBukkit drag system
++ AbstractContainerMenu containerMenu = this.player.containerMenu;
++ int currentStatus = this.player.containerMenu.quickcraftStatus;
++ int newStatus = AbstractContainerMenu.getQuickcraftHeader(packet.getButtonNum());
++ if ((currentStatus != 1 || newStatus != 2 && currentStatus != newStatus)) {
++ } else if (containerMenu.getCarried().isEmpty()) {
++ } else if (newStatus == 0) {
++ } else if (newStatus == 1) {
++ } else if (newStatus == 2) {
++ if (!this.player.containerMenu.quickcraftSlots.isEmpty()) {
++ if (this.player.containerMenu.quickcraftSlots.size() == 1) {
++ int index = containerMenu.quickcraftSlots.iterator().next().index;
++ containerMenu.resetQuickCraft();
++ this.handleContainerClick(new ServerboundContainerClickPacket(packet.getContainerId(), packet.getStateId(), index, containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.getCarriedItem(), packet.getChangedSlots()));
++ return;
++ }
++ }
++ }
++ // Paper end - Fix CraftBukkit drag system
+ this.player.containerMenu.clicked(packet.getSlotNum(), packet.getButtonNum(), packet.getClickType(), this.player);
+ break;
+ case PICKUP_ALL:
+diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+index 46159a127d910028c62ada90ff2d2dccc3b62fc3..dd4218e108f87f3305b76fbc8d88f488b447c609 100644
+--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
++++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+@@ -431,7 +431,7 @@ public abstract class AbstractContainerMenu {
+ }
+ } else if (this.quickcraftStatus == 2) {
+ if (!this.quickcraftSlots.isEmpty()) {
+- if (false && this.quickcraftSlots.size() == 1) { // CraftBukkit - treat everything as a drag since we are unable to easily call InventoryClickEvent instead
++ if (this.quickcraftSlots.size() == 1) { // Paper - Fix CraftBukkit drag system
+ k = ((Slot) this.quickcraftSlots.iterator().next()).index;
+ this.resetQuickCraft();
+ this.doClick(k, this.quickcraftType, ClickType.PICKUP, player);