Skip to content

Commit

Permalink
fix #3
Browse files Browse the repository at this point in the history
문자 입력이 아닌 경우 입력 상태를 NONE으로 전환해야만 함
  • Loading branch information
LemonCaramel committed Aug 27, 2023
1 parent 15fe798 commit 65d1a76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private void setFormatter(final BiFunction<String, Integer, FormattedCharSequenc

@Unique
private void caramelChat$caretFormatter() {
// Set caret renderer
this.formatter = ((original, firstPos) -> {
/* Original */
if (caramelChat$wrapper.getStatus() == AbstractIMEWrapper.InputStatus.NONE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<String> previous = (signField.setMessageFn);
this.signField.setMessageFn = (value) -> {
Expand All @@ -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(
Expand Down

0 comments on commit 65d1a76

Please sign in to comment.