Added prevention against NPEs in MaterialUtil

This commit is contained in:
Acrobot 2012-11-28 21:30:53 +01:00
parent cee04e8940
commit 817fdeae3f

View File

@ -383,7 +383,9 @@ public class MaterialUtil {
if (data instanceof TexturedMaterial) {
return ((TexturedMaterial) data).getMaterial().name();
} else if (data instanceof Colorable) {
return ((Colorable) data).getColor().name();
DyeColor color = ((Colorable) data).getColor();
return (color != null ? color.name() : null);
} else if (data instanceof Tree) {
//TreeSpecies specie = TreeSpecies.getByData((byte) (data.getData() & 3)); //This works, but not as intended
TreeSpecies specie = ((Tree) data).getSpecies();