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 15:35:36 +01:00
committed by GitHub
parent f87cd9c643
commit fd1678dbc9

View File

@@ -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
possibleBlocks.sort(Structs.comps(
Structs.comparingBool(e -> e.building.block.highUnloadPriority),
possibleBlocks.sort(
Structs.comps(
Structs.comparingFloat(e -> e.loadFactor),
Structs.comparingInt(e -> -lastUsed[e.index])
)));
Structs.comps(
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 dumpingTo = null;
@@ -175,7 +181,7 @@ public class Unloader extends Block{
}
//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);
dumpingFrom.building.removeStack(item, 1);
lastUsed[dumpingFrom.index] = 0;