YABBA icon indicating copy to clipboard operation
YABBA copied to clipboard

AE2 Crafting interaction with Barrels

Open 016Nojr opened this issue 6 years ago • 2 comments

42736360-0f3a9656-8866-11e8-987e-dec971780db8

016Nojr avatar Jul 15 '18 21:07 016Nojr

For anyone interested finding this, it turns out that AE2 makes some wacky extractItems requests:

[19:12:48] [Server thread/INFO] [YABBA]: REQUEST: 2395736, simulate: YES
[19:12:48] [Server thread/INFO] [YABBA]: REQUEST: 654592, simulate: YES
[19:12:48] [Server thread/INFO] [YABBA]: REQUEST: 599, simulate: YES
[19:12:48] [Server thread/INFO] [YABBA]: REQUEST: 11618, simulate: YES
[19:12:48] [Server thread/INFO] [YABBA]: REQUEST: 1414100, simulate: YES
[19:12:48] [Server thread/INFO] [YABBA]: REQUEST: 329, simulate: YES
[19:12:48] [Server thread/INFO] [YABBA]: REQUEST: 339987, simulate: YES

AE2 will request the whole thing in a loop until it got the full requested amount. Since YABBA will always give stacks of maxStackSize (i.e 64 in most cases), that create a lot of extractItems calls and a lot of ItemStack copy.

The answer to that is to give it what it wants, i.e the full content of the barrel if it wants it even if the documentation says not to. I had a quick look at StorageDrawer and it seems that they don't check for requests to be less maxStackSize either.

This patch seems to be working for me and fixes the lag issue but keep in mind that it might eat your laundry.

diff --git a/src/main/java/com/latmod/yabba/tile/ItemBarrel.java b/src/main/java/com/latmod/yabba/tile/ItemBarrel.java
index 8288d26..a9c35d4 100644
--- a/src/main/java/com/latmod/yabba/tile/ItemBarrel.java
+++ b/src/main/java/com/latmod/yabba/tile/ItemBarrel.java
@@ -238,7 +238,7 @@ public class ItemBarrel extends BarrelContent implements IItemHandler
                        return ItemHandlerHelper.copyStackWithSize(type, Math.min(amount, type.getMaxStackSize()));
                }

-               ItemStack stack = ItemHandlerHelper.copyStackWithSize(type, Math.min(Math.min(amount, count), type.getMaxStackSize()));
+               ItemStack stack = ItemHandlerHelper.copyStackWithSize(type, Math.min(amount, count));

                if (!simulate)
                {

Eijebong avatar Dec 28 '21 18:12 Eijebong

This is definitely not a valid solution. It breaks the lootbag opener in po3 if you're using enderio conduit as it'll try sending stacks of 4 lootbags at a time. An easy fix ingame is to use the extract speed downgrade but it confirms that this patch is invalid. Maybe it should only be sending stacks of unchecked size during simulation?

Eijebong avatar Dec 29 '21 14:12 Eijebong