From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Lumine1909 <133463833+lumine1909@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:59:56 +0800 Subject: [PATCH] Allow grindstone overstacking diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java index 0fbedd33f036f5aecbe5e7ab3935785c0d645977..7da5f73a57749b498bcbff2d575c44bc4a0a1008 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java @@ -736,10 +736,15 @@ public abstract class AbstractContainerMenu { public abstract boolean stillValid(Player player); protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) { + // Leaves start - Add force move // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent return this.moveItemStackTo(stack, startIndex, endIndex, reverseDirection, false); } protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection, boolean isCheck) { + return this.moveItemStackTo(stack, startIndex, endIndex, reverseDirection, isCheck, false); + } + protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection, boolean isCheck, boolean forceMove) { + // Leaves end - Add force move if (isCheck) { stack = stack.copy(); } @@ -804,6 +809,14 @@ public abstract class AbstractContainerMenu { // Paper end - Add PlayerTradeEvent and PlayerPurchaseEvent if (itemx.isEmpty() && slotx.mayPlace(stack)) { int i1 = slotx.getMaxStackSize(stack); + // Leaves start - Add force move + if (forceMove) { + slotx.setByPlayer(stack.split(stack.getCount())); + slotx.setChanged(); + flag = true; + break; + } + // Leaves end - Add force move // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent if (isCheck) { stack.shrink(Math.min(stack.getCount(), i1)); diff --git a/net/minecraft/world/inventory/GrindstoneMenu.java b/net/minecraft/world/inventory/GrindstoneMenu.java index f85bd2a90c2694d96f67cc3701a9bbf081fe8475..5245ba03d101b51be33ca4952e8c8f788483d3cc 100644 --- a/net/minecraft/world/inventory/GrindstoneMenu.java +++ b/net/minecraft/world/inventory/GrindstoneMenu.java @@ -178,7 +178,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { int i2 = i + i1 + max * 5 / 100; int i3 = 1; if (!inputItem.isDamageableItem()) { - if (inputItem.getMaxStackSize() < 2 || !ItemStack.matches(inputItem, additionalItem)) { + if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && inputItem.getMaxStackSize() < 2 || !ItemStack.matches(inputItem, additionalItem)) { // Leaves - allowGrindstoneOverstaking return ItemStack.EMPTY; } @@ -247,7 +247,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { ItemStack item1 = this.repairSlots.getItem(0); ItemStack item2 = this.repairSlots.getItem(1); if (index == 2) { - if (!this.moveItemStackTo(item, 3, 39, true)) { + if (!this.moveItemStackTo(item, 3, 39, true, false, org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking)) { // Leaves - allowGrindstoneOverstacking: Disable stack check return ItemStack.EMPTY; }