hortiloaders 1.0.3.0 bug fix (#6233)

* hortiloaders 1.0.3.0 bug fix

it didnt unload from StackConveyors/Storage when they had the same loadfactor as the factory

* unloader fix, using fields
This commit is contained in:
hortiSquash
2021-10-26 00:22:56 +02:00
committed by GitHub
parent 46c6a6f6f7
commit 59a480cb30
4 changed files with 7 additions and 4 deletions

View File

@@ -265,6 +265,8 @@ public class Block extends UnlockableContent{
public boolean quickRotate = true;
/** Main subclass. Non-anonymous. */
public @Nullable Class<?> subclass;
/** Determines if this block gets a higher unloader priority. */
public boolean highUnloadPriority = false;
public float selectScroll; //scroll position for certain blocks
public Prov<Building> buildType = null; //initialized later

View File

@@ -42,6 +42,7 @@ public class StackConveyor extends Block implements Autotiler{
hasItems = true;
itemCapacity = 10;
conveyorPlacement = true;
highUnloadPriority = true;
ambientSound = Sounds.conveyor;
ambientSoundVolume = 0.004f;

View File

@@ -25,6 +25,7 @@ public class StorageBlock extends Block{
flags = EnumSet.of(BlockFlag.storage);
allowResupply = true;
envEnabled = Env.any;
highUnloadPriority = true;
}
@Override

View File

@@ -11,7 +11,6 @@ import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.distribution.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@@ -139,7 +138,7 @@ 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
possibleBlocks.sort(Structs.comps(
Structs.comparingBool(e -> e.building.block instanceof StorageBlock || e.building.block instanceof StackConveyor),
Structs.comparingBool(e -> e.building.block.highUnloadPriority),
Structs.comparingFloat(e -> e.loadFactor)
));
@@ -163,7 +162,7 @@ public class Unloader extends Block{
}
//trade the items
if(dumpingFrom != null && dumpingTo != null && dumpingFrom.loadFactor != dumpingTo.loadFactor){
if(dumpingFrom != null && dumpingTo != null && (dumpingFrom.loadFactor != dumpingTo.loadFactor || dumpingFrom.building.block.highUnloadPriority)){
dumpingTo.building.handleItem(this, item);
dumpingFrom.building.removeStack(item, 1);
any = true;