How to use MaterialData

Discussion in 'Spigot Plugin Help' started by Quaiby, Jun 26, 2016.

  1. I want to when player breaks block, block immediately went to inventory.
    But i have this:
    public void onPlayerBreakBlock(BlockBreakEvent event) {
    new ItemStack(event.getBlock().getType(), 1).setData(event.getBlock().getData()));
    And my IntelliJ IDEA tells me what selected code is deprecated, and value needed to setData isn't equals to getted in getData(), but in JavaDoc ( tells me what all right.
  2. Instead of that, do event.getPlayer().getInventory().addItem(event.getBlock().getDrops(event.getPlayer().getInventory().getItem(event.getPlayer().getInventory().getHeldItemSlot()));

    Remember to cancel the event.
  3. Thanks