we can cancel calc even if not safe to cancel pathing

This commit is contained in:
Leijurv 2019-03-17 22:40:11 -08:00
parent cfec67f1f9
commit bcd097c6cb
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -325,6 +325,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
public void softCancelIfSafe() { public void softCancelIfSafe() {
synchronized (pathPlanLock) { synchronized (pathPlanLock) {
getInProgress().ifPresent(AbstractNodeCostSearch::cancel); // only cancel ours
if (!isSafeToCancel()) { if (!isSafeToCancel()) {
return; return;
} }
@ -332,7 +333,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
next = null; next = null;
} }
cancelRequested = true; cancelRequested = true;
getInProgress().ifPresent(AbstractNodeCostSearch::cancel); // only cancel ours
// do everything BUT clear keys // do everything BUT clear keys
} }
@ -340,11 +340,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
public void secretInternalSegmentCancel() { public void secretInternalSegmentCancel() {
queuePathEvent(PathEvent.CANCELED); queuePathEvent(PathEvent.CANCELED);
synchronized (pathPlanLock) { synchronized (pathPlanLock) {
getInProgress().ifPresent(AbstractNodeCostSearch::cancel);
if (current != null) { if (current != null) {
current = null; current = null;
next = null; next = null;
baritone.getInputOverrideHandler().clearAllKeys(); baritone.getInputOverrideHandler().clearAllKeys();
getInProgress().ifPresent(AbstractNodeCostSearch::cancel);
baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock(); baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock();
} }
} }