From c263a75f767e29606da229eb118e03695f892caa Mon Sep 17 00:00:00 2001 From: J-RAP Date: Sat, 4 May 2024 03:26:12 -0600 Subject: [PATCH] reinforce mixin checks --- .../mixins/impl/zume/KeyMappingMixin.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/srrapero720/embeddiumplus/mixins/impl/zume/KeyMappingMixin.java b/src/main/java/me/srrapero720/embeddiumplus/mixins/impl/zume/KeyMappingMixin.java index 610239a..cc09177 100644 --- a/src/main/java/me/srrapero720/embeddiumplus/mixins/impl/zume/KeyMappingMixin.java +++ b/src/main/java/me/srrapero720/embeddiumplus/mixins/impl/zume/KeyMappingMixin.java @@ -7,19 +7,15 @@ import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @Mixin(KeyMapping.class) public class KeyMappingMixin { - @Shadow private InputConstants.Key key; - @Shadow @Final @Mutable private InputConstants.Key defaultKey; + @Shadow @Final private String category; - @WrapOperation(method = "(Ljava/lang/String;Lcom/mojang/blaze3d/platform/InputConstants$Type;ILjava/lang/String;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/KeyMapping;category:Ljava/lang/String;")) - private void redirect$init(KeyMapping instance, String value, Operation original) { - if (value.equals("category.zume")) { - defaultKey = key = InputConstants.Type.KEYSYM.getOrCreate(GLFW.GLFW_KEY_C); - } + @WrapOperation(method = "(Ljava/lang/String;Lcom/mojang/blaze3d/platform/InputConstants$Type;ILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/InputConstants$Type;getOrCreate(I)Lcom/mojang/blaze3d/platform/InputConstants$Key;")) + private InputConstants.Key redirect$init(InputConstants.Type instance, int pKeyCode, Operation original, String pName, InputConstants.Type pType, int methodkeycode, String pCategory) { + return original.call(instance, (category.equals("category.zume") && pKeyCode == GLFW.GLFW_KEY_Z) ? GLFW.GLFW_KEY_C : pKeyCode); } }