build in layers test

This commit is contained in:
Leijurv 2019-04-11 15:17:26 -07:00
parent 76cdaaace6
commit 2bf475d840
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 42 additions and 0 deletions

View File

@ -566,6 +566,11 @@ public final class Settings {
*/ */
public final Setting<Boolean> exploreForBlocks = new Setting<>(true); public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
/**
* Don't consider the next layer in builder until the current one is done
*/
public final Setting<Boolean> buildInLayers = new Setting<>(false);
/** /**
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)? * While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
*/ */

View File

@ -58,10 +58,12 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
private HashSet<BetterBlockPos> incorrectPositions; private HashSet<BetterBlockPos> incorrectPositions;
private String name; private String name;
private ISchematic realSchematic;
private ISchematic schematic; private ISchematic schematic;
private Vec3i origin; private Vec3i origin;
private int ticks; private int ticks;
private boolean paused; private boolean paused;
private int layer;
public BuilderProcess(Baritone baritone) { public BuilderProcess(Baritone baritone) {
super(baritone); super(baritone);
@ -77,8 +79,10 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
public void build(String name, ISchematic schematic, Vec3i origin) { public void build(String name, ISchematic schematic, Vec3i origin) {
this.name = name; this.name = name;
this.schematic = schematic; this.schematic = schematic;
this.realSchematic = null;
this.origin = origin; this.origin = origin;
this.paused = false; this.paused = false;
this.layer = 0;
} }
public void resume() { public void resume() {
@ -285,8 +289,39 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
if (paused) { if (paused) {
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
} }
if (Baritone.settings().buildInLayers.value) {
if (realSchematic == null) {
realSchematic = schematic;
}
schematic = new ISchematic() {
@Override
public IBlockState desiredState(int x, int y, int z) {
return realSchematic.desiredState(x, y, z);
}
@Override
public int widthX() {
return realSchematic.widthX();
}
@Override
public int heightY() {
return layer;
}
@Override
public int lengthZ() {
return realSchematic.lengthZ();
}
};
}
BuilderCalculationContext bcc = new BuilderCalculationContext(); BuilderCalculationContext bcc = new BuilderCalculationContext();
if (!recalc(bcc)) { if (!recalc(bcc)) {
if (Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) {
logDirect("Starting layer " + layer);
layer++;
return onTick(calcFailed, isSafeToCancel);
}
logDirect("Done building"); logDirect("Done building");
onLostControl(); onLostControl();
return null; return null;
@ -540,6 +575,8 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
incorrectPositions = null; incorrectPositions = null;
name = null; name = null;
schematic = null; schematic = null;
realSchematic = null;
layer = 0;
paused = false; paused = false;
} }