mirror of https://github.com/cabaletta/baritone
Merge pull request #3786 from Entropy5/master
bugfix for odd height schematics
This commit is contained in:
commit
c47a6f92c5
|
@ -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[] selectionYBounds = {0, 0};
|
||||
public int stopAtHeight = 0;
|
||||
|
||||
public BuilderProcess(Baritone baritone) {
|
||||
super(baritone);
|
||||
|
@ -95,6 +95,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
this.name = name;
|
||||
this.schematic = schematic;
|
||||
this.realSchematic = null;
|
||||
boolean buildingSelectionSchematic = schematic instanceof SelectionSchematic;
|
||||
if (!Baritone.settings().buildSubstitutes.value.isEmpty()) {
|
||||
this.schematic = new SubstituteSchematic(this.schematic, Baritone.settings().buildSubstitutes.value);
|
||||
}
|
||||
|
@ -113,21 +114,22 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
this.origin = new Vec3i(x, y, z);
|
||||
this.paused = false;
|
||||
this.layer = Baritone.settings().startAtLayer.value;
|
||||
if (Baritone.settings().buildOnlySelection.value) {
|
||||
this.stopAtHeight = schematic.heightY();
|
||||
if (Baritone.settings().buildOnlySelection.value && buildingSelectionSchematic) { // currently redundant but safer maybe
|
||||
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()) {
|
||||
selectionYBounds[0] = Baritone.settings().layerOrder.value ? y + schematic.heightY() - maxim.getAsInt() : minim.getAsInt() - y;
|
||||
selectionYBounds[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 = Math.max(this.layer, startAtHeight / Baritone.settings().layerHeight.value); // startAtLayer or startAtHeight, whichever is highest
|
||||
logDebug(String.format("Schematic starts at y=%s with height %s", y, schematic.heightY()));
|
||||
logDebug(String.format("Selection starts at y=%s and ends at y=%s", minim.getAsInt(), maxim.getAsInt()));
|
||||
logDebug(String.format("Considering relevant height %s - %s", startAtHeight, this.stopAtHeight));
|
||||
}
|
||||
this.layer = this.selectionYBounds[0] / Baritone.settings().layerHeight.value;
|
||||
logDirect("Skipped everything under layer " + this.layer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -479,8 +481,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 +571,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 +584,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.selectionYBounds[1]) {
|
||||
logDirect("Skipped everything above layer " + this.layer);
|
||||
this.layer = realSchematic.heightY() / Baritone.settings().layerHeight.value;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recalc(BuilderCalculationContext bcc) {
|
||||
if (incorrectPositions == null) {
|
||||
incorrectPositions = new HashSet<>();
|
||||
|
|
Loading…
Reference in New Issue