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