Search in sources :

Example 11 with ProtocolVersion

use of com.viaversion.viaversion.api.protocol.version.ProtocolVersion 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() + ")";
    ChannelHandler viaDecoder = ((MixinClientConnectionAccessor) MinecraftClient.getInstance().getNetworkHandler().getClientConnection()).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 12 with ProtocolVersion

use of com.viaversion.viaversion.api.protocol.version.ProtocolVersion in project ViaFabric by ViaVersion.

the class MixinServerEntry method addServerVer.

@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/util/List;)V"))
private void addServerVer(MultiplayerScreen multiplayerScreen, List<Text> tooltipText) {
    ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
    List<Text> lines = new ArrayList<>(tooltipText);
    lines.add(new TranslatableText("gui.ping_version.translated", proto.getName()));
    multiplayerScreen.setTooltip(lines);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ProtocolVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 13 with ProtocolVersion

use of com.viaversion.viaversion.api.protocol.version.ProtocolVersion 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 14 with ProtocolVersion

use of com.viaversion.viaversion.api.protocol.version.ProtocolVersion 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 15 with ProtocolVersion

use of com.viaversion.viaversion.api.protocol.version.ProtocolVersion in project ViaFabric by ViaVersion.

the class MixinServerEntry method addServerVer.

@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/util/List;)V"))
private void addServerVer(MultiplayerScreen multiplayerScreen, List<Text> tooltipText) {
    ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
    List<Text> lines = new ArrayList<>(tooltipText);
    lines.add(new TranslatableText("gui.ping_version.translated", proto.getName()));
    multiplayerScreen.setTooltip(lines);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ProtocolVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

ProtocolVersion (com.viaversion.viaversion.api.protocol.version.ProtocolVersion)21 ProtocolInfo (com.viaversion.viaversion.api.connection.ProtocolInfo)9 FabricDecodeHandler (com.viaversion.fabric.common.handler.FabricDecodeHandler)7 ChannelHandler (io.netty.channel.ChannelHandler)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 Map (java.util.Map)4 ProtocolPathEntry (com.viaversion.viaversion.api.protocol.ProtocolPathEntry)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Text (net.minecraft.text.Text)3 TranslatableText (net.minecraft.text.TranslatableText)3 Redirect (org.spongepowered.asm.mixin.injection.Redirect)3 JsonElement (com.google.gson.JsonElement)2 Via (com.viaversion.viaversion.api.Via)2 ServerProtocolVersion (com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion)2 ServerProtocolVersionSingleton (com.viaversion.viaversion.protocol.ServerProtocolVersionSingleton)2 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 AddressParser (com.viaversion.fabric.common.AddressParser)1