splice better, fixes #215

This commit is contained in:
Leijurv 2018-10-09 16:40:04 -07:00
parent 9e15960581
commit 22d2036657
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 18 additions and 4 deletions

View File

@ -23,15 +23,15 @@ import baritone.api.event.events.PathEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RenderEvent;
import baritone.api.event.events.TickEvent;
import baritone.api.pathing.calc.IPath;
import baritone.api.pathing.calc.IPathFinder;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalXZ;
import baritone.pathing.calc.CutoffPath;
import baritone.api.pathing.calc.IPath;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.interfaces.IGoalRenderPos;
import baritone.pathing.calc.AStarPathFinder;
import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.api.pathing.calc.IPathFinder;
import baritone.pathing.calc.CutoffPath;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.path.PathExecutor;
import baritone.utils.BlockBreakHelper;
@ -123,12 +123,13 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
if (safe) {
// a movement just ended
if (next != null) {
if (next.getPath().positions().contains(playerFeet())) {
if (next.snipsnapifpossible()) {
// jump directly onto the next path
logDebug("Splicing into planned next path early...");
dispatchPathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY);
current = next;
next = null;
current.onTick(event);
return;
}
}

View File

@ -339,6 +339,19 @@ public class PathExecutor implements IPathExecutor, Helper {
}
}
/**
* Regardless of current path position, snap to the current player feet if possible
*/
public boolean snipsnapifpossible() {
int index = path.positions().indexOf(playerFeet());
if (index == -1) {
return false;
}
pathPosition = index;
clearKeys();
return true;
}
private void sprintIfRequested() {
// first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint