add proper setting for suppressing clicks

This commit is contained in:
Leijurv 2019-02-05 09:37:42 -08:00
parent fa75880626
commit a989547976
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 15 additions and 4 deletions

View File

@ -478,6 +478,11 @@ public final class Settings {
*/ */
public Setting<Float> cachedChunksOpacity = new Setting<>(0.5f); public Setting<Float> cachedChunksOpacity = new Setting<>(0.5f);
/**
* If true, Baritone will not allow you to left or right click while pathing
*/
public Setting<Boolean> suppressClicks = new Setting<>(false);
/** /**
* Whether or not to use the "#" command prefix * Whether or not to use the "#" command prefix
*/ */

View File

@ -17,7 +17,9 @@
package baritone.launch.mixins; package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.utils.Helper;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@ -44,11 +46,14 @@ public class MixinKeyBinding {
// only the primary baritone forces keys // only the primary baritone forces keys
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this); Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this);
if (force != null) { if (force != null) {
if (!force && !Baritone.settings().suppressClicks.get()) {
return;
}
cir.setReturnValue(force); // :sunglasses: cir.setReturnValue(force); // :sunglasses:
} }
} }
/*@Inject( @Inject(
method = "isPressed", method = "isPressed",
at = @At("HEAD"), at = @At("HEAD"),
cancellable = true cancellable = true
@ -56,12 +61,13 @@ public class MixinKeyBinding {
private void isPressed(CallbackInfoReturnable<Boolean> cir) { private void isPressed(CallbackInfoReturnable<Boolean> cir) {
// only the primary baritone forces keys // only the primary baritone forces keys
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this); 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) { 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--; pressTime--;
} }
cir.setReturnValue(force); // :sunglasses: cir.setReturnValue(force); // :sunglasses:
} }
}*/ }
} }