diff --git a/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnection.java b/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnectionThread.java similarity index 77% rename from viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnection.java rename to viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnectionThread.java index c63da17..53cd6ba 100644 --- a/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnection.java +++ b/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnectionThread.java @@ -17,23 +17,22 @@ */ package com.viaversion.fabric.mc1204.mixin.pipeline.client; +import com.llamalad7.mixinextras.sugar.Local; import com.viaversion.fabric.mc1204.ViaFabric; import com.viaversion.fabric.mc1204.service.ProtocolAutoDetector; -import io.netty.channel.ChannelFuture; -import net.minecraft.network.ClientConnection; 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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; import java.util.logging.Level; -@Mixin(ClientConnection.class) -public class MixinClientConnection { - @Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD")) - private static void onConnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable cir) { +@Mixin(targets = "net/minecraft/client/gui/screen/multiplayer/ConnectScreen$1") +public class MixinClientConnectionThread { + @Inject(method = "run", at = @At(value = "INVOKE_ASSIGN", args = "fuzz=2", target = "Ljava/util/Optional;get()Ljava/lang/Object;")) + private void onConnect(CallbackInfo ci, @Local InetSocketAddress address) { try { if (!ViaFabric.config.isClientSideEnabled()) return; ProtocolAutoDetector.detectVersion(address).get(10, TimeUnit.SECONDS); diff --git a/viafabric-mc1204/src/main/resources/mixins.viafabric1204.pipeline.json b/viafabric-mc1204/src/main/resources/mixins.viafabric1204.pipeline.json index b8723fb..68b0b7e 100644 --- a/viafabric-mc1204/src/main/resources/mixins.viafabric1204.pipeline.json +++ b/viafabric-mc1204/src/main/resources/mixins.viafabric1204.pipeline.json @@ -6,7 +6,7 @@ "MixinClientConnection" ], "client": [ - "client.MixinClientConnection" + "client.MixinClientConnectionThread" ], "injectors": { "defaultRequire": 1 diff --git a/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnection.java b/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnectionThread.java similarity index 77% rename from viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnection.java rename to viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnectionThread.java index f174235..645347b 100644 --- a/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnection.java +++ b/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnectionThread.java @@ -17,23 +17,22 @@ */ package com.viaversion.fabric.mc1206.mixin.pipeline.client; +import com.llamalad7.mixinextras.sugar.Local; import com.viaversion.fabric.mc1206.ViaFabric; import com.viaversion.fabric.mc1206.service.ProtocolAutoDetector; -import io.netty.channel.ChannelFuture; -import net.minecraft.network.ClientConnection; 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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; import java.util.logging.Level; -@Mixin(ClientConnection.class) -public class MixinClientConnection { - @Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD")) - private static void onConnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable cir) { +@Mixin(targets = "net/minecraft/client/gui/screen/multiplayer/ConnectScreen$1") +public class MixinClientConnectionThread { + @Inject(method = "run", at = @At(value = "INVOKE_ASSIGN", args = "fuzz=2", target = "Ljava/util/Optional;get()Ljava/lang/Object;")) + private void onConnect(CallbackInfo ci, @Local InetSocketAddress address) { try { if (!ViaFabric.config.isClientSideEnabled()) return; ProtocolAutoDetector.detectVersion(address).get(10, TimeUnit.SECONDS); diff --git a/viafabric-mc1206/src/main/resources/mixins.viafabric1206.pipeline.json b/viafabric-mc1206/src/main/resources/mixins.viafabric1206.pipeline.json index ac881a5..beea212 100644 --- a/viafabric-mc1206/src/main/resources/mixins.viafabric1206.pipeline.json +++ b/viafabric-mc1206/src/main/resources/mixins.viafabric1206.pipeline.json @@ -6,7 +6,7 @@ "MixinClientConnection" ], "client": [ - "client.MixinClientConnection" + "client.MixinClientConnectionThread" ], "injectors": { "defaultRequire": 1 diff --git a/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnection.java b/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnectionThread.java similarity index 77% rename from viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnection.java rename to viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnectionThread.java index 4ebc528..e199906 100644 --- a/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnection.java +++ b/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnectionThread.java @@ -17,23 +17,22 @@ */ package com.viaversion.fabric.mc1211.mixin.pipeline.client; +import com.llamalad7.mixinextras.sugar.Local; import com.viaversion.fabric.mc1211.ViaFabric; import com.viaversion.fabric.mc1211.service.ProtocolAutoDetector; -import io.netty.channel.ChannelFuture; -import net.minecraft.network.ClientConnection; 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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; import java.util.logging.Level; -@Mixin(ClientConnection.class) -public class MixinClientConnection { - @Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD")) - private static void onConnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable cir) { +@Mixin(targets = "net/minecraft/client/gui/screen/multiplayer/ConnectScreen$1") +public class MixinClientConnectionThread { + @Inject(method = "run", at = @At(value = "INVOKE_ASSIGN", args = "fuzz=2", target = "Ljava/util/Optional;get()Ljava/lang/Object;")) + private void onConnect(CallbackInfo ci, @Local InetSocketAddress address) { try { if (!ViaFabric.config.isClientSideEnabled()) return; ProtocolAutoDetector.detectVersion(address).get(10, TimeUnit.SECONDS); diff --git a/viafabric-mc1211/src/main/resources/mixins.viafabric1211.pipeline.json b/viafabric-mc1211/src/main/resources/mixins.viafabric1211.pipeline.json index be6a2f6..b2bfd85 100644 --- a/viafabric-mc1211/src/main/resources/mixins.viafabric1211.pipeline.json +++ b/viafabric-mc1211/src/main/resources/mixins.viafabric1211.pipeline.json @@ -6,7 +6,7 @@ "MixinClientConnection" ], "client": [ - "client.MixinClientConnection" + "client.MixinClientConnectionThread" ], "injectors": { "defaultRequire": 1