MaterialData (including NMS values) not working in 1.7.2

Discussion in 'Plugin Development' started by ZephireNZ, Dec 15, 2013.

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

    ZephireNZ

    I have no idea why, but when I try to create and add Wool/Wood/Dyes using their MaterialData classes, it won't actually work. The base item will be added to a player's inventory, but the data such as colour or wood type won't actually be added. I can visibly see the Material data on the ItemStack when debugging, so I'm not sure why it's not working.

    I even tried this with the NMS data values (eg 0x5), but those don't seem to be working either.

    For reference, this is how I'm doing it:
    Code:java
    1. // Wool, with colours
    2. ItemStack item = new ItemStack(Material.WOOL);
    3. item.setData(new Wool(DyeColor.BLACK));
    4.  
    5. // Logs, using TreeSpecies
    6. ItemStack item = new ItemStack(Material.LOG);
    7. item.setData(new Tree(TreeSpecies.BIRCH));
    8.  
    9. // Logs, using the NMS data
    10. ItemStack item = new ItemStack(Material.LOG);
    11. item.setData(new MaterialData(Material.LOG, (byte) 0x2));
    12. player.getInventory().addItem(item);


    Am I doing something wrong, or is it just plain broken?

    Also, I know that changing the damage for the item also works. It just seems like this is meant to replace that, so that the values aren't hardcoded etc.

    Bump, anyone at all able to help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page