Solved Bukkit Drop Item With DataValue

Discussion in 'Plugin Development' started by AngryCupcake274, Dec 28, 2014.

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

    AngryCupcake274

    Hello all,
    I am creating a plugin that sends the blocks that you are mining to your inventory, but if I mine a flower, it gives the flower id with no damage value. Is there a way to get the data value of a block mined (17:1) and drop that item (17:1) as opposed to (17:0)?

    Thanks all,
    me
     
  2. Offline

    mythbusterma

    @AngryCupcake274

    Get the data of the block, set the data of the drop to that value.
     
  3. Offline

    AngryCupcake274

    @mythbusterma I though I tried that! Sorry for taking your time, I thought I had done ".getData()" before.
     
  4. Offline

    WarmakerT

    Try this.
    Code:
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event) {
            event.getBlock().getDrops().clear();
            for(ItemStack is : event.getBlock().getDrops()) {
                HashMap<Integer, ItemStack> rest = event.getPlayer().getInventory().addItem(is);
                if(!rest.isEmpty()) {
                    for(int i = 0; i <= rest.size(); i++) {
                        event.getBlock().getDrops().add(rest.get(i));
                    }
                }
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page