From 30e4070e8ac17b1613168baad8f75a520db8164c Mon Sep 17 00:00:00 2001 From: Tamion <70228790+notTamion@users.noreply.github.com> Date: Sun, 26 May 2024 23:37:43 +0200 Subject: [PATCH] empty if statements --- .../1049-Fix-CraftBukkit-drag-system.patch | 83 +++++++++++-------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/patches/server/1049-Fix-CraftBukkit-drag-system.patch b/patches/server/1049-Fix-CraftBukkit-drag-system.patch index 7b582149f66f2..b1c73efb7df77 100644 --- a/patches/server/1049-Fix-CraftBukkit-drag-system.patch +++ b/patches/server/1049-Fix-CraftBukkit-drag-system.patch @@ -5,58 +5,69 @@ Subject: [PATCH] Fix CraftBukkit drag system == AT == public net.minecraft.world.inventory.AbstractContainerMenu quickcraftSlots +public net.minecraft.world.inventory.AbstractContainerMenu quickcraftType diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c450447585af4c8cdc87abe871c229ff895c3e53..49a3012064ee3d73cf4d5fa1a9e1713f955d8404 100644 +index c450447585af4c8cdc87abe871c229ff895c3e53..e2f9a442878d03d664f48a6df0ef185d3cf622ea 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3118,6 +3118,51 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3118,6 +3118,61 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } break; case QUICK_CRAFT: + // Paper start - Fix CraftBukkit drag system -+ if (AbstractContainerMenu.getQuickcraftHeader(packet.getButtonNum()) == 2 && 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 (cursor.isEmpty()) { -+ action = InventoryAction.PICKUP_ALL; -+ } else 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()) { ++ 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 (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 (toPlace != 0) { -+ action = InventoryAction.PLACE_SOME; + } -+ } 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()) { ++ } else if (slot.mayPickup(this.player)) { ++ if (cursor.isEmpty()) { + action = InventoryAction.PICKUP_ALL; ++ } else 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 (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; + } + } -+ if (!new InventoryClickEvent(inventory, type, this.player.containerMenu.quickcraftSlots.iterator().next().index, click, action).callEvent()) -+ break; + } + // Paper end - Fix CraftBukkit drag system this.player.containerMenu.clicked(packet.getSlotNum(), packet.getButtonNum(), packet.getClickType(), this.player);