|
25 | 25 | import org.spongepowered.asm.mixin.Shadow; |
26 | 26 | import org.spongepowered.asm.mixin.injection.At; |
27 | 27 | import org.spongepowered.asm.mixin.injection.Inject; |
| 28 | +import org.spongepowered.asm.mixin.injection.Redirect; |
28 | 29 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
29 | 30 |
|
30 | 31 | import net.minecraft.client.Keyboard; |
@@ -74,20 +75,26 @@ private void postKeyEvent(int i, boolean[] bls, ParentElement element, int key, |
74 | 75 | } |
75 | 76 |
|
76 | 77 | @Inject(method = "method_1458", at = @At("HEAD"), cancellable = true) |
77 | | - private static void charEvent(Element element, int character, int mods, CallbackInfo info) { |
| 78 | + private static void preCharTyped(Element element, int character, int mods, CallbackInfo info) { |
78 | 79 | if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, (char) character, mods))) { |
79 | 80 | info.cancel(); |
80 | | - } else if (!element.charTyped((char) character, mods)) { |
81 | | - MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, (char) character, mods)); |
82 | 81 | } |
83 | 82 | } |
84 | 83 |
|
| 84 | + @Redirect(method = "method_1458", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Element;charTyped(CI)Z")) |
| 85 | + private static boolean charTyped(Element element, char character, int mods) { |
| 86 | + return element.charTyped(character, mods) || MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, character, mods)); |
| 87 | + } |
| 88 | + |
85 | 89 | @Inject(method = "method_1473", at = @At("HEAD"), cancellable = true) |
86 | | - private static void charEvent(Element element, char character, int mods, CallbackInfo info) { |
87 | | - if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, character, mods))) { |
| 90 | + private static void preCharTyped(Element element, char character, int mods, CallbackInfo info) { |
| 91 | + if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, (char) character, mods))) { |
88 | 92 | info.cancel(); |
89 | | - } else if (!element.charTyped(character, mods)) { |
90 | | - MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, character, mods)); |
91 | 93 | } |
92 | 94 | } |
| 95 | + |
| 96 | + @Redirect(method = "method_1473", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Element;charTyped(CI)Z")) |
| 97 | + private static boolean charTyped2(Element element, char character, int mods) { |
| 98 | + return element.charTyped(character, mods) || MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, character, mods)); |
| 99 | + } |
93 | 100 | } |
0 commit comments