@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class<? extends ARKMessage> clazz = packets.get(discriminator);
if (clazz == null) { throw new NullPointerException("No packet registered for discriminator: "
+ discriminator); }
ARKMessage pkt = clazz.newInstance();
pkt.decodeInto(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide())
{
case CLIENT:
player = getClientPlayer();
pkt.handleClientSide(player);
break;
case SERVER:
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player = ((NetHandlerPlayServer) netHandler).playerEntity;
pkt.handleServerSide(player);
break;
default:
}
out.add(pkt);
}
ARKMessagePipeline.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:ARKCraft
作者:
评论列表
文章目录