|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Tamion <70228790+notTamion@users.noreply.github.com> |
| 3 | +Date: Sun, 26 May 2024 22:20:21 +0200 |
| 4 | +Subject: [PATCH] Fix CraftBukkit drag system |
| 5 | + |
| 6 | +== AT == |
| 7 | +public net.minecraft.world.inventory.AbstractContainerMenu quickcraftSlots |
| 8 | +public net.minecraft.world.inventory.AbstractContainerMenu quickcraftStatus |
| 9 | +public net.minecraft.world.inventory.AbstractContainerMenu quickcraftType |
| 10 | +public net.minecraft.world.inventory.AbstractContainerMenu resetQuickCraft()V |
| 11 | + |
| 12 | +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 13 | +index bb74747ba19e882c820e2dac8d2f34166acb530b..238114d295df0508be6b47b94f478b9906384be0 100644 |
| 14 | +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 15 | ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 16 | +@@ -3123,6 +3123,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl |
| 17 | + } |
| 18 | + break; |
| 19 | + case QUICK_CRAFT: |
| 20 | ++ // Paper start - Fix CraftBukkit drag system |
| 21 | ++ AbstractContainerMenu containerMenu = this.player.containerMenu; |
| 22 | ++ int currentStatus = this.player.containerMenu.quickcraftStatus; |
| 23 | ++ int newStatus = AbstractContainerMenu.getQuickcraftHeader(packet.getButtonNum()); |
| 24 | ++ if ((currentStatus != 1 || newStatus != 2 && currentStatus != newStatus)) { |
| 25 | ++ } else if (containerMenu.getCarried().isEmpty()) { |
| 26 | ++ } else if (newStatus == 0) { |
| 27 | ++ } else if (newStatus == 1) { |
| 28 | ++ } else if (newStatus == 2) { |
| 29 | ++ if (!this.player.containerMenu.quickcraftSlots.isEmpty()) { |
| 30 | ++ if (this.player.containerMenu.quickcraftSlots.size() == 1) { |
| 31 | ++ int index = containerMenu.quickcraftSlots.iterator().next().index; |
| 32 | ++ containerMenu.resetQuickCraft(); |
| 33 | ++ this.handleContainerClick(new ServerboundContainerClickPacket(packet.getContainerId(), packet.getStateId(), index, containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.getCarriedItem(), packet.getChangedSlots())); |
| 34 | ++ return; |
| 35 | ++ } |
| 36 | ++ } |
| 37 | ++ } |
| 38 | ++ // Paper end - Fix CraftBukkit drag system |
| 39 | + this.player.containerMenu.clicked(packet.getSlotNum(), packet.getButtonNum(), packet.getClickType(), this.player); |
| 40 | + break; |
| 41 | + case PICKUP_ALL: |
| 42 | +diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java |
| 43 | +index 46159a127d910028c62ada90ff2d2dccc3b62fc3..dd4218e108f87f3305b76fbc8d88f488b447c609 100644 |
| 44 | +--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java |
| 45 | ++++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java |
| 46 | +@@ -431,7 +431,7 @@ public abstract class AbstractContainerMenu { |
| 47 | + } |
| 48 | + } else if (this.quickcraftStatus == 2) { |
| 49 | + if (!this.quickcraftSlots.isEmpty()) { |
| 50 | +- if (false && this.quickcraftSlots.size() == 1) { // CraftBukkit - treat everything as a drag since we are unable to easily call InventoryClickEvent instead |
| 51 | ++ if (this.quickcraftSlots.size() == 1) { // Paper - Fix CraftBukkit drag system |
| 52 | + k = ((Slot) this.quickcraftSlots.iterator().next()).index; |
| 53 | + this.resetQuickCraft(); |
| 54 | + this.doClick(k, this.quickcraftType, ClickType.PICKUP, player); |
0 commit comments