@Override
    protected void writeToStream(DataOutput output) throws IOException {
      int size = 0;
      for (HeightMapData data : maps.values()) if (data.isValid()) size++;

      ByteUtils.writeVLI(output, size);
      for (Map.Entry<Integer, HeightMapData> e : maps.entrySet()) {
        HeightMapData map = e.getValue();
        if (map.isValid()) {
          ByteUtils.writeVLI(output, e.getKey());
          map.writeToStream(output);
        } else Log.warn("Trying to propagate invalid map data %d", e.getKey());
      }
    }