Skip to content

Commit 9db0f34

Browse files
authored
Fix #8511: Mistake in IItemHandler simulated extract wrapper (#8521)
The mistake was made in #8478.
1 parent 4f205a4 commit 9db0f34

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/appeng/me/storage/ExternalStorageFacade.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,16 @@ private static int extractFromHandler(IItemHandler handler, int slot, AEItemKey
177177

178178
return switch (actionable) {
179179
case SIMULATE -> {
180+
// Query amount before the stack potentially gets modified
181+
int amountInSlot = stackInInventorySlot.getCount();
182+
180183
int extracted = wrapHandlerExtract(handler, slot, maxExtract, true);
181184
// Heuristic for simulation: looping in case of simulations is pointless, since the state of the
182185
// underlying inventory does not change after a simulated extraction. To still support
183186
// inventories that report stacks that are larger than maxStackSize, we use this heuristic
184-
if (extracted == itemKey.getMaxStackSize() && maxExtract > itemKey.getMaxStackSize()) {
185-
yield maxExtract;
187+
if (extracted == itemKey.getMaxStackSize() && maxExtract > itemKey.getMaxStackSize()
188+
&& amountInSlot > itemKey.getMaxStackSize()) {
189+
yield Math.min(amountInSlot, maxExtract);
186190
} else {
187191
yield extracted;
188192
}

0 commit comments

Comments
 (0)