diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 3a1c9fba..b61656a9 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -21,6 +21,7 @@ import baritone.api.utils.SettingsUtil; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.item.Item; +import net.minecraft.util.EnumFacing; import net.minecraft.util.text.ITextComponent; import java.awt.*; @@ -571,6 +572,16 @@ public final class Settings { */ public final Setting buildInLayers = new Setting<>(false); + /** + * How far to move before repeating the build. -1 for the size of the build in that axis. 0 to disable + */ + public final Setting buildRepeatDistance=new Setting<>(0); + + /** + * What direction te repeat the build in + */ + public final Setting buildRepeatDirection = new Setting<>(EnumFacing.NORTH); + /** * While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)? */ diff --git a/src/api/java/baritone/api/utils/ISchematic.java b/src/api/java/baritone/api/utils/ISchematic.java index 1f2cd874..821dc68c 100644 --- a/src/api/java/baritone/api/utils/ISchematic.java +++ b/src/api/java/baritone/api/utils/ISchematic.java @@ -18,6 +18,7 @@ package baritone.api.utils; import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; /** * Basic representation of a schematic. Provides the dimensions and @@ -44,6 +45,19 @@ public interface ISchematic { return x >= 0 && x < widthX() && y >= 0 && y < heightY() && z >= 0 && z < lengthZ(); } + default int size(EnumFacing.Axis axis) { + switch (axis) { + case X: + return widthX(); + case Y: + return heightY(); + case Z: + return lengthZ(); + default: + throw new UnsupportedOperationException(axis + ""); + } + } + /** * Returns the desired block state at a given (X, Y, Z) position relative to the origin (0, 0, 0). * diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 6c38b7ff..4e4fc3df 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -285,6 +285,11 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro @Override public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { + if (baritone.getInputOverrideHandler().isInputForcedDown(Input.CLICK_LEFT)) { + ticks = 5; + } else { + ticks--; + } baritone.getInputOverrideHandler().clearAllKeys(); if (paused) { return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); @@ -322,18 +327,24 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro layer++; return onTick(calcFailed, isSafeToCancel); } - logDirect("Done building"); - onLostControl(); - return null; + int distance = Baritone.settings().buildRepeatDistance.value; + EnumFacing direction = Baritone.settings().buildRepeatDirection.value; + if (distance == 0) { + logDirect("Done building"); + onLostControl(); + return null; + } + // build repeat time + if (distance == -1) { + distance = schematic.size(direction.getAxis()); + } + layer = 0; + origin = new BlockPos(origin).offset(direction, distance); + logDirect("Repeating build " + distance + " blocks to the " + direction + ", new origin is " + origin); } trim(bcc); - if (baritone.getInputOverrideHandler().isInputForcedDown(Input.CLICK_LEFT)) { - ticks = 5; - } else { - ticks--; - } + Optional> toBreak = toBreakNearPlayer(bcc); - baritone.getInputOverrideHandler().clearAllKeys(); if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) { // we'd like to pause to break this block // only change look direction if it's safe (don't want to fuck up an in progress parkour for example