Skip to content

Fix stock link priority being ignored by inventory grouping logic#10090

Open
keckrich wants to merge 2 commits intoCreators-of-Create:mc1.21.1/devfrom
keckrich:mc1.21.1/dev
Open

Fix stock link priority being ignored by inventory grouping logic#10090
keckrich wants to merge 2 commits intoCreators-of-Create:mc1.21.1/devfrom
keckrich:mc1.21.1/dev

Conversation

@keckrich
Copy link
Copy Markdown

Fix stock link priority being ignored by inventory grouping logic

The load balancing change in a previous PR grouped links by InventoryIdentifier
and randomly selected one per group, discarding the priority sort.

Replaced with a single pass deduplication over the already sorted link list.
First occurrence of each inventory = highest priority link.

Closes #9689

Random selection from HashMap-grouped inventory buckets discarded the
priority sort from getAllPresent. Replace with a single-pass deduplication
that preserves priority order while still selecting one link per inventory.
@VoidLeech
Copy link
Copy Markdown
Collaborator

This appears to have given up load balancing entirely to fix the bug? Compare with #9733, which is an another PR fixing the same bug.
If I'm mistaken, please clarify (in which case a performance comparison would also be nice (: )

@VoidLeech VoidLeech added pr type: fix PR fixes a bug pr flag: simple PR has minimal changes labels Mar 25, 2026
@keckrich
Copy link
Copy Markdown
Author

keckrich commented Mar 25, 2026

I updated the code to explicitly load balance (instead of the implicit random order of the Iterable) when multiple stock links are connected to a single inventory. It will still prioritize the stock link with the lowest redstone signal but will then randomly choose one if there are ties.

If this is the incorrect behavior, I will happily update my PR.

@keckrich
Copy link
Copy Markdown
Author

Regarding #9733 it respects priority correctly but has a bug where it prioritizes the first stock link. So if two stock links are on one inventory it will use the first one 66% of the time. (it is also an easy bug to fix if you prefer that PR)

Otherwise, my solution uses one less loop, but I don't imagine that has much impact on performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr flag: simple PR has minimal changes pr type: fix PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analog lever not working properly with stock link

2 participants