properly discard orphan path segments
This commit is contained in:
parent
c0761c0eef
commit
6faa7344aa
@ -61,6 +61,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
|
|
||||||
private boolean lastAutoJump;
|
private boolean lastAutoJump;
|
||||||
|
|
||||||
|
private BlockPos expectedSegmentStart;
|
||||||
|
|
||||||
private final LinkedBlockingQueue<PathEvent> toDispatch = new LinkedBlockingQueue<>();
|
private final LinkedBlockingQueue<PathEvent> toDispatch = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
public PathingBehavior(Baritone baritone) {
|
public PathingBehavior(Baritone baritone) {
|
||||||
@ -88,6 +90,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
baritone.getPathingControlManager().cancelEverything();
|
baritone.getPathingControlManager().cancelEverything();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
expectedSegmentStart = pathStart();
|
||||||
baritone.getPathingControlManager().preTick();
|
baritone.getPathingControlManager().preTick();
|
||||||
tickPath();
|
tickPath();
|
||||||
dispatchEvents();
|
dispatchEvents();
|
||||||
@ -438,8 +441,12 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
Optional<PathExecutor> executor = calcResult.getPath().map(p -> new PathExecutor(PathingBehavior.this, p));
|
Optional<PathExecutor> executor = calcResult.getPath().map(p -> new PathExecutor(PathingBehavior.this, p));
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
if (executor.isPresent()) {
|
if (executor.isPresent()) {
|
||||||
|
if (executor.get().getPath().getSrc().equals(expectedSegmentStart)) {
|
||||||
queuePathEvent(PathEvent.CALC_FINISHED_NOW_EXECUTING);
|
queuePathEvent(PathEvent.CALC_FINISHED_NOW_EXECUTING);
|
||||||
current = executor.get();
|
current = executor.get();
|
||||||
|
} else {
|
||||||
|
logDebug("Warning: discarding orphan path segment with incorrect start");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (calcResult.getType() != PathCalculationResult.Type.CANCELLATION && calcResult.getType() != PathCalculationResult.Type.EXCEPTION) {
|
if (calcResult.getType() != PathCalculationResult.Type.CANCELLATION && calcResult.getType() != PathCalculationResult.Type.EXCEPTION) {
|
||||||
// don't dispatch CALC_FAILED on cancellation
|
// don't dispatch CALC_FAILED on cancellation
|
||||||
|
Loading…
Reference in New Issue
Block a user