Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename playerFeet to playerToes #4261

Open
wants to merge 1 commit into
base: 1.20.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/java/baritone/api/utils/IPlayerContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ default Stream<Entity> entitiesStream() {

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);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/behavior/InventoryBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public boolean hasGenericThrowaway() {

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()))) {
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/baritone/behavior/PathingBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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;
Expand Down Expand Up @@ -139,8 +138,8 @@ private void tickPath() {
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
Expand All @@ -153,7 +152,7 @@ private void tickPath() {
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;
Expand All @@ -162,7 +161,7 @@ private void tickPath() {
}
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
Expand Down Expand Up @@ -265,7 +264,7 @@ public boolean secretInternalSetGoalAndPath(PathingCommand command) {
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) {
Expand Down Expand Up @@ -382,11 +381,11 @@ public CalculationContext secretInternalGetCalculationContext() {
}

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);
}
Expand Down Expand Up @@ -421,7 +420,7 @@ private void resetEstimatedTicksToGoal(BetterBlockPos start) {
* @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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/behavior/WaypointBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void onBlockInteract(BlockInteractEvent event) {
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()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/cache/CachedWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private BlockPos guessPosition() {
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;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/baritone/cache/FasterWorldScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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;
Expand Down Expand Up @@ -56,7 +55,7 @@ public List<BlockPos> scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLooku
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
Expand All @@ -78,7 +77,7 @@ public int repack(IPlayerContext ctx, int range) {
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;
Expand Down Expand Up @@ -156,7 +155,7 @@ private Stream<BlockPos> scanChunkInternal(IPlayerContext ctx, BlockOptionalMeta
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();
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/baritone/cache/WorldScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public List<BlockPos> scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLooku
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();
Expand Down Expand Up @@ -97,7 +97,7 @@ public List<BlockPos> scanChunk(IPlayerContext ctx, BlockOptionalMetaLookup filt

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();
Expand All @@ -118,7 +118,7 @@ public int repack(IPlayerContext ctx, int range) {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/command/defaults/BuildCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void execute(String label, IArgConsumer args) throws CommandException {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/baritone/command/defaults/ExploreCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public void execute(String label, IArgConsumer args) throws CommandException {
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()));
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/baritone/command/defaults/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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;
Expand Down Expand Up @@ -54,7 +53,7 @@ public void execute(String label, IArgConsumer args) throws CommandException {
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(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/command/defaults/GoalCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void execute(String label, IArgConsumer args) throws CommandException {
}
} 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()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/command/defaults/GotoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void execute(String label, IArgConsumer args) throws CommandException {
// 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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/command/defaults/RenderCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public RenderCommand(IBaritone baritone) {
@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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected SurfaceCommand(IBaritone baritone) {

@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();

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/baritone/command/defaults/TunnelCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ public void execute(String label, IArgConsumer args) throws CommandException {
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);
Expand All @@ -81,7 +81,7 @@ public void execute(String label, IArgConsumer args) throws CommandException {
}
} else {
Goal goal = new GoalStrictDirection(
ctx.playerFeet(),
ctx.playerToes(),
ctx.player().getDirection()
);
baritone.getCustomGoalProcess().setGoalAndPath(goal);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/baritone/command/defaults/WaypointsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
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;

Expand Down Expand Up @@ -138,8 +137,8 @@ public void execute(String label, IArgConsumer args) throws CommandException {
}
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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/baritone/pathing/movement/Movement.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Set<BetterBlockPos> getValidPositions() {
}

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());
}

/**
Expand All @@ -123,7 +123,7 @@ protected boolean playerInValidPosition() {
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()) {
Expand Down
Loading
Loading