[SPIGOT-5806] Block#getDrops(ItemStack tool) Does not work as it should. (Only gets drops for some blocks regardless of tool) Created: 25/Jun/20  Updated: 25/Jun/20  Resolved: 25/Jun/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Brendan Butters Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: 1.16.1, drops, getDrops
Environment:

1.16.1

Windows 10


Version: git-Spigot-758abbe-38de0b8 (MC: 1.16.1)
Guidelines Read: Yes

 Description   

Ok, so Block#getDrops(ItemStack tool) should return the block drops for the said tool which I have as whatever the player is holding. When I break cobblestone, stone, and other stone-based materials the results would be the selected material even if I broke it with air/by hand and not a pickaxe. Now when I break any other block by hand or it's recommended/allowed tools that would normally result in a drop the collection of returns drops is empty with nothing in it (Items still drop).

Now this works in 1.15.2 and I've used to test this:

@EventHandler
public void onBreak(BlockBreakEvent e) {
    ItemStack hand = e.getPlayer().getInventory().getItemInMainHand();
    Collection<ItemStack> drops = e.getBlock().getDrops(hand);

    System.out.println("Hand Item: " + hand.getType());
    System.out.println("Amt of Drop Types: " + drops.size());
    System.out.println("Drops: " + e.getBlock().getDrops(hand).toString());
    for (ItemStack d : drops) {
        System.out.println("Drop: Type:" + d.getType() + " Amt: " + d.getAmount());
    }

}

Results - Stone based block

[01:22:38] [Server thread/INFO]: Hand Item: DIAMOND_PICKAXE
[01:22:38] [Server thread/INFO]: Amt of Drop Types: 1
[01:22:38] [Server thread/INFO]: Drops: [ItemStack{COBBLESTONE x 1}]
[01:22:38] [Server thread/INFO]: Drop: Type:COBBLESTONE Amt: 1

Results -  Other blocks which are not stone-based 

[01:24:21] [Server thread/INFO]: Hand Item: AIR
[01:24:21] [Server thread/INFO]: Amt of Drop Types: 0
[01:24:21] [Server thread/INFO]: Drops: []

 

If this was 1.15.2 this would not return any drops as it was mined with Air but on 1.16.1 it's returning items

[02:48:01] [Server thread/INFO]: Hand Item: AIR
[02:48:01] [Server thread/INFO]: Amt of Drop Types: 1
[02:48:01] [Server thread/INFO]: Drops: [ItemStack{COBBLESTONE x 1}]
[02:48:01] [Server thread/INFO]: Drop: Type:COBBLESTONE Amt: 1

 

If this was 1.15.2 this would return a drop of sand.

[02:52:06] [Server thread/INFO]: Hand Item: DIAMOND_SHOVEL
[02:52:06] [Server thread/INFO]: Block Broken: SAND
[02:52:06] [Server thread/INFO]: Amt of Drop Types: 0
[02:52:06] [Server thread/INFO]: Drops: []

 



 Comments   
Comment by md_5 [ 25/Jun/20 ]

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/ca19c2f48ef3a868d9f0ddfc6cf3cd312815aabf

Comment by md_5 [ 25/Jun/20 ]

I see, looks like a boolean needs inverting

Comment by Brendan Butters [ 25/Jun/20 ]

I know that setting AIR will not get the drops of items that require a tool. I'm trying to get the drops of broken blocks based off what tool they use... 

[02:48:01] [Server thread/INFO]: Hand Item: AIR
[02:48:01] [Server thread/INFO]: Amt of Drop Types: 1
[02:48:01] [Server thread/INFO]: Drops: [ItemStack{COBBLESTONE x 1}]
[02:48:01] [Server thread/INFO]: Drop: Type:COBBLESTONE Amt: 1

I understand what your saying but if I use AIR or dirt to mine cobblestone and set that as the tool it still says It will return drops of cobblestone when it should not return any drops.

Then let's say I broke sand with the tool set to a Diamond Shovel I still do not get the drops of the sand.

[02:52:06] [Server thread/INFO]: Hand Item: DIAMOND_SHOVEL
[02:52:06] [Server thread/INFO]: Block Broken: SAND
[02:52:06] [Server thread/INFO]: Amt of Drop Types: 0
[02:52:06] [Server thread/INFO]: Drops: []
Comment by md_5 [ 25/Jun/20 ]

This is correct, see
SPIGOT-5751: Made breakNaturally and getDrops returns the correct item if no argument is given
SPIGOT-5718: Block.BreakBlockNaturally does not reflect tool used

You are putting in hand item of AIR which will not cause drops on a block that requires a tool

Generated at Sat Dec 13 15:22:25 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.