mirror of https://github.com/cabaletta/baritone
Merge branch '1.13.2' into 1.14.4
This commit is contained in:
commit
e0beba38af
4
USAGE.md
4
USAGE.md
|
@ -44,7 +44,7 @@ Some common examples:
|
|||
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
|
||||
- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
|
||||
- `schematica` to build the schematic that is currently open in schematica
|
||||
- `tunnel` to dig just straight ahead and make a tunnel
|
||||
- `tunnel height width depth` to dig and make a tunnel. If you don't supply numbers then it just digs a 1x2 tunnel.
|
||||
- `farm` to automatically harvest, replant, or bone meal crops
|
||||
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
|
||||
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
|
||||
|
@ -73,6 +73,8 @@ There are about a hundred settings, but here are some fun / interesting / import
|
|||
- `worldExploringChunkOffset`
|
||||
- `acceptableThrowawayItems`
|
||||
- `blocksToAvoidBreaking`
|
||||
- `mineScanDroppedItems`
|
||||
- `allowDiagonalAscend`
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import baritone.api.BaritoneAPI;
|
|||
import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.ChunkEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
||||
import net.minecraft.network.play.server.SChunkDataPacket;
|
||||
import net.minecraft.network.play.server.SCombatPacket;
|
||||
|
@ -47,7 +48,8 @@ public class MixinClientPlayNetHandler {
|
|||
)
|
||||
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.PRE,
|
||||
|
@ -66,7 +68,8 @@ public class MixinClientPlayNetHandler {
|
|||
)
|
||||
private void postHandleChunkData(SChunkDataPacket packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
|
@ -85,7 +88,8 @@ public class MixinClientPlayNetHandler {
|
|||
)
|
||||
private void preChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
|
||||
);
|
||||
|
@ -99,7 +103,8 @@ public class MixinClientPlayNetHandler {
|
|||
)
|
||||
private void postChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
|
||||
);
|
||||
|
@ -116,7 +121,8 @@ public class MixinClientPlayNetHandler {
|
|||
)
|
||||
private void onPlayerDeath(SCombatPacket packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onPlayerDeath();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class MixinMinecraft {
|
|||
)
|
||||
private boolean passEvents(Screen screen) {
|
||||
// allow user input is only the primary baritone
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.passEvents;
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.passEvents;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue