Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5806

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 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: []
      

       

            Unassigned Unassigned
            brendanb8548@gmail.com Brendan Butters
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: