public static int createNewMap(World world, byte scale) {
   int id = world.getUniqueDataId("height_map");
   HeightMapData data = new HeightMapData(id, false);
   data.scale = scale;
   data.markDirty();
   world.setItemData(data.mapName, data);
   return id;
 }
 @Override
 protected void readFromStream(DataInput input) throws IOException {
   int length = ByteUtils.readVLI(input);
   for (int i = 0; i < length; i++) {
     int id = ByteUtils.readVLI(input);
     HeightMapData data = new HeightMapData(id, false);
     data.readFromStream(input);
     maps.put(id, data);
   }
 }
    @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());
      }
    }
  public static HeightMapData getMapData(World world, int mapId) {
    if (mapId < 0) return HeightMapData.INVALID;

    String name = HeightMapData.getMapName(mapId);
    HeightMapData result = (HeightMapData) world.loadItemData(HeightMapData.class, name);

    return result != null ? result : HeightMapData.EMPTY;
  }
 public void markDataUpdated(World world, int mapId) {
   HeightMapData data = getMapData(world, mapId);
   data.markDirty();
   mapsToUpdate.add(mapId);
 }