PacketPipeline.java 文件源码

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

项目:NordMod 作者:
@Override
protected void encode(ChannelHandlerContext ctx, PacketAbstract msg,
                      List<Object> out) throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    Class<? extends PacketAbstract> clazz = msg.getClass();
    if (!packets.contains(msg.getClass())) {
        throw new NullPointerException("No Packet Registered for: "
                + msg.getClass().getCanonicalName());
    }
    byte discriminator = (byte) this.packets.indexOf(clazz);
    buffer.writeByte(discriminator);
    msg.encodeInto(ctx, buffer);
    FMLProxyPacket proxyPacket = new FMLProxyPacket((PacketBuffer) buffer.copy(), ctx
            .channel().attr(NetworkRegistry.FML_CHANNEL).get());
    out.add(proxyPacket);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号