Skip to content

Commit

Permalink
add proper setting for suppressing clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
leijurv committed Feb 5, 2019
1 parent fa75880 commit a989547
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ public final class Settings {
*/
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
*/
Expand Down
14 changes: 10 additions & 4 deletions src/launch/java/baritone/launch/mixins/MixinKeyBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,24 +46,28 @@ private void isKeyDown(CallbackInfoReturnable<Boolean> cir) {
// 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
)
private void isPressed(CallbackInfoReturnable<Boolean> 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:
}
}*/
}
}

0 comments on commit a989547

Please sign in to comment.