From b6b74cd538a874cd6ccae95f5b4287fb2d0dc824 Mon Sep 17 00:00:00 2001 From: Thiakil Date: Fri, 29 Mar 2024 14:13:41 +0800 Subject: [PATCH] make right click in qio take half a stack, not half of total stored --- .../common/inventory/container/QIOItemViewerContainer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/mekanism/common/inventory/container/QIOItemViewerContainer.java b/src/main/java/mekanism/common/inventory/container/QIOItemViewerContainer.java index 0388b3358d0..675180e4167 100644 --- a/src/main/java/mekanism/common/inventory/container/QIOItemViewerContainer.java +++ b/src/main/java/mekanism/common/inventory/container/QIOItemViewerContainer.java @@ -522,10 +522,10 @@ public void onClick(Supplier<@Nullable IScrollableSlot> slotProvider, int button if (heldItem.isEmpty()) { IScrollableSlot slot = slotProvider.get(); if (slot != null) { - //Left click -> as much as possible, right click -> half of available - long baseExtract = button == GLFW.GLFW_MOUSE_BUTTON_LEFT ? slot.count() : slot.count() / 2; + int maxStackSize = Math.min(MathUtils.clampToInt(slot.count()), slot.item().getMaxStackSize()); + //Left click -> as much as possible, right click -> half of a stack //Cap it out at the max stack size of the item, but otherwise try to take the desired amount (taking at least one if it is a single item) - int toTake = Mth.clamp(MathUtils.clampToInt(baseExtract), 1, slot.item().getMaxStackSize()); + int toTake = button == GLFW.GLFW_MOUSE_BUTTON_LEFT ? maxStackSize : Math.max(1, maxStackSize / 2); PacketUtils.sendToServer(new PacketQIOItemViewerSlotTake(slot.itemUUID(), toTake)); } } else {