Unloading into plast belts - bug fix (#6347)

* hortiloaders hotfix randomness

Improved the unloaders' balance with multiple blocks having the same load

* deterministic lets go

Co-Authored-By: citrusMarmelade <20476281+citrusMarmelade@users.noreply.github.com>

* update contributors

forgot to add them since they helped a lot for the previous commits/PRs

* unloader - fix cant load

Co-authored-by: citrusMarmelade <20476281+citrusMarmelade@users.noreply.github.com>
This commit is contained in:
hortiSquash
2021-11-17 09:35:36 -05:00
committed by GitHub
co-authored by citrusMarmelade
parent f87cd9c643
commit fd1678dbc9
@@ -143,12 +143,18 @@ public class Unloader extends Block{
} }
//sort so it gives full priority to blocks that can give but not receive (stackConveyors and Storage), and then by load, and then by last use //sort so it gives full priority to blocks that can give but not receive (stackConveyors and Storage), and then by load, and then by last use
possibleBlocks.sort(Structs.comps( possibleBlocks.sort(
Structs.comparingBool(e -> e.building.block.highUnloadPriority),
Structs.comps( Structs.comps(
Structs.comparingFloat(e -> e.loadFactor), Structs.comps(
Structs.comparingInt(e -> -lastUsed[e.index]) Structs.comparingBool(e -> e.building.block.highUnloadPriority && !e.canLoad),
))); Structs.comparingBool(e -> e.canUnload && !e.canLoad)
),
Structs.comps(
Structs.comparingFloat(e -> e.loadFactor),
Structs.comparingInt(e -> -lastUsed[e.index])
)
)
);
ContainerStat dumpingFrom = null; ContainerStat dumpingFrom = null;
ContainerStat dumpingTo = null; ContainerStat dumpingTo = null;
@@ -175,7 +181,7 @@ public class Unloader extends Block{
} }
//trade the items //trade the items
if(dumpingFrom != null && dumpingTo != null && (dumpingFrom.loadFactor != dumpingTo.loadFactor || dumpingFrom.building.block.highUnloadPriority)){ if(dumpingFrom != null && dumpingTo != null && (dumpingFrom.loadFactor != dumpingTo.loadFactor || !dumpingFrom.canLoad)){
dumpingTo.building.handleItem(this, item); dumpingTo.building.handleItem(this, item);
dumpingFrom.building.removeStack(item, 1); dumpingFrom.building.removeStack(item, 1);
lastUsed[dumpingFrom.index] = 0; lastUsed[dumpingFrom.index] = 0;