Get Type of log in player inventory.

Discussion in 'Plugin Development' started by hubeb, May 25, 2013.

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

    hubeb

    Hello im trying to get the type of log within a players inventory.
    (ex. Inventory contains SPRUCE LOG which equals byte 2 (17:2))
    How would I get the byte?
    I need to remove a certain type of log from a players inventory by using the byte, which i cant seem to get.

    Code:
    ItemStack pLog = new ItemStack(Material.LOG, 1);
            pLog.getType().getData();
    returns: GENERIC UP LOG(0)


    Thanks
    Hubeb
     
  2. Offline

    Jogy34

    I've had issues with this in the past and actually made this mistake a few days ago when I couldn't figure out why an items data value wouldn't equal 2 I think. I was using itemStack.getData(). The problem with that is that getData() returns a MaterialData object which isn't just the number that represents the items data value. To get that you have to do pLog.getData().getData(). That will return a byte and if it is a spruce log it should return 2 if that is the correct data value.
     
  3. Offline

    hubeb

    ok ill give it a try and let you know, thanks.
     
Thread Status:
Not open for further replies.

Share This Page