Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 @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);
   }
 }
Exemplo n.º 3
0
    @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());
      }
    }
Exemplo n.º 4
0
  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;
  }
Exemplo n.º 5
0
 public void markDataUpdated(World world, int mapId) {
   HeightMapData data = getMapData(world, mapId);
   data.markDirty();
   mapsToUpdate.add(mapId);
 }