예제 #1
0
  @Override
  public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, MSPacket msg) {
    msg.readData(source);

    try {
      INetHandler net = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
      EntityPlayer player = null;
      if (FMLCommonHandler.instance().getEffectiveSide().isServer())
        player = ((NetHandlerPlayServer) net).playerEntity;
      else player = Minecraft.getMinecraft().thePlayer;

      if (player == null) return;

      switch (msg.getId()) {
        case PacketIds.TILE_UPDATE:
          handleTileUpdate(player, (TileUpdatePacket) msg);
          break;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
 @Override
 public void encodeInto(ChannelHandlerContext ctx, MSPacket msg, ByteBuf target) throws Exception {
   msg.writeData(target);
 }