From 03ae26ebbdb439c255cf8232442e817bc31ecd90 Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Mon, 8 Dec 2025 23:47:50 +0000 Subject: [PATCH] fix: use slot limit instead of item stack limit for insertion/extraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Item insertion and extraction are currently capped at the item’s maximum stack size, which creates severe lag when moving large quantities especially with mods like Applied Energistics 2. In ATM 10, a single ME IO port from Expandedae2 combined with a few Netherite‑upgraded drawers can even crash a server. Many workflows require extracting more than an item’s max stack size, but the existing limit prevents this. Update the logic to enforce the slot’s limit instead of the item’s max stack size, allowing larger transfers where the slot permits. --- .../functionalstorage/inventory/BigInventoryHandler.java | 2 +- .../functionalstorage/inventory/CompactingInventoryHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java b/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java index a56be317..311976fc 100644 --- a/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java +++ b/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java @@ -72,7 +72,7 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) { if (slot < type.getSlots()){ BigStack bigStack = this.storedStacks.get(slot); if (bigStack.getStack().isEmpty()) return ItemStack.EMPTY; - amount = Math.min(amount, bigStack.getStack().getMaxStackSize()); + amount = Math.min(amount, getSlotLimit(slot)); if (!isCreative() && bigStack.getAmount() <= amount) { ItemStack out = bigStack.getStack().copy(); int newAmount = bigStack.getAmount(); diff --git a/src/main/java/com/buuz135/functionalstorage/inventory/CompactingInventoryHandler.java b/src/main/java/com/buuz135/functionalstorage/inventory/CompactingInventoryHandler.java index 7f4e9b5d..4a91a7c2 100644 --- a/src/main/java/com/buuz135/functionalstorage/inventory/CompactingInventoryHandler.java +++ b/src/main/java/com/buuz135/functionalstorage/inventory/CompactingInventoryHandler.java @@ -122,7 +122,7 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) { if (slot < this.slots) { CompactingUtil.Result bigStack = this.resultList.get(slot); if (bigStack.getResult().isEmpty()) return ItemStack.EMPTY; - amount = Math.min(amount, bigStack.getResult().getMaxStackSize()); + amount = Math.min(amount, getSlotLimit(slot)); int stackAmount = bigStack.getNeeded() * amount; if (!isCreative() && stackAmount >= this.amount) { ItemStack out = bigStack.getResult().copy();