From 12b290f298ddef866b3e8179155422c79a20d94f Mon Sep 17 00:00:00 2001 From: miozune Date: Sun, 29 Sep 2024 12:45:16 +0900 Subject: [PATCH] Fix phantom slot ignoring slot limit --- .../cleanroommc/modularui/value/sync/ItemSlotSH.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cleanroommc/modularui/value/sync/ItemSlotSH.java b/src/main/java/com/cleanroommc/modularui/value/sync/ItemSlotSH.java index c40e57c2..d032eaab 100644 --- a/src/main/java/com/cleanroommc/modularui/value/sync/ItemSlotSH.java +++ b/src/main/java/com/cleanroommc/modularui/value/sync/ItemSlotSH.java @@ -83,13 +83,15 @@ public void readOnServer(int id, PacketBuffer buf) throws IOException { setEnabled(buf.readBoolean(), false); } else if (id == 5) { if (!isPhantom()) return; - ItemStack stack = buf.readItemStack(); - this.slot.putStack(stack); + phantomClick(MouseData.create(0), buf.readItemStack()); } } protected void phantomClick(MouseData mouseData) { - ItemStack cursorStack = getSyncManager().getCursorItem(); + phantomClick(mouseData, getSyncManager().getCursorItem()); + } + + protected void phantomClick(MouseData mouseData, ItemStack cursorStack) { ItemStack slotStack = getSlot().getStack(); ItemStack stackToPut; if (!cursorStack.isEmpty() && !slotStack.isEmpty() && !ItemHandlerHelper.canItemStacksStack(cursorStack, slotStack)) { @@ -97,6 +99,7 @@ protected void phantomClick(MouseData mouseData) { if (mouseData.mouseButton == 1) { stackToPut.setCount(1); } + stackToPut.setCount(Math.min(stackToPut.getCount(), slot.getItemStackLimit(stackToPut))); getSlot().putStack(stackToPut); this.lastStoredPhantomItem = stackToPut.copy(); } else if (slotStack.isEmpty()) { @@ -112,6 +115,7 @@ protected void phantomClick(MouseData mouseData) { if (mouseData.mouseButton == 1) { stackToPut.setCount(1); } + stackToPut.setCount(Math.min(stackToPut.getCount(), slot.getItemStackLimit(stackToPut))); getSlot().putStack(stackToPut); this.lastStoredPhantomItem = stackToPut.copy(); } else {