GregTechCEu / GregTech

GregTech CE 1.12 fork continuing progression and development
GNU Lesser General Public License v3.0
238 stars 179 forks source link

Round Robin with Priority voids items #2548

Open ProTriforcer opened 1 month ago

ProTriforcer commented 1 month ago

GregTech CEu Version

2.8.10-beta

Modpack Used

Nomi-CEu 1.7-beta-5c

Addons Installed

No response

Environment

Singleplayer

New Worlds

Yes

Cross-Mod Interaction

No

Expected Behavior

Expected conveyors set to Round Robin with Priority to not void items

Actual Behavior

Conveyors set to Round Robin with Priority voided items

Steps to Reproduce

1) Place a chest and two macerators (or any other inventory with one free slot), connect them with an item pipe 2) Place a conveyor to import from the chest, set it to Round Robin with Priority 2024-07-22_02 13 43 3) Place four stacks of cobblestone into the chest. Two of them will be moved into the macerators with two remaining, as expected 4) Open a macerator and right click the cobblestone to take half of the stack. It will be immediately refilled, as expected 2024-07-22_02 16 46 5) Open the chest and observe a single stack of cobblestone, instead of expected one and a half 2024-07-22_02 18 36

ProTriforcer commented 1 month ago

It looks like you lose stack size/number of inventories items for every inventory you top up

ProTriforcer commented 1 month ago

So i renamed some variables and did some logging, but i'm way too tired to make sense of it all myself. I'll just post a slightly edited log output and the code that made it here. Hope it helps.

https://pastebin.com/3k56sMcm https://pastebin.com/6ccush0A

jkieberking commented 1 week ago

After some debugging, it appears that this block of code, that runs when attempting a dry run here of inserting items into the conveyor from the chest

stack = insertToHandlers(routePathsCopy, stack, simulate);
if (!stack.isEmpty() && !routePathsCopy.isEmpty())
    stack = insertToHandlers(routePathsCopy, stack, simulate);

From what I can tell via debugging, it appears that the first stack = insertToHandlers(routePathsCopy, stack, simulate); tries to split up the stack and insert it to all inventories along the connected network of pipes (but! it looks like it will only insert a max of size of stack / number of connected output inventories into each attached inventory), and the second insertToHandlers() call inserts any remaining items equally into any remaining non-full inventories attached to the network of pipes.

so, for ex: if we have a chest filled with a stack of 64 cobble with 4 macerators attached, each filled with 64 cobble, and we remove half a stack:

my hypothesis (don't have more time right now to further investigate) is that since we are doing a dry run, it still thinks the macerator has free space available (since we aren't actually inserting items into it during the dry run), so it will "insert" 32 cobble from the 48 remaining, which leaves 16 cobble in the chest

I'll investigate further and attempt a fix, but also wanted to update on my findings

jkieberking commented 1 week ago

my hypothesis (don't have more time right now to further investigate) is that since we are doing a dry run, it still thinks the macerator has free space available (since we aren't actually inserting items into it during the dry run), so it will "insert" 32 cobble from the 48 remaining, which leaves 16 cobble in the chest

confirmed this is the case