From a9895479761eece7334b376016e558bf665cb2f0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 09:37:42 -0800 Subject: [PATCH] add proper setting for suppressing clicks --- src/api/java/baritone/api/Settings.java | 5 +++++ .../baritone/launch/mixins/MixinKeyBinding.java | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 508af1cc..152c12b2 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -478,6 +478,11 @@ public final class Settings { */ public Setting cachedChunksOpacity = new Setting<>(0.5f); + /** + * If true, Baritone will not allow you to left or right click while pathing + */ + public Setting suppressClicks = new Setting<>(false); + /** * Whether or not to use the "#" command prefix */ diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 94e8bfd0..9ef080bf 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -17,7 +17,9 @@ package baritone.launch.mixins; +import baritone.Baritone; import baritone.api.BaritoneAPI; +import baritone.utils.Helper; import net.minecraft.client.settings.KeyBinding; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -44,11 +46,14 @@ public class MixinKeyBinding { // only the primary baritone forces keys Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this); if (force != null) { + if (!force && !Baritone.settings().suppressClicks.get()) { + return; + } cir.setReturnValue(force); // :sunglasses: } } - /*@Inject( + @Inject( method = "isPressed", at = @At("HEAD"), cancellable = true @@ -56,12 +61,13 @@ 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 (force != null && !force) { // <-- cursed + 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"); + Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you."); + Helper.HELPER.logDirect("Turn off the suppressClicks setting to allow clicking while pathing."); pressTime--; } cir.setReturnValue(force); // :sunglasses: } - }*/ + } }