diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ecadb571..85d823ea 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -378,6 +378,11 @@ public final class Settings { */ public final Setting pruneRegionsFromRAM = new Setting<>(false); + /** + * Cancel baritone on left click, as a form of "panic button" + */ + public final Setting clickCancel = new Setting<>(false); + /** * Remember the contents of containers (chests, echests, furnaces) *

diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 9ef080bf..4db240e3 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -20,6 +20,7 @@ package baritone.launch.mixins; import baritone.Baritone; import baritone.api.BaritoneAPI; import baritone.utils.Helper; +import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -61,6 +62,9 @@ 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()) { + BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); + } if (force != null && !force && Baritone.settings().suppressClicks.get()) { // <-- cursed if (pressTime > 0) { Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you.");