Why is there no Material.getMaterial(int id, byte data) or getMaxData()?

Discussion in 'Plugin Development' started by PatPeter, Mar 1, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    For instance, how do I get a Material for spruce wood, spruce wood planks, different shades of wool, etc.? Also, how do I find out what the maximum valid data value is? getMaxDurability() doesn't work. For WOOD it returns 0 (it should be 3?). Wool would be 15, etc. There should be a maximum data value stored as well.
  2. I think the point with Material is that the data value does not change the Material, technically.

    It would be nice to have a simple way to retrieve the item names which Minecraft is using. Since Bukkit uses different names this is a bit itchy topic, probably. Not sure ItemMeta allows getting mc-names for item-stacks, haven't found anything on that, yet.

    The maximum data value might be worth a ticket, though some plugins do use out-of-range data values for blocks and items to provide extra functionality.
  3. Offline


    Moved to Plugin Development, as someone may have a good answer for what you're trying to achieve.
  4. Offline


    asofold In my plugin Supply and Demand, I just used all the names from Minecraft Wiki's Data values because Minecraft and Bukkit's naming conventions can be just plain asinine sometimes.
  5. Offline


    In MCP code i found getSubBlocks which adds to given list the same blocks but with diffrent meta. Unfortunetlly i couldn't find in Bukkit/mc-dev repo.
  6. The Material enum only stores the id of the block or item. The data/damage/durability value is not included there.
    getMaxDurability() is only used for the damage of tools. Even though it's actually stored in the same location, bukkit makes a difference between "durability damage value" and "item type damage value".

    For the latter, there is the MaterialData class, which has a bunch of child classes for the various item types.
    You can get it for example through "itemstack.getData()". Then you can cast it to the type you want (of course it has to be of the desired basic material!) and call content-aware methods on that one.

    Tree matData = (Tree) itemStack.getData();
    (and don't ask me why the class is called "Tree", it's actually for the type Material.LOG)

    This is useful for more complex data values for blocks like pistons, attachable stuff and so on.
    ferrybig likes this.
Thread Status:
Not open for further replies.

Share This Page