How do I get the type of log?

Discussion in 'Plugin Development' started by Jakeob22, Jul 23, 2014.

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

    Jakeob22

    I have a Block that I know is a log and want to know what type of log it is. Any idea how?

    Code:java
    1. Block block = location.getBlock();
    2.  
    3. if(block.getType().equals(Material.LOG)){
    4. //get type of log?
    5. }
     
  2. Offline

    LCastr0

    Check the block data (block.getData())
     
  3. Offline

    Deleted user

    I found this, dunno if it still works (or the most efficient way to check - I think there is a way to check with daterial data)
    Code:java
    1.  
    2. @EventHandler
    3. public void onBlockBreak(BlockBreakEvent event) {
    4. if (event.getBlock().getType() == Material.LOG) {
    5. Tree log = (Tree) event.getBlock().getState().getData();
    6. if (log.getSpecies() == TreeSpecies.GENERIC) {
    7. // This is oak.
    8. } else {
    9. getLogger().info(log.getSpecies().name() + " log");
    10. }
    11. }
    12. }
    13.  
    14. [USER=90830465]metalhedd[/USER]
    15. [url]https://forums.bukkit.org/threads/get-a-specific-type-of-material-log-in-blockbreakevent.180244/[/url]
    16.  
     
Thread Status:
Not open for further replies.

Share This Page