Fix pipeline injection in 1.17+

This commit is contained in:
FlorianMichael 2024-04-28 22:57:52 +02:00
parent d2d5ed4458
commit f589b3a28d
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
4 changed files with 40 additions and 52 deletions

View File

@ -20,25 +20,22 @@ package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
import io.netty.channel.Channel;
import net.minecraft.network.Connection;
import org.spongepowered.asm.mixin.Final;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(targets = "net.minecraft.network.Connection$1")
public class MixinConnection_1 {
@Final
@Mutable
Connection val$connection;
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection);
@Redirect(method = "initChannel", at = @At(value = "INVOKE", target = "Lio/netty/channel/ChannelPipeline;addLast(Ljava/lang/String;Lio/netty/channel/ChannelHandler;)Lio/netty/channel/ChannelPipeline;"))
private ChannelPipeline hookViaPipeline(ChannelPipeline instance, String s, ChannelHandler channelHandler) {
final ChannelPipeline handler = instance.addLast(s, channelHandler);
if (channelHandler instanceof VFNetworkManager mixinNetworkManager) {
ViaForgeCommon.getManager().inject(instance.channel(), mixinNetworkManager);
}
return handler;
}
}

View File

@ -20,25 +20,22 @@ package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
import io.netty.channel.Channel;
import net.minecraft.network.Connection;
import org.spongepowered.asm.mixin.Final;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(targets = "net.minecraft.network.Connection$1")
public class MixinConnection_1 {
@Final
@Mutable
Connection val$connection;
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection);
@Redirect(method = "initChannel", at = @At(value = "INVOKE", target = "Lio/netty/channel/ChannelPipeline;addLast(Ljava/lang/String;Lio/netty/channel/ChannelHandler;)Lio/netty/channel/ChannelPipeline;"))
private ChannelPipeline hookViaPipeline(ChannelPipeline instance, String s, ChannelHandler channelHandler) {
final ChannelPipeline handler = instance.addLast(s, channelHandler);
if (channelHandler instanceof VFNetworkManager mixinNetworkManager) {
ViaForgeCommon.getManager().inject(instance.channel(), mixinNetworkManager);
}
return handler;
}
}

View File

@ -20,25 +20,22 @@ package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
import io.netty.channel.Channel;
import net.minecraft.network.Connection;
import org.spongepowered.asm.mixin.Final;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(targets = "net.minecraft.network.Connection$1")
public class MixinConnection_1 {
@Final
@Mutable
Connection val$connection;
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection);
@Redirect(method = "initChannel", at = @At(value = "INVOKE", target = "Lio/netty/channel/ChannelPipeline;addLast(Ljava/lang/String;Lio/netty/channel/ChannelHandler;)Lio/netty/channel/ChannelPipeline;"))
private ChannelPipeline hookViaPipeline(ChannelPipeline instance, String s, ChannelHandler channelHandler) {
final ChannelPipeline handler = instance.addLast(s, channelHandler);
if (channelHandler instanceof VFNetworkManager mixinNetworkManager) {
ViaForgeCommon.getManager().inject(instance.channel(), mixinNetworkManager);
}
return handler;
}
}

View File

@ -20,25 +20,22 @@ package de.florianmichael.viaforge.mixin;
import de.florianmichael.viaforge.common.ViaForgeCommon;
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
import io.netty.channel.Channel;
import net.minecraft.network.Connection;
import org.spongepowered.asm.mixin.Final;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(targets = "net.minecraft.network.Connection$1")
public class MixinConnection_1 {
@Final
@Mutable
Connection val$connection;
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$connection);
@Redirect(method = "initChannel", at = @At(value = "INVOKE", target = "Lio/netty/channel/ChannelPipeline;addLast(Ljava/lang/String;Lio/netty/channel/ChannelHandler;)Lio/netty/channel/ChannelPipeline;"))
private ChannelPipeline hookViaPipeline(ChannelPipeline instance, String s, ChannelHandler channelHandler) {
final ChannelPipeline handler = instance.addLast(s, channelHandler);
if (channelHandler instanceof VFNetworkManager mixinNetworkManager) {
ViaForgeCommon.getManager().inject(instance.channel(), mixinNetworkManager);
}
return handler;
}
}