Skip to content

Commit

Permalink
fall bugs
Browse files Browse the repository at this point in the history
(cherry picked from commit 53c6cd0)
  • Loading branch information
Niroxbtw authored and onixiya1337 committed Dec 11, 2023
1 parent 64661d9 commit 581af1d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class Settings {

public final Setting<Float> yawSmoothingFactor = new Setting<>(0.2f);

public final Setting<Float> pitchSmoothingFactor = new Setting<>(0.22f);
public final Setting<Float> pitchSmoothingFactor = new Setting<>(0.2f);

public final Setting<Boolean> safeMode = new Setting<>(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ public MovementState updateState(MovementState state) {

BlockPos playerFeet = ctx.playerFeet();

Rotation target = RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
VecUtils.getBlockPosCenter(dest),
ctx.playerRotations()).withPitch(ctx.playerRotations().getPitch());

state.setTarget(new MovementState.MovementTarget(
RotationUtils.calcRotationFromVec3d(ctx.playerHead(),
VecUtils.getBlockPosCenter(dest),
ctx.playerRotations()),
false));
target, false));

IBlockState destState = ctx.world().getBlockState(dest);
Block destBlock = destState.getBlock();
Expand All @@ -88,7 +89,7 @@ public MovementState updateState(MovementState state) {
state.setInput(Input.SNEAK, true);
}

MovementHelper.setInputs(ctx, state, destCenter);
MovementHelper.setInputsAccurate(ctx, state, destCenter);
//TODO: Move towards (only keys) dest
}
Vec3i avoid = Optional.ofNullable(avoid()).map(EnumFacing::getDirectionVec).orElse(null);
Expand All @@ -97,7 +98,7 @@ public MovementState updateState(MovementState state) {
} else {
double dist = Math.abs(avoid.getX() * (destCenter.xCoord - avoid.getX() / 2.0 - ctx.playerFeetAsVec().xCoord)) + Math.abs(avoid.getZ() * (destCenter.zCoord - avoid.getZ() / 2.0 - ctx.playerFeetAsVec().zCoord));
if (dist < 0.6) {
MovementHelper.setInputs(ctx, state, destCenter);
MovementHelper.setInputsAccurate(ctx, state, destCenter);
//TODO: move towards (only keys) dest
} else if (!ctx.player().onGround) {
state.setInput(Input.SNEAK, false);
Expand All @@ -106,7 +107,7 @@ public MovementState updateState(MovementState state) {

Vec3 destCenterOffset = new Vec3(destCenter.xCoord + 0.125 * avoid.getX(), destCenter.yCoord - 0.5, destCenter.zCoord + 0.125 * avoid.getZ());
MovementHelper.rotate(ctx, state, src, destCenterOffset);
MovementHelper.setInputs(ctx, state, destCenterOffset);
MovementHelper.setInputsAccurate(ctx, state, destCenterOffset);
//TODO: move towards destCenterOffset

return state;
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/baritone/pathing/path/PathExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.Movement;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.movement.MovementState;
import baritone.pathing.movement.movements.*;
import net.minecraft.potion.Potion;
import net.minecraft.util.BlockPos;
Expand All @@ -22,6 +23,7 @@
import net.minecraft.util.Vec3i;

import java.util.List;
import java.util.Map;
import java.util.Optional;

import static baritone.api.pathing.movement.MovementStatus.*;
Expand Down Expand Up @@ -436,8 +438,12 @@ private boolean shouldSprintNextTick() {
return true;
}
clearKeys();
behavior.baritone.getLookBehavior().updateTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), data.getFirst(), ctx.playerRotations()), false);
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.MOVE_FORWARD, true);
behavior.baritone.getLookBehavior().updateTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), data.getFirst(), ctx.playerRotations()).withPitch(ctx.playerRotations().getPitch()), false);
MovementState state = new MovementState();
MovementHelper.setInputsAccurate(ctx, state, data.getFirst());
for (Map.Entry<Input, Boolean> inputState : state.getInputStates().entrySet()) {
behavior.baritone.getInputOverrideHandler().setInputForceState(inputState.getKey(), inputState.getValue());
}
return true;
}
}
Expand Down

0 comments on commit 581af1d

Please sign in to comment.