zac suggestion
This commit is contained in:
parent
9a9b4a1874
commit
98a87d099b
@ -84,7 +84,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
private int layer;
|
||||
private int numRepeats;
|
||||
private List<IBlockState> approxPlaceable;
|
||||
public final int[] selectionLayerBounds = {0, 0};
|
||||
public int stopAtHeight = 0;
|
||||
|
||||
public BuilderProcess(Baritone baritone) {
|
||||
super(baritone);
|
||||
@ -113,21 +113,24 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
this.origin = new Vec3i(x, y, z);
|
||||
this.paused = false;
|
||||
this.layer = Baritone.settings().startAtLayer.value;
|
||||
this.stopAtHeight = schematic.heightY();
|
||||
if (Baritone.settings().buildOnlySelection.value) {
|
||||
if (baritone.getSelectionManager().getSelections().length == 0) {
|
||||
logDirect("Poor little kitten forgot to set a selection while BuildOnlySelection is true");
|
||||
}
|
||||
if (Baritone.settings().buildInLayers.value) {
|
||||
this.stopAtHeight = 0;
|
||||
} else if (Baritone.settings().buildInLayers.value) {
|
||||
OptionalInt minim = Stream.of(baritone.getSelectionManager().getSelections()).mapToInt(sel -> sel.min().y).min();
|
||||
OptionalInt maxim = Stream.of(baritone.getSelectionManager().getSelections()).mapToInt(sel -> sel.max().y).max();
|
||||
logDirect(String.format("Schematic starts at y=%s with height %s", y, schematic.heightY()));
|
||||
logDirect(String.format("Selection starts at y=%s and ends at y=%s", minim.isPresent() ? minim.getAsInt() : 0, maxim.isPresent() ? maxim.getAsInt() : 0));
|
||||
if (minim.isPresent() && maxim.isPresent()) {
|
||||
selectionLayerBounds[0] = Baritone.settings().layerOrder.value ? y + schematic.heightY() - maxim.getAsInt() : minim.getAsInt() - y;
|
||||
selectionLayerBounds[1] = Baritone.settings().layerOrder.value ? y + schematic.heightY() - minim.getAsInt() : maxim.getAsInt() - y;
|
||||
int startAtHeight = Baritone.settings().layerOrder.value ? y + schematic.heightY() - maxim.getAsInt() : minim.getAsInt() - y;
|
||||
this.stopAtHeight = (Baritone.settings().layerOrder.value ? y + schematic.heightY() - minim.getAsInt() : maxim.getAsInt() - y) + 1;
|
||||
this.layer = startAtHeight / Baritone.settings().layerHeight.value;
|
||||
if (Baritone.settings().chatDebug.value) {
|
||||
logDirect(String.format("Schematic starts at y=%s with height %s", y, schematic.heightY()));
|
||||
logDirect(String.format("Selection starts at y=%s and ends at y=%s", minim.getAsInt(), maxim.getAsInt()));
|
||||
logDirect(String.format("Considering relevant height %s - %s", startAtHeight, this.stopAtHeight));
|
||||
}
|
||||
}
|
||||
this.layer = this.selectionLayerBounds[0] / Baritone.settings().layerHeight.value;
|
||||
logDirect("Skipped everything under layer " + this.layer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,8 +482,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
BuilderCalculationContext bcc = new BuilderCalculationContext();
|
||||
if (!recalc(bcc)) {
|
||||
checkAboveSelection();
|
||||
if (Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < realSchematic.heightY()) {
|
||||
if (Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < stopAtHeight) {
|
||||
logDirect("Starting layer " + layer);
|
||||
layer++;
|
||||
return onTick(calcFailed, isSafeToCancel, recursions + 1);
|
||||
@ -570,7 +572,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
if (goal == null) {
|
||||
goal = assemble(bcc, approxPlaceable, true); // we're far away, so assume that we have our whole inventory to recalculate placeable properly
|
||||
if (goal == null) {
|
||||
checkAboveSelection();
|
||||
if (Baritone.settings().skipFailedLayers.value && Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < realSchematic.heightY()) {
|
||||
logDirect("Skipping layer that I cannot construct! Layer #" + layer);
|
||||
layer++;
|
||||
@ -584,14 +585,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
return new PathingCommandContext(goal, PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH, bcc);
|
||||
}
|
||||
|
||||
private void checkAboveSelection() {
|
||||
if (Baritone.settings().buildInLayers.value && Baritone.settings().buildOnlySelection.value &&
|
||||
this.layer * Baritone.settings().layerHeight.value > this.selectionLayerBounds[1]) {
|
||||
logDirect("Skipped everything above layer " + this.layer);
|
||||
this.layer = realSchematic.heightY() / Baritone.settings().layerHeight.value + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recalc(BuilderCalculationContext bcc) {
|
||||
if (incorrectPositions == null) {
|
||||
incorrectPositions = new HashSet<>();
|
||||
|
Loading…
Reference in New Issue
Block a user