From cb7a0f57e3482125474a9cad7d7aad27cbcb1ef0 Mon Sep 17 00:00:00 2001 From: TheWhiteDog9487 Date: Wed, 30 Oct 2024 17:33:24 +0800 Subject: [PATCH] =?UTF-8?q?0.2.1=20=E6=97=B6=E9=97=B4=EF=BC=9A2024=2010=20?= =?UTF-8?q?30=20=E4=B8=BB=E8=A6=81=E5=86=85=E5=AE=B9=EF=BC=9A=20=E5=8A=A0?= =?UTF-8?q?=E5=A4=A7=E5=89=82=E9=87=8F=EF=BC=8C=201.=20=E4=BB=A5=E5=89=8D?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E5=AF=B9=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E5=B7=B2=E7=BB=8F=E4=BF=9D=E5=AD=98=E7=9A=84?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=9C=B0=E5=9D=80=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E7=8E=B0=E5=9C=A8=E5=8F=AA=E8=A6=81?= =?UTF-8?q?=E6=A8=A1=E7=BB=84=E5=A4=84=E4=BA=8E=E5=90=AF=E7=94=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=BC=9A=E7=9B=B4=E6=8E=A5=E5=AF=B9=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E8=BF=9B=E8=A1=8C=E6=B6=88=E9=99=A4=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC=E6=9B=BF=E6=8D=A2=EF=BC=8C=E7=A1=AE=E4=BF=9D=E4=B8=8D?= =?UTF-8?q?=E7=95=99=E6=AD=BB=E8=A7=92=E3=80=82=20=E8=AF=B4=E4=BA=BA?= =?UTF-8?q?=E8=AF=9D=EF=BC=9A=E6=9C=AA=E5=AE=89=E8=A3=85=E6=88=96=E6=9C=AA?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E6=9C=AC=E6=A8=A1=E7=BB=84=E6=97=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=9A=84=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=9C=89=E7=A9=BA=E6=A0=BC=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E6=9C=AC=E6=A8=A1=E7=BB=84=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E4=BC=9A=E5=9C=A8=E6=89=93=E5=BC=80=E2=80=9C=E5=A4=9A=E4=BA=BA?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E2=80=9D=E7=AA=97=E5=8F=A3=E6=97=B6=E8=A2=AB?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=8E=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/DirectConnectScreenAccessor.java | 12 ------------ .../mixin/client/MixinAddServerScreen.java | 7 ++++--- .../client/MixinDirectConnectScreen.java | 11 +++++++++-- .../mixin/client/MixinServerInfo.java | 19 +++++++++++++++++++ .../resources/twd-sasf.client.mixins.json | 5 +++-- src/main/resources/twd-sasf.mixins.json | 2 +- 6 files changed, 36 insertions(+), 20 deletions(-) delete mode 100644 src/client/java/xyz/thewhitedog9487/mixin/client/DirectConnectScreenAccessor.java create mode 100644 src/client/java/xyz/thewhitedog9487/mixin/client/MixinServerInfo.java diff --git a/src/client/java/xyz/thewhitedog9487/mixin/client/DirectConnectScreenAccessor.java b/src/client/java/xyz/thewhitedog9487/mixin/client/DirectConnectScreenAccessor.java deleted file mode 100644 index dbb8403..0000000 --- a/src/client/java/xyz/thewhitedog9487/mixin/client/DirectConnectScreenAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package xyz.thewhitedog9487.mixin.client; - -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.network.ServerInfo; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen.class) -public interface DirectConnectScreenAccessor { - @Accessor("addressField") - TextFieldWidget Mixin_GetAddressField(); -} diff --git a/src/client/java/xyz/thewhitedog9487/mixin/client/MixinAddServerScreen.java b/src/client/java/xyz/thewhitedog9487/mixin/client/MixinAddServerScreen.java index 85c146a..34abb3e 100644 --- a/src/client/java/xyz/thewhitedog9487/mixin/client/MixinAddServerScreen.java +++ b/src/client/java/xyz/thewhitedog9487/mixin/client/MixinAddServerScreen.java @@ -1,14 +1,15 @@ package xyz.thewhitedog9487.mixin.client; +import net.minecraft.client.gui.screen.multiplayer.AddServerScreen; import net.minecraft.client.gui.widget.TextFieldWidget; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import xyz.thewhitedog9487.Settings; -@Mixin(net.minecraft.client.gui.screen.multiplayer.AddServerScreen.class) +@Mixin(AddServerScreen.class) public class MixinAddServerScreen { @Redirect(method = "addAndClose", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;getText()Ljava/lang/String;", ordinal = 1)) private String trimGetText(TextFieldWidget instance) { - if( !Settings.ModEnabled ) { return instance.getText(); } - return instance.getText().replace(" ", "");}} \ No newline at end of file + if( Settings.ModEnabled == false ) { return instance.getText(); } + else return instance.getText().replace(" ", "");}} \ No newline at end of file diff --git a/src/client/java/xyz/thewhitedog9487/mixin/client/MixinDirectConnectScreen.java b/src/client/java/xyz/thewhitedog9487/mixin/client/MixinDirectConnectScreen.java index 24f8b59..835c45b 100644 --- a/src/client/java/xyz/thewhitedog9487/mixin/client/MixinDirectConnectScreen.java +++ b/src/client/java/xyz/thewhitedog9487/mixin/client/MixinDirectConnectScreen.java @@ -1,16 +1,23 @@ package xyz.thewhitedog9487.mixin.client; +import net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen; import net.minecraft.client.gui.widget.TextFieldWidget; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import xyz.thewhitedog9487.Settings; -@Mixin(net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen.class) +@Mixin(DirectConnectScreen.class) +interface DirectConnectScreenAccessor { + @Accessor("addressField") + TextFieldWidget Mixin_GetAddressField();} + +@Mixin(DirectConnectScreen.class) public class MixinDirectConnectScreen { @Redirect(method = "saveAndClose", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;getText()Ljava/lang/String;")) private String trimGetText(TextFieldWidget instance) { - if( !Settings.ModEnabled ) { return instance.getText(); } + if( Settings.ModEnabled == false ) { return instance.getText(); } String trimmedText = instance.getText().replace(" ", ""); ((DirectConnectScreenAccessor) this).Mixin_GetAddressField().setText(trimmedText); return trimmedText;}} \ No newline at end of file diff --git a/src/client/java/xyz/thewhitedog9487/mixin/client/MixinServerInfo.java b/src/client/java/xyz/thewhitedog9487/mixin/client/MixinServerInfo.java new file mode 100644 index 0000000..0985c0c --- /dev/null +++ b/src/client/java/xyz/thewhitedog9487/mixin/client/MixinServerInfo.java @@ -0,0 +1,19 @@ +package xyz.thewhitedog9487.mixin.client; + +import net.minecraft.client.network.ServerInfo; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import xyz.thewhitedog9487.Settings; + +import java.nio.file.Paths; + +@Mixin(ServerInfo.class) +public class MixinServerInfo { + @Redirect(method = "", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/network/ServerInfo;address:Ljava/lang/String;")) + private void RemoveSpace_Write(ServerInfo original, String value) { + if( Settings.ModEnabled == false ) { + original.address = value; + return; } + else { original.address = value.replace(" ", ""); } }} \ No newline at end of file diff --git a/src/client/resources/twd-sasf.client.mixins.json b/src/client/resources/twd-sasf.client.mixins.json index 538a0d2..f28f92e 100644 --- a/src/client/resources/twd-sasf.client.mixins.json +++ b/src/client/resources/twd-sasf.client.mixins.json @@ -1,11 +1,12 @@ { "required": true, "package": "xyz.thewhitedog9487.mixin.client", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "client": [ "DirectConnectScreenAccessor", "MixinAddServerScreen", - "MixinDirectConnectScreen" + "MixinDirectConnectScreen", + "MixinServerInfo" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/twd-sasf.mixins.json b/src/main/resources/twd-sasf.mixins.json index 5c46f72..0b9a9b5 100644 --- a/src/main/resources/twd-sasf.mixins.json +++ b/src/main/resources/twd-sasf.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "xyz.thewhitedog9487.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [], "injectors": { "defaultRequire": 1