From 24c5c5d2381508a1aeeb5dbf1ea635c128b56cb1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 31 Aug 2018 15:21:59 -0700 Subject: [PATCH] instant cancel when more than 3 blocks away --- .../java/baritone/pathing/path/PathExecutor.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 76fcc3c1..4adda1f2 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -25,6 +25,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.movements.MovementDescend; import baritone.pathing.movement.movements.MovementDiagonal; +import baritone.pathing.movement.movements.MovementFall; import baritone.pathing.movement.movements.MovementTraverse; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; @@ -46,6 +47,7 @@ import static baritone.pathing.movement.MovementState.MovementStatus.*; * @author leijurv */ public class PathExecutor implements Helper { + private static final double MAX_MAX_DIST_FROM_PATH = 3; private static final double MAX_DIST_FROM_PATH = 2; private static final double MAX_TICKS_AWAY = 200; // ten seconds. ok to decrease this, but it must be at least 110, see issue #102 private final IPath path; @@ -132,6 +134,17 @@ public class PathExecutor implements Helper { } else { ticksAway = 0; } + if (distanceFromPath > MAX_MAX_DIST_FROM_PATH) { + if (!(path.movements().get(pathPosition) instanceof MovementFall)) { // might be midair + if (pathPosition > 0 || !(path.movements().get(pathPosition - 1) instanceof MovementFall)) { // might have overshot the landing + displayChatMessageRaw("too far from path"); + pathPosition = path.length() + 3; + Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + failed = true; + return false; + } + } + } //this commented block is literally cursed. /*Out.log(actions.get(pathPosition)); if (pathPosition < actions.size() - 1) {//if there are two ActionBridges in a row and they are at right angles, walk diagonally. This makes it so you walk at 45 degrees along a zigzag path instead of doing inefficient zigging and zagging