How to set sapling species? [Solved]

Discussion in 'Spigot Plugin Development' started by dark4rr0w, Jul 3, 2015.

  1. Hi all. I'm having a problem with setting a sapling species.
    Code (Text):

    BlockState state =l.getBlock().getState();
                   MaterialData data = state.getData().clone();
                   data.setData(l.getBlock().getState().getData().getData());
                   Block a=l.getWorld().getHighestBlockAt(l);
                   a.setType(Material.SAPLING);
                   a.getState().getData().setData(data.getData());
                   a.getState().update();
     
    The l.getBlock() is a log and i want to plant a sapling depending on that log's data. What am I doing wrong? I know that data returns actual data value, but when i make this data sapling's data, it returns 0 after i use
    Code (Text):
    p.sendMessage(a.getState().getData().toString());
     
  2. Never mind fixed it by replacing:
    Code (Text):
    a.getState().getData().setData(data.getData());
    with
    Code (Text):
    a.setData(data.getData());