From 65d1a76608c77fe31d54155acdc9d1280a662416 Mon Sep 17 00:00:00 2001 From: LemonCaramel Date: Sun, 27 Aug 2023 16:00:55 +0900 Subject: [PATCH] fix #3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문자 입력이 아닌 경우 입력 상태를 NONE으로 전환해야만 함 --- .../moe/caramel/chat/mixin/MixinEditBox.java | 1 + .../chat/mixin/MixinSignEditScreen.java | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/moe/caramel/chat/mixin/MixinEditBox.java b/common/src/main/java/moe/caramel/chat/mixin/MixinEditBox.java index a326249..636d7a4 100644 --- a/common/src/main/java/moe/caramel/chat/mixin/MixinEditBox.java +++ b/common/src/main/java/moe/caramel/chat/mixin/MixinEditBox.java @@ -55,6 +55,7 @@ private void setFormatter(final BiFunction { /* Original */ if (caramelChat$wrapper.getStatus() == AbstractIMEWrapper.InputStatus.NONE) { diff --git a/common/src/main/java/moe/caramel/chat/mixin/MixinSignEditScreen.java b/common/src/main/java/moe/caramel/chat/mixin/MixinSignEditScreen.java index 7458d32..3159861 100644 --- a/common/src/main/java/moe/caramel/chat/mixin/MixinSignEditScreen.java +++ b/common/src/main/java/moe/caramel/chat/mixin/MixinSignEditScreen.java @@ -15,6 +15,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -27,7 +28,7 @@ public final class MixinSignEditScreen implements ScreenController { @Unique private WrapperSignEditScreen caramelChat$wrapper; - @Unique private boolean caramelChat$textFieldInit; + @Unique private boolean caramelChat$lazyInit; @Shadow @Nullable public TextFieldHelper signField; @Shadow @Final public SignBlockEntity sign; @Shadow public int line; @@ -39,10 +40,10 @@ private void init(final CallbackInfo ci) { } @Inject(method = "tick", at = @At("HEAD")) - private void tick(final CallbackInfo ci) { + private void lazyInit(final CallbackInfo ci) { // Stendhal mod creates a new signField... :scream: - if (!caramelChat$textFieldInit && signField != null) { - this.caramelChat$textFieldInit = true; + if (!caramelChat$lazyInit && signField != null) { + this.caramelChat$lazyInit = true; final Consumer previous = (signField.setMessageFn); this.signField.setMessageFn = (value) -> { @@ -60,6 +61,21 @@ private void keyPressed(final int key, final int scancode, final int action, fin this.caramelChat$wrapper.setOrigin(); } + @Redirect( + method = "keyPressed", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/font/TextFieldHelper;keyPressed(I)Z" + ) + ) + private boolean helperKeyPressed(final TextFieldHelper helper, final int key) { + final boolean result = helper.keyPressed(key); + if (result) { + this.caramelChat$wrapper.setToNoneStatus(); + } + return result; + } + @ModifyArgs( method = "renderSignText", at = @At(