Search in sources :

Example 1 with FabricDecodeHandler

use of com.viaversion.fabric.common.handler.FabricDecodeHandler in project ViaFabric by ViaVersion.

the class MixinDebugHud method getLeftText.

@Inject(at = @At("RETURN"), method = "getLeftText")
protected void getLeftText(CallbackInfoReturnable<List<String>> info) {
    String line = "[ViaFabric] I: " + Via.getManager().getConnectionManager().getConnections().size() + " (F: " + Via.getManager().getConnectionManager().getConnectedClients().size() + ")";
    @SuppressWarnings("ConstantConditions") ChannelHandler viaDecoder = ((MixinClientConnectionAccessor) MinecraftClient.getInstance().getNetworkHandler().getConnection()).getChannel().pipeline().get(CommonTransformer.HANDLER_DECODER_NAME);
    if (viaDecoder instanceof FabricDecodeHandler) {
        ProtocolInfo protocol = ((FabricDecodeHandler) viaDecoder).getInfo().getProtocolInfo();
        if (protocol != null) {
            ProtocolVersion serverVer = ProtocolVersion.getProtocol(protocol.getServerProtocolVersion());
            ProtocolVersion clientVer = ProtocolVersion.getProtocol(protocol.getProtocolVersion());
            line += " / C: " + clientVer + " S: " + serverVer + " A: " + protocol.getUser().isActive();
        }
    }
    info.getReturnValue().add(line);
}
Also used : FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) ProtocolInfo(com.viaversion.viaversion.api.connection.ProtocolInfo) ChannelHandler(io.netty.channel.ChannelHandler) ProtocolVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with FabricDecodeHandler

use of com.viaversion.fabric.common.handler.FabricDecodeHandler in project ViaFabric by ViaVersion.

the class MixinMultiplayerServerListPingerListener method onResponseCaptureServerInfo.

@Redirect(method = "onResponse(Lnet/minecraft/network/packet/s2c/query/QueryResponseS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerInfo;getIcon()Ljava/lang/String;"))
private String onResponseCaptureServerInfo(ServerInfo serverInfo) {
    FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getConnection()).getChannel().pipeline().get(FabricDecodeHandler.class);
    if (decoder != null) {
        ((ViaServerInfo) serverInfo).setViaTranslating(decoder.getInfo().isActive());
        ((ViaServerInfo) serverInfo).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
    }
    return serverInfo.getIcon();
}
Also used : FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) MixinClientConnectionAccessor(com.viaversion.fabric.mc118.mixin.debug.client.MixinClientConnectionAccessor) ViaServerInfo(com.viaversion.fabric.common.gui.ViaServerInfo) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 3 with FabricDecodeHandler

use of com.viaversion.fabric.common.handler.FabricDecodeHandler in project ViaFabric by ViaVersion.

the class MixinServerNetworkIoChInit method onInitChannel.

@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
    if (channel instanceof SocketChannel) {
        UserConnection user = new UserConnectionImpl(channel);
        new ProtocolPipelineImpl(user);
        channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user));
        channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) FabricEncodeHandler(com.viaversion.fabric.common.handler.FabricEncodeHandler) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with FabricDecodeHandler

use of com.viaversion.fabric.common.handler.FabricDecodeHandler in project ViaFabric by ViaVersion.

the class MixinMultiplayerServerListPingerListener method onResponseCaptureServerInfo.

@Redirect(method = "onResponse(Lnet/minecraft/network/packet/s2c/query/QueryResponseS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerInfo;getIcon()Ljava/lang/String;"))
private String onResponseCaptureServerInfo(ServerInfo serverInfo) {
    FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getConnection()).getChannel().pipeline().get(FabricDecodeHandler.class);
    if (decoder != null) {
        ((ViaServerInfo) serverInfo).setViaTranslating(decoder.getInfo().isActive());
        ((ViaServerInfo) serverInfo).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
    }
    return serverInfo.getIcon();
}
Also used : FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) MixinClientConnectionAccessor(com.viaversion.fabric.mc117.mixin.debug.client.MixinClientConnectionAccessor) ViaServerInfo(com.viaversion.fabric.common.gui.ViaServerInfo) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 5 with FabricDecodeHandler

use of com.viaversion.fabric.common.handler.FabricDecodeHandler in project ViaFabric by ViaVersion.

the class MixinServerNetworkIoChInit method onInitChannel.

@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
    if (channel instanceof SocketChannel) {
        UserConnection user = new UserConnectionImpl(channel);
        new ProtocolPipelineImpl(user);
        channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user));
        channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) FabricEncodeHandler(com.viaversion.fabric.common.handler.FabricEncodeHandler) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

FabricDecodeHandler (com.viaversion.fabric.common.handler.FabricDecodeHandler)24 Inject (org.spongepowered.asm.mixin.injection.Inject)21 FabricEncodeHandler (com.viaversion.fabric.common.handler.FabricEncodeHandler)14 UserConnection (com.viaversion.viaversion.api.connection.UserConnection)14 UserConnectionImpl (com.viaversion.viaversion.connection.UserConnectionImpl)14 ProtocolPipelineImpl (com.viaversion.viaversion.protocol.ProtocolPipelineImpl)14 SocketChannel (io.netty.channel.socket.SocketChannel)14 ProtocolInfo (com.viaversion.viaversion.api.connection.ProtocolInfo)7 ProtocolVersion (com.viaversion.viaversion.api.protocol.version.ProtocolVersion)7 ChannelHandler (io.netty.channel.ChannelHandler)7 ViaServerInfo (com.viaversion.fabric.common.gui.ViaServerInfo)3 Redirect (org.spongepowered.asm.mixin.injection.Redirect)3 MixinClientConnectionAccessor (com.viaversion.fabric.mc117.mixin.debug.client.MixinClientConnectionAccessor)1 MixinClientConnectionAccessor (com.viaversion.fabric.mc118.mixin.debug.client.MixinClientConnectionAccessor)1 MixinClientConnectionAccessor (com.viaversion.fabric.mc119.mixin.debug.client.MixinClientConnectionAccessor)1