build repeat option

This commit is contained in:
Leijurv 2019-04-11 16:36:20 -07:00
parent 2bf475d840
commit a09bb0d538
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 45 additions and 9 deletions

View File

@ -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<Boolean> 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<Integer> buildRepeatDistance=new Setting<>(0);
/**
* What direction te repeat the build in
*/
public final Setting<EnumFacing> 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)?
*/

View File

@ -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).
*

View File

@ -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);
}
int distance = Baritone.settings().buildRepeatDistance.value;
EnumFacing direction = Baritone.settings().buildRepeatDirection.value;
if (distance == 0) {
logDirect("Done building");
onLostControl();
return null;
}
trim(bcc);
if (baritone.getInputOverrideHandler().isInputForcedDown(Input.CLICK_LEFT)) {
ticks = 5;
} else {
ticks--;
// 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);
Optional<Tuple<BetterBlockPos, Rotation>> 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