PacketChannel.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:mcplus_mods 作者:
@Override
protected void encode(ChannelHandlerContext ctx, Packet msg, List<Object> out) throws Exception
{
    ByteBuf buffer = Unpooled.buffer();
    Class<? extends Packet> msgClass = msg.getClass();
    if (!this.packets.contains(msg.getClass()))
    {
        throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName());
    }

    byte discriminator = (byte) this.packets.indexOf(msgClass);
    buffer.writeByte(discriminator);
    msg.encode(ctx, buffer);
    FMLProxyPacket proxyPacket = new FMLProxyPacket((PacketBuffer) buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
    out.add(proxyPacket);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号