[Solved] Differentiate between types of saplings?

Discussion in 'Plugin Development' started by emikodo, Oct 30, 2011.

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

    emikodo

    How do you differentiate between saplings? I know about tree.getSpecies and Material.SAPLING, but I don't see any way to get the sapling species. Any help would be appreciated!
     
  2. Offline

    Jogy34

    you have to use data values. if you are looking to switch them is would be something like this.
    Code:
    block = world.getBlockAt(x, y, z);//x, y, z is the location of the sapling
    //this next part is changing the sapling type.
    block.setTypeIdAndData(6, (byte)0, false);//Normal sapling
    block.setTypeIdAndData(6, (byte)1, false);//Pine sapling
    block.setTypeIdAndData(6, (byte)2, false);//Birtch sapling
    
     
  3. Code:java
    1. MaterialData data = block.getType().getData()
    2. if (data != null && data instanceof Tree) {
    3. Byte b = data.getSpecies().getData();
    4. }


    This should work, but I am not entirely sure.
     
  4. Offline

    emikodo

    Thank you!

    I got it to work. Thank you very much!
     
Thread Status:
Not open for further replies.

Share This Page