diff --git a/core/src/mindustry/entities/units/BuildPlan.java b/core/src/mindustry/entities/units/BuildPlan.java index f9930f707f..8dfb53de7a 100644 --- a/core/src/mindustry/entities/units/BuildPlan.java +++ b/core/src/mindustry/entities/units/BuildPlan.java @@ -21,8 +21,6 @@ public class BuildPlan implements Position, QuadTreeObject{ public boolean breaking; /** Config int. Not used unless hasConfig is true.*/ public Object config; - /** Original position, only used in schematics.*/ - public int originalX, originalY, originalWidth, originalHeight; /** Last progress.*/ public float progress; @@ -65,6 +63,7 @@ public class BuildPlan implements Position, QuadTreeObject{ public BuildPlan(){ } + public boolean placeable(Team team){ return Build.validPlace(block, team, x, y, rotation); } @@ -111,22 +110,12 @@ public class BuildPlan implements Position, QuadTreeObject{ copy.block = block; copy.breaking = breaking; copy.config = config; - copy.originalX = originalX; - copy.originalY = originalY; copy.progress = progress; copy.initialized = initialized; copy.animScale = animScale; return copy; } - public BuildPlan original(int x, int y, int originalWidth, int originalHeight){ - originalX = x; - originalY = y; - this.originalWidth = originalWidth; - this.originalHeight = originalHeight; - return this; - } - public Rect bounds(Rect rect){ if(breaking){ return rect.set(-100f, -100f, 0f, 0f); diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index 71c227a32b..93b85a591a 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -275,7 +275,7 @@ public class Schematics implements Loadable{ /** Creates an array of build plans from a schematic's data, centered on the provided x+y coordinates. */ public Seq toPlans(Schematic schem, int x, int y){ - return schem.tiles.map(t -> new BuildPlan(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block, t.config).original(t.x, t.y, schem.width, schem.height)) + return schem.tiles.map(t -> new BuildPlan(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block, t.config)) .removeAll(s -> (!s.block.isVisible() && !(s.block instanceof CoreBlock)) || !s.block.unlockedNow()).sort(Structs.comparingInt(s -> -s.block.schematicPriority)); } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 6edf52a2cc..345202ea8e 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -1331,9 +1331,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ plans.each(plan -> { if(plan.breaking) return; + float off = plan.block.size % 2 == 0 ? -0.5f : 0f; + plan.pointConfig(p -> { - int cx = p.x, cy = p.y; - int lx = cx; + float cx = p.x + off, cy = p.y + off; + float lx = cx; if(direction >= 0){ cx = -cy; @@ -1342,7 +1344,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ cx = cy; cy = -lx; } - p.set(cx, cy); + p.set(Mathf.floor(cx - off), Mathf.floor(cy - off)); }); //rotate actual plan, centered on its multiblock position @@ -1376,14 +1378,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } plan.pointConfig(p -> { - int corigin = x ? plan.originalWidth/2 : plan.originalHeight/2; - int nvalue = -(x ? p.x : p.y); if(x){ - plan.originalX = -(plan.originalX - corigin) + corigin; - p.x = nvalue; + if(plan.block.size % 2 == 0) p.x --; + p.x = -p.x; }else{ - plan.originalY = -(plan.originalY - corigin) + corigin; - p.y = nvalue; + if(plan.block.size % 2 == 0) p.y --; + p.y = -p.y; } }); diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index a3eae8fb08..f01d93ef9a 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -328,6 +328,11 @@ public class PowerNode extends PowerBlock{ } }); + //uncomment for debugging connection translation issues in schematics + //Draw.color(Color.red); + //Lines.line(plan.drawx(), plan.drawy(), px * tilesize, py * tilesize); + //Draw.color(); + if(otherReq == null || otherReq.block == null) continue; drawLaser(plan.drawx(), plan.drawy(), otherReq.drawx(), otherReq.drawy(), size, otherReq.block.size); diff --git a/tools/src/mindustry/tools/Generators.java b/tools/src/mindustry/tools/Generators.java index 833ffae080..8fbda7d9f8 100644 --- a/tools/src/mindustry/tools/Generators.java +++ b/tools/src/mindustry/tools/Generators.java @@ -78,7 +78,7 @@ public class Generators{ mainExecutor.submit(() -> { try{ ImageTileGenerator.generate(basePath, floor.name, new Fi("../../../assets-raw/sprites_out/blocks/environment/" + floor.name)); - }catch(Exception e){ + }catch(Throwable e){ Log.err("Failed to autotile: " + floor.name, e); }finally{ //the raw autotile source image must never be included, it isn't useful