mirror of
https://github.com/cabaletta/baritone
synced 2025-02-23 15:46:59 +00:00
Merge branch 'master' into 1.13.2
This commit is contained in:
commit
6289e540b8
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`
|
||||
|
||||
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class MixinMinecraft {
|
||||
)
|
||||
private boolean isAllowUserInput(GuiScreen screen) {
|
||||
// allow user input is only the primary baritone
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput;
|
||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.allowUserInput;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
|
@ -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.EntityPlayerSP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketCombatEvent;
|
||||
@ -46,7 +47,8 @@ public class MixinNetHandlerPlayClient {
|
||||
)
|
||||
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
EntityPlayerSP player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.PRE,
|
||||
@ -65,7 +67,8 @@ public class MixinNetHandlerPlayClient {
|
||||
)
|
||||
private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
EntityPlayerSP player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onChunkEvent(
|
||||
new ChunkEvent(
|
||||
EventState.POST,
|
||||
@ -115,7 +118,8 @@ public class MixinNetHandlerPlayClient {
|
||||
)
|
||||
private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
||||
EntityPlayerSP player = ibaritone.getPlayerContext().player();
|
||||
if (player != null && player.connection == (NetHandlerPlayClient) (Object) this) {
|
||||
ibaritone.getGameEventHandler().onPlayerDeath();
|
||||
}
|
||||
}
|
||||
|
@ -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.EnumFacing;
|
||||
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;
|
||||
EnumFacing 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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +314,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)) {
|
||||
|
@ -209,7 +209,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
continue; // irrelevant
|
||||
}
|
||||
IBlockState curr = bcc.bsi.get0(x, y, z);
|
||||
if (!(curr.getBlock() instanceof BlockAir) && !(curr.getBlock() == Blocks.WATER || curr.getBlock() == Blocks.LAVA) && !valid(curr, desired)) {
|
||||
if (!(curr.getBlock() instanceof BlockAir) && !(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()) {
|
||||
@ -250,7 +250,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
continue; // irrelevant
|
||||
}
|
||||
IBlockState 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 BlockAir) {
|
||||
continue;
|
||||
}
|
||||
@ -331,7 +331,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);
|
||||
}
|
||||
}
|
||||
@ -474,7 +474,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
outer:
|
||||
for (IBlockState 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;
|
||||
}
|
||||
@ -485,7 +485,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
outer:
|
||||
for (int i = 9; i < 36; i++) {
|
||||
for (IBlockState desired : noValidHotbarOption) {
|
||||
if (valid(approxPlaceable.get(i), desired)) {
|
||||
if (valid(approxPlaceable.get(i), desired, true)) {
|
||||
baritone.getInventoryBehavior().attemptToPutOnHotbar(i, usefulSlots::contains);
|
||||
break outer;
|
||||
}
|
||||
@ -541,7 +541,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 {
|
||||
@ -568,7 +568,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));
|
||||
@ -786,7 +786,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean valid(IBlockState current, IBlockState desired) {
|
||||
private boolean valid(IBlockState current, IBlockState desired, boolean itemVerify) {
|
||||
if (desired == null) {
|
||||
return true;
|
||||
}
|
||||
@ -800,7 +800,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
if (desired.getBlock() instanceof BlockAir && Baritone.settings().buildIgnoreBlocks.value.contains(current.getBlock())) {
|
||||
return true;
|
||||
}
|
||||
if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value) {
|
||||
if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) {
|
||||
return true;
|
||||
}
|
||||
return current.equals(desired);
|
||||
@ -882,7 +882,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
Block a user