Fix issue with InputOverrideHandler that could cause while loop holdups
This commit is contained in:
@@ -2,11 +2,9 @@ package baritone.launch.mixins;
|
||||
|
||||
import baritone.bot.Baritone;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.IntHashMap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
@@ -16,33 +14,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(KeyBinding.class)
|
||||
public abstract class MixinKeyBinding {
|
||||
|
||||
@Redirect(
|
||||
method = "onTick",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/util/IntHashMap.lookup(I)Ljava/lang/Object;"
|
||||
)
|
||||
)
|
||||
private static Object lookup(IntHashMap<KeyBinding> HASH, int keyCode) {
|
||||
KeyBinding keyBinding = HASH.lookup(keyCode);
|
||||
|
||||
// If we're overriding the key state, we don't want to be incrementing the pressTime
|
||||
if (keyBinding != null && Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown(keyBinding))
|
||||
return null;
|
||||
|
||||
return keyBinding;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "isPressed",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void isPressed(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this))
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "isKeyDown",
|
||||
at = @At("HEAD"),
|
||||
|
||||
@@ -57,6 +57,14 @@ public class MixinMinecraft {
|
||||
return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "processKeyBinds",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void runTickKeyboard(CallbackInfo ci) {
|
||||
Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds();
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = {
|
||||
"setIngameFocus",
|
||||
|
||||
Reference in New Issue
Block a user