How can we know if material is WOOD OAK or WOOD BIRCH etc.

Discussion in 'Plugin Development' started by sbeex, Mar 29, 2012.

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

    sbeex

    Hello devs !

    I try to get the kind of wood my player break. Like white one, black one etc. but with getType() I can only compare it to Material.WOOD ... There is no distinct names for differents wood.

    Do you have any idea how I can do it ?

    Thank's in advance :)
     
  2. Offline

    arnie231

    Code:java
    1.  
    2.  
    3. int item = event.getTypeId();
    4.  
    5. if ((item == 17)) || ((item == 17:1)) || ((item == 17:2)) || ((item == 17:3))
    6. // do something
    7. [syntax][/syntax]
     
  3. Offline

    sbeex

    Thank you but it doesn't works ... event.getBlock().getTypeId() return an Integer and 17:2 will return a float or something like that I think that's why it's wrong.

    (I'm using 1.2.4 bukkit api)
     
  4. Offline

    desht

    The above code won't even compile.

    What you actually need to do is check the result of block.getData() (after you've verified that block.getType() == Material.WOOD for planks or Material.LOG for raw wood). The best reference for the data byte meanings is probably http://www.minecraftwiki.net/wiki/Data_values.
     
  5. Offline

    sbeex

    Thank you desht :) just a small question the byte value should be 0, 1, 2, 3 according to that :

    Wood textures
    0 Oak Wood
    1 Pine/Spruce Wood
    2 Birch Wood
    3 Jungle Wood

    ?

    Thank you :)
     
  6. Offline

    desht

Thread Status:
Not open for further replies.

Share This Page