diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMultiplayerScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMultiplayerScreen.java index f55bd843..079656f3 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMultiplayerScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinMultiplayerScreen.java @@ -17,15 +17,21 @@ */ package de.florianmichael.viafabricplus.injection.mixin.base; +import de.florianmichael.viafabricplus.definition.v1_14_4.LegacyServerAddress; +import de.florianmichael.viafabricplus.injection.access.IServerInfo; import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen; import de.florianmichael.viafabricplus.settings.groups.GeneralSettings; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.network.ServerAddress; +import net.minecraft.client.network.ServerInfo; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MultiplayerScreen.class) @@ -49,4 +55,17 @@ public class MixinMultiplayerScreen extends Screen { this.addDrawableChild(builder.size(98, 20).build()); } + + @Unique + private ServerInfo viafabricplus_lastConnect; + + @Inject(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At("HEAD")) + public void track(ServerInfo entry, CallbackInfo ci) { + viafabricplus_lastConnect = entry; + } + + @Redirect(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;")) + public ServerAddress doOwnParse(String address) { + return LegacyServerAddress.parse(((IServerInfo) viafabricplus_lastConnect).viafabricplus_forcedVersion(), address); + } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinMultiplayerScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinMultiplayerScreen.java deleted file mode 100644 index ec0994ad..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinMultiplayerScreen.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen; - -import de.florianmichael.viafabricplus.definition.v1_14_4.LegacyServerAddress; -import de.florianmichael.viafabricplus.injection.access.IServerInfo; -import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; -import net.minecraft.client.network.ServerAddress; -import net.minecraft.client.network.ServerInfo; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(MultiplayerScreen.class) -public class MixinMultiplayerScreen { - - @Unique - private ServerInfo viafabricplus_lastConnect; - - @Inject(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At("HEAD")) - public void track(ServerInfo entry, CallbackInfo ci) { - viafabricplus_lastConnect = entry; - } - - @Redirect(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;")) - public ServerAddress doOwnParse(String address) { - return LegacyServerAddress.parse(((IServerInfo) viafabricplus_lastConnect).viafabricplus_forcedVersion(), address); - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 340b9828..95357b47 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ "accessWidener": "viafabricplus.accesswidener", "depends": { "fabricloader": ">=0.14.11", - "minecraft": "~1.19.3", + "minecraft": "~1.19.4", "java": ">=17" }, "breaks": { diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 0ec3c9b4..7787c11b 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -107,7 +107,6 @@ "fixes.minecraft.screen.MixinGameModeSelectionScreen", "fixes.minecraft.screen.MixinGameModeSelectionScreen_GameModeSelection", "fixes.minecraft.screen.MixinJigsawBlockScreen", - "fixes.minecraft.screen.MixinMultiplayerScreen", "fixes.minecraft.screen.MixinStructureBlockScreen_1", "fixes.minecraft.screen.merchant.MixinMerchantScreen", "fixes.minecraft.screen.merchant.MixinMerchantScreenHandler", @@ -150,12 +149,10 @@ "fixes.viaversion.protocol1_9to1_8.MixinViaIdleThread", "jsonwebtoken.MixinClasses", "jsonwebtoken.MixinDefaultCompressionCodecResolver", - "jsonwebtoken.MixinDefaultJwtParserBuilder" + "jsonwebtoken.MixinDefaultJwtParserBuilder", + "fixes.vialegacy.MixinViaLegacyConfig" ], "injectors": { "defaultRequire": 1 - }, - "mixins": [ - "fixes.vialegacy.MixinViaLegacyConfig" - ] + } }