diff --git a/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnectionThread.java b/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnectionThread.java index 53cd6ba..d1df500 100644 --- a/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnectionThread.java +++ b/viafabric-mc1204/src/main/java/com/viaversion/fabric/mc1204/mixin/pipeline/client/MixinClientConnectionThread.java @@ -17,27 +17,29 @@ */ package com.viaversion.fabric.mc1204.mixin.pipeline.client; -import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.viaversion.fabric.mc1204.ViaFabric; import com.viaversion.fabric.mc1204.service.ProtocolAutoDetector; 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; import java.net.InetSocketAddress; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @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) { + @WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Ljava/util/Optional;get()Ljava/lang/Object;")) + private Object onConnect(Optional instance, Operation original) { + InetSocketAddress address = original.call(instance); try { - if (!ViaFabric.config.isClientSideEnabled()) return; + if (!ViaFabric.config.isClientSideEnabled()) return address; ProtocolAutoDetector.detectVersion(address).get(10, TimeUnit.SECONDS); } catch (Exception e) { ViaFabric.JLOGGER.log(Level.WARNING, "Could not auto-detect protocol for " + address + " " + e); } + return address; } } diff --git a/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnectionThread.java b/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnectionThread.java index 645347b..ecc499e 100644 --- a/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnectionThread.java +++ b/viafabric-mc1206/src/main/java/com/viaversion/fabric/mc1206/mixin/pipeline/client/MixinClientConnectionThread.java @@ -17,27 +17,29 @@ */ package com.viaversion.fabric.mc1206.mixin.pipeline.client; -import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.viaversion.fabric.mc1206.ViaFabric; import com.viaversion.fabric.mc1206.service.ProtocolAutoDetector; 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; import java.net.InetSocketAddress; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @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) { + @WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Ljava/util/Optional;get()Ljava/lang/Object;")) + private Object onConnect(Optional instance, Operation original) { + InetSocketAddress address = original.call(instance); try { - if (!ViaFabric.config.isClientSideEnabled()) return; + if (!ViaFabric.config.isClientSideEnabled()) return address; ProtocolAutoDetector.detectVersion(address).get(10, TimeUnit.SECONDS); } catch (Exception e) { ViaFabric.JLOGGER.log(Level.WARNING, "Could not auto-detect protocol for " + address + " " + e); } + return address; } } diff --git a/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnectionThread.java b/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnectionThread.java index e199906..5947647 100644 --- a/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnectionThread.java +++ b/viafabric-mc1211/src/main/java/com/viaversion/fabric/mc1211/mixin/pipeline/client/MixinClientConnectionThread.java @@ -17,27 +17,29 @@ */ package com.viaversion.fabric.mc1211.mixin.pipeline.client; -import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.viaversion.fabric.mc1211.ViaFabric; import com.viaversion.fabric.mc1211.service.ProtocolAutoDetector; 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; import java.net.InetSocketAddress; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @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) { + @WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Ljava/util/Optional;get()Ljava/lang/Object;")) + private Object onConnect(Optional instance, Operation original) { + InetSocketAddress address = original.call(instance); try { - if (!ViaFabric.config.isClientSideEnabled()) return; + if (!ViaFabric.config.isClientSideEnabled()) return address; ProtocolAutoDetector.detectVersion(address).get(10, TimeUnit.SECONDS); } catch (Exception e) { ViaFabric.JLOGGER.log(Level.WARNING, "Could not auto-detect protocol for " + address + " " + e); } + return address; } }