Merge branch '1.14.4' into 1.15.2

This commit is contained in:
Brady
2020-03-07 20:45:07 -06:00
8 changed files with 85 additions and 31 deletions

View File

@@ -103,7 +103,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
@Override
public void onPlayerSprintState(SprintStateEvent event) {
if (current != null) {
if (isPathing()) {
event.setState(current.isSprinting());
}
}

View File

@@ -18,11 +18,13 @@
package baritone.command.defaults;
import baritone.api.IBaritone;
import baritone.api.command.Command;
import baritone.api.command.argument.IArgConsumer;
import baritone.api.command.exception.CommandException;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalStrictDirection;
import baritone.api.command.Command;
import baritone.api.command.exception.CommandException;
import baritone.api.command.argument.IArgConsumer;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import java.util.Arrays;
import java.util.List;
@@ -36,13 +38,56 @@ public class TunnelCommand extends Command {
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(0);
Goal goal = new GoalStrictDirection(
ctx.playerFeet(),
ctx.player().getHorizontalFacing()
);
baritone.getCustomGoalProcess().setGoalAndPath(goal);
logDirect(String.format("Goal: %s", goal.toString()));
args.requireMax(3);
if (args.hasExactly(3)) {
boolean cont = true;
int height = Integer.parseInt(args.getArgs().get(0).getValue());
int width = Integer.parseInt(args.getArgs().get(1).getValue());
int depth = Integer.parseInt(args.getArgs().get(2).getValue());
if (width < 1 || height < 2 || depth < 1 || height > 255) {
logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks, and cannot be greater than the build limit.");
cont = false;
}
if (cont) {
height--;
width--;
BlockPos corner1;
BlockPos corner2;
Direction enumFacing = ctx.player().getHorizontalFacing();
int addition = ((width % 2 == 0) ? 0 : 1);
switch (enumFacing) {
case EAST:
corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z - width / 2);
corner2 = new BlockPos(ctx.playerFeet().x + depth, ctx.playerFeet().y + height, ctx.playerFeet().z + width / 2 + addition);
break;
case WEST:
corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z + width / 2 + addition);
corner2 = new BlockPos(ctx.playerFeet().x - depth, ctx.playerFeet().y + height, ctx.playerFeet().z - width / 2);
break;
case NORTH:
corner1 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y, ctx.playerFeet().z);
corner2 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y + height, ctx.playerFeet().z - depth);
break;
case SOUTH:
corner1 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y, ctx.playerFeet().z);
corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth);
break;
default:
throw new IllegalStateException("Unexpected value: " + enumFacing);
}
logDirect(String.format("Creating a tunnel %s block(s) high, %s block(s) wide, and %s block(s) deep", height+1, width+1, depth));
baritone.getBuilderProcess().clearArea(corner1, corner2);
}
} else {
Goal goal = new GoalStrictDirection(
ctx.playerFeet(),
ctx.player().getHorizontalFacing()
);
baritone.getCustomGoalProcess().setGoalAndPath(goal);
logDirect(String.format("Goal: %s", goal.toString()));
}
}
@Override
@@ -61,7 +106,8 @@ public class TunnelCommand extends Command {
"The tunnel command sets a goal that tells Baritone to mine completely straight in the direction that you're facing.",
"",
"Usage:",
"> tunnel"
"> tunnel - No arguments, mines in a 1x2 radius.",
"> tunnel <height> <width> <depth> - Tunnels in a user defined height, width and depth."
);
}
}

View File

@@ -309,7 +309,7 @@ public interface MovementHelper extends ActionCosts, Helper {
if (block == Blocks.FARMLAND || block == Blocks.GRASS_PATH) {
return true;
}
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) {
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST ) {
return true;
}
if (isWater(state)) {

View File

@@ -210,7 +210,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
continue; // irrelevant
}
BlockState curr = bcc.bsi.get0(x, y, z);
if (!(curr.getBlock() instanceof AirBlock) && !(curr.getBlock() == Blocks.WATER || curr.getBlock() == Blocks.LAVA) && !valid(curr, desired)) {
if (!(curr.getBlock() instanceof AirBlock) && !(curr.getBlock() == Blocks.WATER || curr.getBlock() == Blocks.LAVA) && !valid(curr, desired, false)) {
BetterBlockPos pos = new BetterBlockPos(x, y, z);
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
if (rot.isPresent()) {
@@ -251,7 +251,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
continue; // irrelevant
}
BlockState curr = bcc.bsi.get0(x, y, z);
if (MovementHelper.isReplaceable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) {
if (MovementHelper.isReplaceable(x, y, z, curr, bcc.bsi) && !valid(curr, desired, false)) {
if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() instanceof AirBlock) {
continue;
}
@@ -330,7 +330,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (!meme.canPlace()) {
continue;
}
if (valid(wouldBePlaced, desired)) {
if (valid(wouldBePlaced, desired, true)) {
return OptionalInt.of(i);
}
}
@@ -473,7 +473,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
outer:
for (BlockState desired : desirableOnHotbar) {
for (int i = 0; i < 9; i++) {
if (valid(approxPlaceable.get(i), desired)) {
if (valid(approxPlaceable.get(i), desired, true)) {
usefulSlots.add(i);
continue outer;
}
@@ -484,7 +484,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
outer:
for (int i = 9; i < 36; i++) {
for (BlockState desired : noValidHotbarOption) {
if (valid(approxPlaceable.get(i), desired)) {
if (valid(approxPlaceable.get(i), desired, true)) {
baritone.getInventoryBehavior().attemptToPutOnHotbar(i, usefulSlots::contains);
break outer;
}
@@ -540,7 +540,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (desired != null) {
// we care about this position
BetterBlockPos pos = new BetterBlockPos(x, y, z);
if (valid(bcc.bsi.get0(x, y, z), desired)) {
if (valid(bcc.bsi.get0(x, y, z), desired, false)) {
incorrectPositions.remove(pos);
observedCompleted.add(BetterBlockPos.longHash(pos));
} else {
@@ -567,7 +567,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
if (bcc.bsi.worldContainsLoadedChunk(blockX, blockZ)) { // check if its in render distance, not if its in cache
// we can directly observe this block, it is in render distance
if (valid(bcc.bsi.get0(blockX, blockY, blockZ), schematic.desiredState(x, y, z, current, this.approxPlaceable))) {
if (valid(bcc.bsi.get0(blockX, blockY, blockZ), schematic.desiredState(x, y, z, current, this.approxPlaceable), false)) {
observedCompleted.add(BetterBlockPos.longHash(blockX, blockY, blockZ));
} else {
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
@@ -785,7 +785,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
return result;
}
private boolean valid(BlockState current, BlockState desired) {
private boolean valid(BlockState current, BlockState desired, boolean itemVerify) {
if (desired == null) {
return true;
}
@@ -799,7 +799,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
if (desired.getBlock() instanceof AirBlock && Baritone.settings().buildIgnoreBlocks.value.contains(current.getBlock())) {
return true;
}
if (!(current.getBlock() instanceof AirBlock) && Baritone.settings().buildIgnoreExisting.value) {
if (!(current.getBlock() instanceof AirBlock) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) {
return true;
}
return current.equals(desired);
@@ -881,7 +881,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
// it should be a real block
// is it already that block?
if (valid(bsi.get0(x, y, z), sch)) {
if (valid(bsi.get0(x, y, z), sch, false)) {
return Baritone.settings().breakCorrectBlockPenaltyMultiplier.value;
} else {
// can break if it's wrong

View File

@@ -41,7 +41,7 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockReader {
@Nullable
@Override
public TileEntity getTileEntity(BlockPos pos) {
throw new UnsupportedOperationException("getTileEntity not supported by BlockStateInterfaceAccessWrapper");
return null;
}
@Override