diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index 78a596bb9d..b7b0cfc907 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -7,6 +7,7 @@ import arc.struct.*; import arc.util.*; import arc.util.async.*; import mindustry.annotations.Annotations.*; +import mindustry.content.*; import mindustry.core.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -116,7 +117,7 @@ public class Pathfinder implements Runnable{ tile.getTeamID(), tile.solid(), tile.floor().isLiquid, - tile.staticDarkness() >= 2, + tile.staticDarkness() >= 2 || (tile.floor().solid && tile.block() == Blocks.air), nearLiquid, nearGround, nearSolid, diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index 45a919bebb..8fb2a01d23 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -418,13 +418,27 @@ public class Schematics implements Loadable{ } public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource){ + placeLoadout(schem, x, y, team, resource, true); + } + + public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource, boolean check){ Stile coreTile = schem.tiles.find(s -> s.block instanceof CoreBlock); + Seq seq = new Seq<>(); if(coreTile == null) throw new IllegalArgumentException("Loadout schematic has no core tile!"); int ox = x - coreTile.x, oy = y - coreTile.y; schem.tiles.each(st -> { Tile tile = world.tile(st.x + ox, st.y + oy); if(tile == null) return; + //check for blocks that are in the way. + if(check && !(st.block instanceof CoreBlock)){ + seq.clear(); + tile.getLinkedTilesAs(st.block, seq); + if(seq.contains(t -> !t.block().alwaysReplace)){ + return; + } + } + tile.setBlock(st.block, team, st.rotation); Object config = st.config; diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index cfb0a58b0f..afd19fc0d5 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -21,7 +21,7 @@ public class Universe{ private int turn; private float turnCounter; - private Schematic lastLoadout; + private @Nullable Schematic lastLoadout; private ItemSeq lastLaunchResources = new ItemSeq(); public Universe(){ @@ -92,6 +92,15 @@ public class Universe{ } } + public void clearLoadoutInfo(){ + lastLoadout = null; + lastLaunchResources = new ItemSeq(); + Core.settings.remove("launch-resources-seq"); + Core.settings.remove("lastloadout-core-shard"); + Core.settings.remove("lastloadout-core-nucleus"); + Core.settings.remove("lastloadout-core-foundation"); + } + public ItemSeq getLaunchResources(){ lastLaunchResources = Core.settings.getJson("launch-resources-seq", ItemSeq.class, ItemSeq::new); return lastLaunchResources; diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index c282feaba5..41d1df4b16 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -159,9 +159,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ player.unit().eachGroup(unit -> { Item item = unit.item(); int accepted = tile.acceptStack(item, unit.stack.amount, unit); - unit.stack.amount -= accepted; - Call.transferItemTo(item, accepted, unit.x, unit.y, tile); + Call.transferItemTo(unit, item, accepted, unit.x, unit.y, tile); if(unit == player.unit()){ Events.fire(new DepositEvent(tile, player, item, accepted)); diff --git a/core/src/mindustry/maps/generators/BaseGenerator.java b/core/src/mindustry/maps/generators/BaseGenerator.java index 3a28078f74..035d654c10 100644 --- a/core/src/mindustry/maps/generators/BaseGenerator.java +++ b/core/src/mindustry/maps/generators/BaseGenerator.java @@ -60,7 +60,7 @@ public class BaseGenerator{ for(Tile tile : cores){ tile.clearOverlay(); - Schematics.placeLoadout(coreschem.schematic, tile.x, tile.y, team, coreschem.required instanceof Item ? bases.ores.get((Item)coreschem.required) : Blocks.oreCopper); + Schematics.placeLoadout(coreschem.schematic, tile.x, tile.y, team, coreschem.required instanceof Item ? bases.ores.get((Item)coreschem.required) : Blocks.oreCopper, false); //fill core with every type of item (even non-material) Building entity = tile.build; diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index 2e66d333bd..8de3384027 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -121,6 +121,7 @@ public class SettingsMenuDialog extends SettingsDialog{ t.button("@settings.clearresearch", Icon.trash, style, () -> { ui.showConfirm("@confirm", "@settings.clearresearch.confirm", () -> { + universe.clearLoadoutInfo(); for(TechNode node : TechTree.all){ node.reset(); } diff --git a/core/src/mindustry/world/blocks/distribution/StackConveyor.java b/core/src/mindustry/world/blocks/distribution/StackConveyor.java index 48ac8c8138..6454cdb5bf 100644 --- a/core/src/mindustry/world/blocks/distribution/StackConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/StackConveyor.java @@ -58,16 +58,16 @@ public class StackConveyor extends Block implements Autotiler{ @Override public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ - if(tile.build instanceof StackConveyorBuild){ - int state = ((StackConveyorBuild)tile.build).state; + if(tile.build instanceof StackConveyorBuild b){ + int state = b.state; if(state == stateLoad){ //standard conveyor mode return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock); }else if(state == stateUnload){ //router mode return otherblock.acceptsItems && (notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) || (otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) && - !(world.build(otherx, othery) instanceof StackConveyorBuild && ((StackConveyorBuild)world.build(otherx, othery)).state == stateUnload) && - !(world.build(otherx, othery) instanceof StackConveyorBuild && ((StackConveyorBuild)world.build(otherx, othery)).state == stateMove && + !(world.build(otherx, othery) instanceof StackConveyorBuild s && s.state == stateUnload) && + !(world.build(otherx, othery) instanceof StackConveyorBuild s2 && s2.state == stateMove && !facing(otherx, othery, otherrot, tile.x, tile.y)); } }