From 6a402b4a2bd6867e2fdff0348bc4b63300f7095d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 29 Nov 2018 20:36:19 -0800 Subject: [PATCH] fix the fire thing in a slightly different way --- src/api/java/baritone/api/utils/Rotation.java | 11 +++++++++++ src/main/java/baritone/pathing/movement/Movement.java | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/utils/Rotation.java b/src/api/java/baritone/api/utils/Rotation.java index ea10c7ec..28afbf65 100644 --- a/src/api/java/baritone/api/utils/Rotation.java +++ b/src/api/java/baritone/api/utils/Rotation.java @@ -110,6 +110,17 @@ public class Rotation { ); } + /** + * Is really close to + * + * @param other another rotation + * @return are they really close + */ + public boolean isReallyCloseTo(Rotation other) { + float yawDiff = Math.abs(this.yaw - other.yaw); // you cant fool me + return (yawDiff < 0.01 || yawDiff > 359.9) && Math.abs(this.pitch - other.pitch) < 0.01; + } + /** * Clamps the specified pitch value between -90 and 90. * diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index f0f20648..4105b5e7 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -151,9 +151,10 @@ public abstract class Movement implements IMovement, MovementHelper { somethingInTheWay = true; Optional reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance()); if (reachable.isPresent()) { + Rotation rotTowardsBlock = reachable.get(); MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos)); - state.setTarget(new MovementState.MovementTarget(reachable.get(), true)); - if (Objects.equals(ctx.getSelectedBlock().orElse(null), blockPos)) { + state.setTarget(new MovementState.MovementTarget(rotTowardsBlock, true)); + if (Objects.equals(ctx.getSelectedBlock().orElse(null), blockPos) || ctx.playerRotations().isReallyCloseTo(rotTowardsBlock)) { state.setInput(Input.CLICK_LEFT, true); } return false;