Solved How to get durability of Block?

Discussion in 'Plugin Development' started by bfgbfggf, Aug 9, 2013.

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

    bfgbfggf

    I have that:
    Block block = player.getTargetBlock(null, 5);
    if (block.getType().equals(Material.COBBLE_WALL)){

    }

    But how to check if that block is Mossy Cobble Wall or normal? 139:0 or 139:1
     
  2. Offline

    xxMOxMOxx

    They have different durability values, use .getDurability
     
  3. Offline

    bfgbfggf

    Block don't have getDurability method ;/
     
  4. Offline

    xxMOxMOxx

    Oh sorry, I'm thinking about items, not blocks
     
  5. Offline

    bfgbfggf

    Hyyym... that weird... why bukkit don't have method to easy get durability of block ;/
     
  6. Offline

    etaxi341

    bfgbfggf I think it is working with the getDurability Method. Do it like this:
    Code:java
    1. block.getType().getDurability();
     
  7. Offline

    chasechocolate

    Materials don't have durability. etaxi341 use block.getData().
     
    bfgbfggf likes this.
  8. Offline

    bfgbfggf

    so block.getData() just return that durability? why is in byte? not short like in others ? :p
     
  9. Offline

    chasechocolate

    Erm...
    Code:java
    1. if(block.getType() == Material.COBBLE_WALL && block.getData() == (byte) 1){
    2.  
    3. }
     
    bfgbfggf likes this.
  10. Offline

    bfgbfggf

    I just thought that byte isn't number so I try find something what will be return short or int:D I'm idiot :)
    Thanks for help :D
     
  11. Offline

    Kiwz

    chasechocolate
    Seems like block.getData is deprecated, what to use now?

    block.getState().getData().toItemStack().getDurability()?
     
    bennie3211 likes this.
  12. Offline

    Kiwz

    ** Bump **
     
Thread Status:
Not open for further replies.

Share This Page