Skip to content

Commit

Permalink
make right click in qio take half a stack, not half of total stored
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Mar 29, 2024
1 parent 72bc520 commit b6b74cd
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -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 {
Expand Down

0 comments on commit b6b74cd

Please sign in to comment.