This commit is contained in:
babbaj 2024-04-24 18:55:00 -04:00 committed by GitHub
commit 5ef2a9d8ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 103 additions and 107 deletions

View File

@ -60,7 +60,7 @@ public interface IPlayerContext {
HitResult objectMouseOver();
default BetterBlockPos playerFeet() {
default BetterBlockPos playerToes() {
// TODO find a better way to deal with soul sand!!!!!
BetterBlockPos feet = new BetterBlockPos(player().position().x, player().position().y + 0.1251, player().position().z);

View File

@ -169,7 +169,7 @@ public final class InventoryBehavior extends Behavior implements Helper {
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z, baritone.bsi.get0(x, y, z));
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {}))))) {
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerToes(), false)) {}))))) {
return true; // gotem
}
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && ((BlockItem) stack.getItem()).getBlock().equals(maybe.getBlock()))) {

View File

@ -33,7 +33,6 @@ import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.path.PathExecutor;
import baritone.process.ElytraProcess;
import baritone.utils.PathRenderer;
import baritone.utils.PathingCommandContext;
import baritone.utils.pathing.Favoring;
@ -139,8 +138,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
BetterBlockPos calcFrom = inProgress.getStart();
Optional<IPath> currentBest = inProgress.bestPathSoFar();
if ((current == null || !current.getPath().getDest().equals(calcFrom)) // if current ends in inProgress's start, then we're ok
&& !calcFrom.equals(ctx.playerFeet()) && !calcFrom.equals(expectedSegmentStart) // if current starts in our playerFeet or pathStart, then we're ok
&& (!currentBest.isPresent() || (!currentBest.get().positions().contains(ctx.playerFeet()) && !currentBest.get().positions().contains(expectedSegmentStart))) // if
&& !calcFrom.equals(ctx.playerToes()) && !calcFrom.equals(expectedSegmentStart) // if current starts in our playerFeet or pathStart, then we're ok
&& (!currentBest.isPresent() || (!currentBest.get().positions().contains(ctx.playerToes()) && !currentBest.get().positions().contains(expectedSegmentStart))) // if
) {
// when it was *just* started, currentBest will be empty so we need to also check calcFrom since that's always present
inProgress.cancel(); // cancellation doesn't dispatch any events
@ -153,7 +152,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
safeToCancel = current.onTick();
if (current.failed() || current.finished()) {
current = null;
if (goal == null || goal.isInGoal(ctx.playerFeet())) {
if (goal == null || goal.isInGoal(ctx.playerToes())) {
logDebug("All done. At " + goal);
queuePathEvent(PathEvent.AT_GOAL);
next = null;
@ -162,7 +161,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
return;
}
if (next != null && !next.getPath().positions().contains(ctx.playerFeet()) && !next.getPath().positions().contains(expectedSegmentStart)) { // can contain either one
if (next != null && !next.getPath().positions().contains(ctx.playerToes()) && !next.getPath().positions().contains(expectedSegmentStart)) { // can contain either one
// if the current path failed, we may not actually be on the next one, so make sure
logDebug("Discarding next path as it does not contain current position");
// for example if we had a nicely planned ahead path that starts where current ends
@ -265,7 +264,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
if (goal == null) {
return false;
}
if (goal.isInGoal(ctx.playerFeet()) || goal.isInGoal(expectedSegmentStart)) {
if (goal.isInGoal(ctx.playerToes()) || goal.isInGoal(expectedSegmentStart)) {
return false;
}
synchronized (pathPlanLock) {
@ -382,11 +381,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
}
public Optional<Double> estimatedTicksToGoal() {
BetterBlockPos currentPos = ctx.playerFeet();
BetterBlockPos currentPos = ctx.playerToes();
if (goal == null || currentPos == null || startPosition == null) {
return Optional.empty();
}
if (goal.isInGoal(ctx.playerFeet())) {
if (goal.isInGoal(ctx.playerToes())) {
resetEstimatedTicksToGoal();
return Optional.of(0.0);
}
@ -421,7 +420,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
* @return The starting {@link BlockPos} for a new path
*/
public BetterBlockPos pathStart() { // TODO move to a helper or util class
BetterBlockPos feet = ctx.playerFeet();
BetterBlockPos feet = ctx.playerToes();
if (!MovementHelper.canWalkOn(ctx, feet.below())) {
if (ctx.player().onGround()) {
double playerX = ctx.player().position().x;

View File

@ -68,7 +68,7 @@ public class WaypointBehavior extends Behavior {
public void onPlayerDeath() {
if (!Baritone.settings().doDeathWaypoints.value)
return;
Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet());
Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerToes());
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint);
MutableComponent component = Component.literal("Death position saved.");
component.setStyle(component.getStyle()

View File

@ -209,7 +209,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
IWorldData data = ibaritone.getWorldProvider().getCurrentWorld();
if (data != null && data.getCachedWorld() == this && ibaritone.getPlayerContext().player() != null) {
return ibaritone.getPlayerContext().playerFeet();
return ibaritone.getPlayerContext().playerToes();
}
}
CachedChunk mostRecentlyModified = null;

View File

@ -26,7 +26,6 @@ import baritone.api.utils.IPlayerContext;
import baritone.utils.accessor.IPalettedContainer;
import io.netty.buffer.Unpooled;
import net.minecraft.core.BlockPos;
import net.minecraft.core.IdMapper;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.BitStorage;
import net.minecraft.world.level.ChunkPos;
@ -56,7 +55,7 @@ public enum FasterWorldScanner implements IWorldScanner {
if (maxSearchRadius < 0) {
throw new IllegalArgumentException("chunkRange must be >= 0");
}
return scanChunksInternal(ctx, filter, getChunkRange(ctx.playerFeet().x >> 4, ctx.playerFeet().z >> 4, maxSearchRadius), max);
return scanChunksInternal(ctx, filter, getChunkRange(ctx.playerToes().x >> 4, ctx.playerToes().z >> 4, maxSearchRadius), max);
}
@Override
@ -78,7 +77,7 @@ public enum FasterWorldScanner implements IWorldScanner {
ChunkSource chunkProvider = ctx.world().getChunkSource();
ICachedWorld cachedWorld = ctx.worldData().getCachedWorld();
BetterBlockPos playerPos = ctx.playerFeet();
BetterBlockPos playerPos = ctx.playerToes();
int playerChunkX = playerPos.getX() >> 4;
int playerChunkZ = playerPos.getZ() >> 4;
@ -156,7 +155,7 @@ public enum FasterWorldScanner implements IWorldScanner {
long chunkX = (long) pos.x << 4;
long chunkZ = (long) pos.z << 4;
int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 4;
int playerSectionY = (ctx.playerToes().y - ctx.world().getMinBuildHeight()) >> 4;
return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream();
}

View File

@ -48,9 +48,9 @@ public enum WorldScanner implements IWorldScanner {
ClientChunkCache chunkProvider = (ClientChunkCache) ctx.world().getChunkSource();
int maxSearchRadiusSq = maxSearchRadius * maxSearchRadius;
int playerChunkX = ctx.playerFeet().getX() >> 4;
int playerChunkZ = ctx.playerFeet().getZ() >> 4;
int playerY = ctx.playerFeet().getY() - ctx.world().dimensionType().minY();
int playerChunkX = ctx.playerToes().getX() >> 4;
int playerChunkZ = ctx.playerToes().getZ() >> 4;
int playerY = ctx.playerToes().getY() - ctx.world().dimensionType().minY();
int playerYBlockStateContainerIndex = playerY >> 4;
int[] coordinateIterationOrder = IntStream.range(0, ctx.world().dimensionType().height() / 16).boxed().sorted(Comparator.comparingInt(y -> Math.abs(y - playerYBlockStateContainerIndex))).mapToInt(x -> x).toArray();
@ -97,7 +97,7 @@ public enum WorldScanner implements IWorldScanner {
ClientChunkCache chunkProvider = (ClientChunkCache) ctx.world().getChunkSource();
LevelChunk chunk = chunkProvider.getChunk(pos.x, pos.z, null, false);
int playerY = ctx.playerFeet().getY();
int playerY = ctx.playerToes().getY();
if (chunk == null || chunk.isEmpty()) {
return Collections.emptyList();
@ -118,7 +118,7 @@ public enum WorldScanner implements IWorldScanner {
ChunkSource chunkProvider = ctx.world().getChunkSource();
ICachedWorld cachedWorld = ctx.worldData().getCachedWorld();
BetterBlockPos playerPos = ctx.playerFeet();
BetterBlockPos playerPos = ctx.playerToes();
int playerChunkX = playerPos.getX() >> 4;
int playerChunkZ = playerPos.getZ() >> 4;

View File

@ -48,7 +48,7 @@ public class BuildCommand extends Command {
if (FilenameUtils.getExtension(file.getAbsolutePath()).isEmpty()) {
file = new File(file.getAbsolutePath() + "." + Baritone.settings().schematicFallbackExtension.value);
}
BetterBlockPos origin = ctx.playerFeet();
BetterBlockPos origin = ctx.playerToes();
BetterBlockPos buildOrigin;
if (args.hasAny()) {
args.requireMax(3);

View File

@ -42,8 +42,8 @@ public class ExploreCommand extends Command {
args.requireMax(0);
}
GoalXZ goal = args.hasAny()
? args.getDatatypePost(RelativeGoalXZ.INSTANCE, ctx.playerFeet())
: new GoalXZ(ctx.playerFeet());
? args.getDatatypePost(RelativeGoalXZ.INSTANCE, ctx.playerToes())
: new GoalXZ(ctx.playerToes());
baritone.getExploreProcess().explore(goal.getX(), goal.getZ());
logDirect(String.format("Exploring from %s", goal.toString()));
}

View File

@ -25,7 +25,6 @@ import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.BetterBlockPos;
import baritone.cache.CachedChunk;
import net.minecraft.core.Registry;
import net.minecraft.ChatFormatting;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.ClickEvent;
@ -54,7 +53,7 @@ public class FindCommand extends Command {
while (args.hasAny()) {
toFind.add(args.getDatatypeFor(BlockById.INSTANCE));
}
BetterBlockPos origin = ctx.playerFeet();
BetterBlockPos origin = ctx.playerToes();
Component[] components = toFind.stream()
.flatMap(block ->
ctx.worldData().getCachedWorld().getLocationsOf(

View File

@ -51,7 +51,7 @@ public class GoalCommand extends Command {
}
} else {
args.requireMax(3);
BetterBlockPos origin = ctx.playerFeet();
BetterBlockPos origin = ctx.playerToes();
Goal goal = args.getDatatypePost(RelativeGoal.INSTANCE, origin);
goalProcess.setGoal(goal);
logDirect(String.format("Goal: %s", goal.toString()));

View File

@ -45,7 +45,7 @@ public class GotoCommand extends Command {
// is no need to handle the case of empty arguments.
if (args.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) != null) {
args.requireMax(3);
BetterBlockPos origin = ctx.playerFeet();
BetterBlockPos origin = ctx.playerToes();
Goal goal = args.getDatatypePost(RelativeGoal.INSTANCE, origin);
logDirect(String.format("Going to: %s", goal.toString()));
baritone.getCustomGoalProcess().setGoalAndPath(goal);

View File

@ -36,7 +36,7 @@ public class RenderCommand extends Command {
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(0);
BetterBlockPos origin = ctx.playerFeet();
BetterBlockPos origin = ctx.playerToes();
int renderDistance = (ctx.minecraft().options.renderDistance().get() + 1) * 16;
ctx.minecraft().levelRenderer.setBlocksDirty(
origin.x - renderDistance,

View File

@ -37,7 +37,7 @@ public class SurfaceCommand extends Command {
@Override
public void execute(String label, IArgConsumer args) throws CommandException {
final BetterBlockPos playerPos = ctx.playerFeet();
final BetterBlockPos playerPos = ctx.playerToes();
final int surfaceLevel = ctx.world().getSeaLevel();
final int worldHeight = ctx.world().getHeight();

View File

@ -58,20 +58,20 @@ public class TunnelCommand extends Command {
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);
corner1 = new BlockPos(ctx.playerToes().x, ctx.playerToes().y, ctx.playerToes().z - width / 2);
corner2 = new BlockPos(ctx.playerToes().x + depth, ctx.playerToes().y + height, ctx.playerToes().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);
corner1 = new BlockPos(ctx.playerToes().x, ctx.playerToes().y, ctx.playerToes().z + width / 2 + addition);
corner2 = new BlockPos(ctx.playerToes().x - depth, ctx.playerToes().y + height, ctx.playerToes().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);
corner1 = new BlockPos(ctx.playerToes().x - width / 2, ctx.playerToes().y, ctx.playerToes().z);
corner2 = new BlockPos(ctx.playerToes().x + width / 2 + addition, ctx.playerToes().y + height, ctx.playerToes().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);
corner1 = new BlockPos(ctx.playerToes().x + width / 2 + addition, ctx.playerToes().y, ctx.playerToes().z);
corner2 = new BlockPos(ctx.playerToes().x - width / 2, ctx.playerToes().y + height, ctx.playerToes().z + depth);
break;
default:
throw new IllegalStateException("Unexpected value: " + enumFacing);
@ -81,7 +81,7 @@ public class TunnelCommand extends Command {
}
} else {
Goal goal = new GoalStrictDirection(
ctx.playerFeet(),
ctx.playerToes(),
ctx.player().getDirection()
);
baritone.getCustomGoalProcess().setGoalAndPath(goal);

View File

@ -44,7 +44,6 @@ import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
@ -138,8 +137,8 @@ public class WaypointsCommand extends Command {
}
String name = (args.hasExactlyOne() || args.hasExactly(4)) ? args.getString() : "";
BetterBlockPos pos = args.hasAny()
? args.getDatatypePost(RelativeBlockPos.INSTANCE, ctx.playerFeet())
: ctx.playerFeet();
? args.getDatatypePost(RelativeBlockPos.INSTANCE, ctx.playerToes())
: ctx.playerToes();
args.requireMax(0);
IWaypoint waypoint = new Waypoint(name, tag, pos);
ForWaypoints.waypoints(this.baritone).addWaypoint(waypoint);

View File

@ -110,7 +110,7 @@ public abstract class Movement implements IMovement, MovementHelper {
}
protected boolean playerInValidPosition() {
return getValidPositions().contains(ctx.playerFeet()) || getValidPositions().contains(((PathingBehavior) baritone.getPathingBehavior()).pathStart());
return getValidPositions().contains(ctx.playerToes()) || getValidPositions().contains(((PathingBehavior) baritone.getPathingBehavior()).pathStart());
}
/**
@ -123,7 +123,7 @@ public abstract class Movement implements IMovement, MovementHelper {
public MovementStatus update() {
ctx.player().getAbilities().flying = false;
currentState = updateState(currentState);
if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && ctx.player().position().y < dest.y + 0.6) {
if (MovementHelper.isLiquid(ctx, ctx.playerToes()) && ctx.player().position().y < dest.y + 0.6) {
currentState.setInput(Input.JUMP, true);
}
if (ctx.player().isInWall()) {

View File

@ -156,7 +156,7 @@ public class MovementAscend extends Movement {
@Override
public MovementState updateState(MovementState state) {
if (ctx.playerFeet().y < src.y) {
if (ctx.playerToes().y < src.y) {
// this check should run even when in preparing state (breaking blocks)
return state.setStatus(MovementStatus.UNREACHABLE);
}
@ -167,7 +167,7 @@ public class MovementAscend extends Movement {
return state;
}
if (ctx.playerFeet().equals(dest) || ctx.playerFeet().equals(dest.offset(getDirection().below()))) {
if (ctx.playerToes().equals(dest) || ctx.playerToes().equals(dest.offset(getDirection().below()))) {
return state.setStatus(MovementStatus.SUCCESS);
}
@ -192,7 +192,7 @@ public class MovementAscend extends Movement {
return state; // don't jump while walking from a non double slab into a bottom slab
}
if (Baritone.settings().assumeStep.value || ctx.playerFeet().equals(src.above())) {
if (Baritone.settings().assumeStep.value || ctx.playerToes().equals(src.above())) {
// no need to hit space if we're already jumping
return state;
}

View File

@ -229,7 +229,7 @@ public class MovementDescend extends Movement {
return state;
}
BlockPos playerFeet = ctx.playerFeet();
BlockPos playerFeet = ctx.playerToes();
BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ());
if ((playerFeet.equals(dest) || playerFeet.equals(fakeDest)) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().position().y - dest.getY() < 0.5)) { // lilypads
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately

View File

@ -66,7 +66,7 @@ public class MovementDiagonal extends Movement {
double y = player.position().y - 1;
double z = player.position().z;
//standard
if (ctx.playerFeet().equals(src)) {
if (ctx.playerToes().equals(src)) {
return true;
}
//both corners are walkable
@ -75,8 +75,8 @@ public class MovementDiagonal extends Movement {
return true;
}
//we are in a likely unwalkable corner, check for a supporting block
if (ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z))
|| ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))) {
if (ctx.playerToes().equals(new BetterBlockPos(src.x, src.y, dest.z))
|| ctx.playerToes().equals(new BetterBlockPos(dest.x, src.y, src.z))) {
return (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset))
|| MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z - offset))
|| MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z + offset))
@ -259,9 +259,9 @@ public class MovementDiagonal extends Movement {
return state;
}
if (ctx.playerFeet().equals(dest)) {
if (ctx.playerToes().equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS);
} else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().above()))) {
} else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerToes().above()))) {
return state.setStatus(MovementStatus.UNREACHABLE);
}
if (dest.y > src.y && ctx.player().position().y < src.y + 0.1 && ctx.player().horizontalCollision) {
@ -275,7 +275,7 @@ public class MovementDiagonal extends Movement {
}
private boolean sprint() {
if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.value) {
if (MovementHelper.isLiquid(ctx, ctx.playerToes()) && !Baritone.settings().sprintInWater.value) {
return false;
}
for (int i = 0; i < 4; i++) {

View File

@ -78,7 +78,7 @@ public class MovementDownward extends Movement {
return state;
}
if (ctx.playerFeet().equals(dest)) {
if (ctx.playerToes().equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS);
} else if (!playerInValidPosition()) {
return state.setStatus(MovementStatus.UNREACHABLE);

View File

@ -89,7 +89,7 @@ public class MovementFall extends Movement {
return state;
}
BlockPos playerFeet = ctx.playerFeet();
BlockPos playerFeet = ctx.playerToes();
Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations());
Rotation targetRotation = null;
BlockState destState = ctx.world().getBlockState(dest);
@ -160,7 +160,7 @@ public class MovementFall extends Movement {
private Direction avoid() {
for (int i = 0; i < 15; i++) {
BlockState state = ctx.world().getBlockState(ctx.playerFeet().below(i));
BlockState state = ctx.world().getBlockState(ctx.playerToes().below(i));
if (state.getBlock() == Blocks.LADDER) {
return state.getValue(LadderBlock.FACING);
}
@ -172,7 +172,7 @@ public class MovementFall extends Movement {
public boolean safeToCancel(MovementState state) {
// if we haven't started walking off the edge yet, or if we're in the process of breaking blocks before doing the fall
// then it's safe to cancel this
return ctx.playerFeet().equals(src) || state.getStatus() != MovementStatus.RUNNING;
return ctx.playerToes().equals(src) || state.getStatus() != MovementStatus.RUNNING;
}
private static BetterBlockPos[] buildPositionsToBreak(BetterBlockPos src, BetterBlockPos dest) {

View File

@ -255,7 +255,7 @@ public class MovementParkour extends Movement {
if (state.getStatus() != MovementStatus.RUNNING) {
return state;
}
if (ctx.playerFeet().y < src.y) {
if (ctx.playerToes().y < src.y) {
// we have fallen
logDebug("sorry");
return state.setStatus(MovementStatus.UNREACHABLE);
@ -264,18 +264,18 @@ public class MovementParkour extends Movement {
state.setInput(Input.SPRINT, true);
}
MovementHelper.moveTowards(ctx, state, dest);
if (ctx.playerFeet().equals(dest)) {
if (ctx.playerToes().equals(dest)) {
Block d = BlockStateInterface.getBlock(ctx, dest);
if (d == Blocks.VINE || d == Blocks.LADDER) {
// it physically hurt me to add support for parkour jumping onto a vine
// but i did it anyway
return state.setStatus(MovementStatus.SUCCESS);
}
if (ctx.player().position().y - ctx.playerFeet().getY() < 0.094) { // lilypads
if (ctx.player().position().y - ctx.playerToes().getY() < 0.094) { // lilypads
state.setStatus(MovementStatus.SUCCESS);
}
} else if (!ctx.playerFeet().equals(src)) {
if (ctx.playerFeet().equals(src.relative(direction)) || ctx.player().position().y - src.y > 0.0001) {
} else if (!ctx.playerToes().equals(src)) {
if (ctx.playerToes().equals(src.relative(direction)) || ctx.player().position().y - src.y > 0.0001) {
if (Baritone.settings().allowPlace.value // see PR #3775
&& ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway()
&& !MovementHelper.canWalkOn(ctx, dest.below())
@ -296,9 +296,9 @@ public class MovementParkour extends Movement {
}
state.setInput(Input.JUMP, true);
} else if (!ctx.playerFeet().equals(dest.relative(direction, -1))) {
} else if (!ctx.playerToes().equals(dest.relative(direction, -1))) {
state.setInput(Input.SPRINT, false);
if (ctx.playerFeet().equals(src.relative(direction, -1))) {
if (ctx.playerToes().equals(src.relative(direction, -1))) {
MovementHelper.moveTowards(ctx, state, src);
} else {
MovementHelper.moveTowards(ctx, state, src.relative(direction, -1));

View File

@ -168,7 +168,7 @@ public class MovementPillar extends Movement {
return state;
}
if (ctx.playerFeet().y < src.y) {
if (ctx.playerToes().y < src.y) {
return state.setStatus(MovementStatus.UNREACHABLE);
}
@ -180,7 +180,7 @@ public class MovementPillar extends Movement {
if (Math.abs(ctx.player().position().x - destCenter.x) > 0.2 || Math.abs(ctx.player().position().z - destCenter.z) > 0.2) {
state.setInput(Input.MOVE_FORWARD, true);
}
if (ctx.playerFeet().equals(dest)) {
if (ctx.playerToes().equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS);
}
return state;
@ -202,7 +202,7 @@ public class MovementPillar extends Movement {
return state.setStatus(MovementStatus.UNREACHABLE);
}
if (ctx.playerFeet().equals(against.above()) || ctx.playerFeet().equals(dest)) {
if (ctx.playerToes().equals(against.above()) || ctx.playerToes().equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS);
}
if (MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.below()))) {
@ -263,7 +263,7 @@ public class MovementPillar extends Movement {
}
// If we are at our goal and the block below us is placed
if (ctx.playerFeet().equals(dest) && blockIsThere) {
if (ctx.playerToes().equals(dest) && blockIsThere) {
return state.setStatus(MovementStatus.SUCCESS);
}
@ -272,7 +272,7 @@ public class MovementPillar extends Movement {
@Override
protected boolean prepared(MovementState state) {
if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.below())) {
if (ctx.playerToes().equals(src) || ctx.playerToes().equals(src.below())) {
Block block = BlockStateInterface.getBlock(ctx, src.below());
if (block == Blocks.LADDER || block == Blocks.VINE) {
state.setInput(Input.SNEAK, true);

View File

@ -242,7 +242,7 @@ public class MovementTraverse extends Movement {
}
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder || MovementHelper.canUseFrostWalker(ctx, positionToPlace);
BlockPos feet = ctx.playerFeet();
BlockPos feet = ctx.playerToes();
if (feet.getY() != dest.getY() && !ladder) {
logDebug("Wrong Y coordinate");
if (feet.getY() < dest.getY()) {
@ -368,7 +368,7 @@ public class MovementTraverse extends Movement {
@Override
protected boolean prepared(MovementState state) {
if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.below())) {
if (ctx.playerToes().equals(src) || ctx.playerToes().equals(src.below())) {
Block block = BlockStateInterface.getBlock(ctx, src.below());
if (block == Blocks.LADDER || block == Blocks.VINE) {
state.setInput(Input.SNEAK, true);

View File

@ -97,7 +97,7 @@ public class PathExecutor implements IPathExecutor, Helper {
return true; // stop bugging me, I'm done
}
Movement movement = (Movement) path.movements().get(pathPosition);
BetterBlockPos whereAmI = ctx.playerFeet();
BetterBlockPos whereAmI = ctx.playerToes();
if (!movement.getValidPositions().contains(whereAmI)) {
for (int i = 0; i < pathPosition && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
if (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) {
@ -275,11 +275,11 @@ public class PathExecutor implements IPathExecutor, Helper {
if (!ctx.player().onGround()) {
return false;
}
if (!MovementHelper.canWalkOn(ctx, ctx.playerFeet().below())) {
if (!MovementHelper.canWalkOn(ctx, ctx.playerToes().below())) {
// we're in some kind of sketchy situation, maybe parkouring
return false;
}
if (!MovementHelper.canWalkThrough(ctx, ctx.playerFeet()) || !MovementHelper.canWalkThrough(ctx, ctx.playerFeet().above())) {
if (!MovementHelper.canWalkThrough(ctx, ctx.playerToes()) || !MovementHelper.canWalkThrough(ctx, ctx.playerToes().above())) {
// suffocating?
return false;
}
@ -297,7 +297,7 @@ public class PathExecutor implements IPathExecutor, Helper {
// the first block of the next path will always overlap
// no need to pause our very last movement when it would have otherwise cleanly exited with MovementStatus SUCCESS
positions = positions.subList(1, positions.size());
return positions.contains(ctx.playerFeet());
return positions.contains(ctx.playerToes());
}
private boolean possiblyOffPath(Tuple<Double, BlockPos> status, double leniency) {
@ -321,7 +321,7 @@ public class PathExecutor implements IPathExecutor, Helper {
* @return Whether or not it was possible to snap to the current player feet
*/
public boolean snipsnapifpossible() {
if (!ctx.player().onGround() && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
if (!ctx.player().onGround() && ctx.world().getFluidState(ctx.playerToes()).isEmpty()) {
// if we're falling in the air, and not in water, don't splice
return false;
} else {
@ -332,7 +332,7 @@ public class PathExecutor implements IPathExecutor, Helper {
return false; // so don't
}
}
int index = path.positions().indexOf(ctx.playerFeet());
int index = path.positions().indexOf(ctx.playerToes());
if (index == -1) {
return false;
}
@ -423,7 +423,7 @@ public class PathExecutor implements IPathExecutor, Helper {
}
}
if (ctx.playerFeet().equals(current.getDest())) {
if (ctx.playerToes().equals(current.getDest())) {
pathPosition++;
onChangeInPathPosition();
onTick();
@ -457,7 +457,7 @@ public class PathExecutor implements IPathExecutor, Helper {
if (!path.positions().contains(fallDest)) {
throw new IllegalStateException();
}
if (ctx.playerFeet().equals(fallDest)) {
if (ctx.playerToes().equals(fallDest)) {
pathPosition = path.positions().indexOf(fallDest);
onChangeInPathPosition();
onTick();

View File

@ -104,7 +104,7 @@ public final class BackfillProcess extends BaritoneProcessHelper {
.filter(pos -> ctx.world().getBlockState(pos).getBlock() == Blocks.AIR)
.filter(pos -> baritone.getBuilderProcess().placementPlausible(pos, Blocks.DIRT.defaultBlockState()))
.filter(pos -> !partOfCurrentMovement(pos))
.sorted(Comparator.<BlockPos>comparingDouble(ctx.playerFeet()::distSqr).reversed())
.sorted(Comparator.<BlockPos>comparingDouble(ctx.playerToes()::distSqr).reversed())
.collect(Collectors.toList());
}

View File

@ -282,7 +282,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
private Optional<Tuple<BetterBlockPos, Rotation>> toBreakNearPlayer(BuilderCalculationContext bcc) {
BetterBlockPos center = ctx.playerFeet();
BetterBlockPos center = ctx.playerToes();
BetterBlockPos pathStart = baritone.getPathingBehavior().pathStart();
for (int dx = -5; dx <= 5; dx++) {
for (int dy = Baritone.settings().breakFromAbove.value ? -1 : 0; dy <= 5; dy++) {
@ -327,7 +327,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
private Optional<Placement> searchForPlacables(BuilderCalculationContext bcc, List<BlockState> desirableOnHotbar) {
BetterBlockPos center = ctx.playerFeet();
BetterBlockPos center = ctx.playerToes();
for (int dx = -5; dx <= 5; dx++) {
for (int dy = -5; dy <= 1; dy++) {
for (int dz = -5; dz <= 5; dz++) {
@ -643,7 +643,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
private void recalcNearby(BuilderCalculationContext bcc) {
BetterBlockPos center = ctx.playerFeet();
BetterBlockPos center = ctx.playerToes();
int radius = Baritone.settings().builderTickScanRadius.value;
for (int dx = -radius; dx <= radius; dx++) {
for (int dy = -radius; dy <= radius; dy++) {
@ -1006,7 +1006,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
.getBlock()
.getStateForPlacement(
new BlockPlaceContext(
new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {}
new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerToes(), false)) {}
)
);
if (itemState != null) {

View File

@ -102,7 +102,7 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC
onLostControl();
return new PathingCommand(this.goal, PathingCommandType.CANCEL_AND_SET_GOAL);
}
if (this.goal == null || (this.goal.isInGoal(ctx.playerFeet()) && this.goal.isInGoal(baritone.getPathingBehavior().pathStart()))) {
if (this.goal == null || (this.goal.isInGoal(ctx.playerToes()) && this.goal.isInGoal(baritone.getPathingBehavior().pathStart()))) {
onLostControl(); // we're there xd
if (Baritone.settings().disconnectOnArrival.value) {
ctx.world().disconnect();

View File

@ -141,7 +141,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
final BetterBlockPos last = this.behavior.pathManager.path.getLast();
if (last != null && (ctx.player().position().distanceToSqr(last.getCenter()) < (48 * 48) || safetyLanding) && (!goingToLandingSpot || (safetyLanding && this.landingSpot == null))) {
logDirect("Path complete, picking a nearby safe landing spot...");
BetterBlockPos landingSpot = findSafeLandingSpot(ctx.playerFeet());
BetterBlockPos landingSpot = findSafeLandingSpot(ctx.playerToes());
// if this fails we will just keep orbiting the last node until we run out of rockets or the user intervenes
if (landingSpot != null) {
this.pathTo0(landingSpot, true);

View File

@ -110,7 +110,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
@Override
public void farm(int range, BlockPos pos) {
if (pos == null) {
center = baritone.getPlayerContext().playerFeet();
center = baritone.getPlayerContext().playerToes();
} else {
center = pos;
}

View File

@ -56,7 +56,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG
public void getToBlock(BlockOptionalMeta block) {
onLostControl();
gettingTo = block;
start = ctx.playerFeet();
start = ctx.playerToes();
blacklist = new ArrayList<>();
arrivalTickCount = 0;
rescan(new ArrayList<>(), new GetToBlockCalculationContext(false));
@ -112,7 +112,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG
CalculationContext context = new GetToBlockCalculationContext(true);
Baritone.getExecutor().execute(() -> rescan(current, context));
}
if (goal.isInGoal(ctx.playerFeet()) && goal.isInGoal(baritone.getPathingBehavior().pathStart()) && isSafeToCancel) {
if (goal.isInGoal(ctx.playerToes()) && goal.isInGoal(baritone.getPathingBehavior().pathStart()) && isSafeToCancel) {
// we're there
if (rightClickOnArrival(gettingTo.getBlock())) {
if (rightClick()) {
@ -130,7 +130,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG
// blacklist the closest block and its adjacent blocks
public synchronized boolean blacklistClosest() {
List<BlockPos> newBlacklist = new ArrayList<>();
knownLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distSqr)).ifPresent(newBlacklist::add);
knownLocations.stream().min(Comparator.comparingDouble(ctx.playerToes()::distSqr)).ifPresent(newBlacklist::add);
outer:
while (true) {
for (BlockPos known : knownLocations) {

View File

@ -90,7 +90,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
if (Baritone.settings().notificationOnMineFail.value) {
logNotification("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance...", true);
}
knownOreLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distSqr)).ifPresent(blacklist::add);
knownOreLocations.stream().min(Comparator.comparingDouble(ctx.playerToes()::distSqr)).ifPresent(blacklist::add);
knownOreLocations.removeIf(blacklist::contains);
} else {
logDirect("Unable to find any path to " + filter + ", canceling mine");
@ -116,10 +116,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
}
}
Optional<BlockPos> shaft = curr.stream()
.filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ())
.filter(pos -> pos.getY() >= ctx.playerFeet().getY())
.filter(pos -> pos.getX() == ctx.playerToes().getX() && pos.getZ() == ctx.playerToes().getZ())
.filter(pos -> pos.getY() >= ctx.playerToes().getY())
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
.min(Comparator.comparingDouble(ctx.playerFeet()::distSqr));
.min(Comparator.comparingDouble(ctx.playerToes()::distSqr));
baritone.getInputOverrideHandler().clearAllKeys();
if (shaft.isPresent() && ctx.player().onGround()) {
BlockPos pos = shaft.get();
@ -204,7 +204,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
} else {
return new GoalYLevel(y);
}*/
branchPoint = ctx.playerFeet();
branchPoint = ctx.playerToes();
}
// TODO shaft mode, mine 1x1 shafts to either side
// TODO also, see if the GoalRunAway with maintain Y at 11 works even from the surface
@ -363,7 +363,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
for (BlockOptionalMeta bom : filter.blocks()) {
Block block = bom.getBlock();
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
BetterBlockPos pf = ctx.baritone.getPlayerContext().playerFeet();
BetterBlockPos pf = ctx.baritone.getPlayerContext().playerToes();
// maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that
locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(
@ -398,7 +398,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
private boolean addNearby() {
List<BlockPos> dropped = droppedItemsScan();
knownOreLocations.addAll(dropped);
BlockPos playerFeet = ctx.playerFeet();
BlockPos playerFeet = ctx.playerToes();
BlockStateInterface bsi = new BlockStateInterface(ctx);

View File

@ -167,7 +167,7 @@ public final class ElytraBehavior implements Helper {
}
public CompletableFuture<Void> pathToDestination() {
return this.pathToDestination(ctx.playerFeet());
return this.pathToDestination(ctx.playerToes());
}
public CompletableFuture<Void> pathToDestination(final BlockPos from) {
@ -203,7 +203,7 @@ public final class ElytraBehavior implements Helper {
final List<BetterBlockPos> after = upToIncl.isPresent() ? this.path.subList(upToIncl.getAsInt() + 1, this.path.size()) : Collections.emptyList();
final boolean complete = this.completePath;
return this.path0(ctx.playerFeet(), upToIncl.isPresent() ? this.path.get(upToIncl.getAsInt()) : ElytraBehavior.this.destination, segment -> segment.append(after.stream(), complete || (segment.isFinished() && !upToIncl.isPresent())))
return this.path0(ctx.playerToes(), upToIncl.isPresent() ? this.path.get(upToIncl.getAsInt()) : ElytraBehavior.this.destination, segment -> segment.append(after.stream(), complete || (segment.isFinished() && !upToIncl.isPresent())))
.whenComplete((result, ex) -> {
this.recalculating = false;
if (ex != null) {
@ -338,14 +338,14 @@ public final class ElytraBehavior implements Helper {
// obstacle. where do we return to pathing?
// if the end of render distance is closer to goal, then that's fine, otherwise we'd be "digging our hole deeper" and making an already bad backtrack worse
OptionalInt rejoinMainPathAt;
if (this.path.get(rangeEndExcl - 1).distanceSq(ElytraBehavior.this.destination) < ctx.playerFeet().distanceSq(ElytraBehavior.this.destination)) {
if (this.path.get(rangeEndExcl - 1).distanceSq(ElytraBehavior.this.destination) < ctx.playerToes().distanceSq(ElytraBehavior.this.destination)) {
rejoinMainPathAt = OptionalInt.of(rangeEndExcl - 1); // rejoin after current render distance
} else {
rejoinMainPathAt = OptionalInt.empty(); // large backtrack detected. ignore render distance, rejoin later on
}
final BetterBlockPos blockage = this.path.get(i);
final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt.orElse(path.size() - 1)));
final double distance = ctx.playerToes().distanceTo(this.path.get(rejoinMainPathAt.orElse(path.size() - 1)));
final long start = System.nanoTime();
this.pathRecalcSegment(rejoinMainPathAt)
@ -383,7 +383,7 @@ public final class ElytraBehavior implements Helper {
}
int index = this.playerNear;
final BetterBlockPos pos = ctx.playerFeet();
final BetterBlockPos pos = ctx.playerToes();
for (int i = index; i >= Math.max(index - 1000, 0); i -= 10) {
if (path.get(i).distanceSq(pos) < path.get(index).distanceSq(pos)) {
index = i; // intentional: this changes the bound of the loop
@ -488,7 +488,7 @@ public final class ElytraBehavior implements Helper {
public void repackChunks() {
ChunkSource chunkProvider = ctx.world().getChunkSource();
BetterBlockPos playerPos = ctx.playerFeet();
BetterBlockPos playerPos = ctx.playerToes();
int playerChunkX = playerPos.getX() >> 4;
int playerChunkZ = playerPos.getZ() >> 4;

View File

@ -67,7 +67,7 @@ public class Avoidance {
double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value;
double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value;
if (mobSpawnerCoeff != 1.0D) {
ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2)
ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerToes().x, ctx.playerToes().z, 2)
.forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value)));
}
if (mobCoeff != 1.0D) {

View File

@ -72,7 +72,7 @@ public final class BaritonePlayerContext implements IPlayerContext {
@Override
public BetterBlockPos viewerPos() {
final Entity entity = this.mc.getCameraEntity();
return entity == null ? this.playerFeet() : BetterBlockPos.from(entity.blockPosition());
return entity == null ? this.playerToes() : BetterBlockPos.from(entity.blockPosition());
}
@Override