From f9f1e491013d8906084140d12c8a4ded04dd7edd Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:17:10 +0100 Subject: [PATCH] Implement HWYLA keybindings fix TehNut-Mods/HWYLA#127 --- README.md | 2 ++ build.gradle | 1 + .../universaltweaks/core/UTMixinLoader.java | 3 +++ .../hwyla/mixin/UTHwylaKeybindingMixin.java | 19 +++++++++++++++++++ src/main/resources/mixins.mods.hwyla.json | 7 +++++++ 5 files changed, 32 insertions(+) create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/hwyla/mixin/UTHwylaKeybindingMixin.java create mode 100644 src/main/resources/mixins.mods.hwyla.json diff --git a/README.md b/README.md index b948313a..7be956a4 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,8 @@ All changes are toggleable via config files. * **Disable Bee Damage Armor Bypass:** Disables damage caused by bees bypassing player armor * **Duplication Fixes:** Fixes various duplication exploits * **Replanting Cocoa Beans:** Allows Forestry farms to automatically replant cocoa beans +* **HWYLA** + * **Keybindings Fix:** Fixes crashes in all menus when changing HWYLA keybindings to unsupported values * **IndustrialCraft 2** * **Duplication Fixes:** Fixes various duplication exploits * **Industrial Foregoing** diff --git a/build.gradle b/build.gradle index 03e3c0e7..2640b09c 100644 --- a/build.gradle +++ b/build.gradle @@ -178,6 +178,7 @@ dependencies { compileOnly 'curse.maven:extrautilities-225561:2678374' compileOnly 'curse.maven:forgemultipartcbe-258426:2755790' // aka "CB Multipart" compileOnly 'curse.maven:guideapi-228832:2645992' + compileOnly 'curse.maven:hwyla-253449:2568751' compileOnly 'curse.maven:industrialcraft-242638:3078604' compileOnly 'curse.maven:ironbackpacks-227049:2564573' compileOnly 'curse.maven:mekanism-268560:2835175' diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java index f29bf880..2d57e1d2 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java @@ -20,6 +20,7 @@ public List getMixinConfigs() configs.add("mixins.mods.cbmultipart.client.json"); configs.add("mixins.mods.compactmachines.json"); configs.add("mixins.mods.crafttweaker.json"); + configs.add("mixins.mods.hwyla.json"); configs.add("mixins.mods.roost.json"); configs.add("mixins.mods.storagedrawers.client.json"); configs.add("mixins.mods.thaumcraft.entities.client.json"); @@ -98,6 +99,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return Loader.isModLoaded("compactmachines3") && UTConfigMods.COMPACT_MACHINES.utCMRenderFixToggle; case "mixins.mods.crafttweaker.json": return Loader.isModLoaded("crafttweaker"); + case "mixins.mods.hwyla.json": + return Loader.isModLoaded("waila"); case "mixins.mods.roost.json": return Loader.isModLoaded("roost") && Loader.isModLoaded("contenttweaker"); case "mixins.mods.storagedrawers.client.json": diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/hwyla/mixin/UTHwylaKeybindingMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/hwyla/mixin/UTHwylaKeybindingMixin.java new file mode 100644 index 00000000..91a81754 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/hwyla/mixin/UTHwylaKeybindingMixin.java @@ -0,0 +1,19 @@ +package mod.acgaming.universaltweaks.mods.hwyla.mixin; + +import net.minecraft.client.settings.GameSettings; + +import mcp.mobius.waila.client.KeyEvent; +import mcp.mobius.waila.overlay.WailaTickHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = WailaTickHandler.class, remap = false) +public class UTHwylaKeybindingMixin +{ + @Redirect(method = "tickClient", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;isKeyDown(I)Z")) + private static boolean utHwylaKeybinding(int key) + { + return GameSettings.isKeyDown(KeyEvent.key_show); + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.mods.hwyla.json b/src/main/resources/mixins.mods.hwyla.json new file mode 100644 index 00000000..5ca94003 --- /dev/null +++ b/src/main/resources/mixins.mods.hwyla.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.mods.hwyla.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "client": ["UTHwylaKeybindingMixin"] +} \ No newline at end of file