Get the block data, and set it in an ItemStacl

Discussion in 'Plugin Development' started by Maximvdw, Jan 19, 2014.

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

    Maximvdw

    Hello,

    I want to get the block data of (any block that has data, leaves, wool, colored clay ,..) and set it to an itemstack:
    This works, but "block.getData()" is deprecated, and I don't know the new solution:
    myitem = new ItemStack(block.getType());
    myitem.setDurability(block.getData());

    Best Regards,
    Maximvdw

    Ok found the solution:
    block.getState().getData().toItemStack(1);
    I tried
    block.getState().getData().toItemStack();
    before, but I coudn't pick the item up. I went in the source, and this function is 0 as default.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page