Block#getDrops(ItemStack tool) Does not work as it should. (Only gets drops for some blocks regardless of tool)

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • Environment:

      1.16.1

      Windows 10

    • git-Spigot-758abbe-38de0b8 (MC: 1.16.1)
    • Yes

      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: []
      

       

          [SPIGOT-5806] Block#getDrops(ItemStack tool) Does not work as it should. (Only gets drops for some blocks regardless of tool)

          md_5 added a comment - https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/ca19c2f48ef3a868d9f0ddfc6cf3cd312815aabf

          md_5 added a comment -

          I see, looks like a boolean needs inverting

          md_5 added a comment - I see, looks like a boolean needs inverting

          Brendan Butters added a comment - - edited

          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: []
          

          Brendan Butters added a comment - - edited 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: []

          md_5 added a comment -

          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

          md_5 added a comment - 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

            Assignee:
            Unassigned
            Reporter:
            Brendan Butters
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: