Hey i have a material but i would like to get the damage value Code: Material mat; //i can get my ID easily using mat.getID(); //how do i get the damage value?
The item 'damage' value is not in the Material, it is an attribute for Item(Stack)s. Code: ItemStack item = new ItemStack(Material.WOOL, 64); short dam = 8; item.setDurability(dam); dam = item.getDurability(); For blocks you probably have to use getData() and/or getState()/or getState().getData() For blocks you probably need to cast the MaterialData to a certain type. Example: wool Code: Block b = event.getClickedBlock(); if (b != null && b.getType() == Material.WOOL) { Wool w = (Wool) b.getState().getData(); DyeColor color = w.getColor(); } Or try to convert the block to an ItemStack (toItemStack()) and get the durability value from that.
But im using this to get my material Code:java MaterialData dat = new MaterialData(id, data); return dat.getItemType(); Im not trying to get damage values but item types such as 17:2 EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Are you using Material or MaterialData? Material does not have data, but MaterialData has a getData() method. Other objects like Block and ItemStack also have a getData() method. But Material itself is the type, so it doesn't have data.