instant cancel when more than 3 blocks away

This commit is contained in:
Leijurv 2018-08-31 15:21:59 -07:00
parent c08f0f1e4d
commit 24c5c5d238
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -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