Fix stock link priority being ignored by inventory grouping logic#10090
Fix stock link priority being ignored by inventory grouping logic#10090keckrich wants to merge 2 commits intoCreators-of-Create:mc1.21.1/devfrom
Conversation
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.
|
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. |
|
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. |
|
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. |
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