From a21ec54d4f203eb7880a229e5d2503c7572638fc Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 13 Feb 2019 14:05:14 -0800 Subject: [PATCH] stop breaking block when you let go of left click lol --- .../java/baritone/launch/mixins/MixinKeyBinding.java | 2 +- src/main/java/baritone/behavior/PathingBehavior.java | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 6814b6d6..d61537c9 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -62,7 +62,7 @@ public class MixinKeyBinding { private void isPressed(CallbackInfoReturnable cir) { // only the primary baritone forces keys Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this); - if (pressTime > 0 && (KeyBinding) (Object) this == Minecraft.getMinecraft().gameSettings.keyBindAttack && Baritone.settings().clickCancel.get()) { + if (pressTime > 0 && (KeyBinding) (Object) this == Minecraft.getMinecraft().gameSettings.keyBindAttack && Baritone.settings().clickCancel.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing()) { Helper.HELPER.logDirect("Cancelling path on left click since the clickCancel setting is enabled!"); BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); return; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index d441c416..bf96fd03 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -301,12 +301,14 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, public void secretInternalSegmentCancel() { queuePathEvent(PathEvent.CANCELED); synchronized (pathPlanLock) { - current = null; - next = null; + if (current != null) { + current = null; + next = null; + baritone.getInputOverrideHandler().clearAllKeys(); + getInProgress().ifPresent(AbstractNodeCostSearch::cancel); + baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock(); + } } - baritone.getInputOverrideHandler().clearAllKeys(); - getInProgress().ifPresent(AbstractNodeCostSearch::cancel); - baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock(); } public void forceCancel() { // NOT exposed on public api