CLLPacketHandler.java 文件源码

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

项目:Combustible-Lemon-Launcher 作者:
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
    ByteBuf packetPayload = msg.payload();
    byte indexOfClass = packetPayload.readByte();
    ByteBufInputStream bbis = new ByteBufInputStream(packetPayload.slice());
    Class<? extends CLLPacket> packetClass = registeredPackets.get(indexOfClass);
    if(packetClass != null){
        CLLPacket packetCLL = packetClass.newInstance();
        packetCLL.readDataFrom(bbis);
        switch(FMLCommonHandler.instance().getEffectiveSide()){
        case CLIENT:
            handleClient(packetCLL);
            break;
        case SERVER:
            packetCLL.handleServerSide(((NetHandlerPlayServer)ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()).player);
            break;          
        }
        bbis.close();
        out.add(packetCLL);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号