diff --git a/core/src/mindustry/world/blocks/storage/Unloader.java b/core/src/mindustry/world/blocks/storage/Unloader.java index 4732141ac7..fd48fe263b 100644 --- a/core/src/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/mindustry/world/blocks/storage/Unloader.java @@ -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 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);