From 4a7b4924459efd1d12370988d03fbda44077583f Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 15 Sep 2023 15:57:36 +0200 Subject: [PATCH] Fixed mixin issue --- build.gradle | 4 ++-- .../infinityitemeditor/mixin/SharedConstantsMixin.java | 3 ++- .../java/infinityitemeditor/screen/TextEditorScreen.java | 3 ++- .../infinityitemeditor/screen/widgets/StyledTextField.java | 3 ++- src/main/java/infinityitemeditor/util/CharUtils.java | 7 +++++++ 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 src/main/java/infinityitemeditor/util/CharUtils.java diff --git a/build.gradle b/build.gradle index b3aa3b6..d5ecd70 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'eclipse' apply plugin: 'maven-publish' String modid = 'infinityitemeditor' -version = '1.2.3' +version = '1.2.4' group = modid // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = modid @@ -133,7 +133,7 @@ dependencies { compileOnly 'org.projectlombok:lombok:1.18.20' annotationProcessor 'org.projectlombok:lombok:1.18.20' - annotationProcessor 'org.spongepowered:mixin:0.8:processor' + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' testCompileOnly 'org.projectlombok:lombok:1.18.20' testAnnotationProcessor 'org.projectlombok:lombok:1.18.20' diff --git a/src/main/java/infinityitemeditor/mixin/SharedConstantsMixin.java b/src/main/java/infinityitemeditor/mixin/SharedConstantsMixin.java index b0d9960..a39f124 100644 --- a/src/main/java/infinityitemeditor/mixin/SharedConstantsMixin.java +++ b/src/main/java/infinityitemeditor/mixin/SharedConstantsMixin.java @@ -1,5 +1,6 @@ package infinityitemeditor.mixin; +import infinityitemeditor.util.CharUtils; import net.minecraft.util.SharedConstants; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -13,7 +14,7 @@ public class SharedConstantsMixin { */ @Overwrite public static boolean isAllowedChatCharacter(char c) { //func_71566_a - return (c != 167 && c >= ' ' && c != 127) || c == '\u00a7'; + return CharUtils.isAllowedChatCharacter(c); } } diff --git a/src/main/java/infinityitemeditor/screen/TextEditorScreen.java b/src/main/java/infinityitemeditor/screen/TextEditorScreen.java index 17b77fb..adf5ae4 100644 --- a/src/main/java/infinityitemeditor/screen/TextEditorScreen.java +++ b/src/main/java/infinityitemeditor/screen/TextEditorScreen.java @@ -4,6 +4,7 @@ import infinityitemeditor.data.base.DataString; import infinityitemeditor.mixin.SharedConstantsMixin; import infinityitemeditor.screen.widgets.StyledButton; +import infinityitemeditor.util.CharUtils; import infinityitemeditor.util.ColorUtils.Color; import infinityitemeditor.util.GuiUtil; import net.minecraft.client.gui.screen.Screen; @@ -122,7 +123,7 @@ public boolean keyPressed(int keyCode, int scan, int modifier) { public boolean charTyped(char key, int modifier) { if (super.charTyped(key, modifier)) return true; - if (key == 167 || SharedConstantsMixin.isAllowedChatCharacter(key)) { + if (key == 167 || CharUtils.isAllowedChatCharacter(key)) { String s = text.get(); text.set(s.substring(0, cursor) + key + s.substring(cursor)); cursor++; diff --git a/src/main/java/infinityitemeditor/screen/widgets/StyledTextField.java b/src/main/java/infinityitemeditor/screen/widgets/StyledTextField.java index e73885e..02c0415 100644 --- a/src/main/java/infinityitemeditor/screen/widgets/StyledTextField.java +++ b/src/main/java/infinityitemeditor/screen/widgets/StyledTextField.java @@ -6,6 +6,7 @@ import infinityitemeditor.mixin.SharedConstantsMixin; import infinityitemeditor.styles.StyleManager; import infinityitemeditor.styles.StyleVanilla; +import infinityitemeditor.util.CharUtils; import infinityitemeditor.util.GuiUtil; import lombok.Getter; import lombok.Setter; @@ -420,7 +421,7 @@ public boolean charTyped(char char1, int char2) { if (!this.getActive()) { return false; } - if (!SharedConstantsMixin.isAllowedChatCharacter(char1)) { + if (!CharUtils.isAllowedChatCharacter(char1)) { return false; } this.writeText(Character.toString(char1)); diff --git a/src/main/java/infinityitemeditor/util/CharUtils.java b/src/main/java/infinityitemeditor/util/CharUtils.java new file mode 100644 index 0000000..79ac5df --- /dev/null +++ b/src/main/java/infinityitemeditor/util/CharUtils.java @@ -0,0 +1,7 @@ +package infinityitemeditor.util; + +public class CharUtils { + public static boolean isAllowedChatCharacter(char c) { //func_71566_a + return (c != 167 && c >= ' ' && c != 127) || c == '\u00a7'; + } +}