Unloader fixed stupid bug (#11452)

* aaaaaaa

* unloader fixed stupid bug (check #development)

* a
This commit is contained in:
EggleEgg 2025-12-28 03:43:02 +01:00 committed by GitHub
parent 8fb7aa34e3
commit 54ea4acf22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,8 @@ import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import mindustry.world.blocks.storage.StorageBlock.*;
import mindustry.world.meta.*;
import java.util.*;
@ -24,6 +26,7 @@ public class Unloader extends Block{
public @Load(value = "@-center", fallback = "unloader-center") TextureRegion centerRegion;
public float speed = 1f;
public boolean allowCoreUnload = true;
/** Cached result of content.items() */
static Item[] allItems;
@ -94,6 +97,8 @@ public class Unloader extends Block{
protected final Comparator<ContainerStat> comparator = (x, y) -> {
//sort so it gives priority for blocks that can only either receive or give (not both), and then by load, and then by last use
//highest = unload from, lowest = unload to
int unloadCore = Boolean.compare(!x.notStorage, !y.notStorage); //priority to core and core containers always
if(unloadCore != 0) return unloadCore;
int unloadPriority = Boolean.compare(x.canUnload && !x.canLoad, y.canUnload && !y.canLoad); //priority to receive if it cannot give
if(unloadPriority != 0) return unloadPriority;
int loadPriority = Boolean.compare(x.canUnload || !x.canLoad, y.canUnload || !y.canLoad); //priority to give if it cannot receive
@ -138,8 +143,8 @@ public class Unloader extends Block{
if(!other.interactable(team)) continue; //avoid blocks of the wrong team
//partial check
boolean canLoad = !(other.block instanceof StorageBlock);
boolean canUnload = other.canUnload() && other.items != null;
boolean canLoad = !(other instanceof CoreBuild || (other instanceof StorageBuild sb && sb.linkedCore != null));
boolean canUnload = other.canUnload() && (allowCoreUnload || canLoad) && other.items != null;
if(canLoad || canUnload){ //avoid blocks that can neither give nor receive items
var pb = Pools.obtain(ContainerStat.class, ContainerStat::new);