diff --git a/src/main/java/de/zonlykroks/advancedscripts/mixin/ClientLoginNetworkHandlerMixin.java b/src/main/java/de/zonlykroks/advancedscripts/mixin/ConnectScreenMixin.java similarity index 58% rename from src/main/java/de/zonlykroks/advancedscripts/mixin/ClientLoginNetworkHandlerMixin.java rename to src/main/java/de/zonlykroks/advancedscripts/mixin/ConnectScreenMixin.java index 979e8af..e890bd0 100644 --- a/src/main/java/de/zonlykroks/advancedscripts/mixin/ClientLoginNetworkHandlerMixin.java +++ b/src/main/java/de/zonlykroks/advancedscripts/mixin/ConnectScreenMixin.java @@ -17,19 +17,24 @@ package de.zonlykroks.advancedscripts.mixin; import de.zonlykroks.advancedscripts.AdvancedScripts; -import net.minecraft.client.network.ClientLoginNetworkHandler; -import net.minecraft.network.packet.s2c.login.LoginSuccessS2CPacket; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ConnectScreen; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.client.network.ServerAddress; +import net.minecraft.client.network.ServerInfo; +import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ClientLoginNetworkHandler.class) -public class ClientLoginNetworkHandlerMixin { +@Mixin(ConnectScreen.class) +public class ConnectScreenMixin { - @Inject(method = "onSuccess", at = @At("TAIL")) - public void isOnSteamwar(LoginSuccessS2CPacket packet, CallbackInfo ci) { - String adress = ((ClientLoginNetworkHandler) (Object)this).serverInfo.address; + @Inject(method = "connect(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;)V", at = @At("TAIL")) + private static void isOnSteamwar(Screen screen, MinecraftClient client, ServerAddress address, ServerInfo info, CallbackInfo ci) { + String adress = address.getAddress(); AdvancedScripts.isOnSteamwar = adress == "steamwar.de" || adress == "78.31.71.136"; } diff --git a/src/main/resources/advancedscripts.accesswidener b/src/main/resources/advancedscripts.accesswidener index 263cd62..85a20a8 100644 --- a/src/main/resources/advancedscripts.accesswidener +++ b/src/main/resources/advancedscripts.accesswidener @@ -1,4 +1,4 @@ accessWidener v1 named -accessible field net/minecraft/client/network/ClientLoginNetworkHandler serverInfo Lnet/minecraft/client/network/ServerInfo; +accessible field net/minecraft/client/network/ClientPlayNetworkHandler serverInfo Lnet/minecraft/client/network/ServerInfo; accessible field net/minecraft/client/Keyboard client Lnet/minecraft/client/MinecraftClient; \ No newline at end of file diff --git a/src/main/resources/advancedscripts.mixins.json b/src/main/resources/advancedscripts.mixins.json index c4c8409..92d0313 100644 --- a/src/main/resources/advancedscripts.mixins.json +++ b/src/main/resources/advancedscripts.mixins.json @@ -6,7 +6,7 @@ "mixins": [ ], "client": [ - "ClientLoginNetworkHandlerMixin", + "ConnectScreenMixin", "KeyboardMixin" ], "injectors": {