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

getDrops() method for BlockBreak event that takes into account tools used

XMLWordPrintable

      The EntityDeathEvent already has a getDrops method, which can be edited for completely custom drops, or to prevent certain drops from being given. However, there hasn't been (at least to my knowledge) any such method for breaking blocks that actually takes into account the tools used, and the enchantments present on said tools at the time of the event

      I know that the CraftBlock class has a method called getDrops, as well as one that takes an ItemStack parameter, but these methods are to my knowledge ONLY for skulls with player faces, and cocoa beans.

      This method could be used for editing the drops of a block without having to cache the last block a player breaks and then listening for the itemspawn event, which isn't the cleanest method out there. My personal method uses reflection and NMS references, which works but is something that I feel could be maintained by the spigot team quite easily, as it is useful for changing the output of the event

      My code:
      http://pastebin.com/Hf0911YJ

            Unassigned Unassigned
            Abs0rbed Abs0rbed
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: