diff --git a/patches/server/1049-Fix-CraftBukkit-drag-system.patch b/patches/server/1049-Fix-CraftBukkit-drag-system.patch index 45ea382fbb0c6..9694a2285f7b6 100644 --- a/patches/server/1049-Fix-CraftBukkit-drag-system.patch +++ b/patches/server/1049-Fix-CraftBukkit-drag-system.patch @@ -6,66 +6,32 @@ 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 c450447585af4c8cdc87abe871c229ff895c3e53..a69038b4a9f0ac589c8a533476894302bb731c11 100644 +index c450447585af4c8cdc87abe871c229ff895c3e53..efd87b4ff8514ed22a895a2caeacfc5efd1d3d94 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3118,6 +3118,61 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3118,6 +3118,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 (this.player.containerMenu.getCarried().isEmpty()) { ++ } 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) { -+ if (packet.getButtonNum() == 6) { -+ click = ClickType.RIGHT; -+ action = InventoryAction.PLACE_ONE; -+ } else { -+ click = ClickType.LEFT; -+ Slot slot = this.player.containerMenu.quickcraftSlots.iterator().next(); -+ ItemStack clickedItem = slot.getItem(); -+ ItemStack cursor = this.player.containerMenu.getCarried(); -+ if (clickedItem.isEmpty()) { -+ if (!cursor.isEmpty()) { -+ action = InventoryAction.PLACE_ALL; -+ } -+ } else if (slot.mayPickup(this.player)) { -+ if (slot.mayPlace(cursor)) { -+ if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { -+ int toPlace = cursor.getCount(); -+ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); -+ toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); -+ if (toPlace == 1) { -+ action = InventoryAction.PLACE_ONE; -+ } else if (toPlace == cursor.getCount()) { -+ action = InventoryAction.PLACE_ALL; -+ } else if (toPlace != 0) { -+ action = InventoryAction.PLACE_SOME; -+ } else if (toPlace == 0) { -+ action = InventoryAction.NOTHING; -+ } -+ } else if (cursor.getCount() <= slot.getMaxStackSize()) { -+ action = InventoryAction.SWAP_WITH_CURSOR; -+ } -+ } else if (ItemStack.isSameItemSameComponents(cursor, clickedItem)) { -+ if (clickedItem.getCount() >= 0) { -+ if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { -+ action = InventoryAction.PICKUP_ALL; -+ } -+ } -+ } -+ } -+ } -+ if (!new InventoryClickEvent(inventory, type, this.player.containerMenu.quickcraftSlots.iterator().next().index, click, action).callEvent()) -+ break; ++ 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; + } + } + } @@ -74,7 +40,7 @@ index c450447585af4c8cdc87abe871c229ff895c3e53..a69038b4a9f0ac589c8a533476894302 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 4b6284ba15eae215ecf43761173db35f2e2f07e6..b6c2d574b2bcc66d7ed95606bbca9077795e3c2a 100644 +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 {