Solved BlockBreak to ItemStack (1.19.3)

Discussion in 'Plugin Development' started by ItZ_JameZ_, Mar 12, 2023.

  1. Offline


    Hello yall I'm trying to make a method where when a Player breaks a block via BlockBreakEvent it takes the item that's gonna naturally drop and make it into a ItemStack

    Currently I'm using
        public void blockBreak(BlockBreakEvent event)
            event.getPlayer().getInventory().addItem(new ItemStack(event.getBlock().getType()));
    But if a player breaks coal ore it gives them Coal Ore instead of the coal.

    If anyone has any suggestions I would greatly appreciate any help
  2. Offline

    timtower Administrator Administrator Moderator

    Try event.getDrops() and add those to the inventory
  3. Offline


    I don’t see that method under BlockBreakEvent only a Boolean to toggled if they drop #isDropItems()
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline


    I see your using the Block class I’ll try that method when I redo it

    Edit: that worked thank you
    Last edited: Mar 13, 2023

Share This Page