public static int parseMaterialData(String text, Material material, int def) {
try {
return Integer.parseInt(text);
} catch (NumberFormatException ex) {
if (material == Material.WOOD) {
TreeSpecies ts = parseTreeSpecies(text, null);
if (ts != null) {
return MaterialUtil.getRawData(ts);
}
return def;
} else {
MaterialData dat = MaterialUtil.getData(material, 0);
if (dat instanceof TexturedMaterial) {
TexturedMaterial tdat = (TexturedMaterial) dat;
Material mat = parseMaterial(text, null);
if (mat == null)
return def;
tdat.setMaterial(mat);
} else if (dat instanceof Wool) {
Wool wdat = (Wool) dat;
DyeColor color = parseEnum(DyeColor.class, text, null);
if (color == null)
return def;
wdat.setColor(color);
} else if (dat instanceof Tree) {
Tree tdat = (Tree) dat;
TreeSpecies species = parseTreeSpecies(text, null);
if (species == null)
return def;
tdat.setSpecies(species);
} else if (dat instanceof Leaves) {
Leaves tdat = (Leaves) dat;
TreeSpecies species = parseTreeSpecies(text, null);
if (species == null)
return def;
tdat.setSpecies(species);
} else if (dat instanceof LongGrass) {
LongGrass ldat = (LongGrass) dat;