Skip to content

Commit

Permalink
Merge remote-tracking branch 'GTNH/fix_keybind_journeymap' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Sep 14, 2022
2 parents 9b62f1e + ccb2e1b commit 4dcae45
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import journeymap.client.Constants;
import net.minecraft.client.settings.KeyBinding;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Constants.class)
public class MixinConstants {
Expand All @@ -12,8 +14,11 @@ public class MixinConstants {
* @author Alexdoru
* @reason Prevent unbinded keybinds from triggering when pressing certain keys
*/
@Overwrite(remap = false)
public static boolean isPressed(KeyBinding keyBinding) {
return keyBinding.isPressed();
@Inject(method = "isPressed", at = @At("HEAD"), remap = false, cancellable = true)
private static void isPressed(KeyBinding keyBinding, CallbackInfoReturnable<Boolean> cir) {
if (keyBinding.getKeyCode() == 0) {
cir.setReturnValue(false);
cir.cancel();
}
}
}

0 comments on commit 4dcae45

Please sign in to comment.