Solved Create diorite block and spruce wood with direction

Discussion in 'Plugin Development' started by JikaiNoTsubasa, Oct 18, 2017.

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

    JikaiNoTsubasa

    Hi all,
    I'm quite new to bukkit and can't find out how to create diorite block, as I only have stone material. I saw on several threads that you have to use data but setData is deprecated in 1.10.

    In addition I'd like to place spruce wood with a specific direction, how could I manage this? Any ideas?

    Thank you in advance
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    JikaiNoTsubasa

    Thank you for the fast answer, do you have a small example as I don't know how to passe the value to MaterialData or should I use a subclass?
     
  4. Online

    timtower Administrator Administrator Moderator

  5. Offline

    JikaiNoTsubasa

    Ok but do you have a small code example?
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    JikaiNoTsubasa

    I found some examples for Trees, to have birch instead of default one by using TreeSpeces but coulnd't find yet something for diorite or stones in general.

    Should I set the byte data from MeterialData even if it's deprecated? Is it the only way?
    I was looking for something better like a subclass of Stone.
     
  8. Online

    timtower Administrator Administrator Moderator

    @JikaiNoTsubasa Diorite uses the same method.
    Yes, you should use it even if it is deprecated.
    Not everything has a subclass specific.
     
  9. Offline

    MightyOne

    Why exactly are you talking about BlocksStates? I mean Block#setData() was already the right method, even if it is deprecated.
    Also the wood direction comes with greater bytes. Like 0 - 3 is oak, spruce, birch, tropic wood (probably) and 4 - 7 oak wood etc. Better test it yourself
     
  10. Offline

    JikaiNoTsubasa

    Well, was looking for a solution to not have deprecated code.
    BTW is resolved now.
     
  11. Offline

    MrGazdag

    Code:
    Log directions: 
       Oak log:
          Normal: Material.LOG (data: 0)
          Facing west-east: Material.LOG (data: 4)
          Facing north-south: Material.LOG (data: 8)
          All sides: Material.LOG (data: 12)
       Spruce log:
          Normal: Material.LOG (data: 1)
          Facing west-east: Material.LOG (data: 5)
          Facing north-south: Material.LOG (data: 9)
          All sides: Material.LOG (data: 13)
       Birch log:
          Normal: Material.LOG (data: 2)
          Facing west-east: Material.LOG (data: 6)
          Facing north-south: Material.LOG (data: 10)
          All sides: Material.LOG (data: 14)
       Jungle log:
          Normal: Material.LOG (data: 3)
          Facing west-east: Material.LOG (data: 7)
          Facing north-south: Material.LOG (data: 11)
          All sides: Material.LOG (data: 15)
       Acacia log:
          Normal: Material.LOG_2 (data: 0)
          Facing west-east: Material.LOG_2 (data: 4)
          Facing north-south: Material.LOG_2 (data: 8)
          All sides: Material.LOG_2 (data: 12)
       Darkoak log:
          Normal: Material.LOG_2 (data: 1)
          Facing west-east: Material.LOG_2 (data: 5)
          Facing north-south: Material.LOG_2 (data: 9)
          All sides: Material.LOG_2 (data: 13)
    Hope i helped some ;)
     
    Last edited by a moderator: Oct 18, 2017
  12. Offline

    MightyOne

    Without deprecation?
     
  13. @timtower @MightyOne @JikaiNoTsubasa
    There is a reason this method is deprecated, and it's because you shouldn't use it. Using direct data values has been phased out by both Mojang and Spigot, so you should avoid using it as much as possible.

    In this case you should just use the MaterialData API with the 'Tree' subclass.
    Code:java
    1. Block block = ...
    2. block.setType(Material.LOG);
    3. BlockState state = block.getState();
    4. Tree data = new Tree();
    5. data.setSpecies(TreeSpecies.REDWOOD);
    6. data.setDirection(BlockFace.SELF);
    7. state.setData(data);
    8. state.update();
     
  14. Online

    timtower Administrator Administrator Moderator

    @AlvinB And how about stone then?
     
  15. @timtower
    Stone is one of the few materials not yet covered by the MaterialData API (although I really hope it will be soon), so for that one you're forced to use the raw data values.
     
Thread Status:
Not open for further replies.

Share This Page