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

Add some way to get the drops caused by a broken block

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 1.13.1
    • Yes

      Hello,

      I need a way to get all drops caused by a block break, for example if a torch is placed on top of a stone block, I need both drops, the stone drop and the torch drop. This also needs to respect if the block was mined with silktouch, fortune, bare hand or something else. The BlockBreakEvent can't give away this information, because it is called before the breaking calculation. If my understanding of the Code is correct, the thing I need is already in the PlayerInteractManager, (Decompiled Lines 315 to 326 in Method public boolean breakBlock(BlockPosition))

      this.world.captureDrops = new ArrayList();
      boolean flag = this.c(blockposition);
      if (event.isDropItems()) {
          Iterator var21 = this.world.captureDrops.iterator();
      
          while(var21.hasNext()) {
              EntityItem item = (EntityItem)var21.next();
              this.world.addEntity(item);
          }
      }
      
      this.world.captureDrops = null;
      

      this.world.captureDrops seems to store all drops caused by the block to break, so they can be prevented dropping, if isDropItems was set to false. It would be awesome if some sort of event could be added on this place, something like BlockBreakDropItemsEvent(Player, Block, List<Items>), to access the excact drops caused by the breaking of this block.

       

      Best regards

            Unassigned Unassigned
            AndaBlock Anda Block
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: