From 5cdacb49394ab3af8655a95a2783f211af8cc919 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 6 Aug 2018 21:07:15 -0700 Subject: [PATCH] continuous pathfinding and clearing --- src/main/java/baritone/bot/InputOverrideHandler.java | 5 +++++ .../baritone/bot/behavior/impl/PathingBehavior.java | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/baritone/bot/InputOverrideHandler.java b/src/main/java/baritone/bot/InputOverrideHandler.java index 4dde5ec6..6b07e501 100755 --- a/src/main/java/baritone/bot/InputOverrideHandler.java +++ b/src/main/java/baritone/bot/InputOverrideHandler.java @@ -29,6 +29,11 @@ public final class InputOverrideHandler implements Helper { */ private final Map keyCodeForceStateMap = new HashMap<>(); + public final void clearAllKeys() { + inputForceStateMap.clear(); + keyCodeForceStateMap.clear(); + } + /** * Returns whether or not we are forcing down the specified {@link KeyBinding}. * diff --git a/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java b/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java index 9be45c95..90407f5a 100644 --- a/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java +++ b/src/main/java/baritone/bot/behavior/impl/PathingBehavior.java @@ -1,5 +1,6 @@ package baritone.bot.behavior.impl; +import baritone.bot.Baritone; import baritone.bot.behavior.Behavior; import baritone.bot.event.events.ChatEvent; import baritone.bot.event.events.RenderEvent; @@ -49,6 +50,8 @@ public class PathingBehavior extends Behavior { current.onTick(event); if (current.failed() || current.finished()) { current = null; + if (!goal.isInGoal(playerFeet())) + findPathInNewThread(playerFeet(), true); } } @@ -79,6 +82,13 @@ public class PathingBehavior extends Behavior { event.cancel(); return; } + if (msg.toLowerCase().equals("cancel")) { + current = null; + Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); + event.cancel(); + displayChatMessageRaw("ok canceled"); + return; + } }