diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 431f0c40..33b1c134 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -834,6 +834,13 @@ public final class Settings { */ public final Setting buildRepeatCount = new Setting<>(-1); + /** + * Don't notify schematics that they are moved. + * e.g. replacing will replace the same spots for every repetition + * Mainly for backward compatibility. + */ + public final Setting buildRepeatSneaky = new Setting<>(true); + /** * Allow standing above a block while mining it, in BuilderProcess *

diff --git a/src/api/java/baritone/api/schematic/CompositeSchematic.java b/src/api/java/baritone/api/schematic/CompositeSchematic.java index 2f119de1..234f1d4f 100644 --- a/src/api/java/baritone/api/schematic/CompositeSchematic.java +++ b/src/api/java/baritone/api/schematic/CompositeSchematic.java @@ -71,4 +71,11 @@ public class CompositeSchematic extends AbstractSchematic { } return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable); } + + @Override + public void reset() { + for (CompositeSchematicEntry entry : schematicArr) { + entry.schematic.reset(); + } + } } diff --git a/src/api/java/baritone/api/schematic/ISchematic.java b/src/api/java/baritone/api/schematic/ISchematic.java index 88cfc899..deb81182 100644 --- a/src/api/java/baritone/api/schematic/ISchematic.java +++ b/src/api/java/baritone/api/schematic/ISchematic.java @@ -73,6 +73,11 @@ public interface ISchematic { */ IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable); + /** + * Resets possible caches to avoid wrong behavior when moving the schematic around + */ + default void reset() {} + /** * @return The width (X axis length) of this schematic */ diff --git a/src/api/java/baritone/api/schematic/ReplaceSchematic.java b/src/api/java/baritone/api/schematic/ReplaceSchematic.java index f064435e..f8cd6656 100644 --- a/src/api/java/baritone/api/schematic/ReplaceSchematic.java +++ b/src/api/java/baritone/api/schematic/ReplaceSchematic.java @@ -31,6 +31,18 @@ public class ReplaceSchematic extends MaskSchematic { this.cache = new Boolean[widthX()][heightY()][lengthZ()]; } + @Override + public void reset() { + // it's final, can't use this.cache = new Boolean[widthX()][heightY()][lengthZ()] + for (int x = 0; x < cache.length; x++) { + for (int y = 0; y < cache[0].length; y++) { + for (int z = 0; z < cache[0][0].length; z++) { + cache[x][y][z] = null; + } + } + } + } + @Override protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { if (cache[x][y][z] == null) { diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 15d88bdd..bae136e0 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -387,6 +387,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return ISchematic.super.inSchematic(x, y, z, currentState) && y >= minYInclusive && y <= maxYInclusive && realSchematic.inSchematic(x, y, z, currentState); } + @Override + public void reset() { + realSchematic.reset(); + } + @Override public int widthX() { return realSchematic.widthX(); @@ -424,6 +429,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil // build repeat time layer = 0; origin = new BlockPos(origin).add(repeat); + if (!Baritone.settings().buildRepeatSneaky.value) { + schematic.reset(); + } logDirect("Repeating build in vector " + repeat + ", new origin is " + origin); return onTick(calcFailed, isSafeToCancel, recursions + 1); }