Skip to content

Commit

Permalink
Cleanup and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Minenash committed Apr 5, 2024
1 parent c334d99 commit 779e961
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 122 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.15.7

# Mod Properties
mod_version = 1.4.1+1.20.2
mod_version = 1.5.0+1.20.2
maven_group = com.minenash
archives_base_name = rebind-all-the-keys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class RebindAllTheKeys implements ClientModInitializer {
public static final KeyBinding SCREEN_SECONDARY = mousebind("screen_secondary", 1, KeyBinding.INVENTORY_CATEGORY);

public static final KeyBinding FLY = keybind("fly", GLFW.GLFW_KEY_UNKNOWN, KeyBinding.MOVEMENT_CATEGORY);
public static final KeyBinding DISMOUNT = keybind("dismount", GLFW.GLFW_KEY_LEFT_SHIFT, KeyBinding.MISC_CATEGORY); //TODO: FIX
public static final KeyBinding DISMOUNT = keybind("dismount", GLFW.GLFW_KEY_LEFT_SHIFT, KeyBinding.MISC_CATEGORY);



Expand Down Expand Up @@ -144,24 +144,24 @@ public void onInitializeClient() {

public static void updateDebugKeybinds() {
DEBUG_REBINDS.clear();
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(RELOAD_CHUNKS).getCode(), GLFW.GLFW_KEY_A);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SHOW_HITBOXES).getCode(), GLFW.GLFW_KEY_B);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(COPY_LOCATION).getCode(), GLFW.GLFW_KEY_C);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CLEAR_CHAT).getCode(), GLFW.GLFW_KEY_D);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CYCLE_RENDER_DISTANCE).getCode(), GLFW.GLFW_KEY_F);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SHOW_CHUNK_BOUNDARIES).getCode(), GLFW.GLFW_KEY_G);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(ADVANCE_TOOLTIPS).getCode(), GLFW.GLFW_KEY_H);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(COPY_DATA_TO_CLIPBOARD).getCode(), GLFW.GLFW_KEY_I);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(START_STOP_PROFILING).getCode(), GLFW.GLFW_KEY_L);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SWAP_GAMEMODE).getCode(), GLFW.GLFW_KEY_N);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(PAUSE_ON_LOST_FOCUS).getCode(), GLFW.GLFW_KEY_P);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SHOW_DEBUG_BINDINGS).getCode(), GLFW.GLFW_KEY_Q);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(RELOAD_RESOURCES).getCode(), GLFW.GLFW_KEY_T);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(GAMEMODE_SWITCHER).getCode(), GLFW.GLFW_KEY_F4);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(DYNAMIC_TEXTURE_DUMP).getCode(), GLFW.GLFW_KEY_S);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CHART_PIE).getCode(), GLFW.GLFW_KEY_1);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CHART_FPS_TPS).getCode(), GLFW.GLFW_KEY_2);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CHART_BANDWIDTH_PING).getCode(), GLFW.GLFW_KEY_3);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(RELOAD_CHUNKS ).getCode(), GLFW.GLFW_KEY_A);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SHOW_HITBOXES ).getCode(), GLFW.GLFW_KEY_B);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(COPY_LOCATION ).getCode(), GLFW.GLFW_KEY_C);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CLEAR_CHAT ).getCode(), GLFW.GLFW_KEY_D);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CYCLE_RENDER_DISTANCE ).getCode(), GLFW.GLFW_KEY_F);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SHOW_CHUNK_BOUNDARIES ).getCode(), GLFW.GLFW_KEY_G);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(ADVANCE_TOOLTIPS ).getCode(), GLFW.GLFW_KEY_H);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(COPY_DATA_TO_CLIPBOARD ).getCode(), GLFW.GLFW_KEY_I);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(START_STOP_PROFILING ).getCode(), GLFW.GLFW_KEY_L);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SWAP_GAMEMODE ).getCode(), GLFW.GLFW_KEY_N);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(PAUSE_ON_LOST_FOCUS ).getCode(), GLFW.GLFW_KEY_P);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(SHOW_DEBUG_BINDINGS ).getCode(), GLFW.GLFW_KEY_Q);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(RELOAD_RESOURCES ).getCode(), GLFW.GLFW_KEY_T);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(GAMEMODE_SWITCHER ).getCode(), GLFW.GLFW_KEY_F4);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(DYNAMIC_TEXTURE_DUMP ).getCode(), GLFW.GLFW_KEY_S);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CHART_PIE ).getCode(), GLFW.GLFW_KEY_1);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CHART_FPS_TPS ).getCode(), GLFW.GLFW_KEY_2);
DEBUG_REBINDS.put(KeyBindingHelper.getBoundKeyOf(CHART_BANDWIDTH_PING ).getCode(), GLFW.GLFW_KEY_3);

if (gamemodeSwitcherSelectText != null)
updateGamemodeSwitcherSelectText();
Expand All @@ -187,12 +187,12 @@ public static String getDebugKeybindString(KeyBinding key) {
}

public static int getKeyCode(KeyBinding key) {
return Math.abs(KeyBindingHelper.getBoundKeyOf(key).getCode());
return KeyBindingHelper.getBoundKeyOf(key).getCode();
}

public static boolean isKeybindPressed(KeyBinding key) {
if (key.boundKey.type == InputUtil.Type.MOUSE)
return IS_MOUSE_DOWN.getOrDefault(key.boundKey.getCode(), false);
return IS_MOUSE_DOWN.getOrDefault(getKeyCode(key), false);
return InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), getKeyCode(key));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public int moveDoneButton(int in) {
public void addMacCommandToControl(CallbackInfo info, int i, int j, int k) {
this.addDrawableChild(RebindAllTheKeys.doubleTapSprint.createWidget(gameOptions, i, k, 150));
this.addDrawableChild(RebindAllTheKeys.doubleTapFly.createWidget(gameOptions, j, k, 150));
// this.addDrawableChild(RebindAllTheKeys.persistentSprint.createWidget(gameOptions, i, k+24, 150));
// this.addDrawableChild(RebindAllTheKeys.persistentSneak.createWidget(gameOptions, j, k+24, 150));
if (MinecraftClient.IS_SYSTEM_MAC)
this.addDrawableChild(RebindAllTheKeys.macCommandToControl.createWidget(gameOptions, i, k+24, 150));
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ public KeybindsScreenMixin(Screen parent, GameOptions gameOptions, Text title) {
super(parent, gameOptions, title);
}

@Redirect(method = "keyPressed", at = @At(value = "INVOKE", ordinal = 1,
target = "Lnet/minecraft/client/option/GameOptions;setKeyCode(Lnet/minecraft/client/option/KeyBinding;Lnet/minecraft/client/util/InputUtil$Key;)V"))
public void setKeyCode(GameOptions options, KeyBinding binding, InputUtil.Key _key, int keyCode, int scanCode) {
//TODO: REMOVE?
// boolean setNegative = binding.getCategory().equals("rebind_all_the_keys.keybind_group.debug") && !binding.getTranslationKey().equals("rebind_all_the_keys.keybind.debug_key");
options.setKeyCode(binding, InputUtil.fromKeyCode(keyCode, scanCode));
}

@Redirect(method = "keyPressed", at = @At(value = "INVOKE", ordinal = 0,
target = "Lnet/minecraft/client/option/GameOptions;setKeyCode(Lnet/minecraft/client/option/KeyBinding;Lnet/minecraft/client/util/InputUtil$Key;)V"))
public void ScreenPrimaryCanNotBeUnbound(GameOptions options, KeyBinding binding, InputUtil.Key key, int keyCode, int scanCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
Expand Down Expand Up @@ -50,24 +51,25 @@ public int remapIntentionalCrashKey(int _key) {
return RebindAllTheKeys.getKeyCode(INTENTIONAL_CRASH);
}

int key;
@Redirect(method = "onKey", at= @At(value = "INVOKE", target = "Lnet/minecraft/client/util/InputUtil;isKeyPressed(JI)Z"))
public boolean fixErrorWhenUnbound(long handle, int code) {
return code != -1 && InputUtil.isKeyPressed(handle, code);
}

@Unique int key;
@Inject(method = "onKey", at = @At("HEAD"))
public void getKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
this.key = key;
}

@ModifyConstant(method = "onKey", constant = @Constant(intValue = GLFW.GLFW_KEY_ESCAPE /*256*/))
public int remapQuitKey(int _key) {
if (key == 256)
return key;
return RebindAllTheKeys.getKeyCode(QUIT_ALIAS);
return key == 256 ? key : RebindAllTheKeys.getKeyCode(QUIT_ALIAS);
}

@ModifyConstant(method = "onKey", constant = @Constant(intValue = GLFW.GLFW_KEY_B /*66*/))
public int remapToggleNarratorCrashKey(int key) {
if (TOGGLE_NARRATOR_OVERRIDE.isUnbound())
return key;
return RebindAllTheKeys.getKeyCode(TOGGLE_NARRATOR_OVERRIDE);
return TOGGLE_NARRATOR_OVERRIDE.isUnbound() ? key : RebindAllTheKeys.getKeyCode(TOGGLE_NARRATOR_OVERRIDE);
}

@Redirect(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;hasControlDown()Z"))
Expand All @@ -77,13 +79,12 @@ public boolean removeCtrlRequirementIfToggleNarratorOverrideIsUsed() {

@Redirect(method = "pollDebugCrash", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Keyboard;debugLog(Ljava/lang/String;[Ljava/lang/Object;)V"))
public void showActualIntentionalCrashKeybind(Keyboard keyboard, String key, Object[] objects) {

this.client.inGameHud.getChatHud().addMessage((Text.literal(""))
.append((Text.translatable("debug.prefix")).formatted(Formatting.YELLOW, Formatting.BOLD))
.append(" ").append(I18n.translate(key).replace("F3 + C", RebindAllTheKeys.getDebugKeybindString(INTENTIONAL_CRASH))));
}

//TODO: Update

@Inject(method = "processF3", at = @At("HEAD"), cancellable = true)
public void showDebugKeybinds(int key, CallbackInfoReturnable<Boolean> info) {
if (key != 81)
Expand Down
15 changes: 5 additions & 10 deletions src/main/resources/rebind_all_the_keys.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,19 @@
"DebugHudMixin",
"GameModeSelectionScreenMixin",
"GameOptionsMixin",
"InputKeyMixin",
"InputUtilKeyMixin",
"InputUtilTypeAccessor",
"KeyBindingMixin",
"KeybindsScreenMixin",
"KeyboardInputMixin",
"KeyboardMixin",
"MinecraftClientMixin",
"MouseMixin",
"MultiplayerScreenMixin",
"ScreenMixin"
],
"injectors": {
"defaultRequire": 1
},
"mixins": [
"ScreenMixin",
"GameOptionsAccessor",
"HandledScreenMixin",
"LivingEntityMixin"
]
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 779e961

Please sign in to comment.