diff options
author | Linnea Gräf <nea@nea.moe> | 2024-07-05 22:52:06 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-07-05 22:52:06 +0200 |
commit | dc3adecc1b34758ccd62b5086d0052ef70555282 (patch) | |
tree | dc487f4c14901c5dc59cabbaceaeae13c7feecf0 /src/main/java/moe/nea/firmament | |
parent | 3d792dbef7c7e0f186e29f2e3999f99c2c14f5d7 (diff) | |
download | firmament-dc3adecc1b34758ccd62b5086d0052ef70555282.tar.gz firmament-dc3adecc1b34758ccd62b5086d0052ef70555282.tar.bz2 firmament-dc3adecc1b34758ccd62b5086d0052ef70555282.zip |
Improve keybinding support
Diffstat (limited to 'src/main/java/moe/nea/firmament')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java b/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java index be3a3c0..78da3b3 100644 --- a/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/FirmKeybindsInVanillaControlsPatch.java @@ -6,6 +6,7 @@ package moe.nea.firmament.mixins; +import moe.nea.firmament.gui.config.KeyBindingHandler; import moe.nea.firmament.gui.config.ManagedConfig; import moe.nea.firmament.keybindings.FirmamentKeyBindings; import net.minecraft.client.MinecraftClient; @@ -40,19 +41,21 @@ public class FirmKeybindsInVanillaControlsPatch { @ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;builder(Lnet/minecraft/text/Text;Lnet/minecraft/client/gui/widget/ButtonWidget$PressAction;)Lnet/minecraft/client/gui/widget/ButtonWidget$Builder;")) public ButtonWidget.PressAction onInit(ButtonWidget.PressAction action) { - ManagedConfig config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); + var config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); if (config == null) return action; return button -> { - config.showConfigEditor(MinecraftClient.getInstance().currentScreen); + ((KeyBindingHandler) config.getHandler()) + .getManagedConfig() + .showConfigEditor(MinecraftClient.getInstance().currentScreen); }; } @Inject(method = "update", at = @At("HEAD"), cancellable = true) public void onUpdate(CallbackInfo ci) { - ManagedConfig config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); + var config = FirmamentKeyBindings.INSTANCE.getKeyBindings().get(binding); if (config == null) return; resetButton.active = false; - editButton.setMessage(Text.translatable("firmament.keybinding.external")); + editButton.setMessage(Text.translatable("firmament.keybinding.external", config.value.format())); ci.cancel(); } |