Ejemplo n.º 1
0
  /**
   * Gets the material name back from the id and data.
   *
   * @param id The block id
   * @param data The block data
   * @return String in the format blockname[.blockdata]
   */
  protected String makeMaterial(int id, int data) {
    String materialString = "" + id;
    DefaultMaterial material = DefaultMaterial.getMaterial(id);
    if (material != DefaultMaterial.UNKNOWN_BLOCK) {
      // No name, return number as String
      materialString = material.toString();
    }

    if (data > 0) {
      materialString = materialString + "." + data;
    }

    return materialString;
  }
Ejemplo n.º 2
0
  /**
   * Returns the block id with the given name.
   *
   * @param string
   * @return
   */
  protected int readBlockId(String string) throws InvalidResourceException {
    if (string.indexOf('.') != -1) {
      // Ignore block data
      string = string.split("\\.")[0];
    }

    DefaultMaterial material = DefaultMaterial.getMaterial(string);
    if (material != null) {
      return material.id;
    }

    return readInt(string, 0, TerrainControl.supportedBlockIds);
  }