
Drawers destroyed by explosions drop nothing
saltyseadoggo opened this issue ยท 0 comments
The problem
Drawers that are destroyed by anything other than a player do not drop themselves or their contents. This notably means creepers, TNT, ghasts, withers and their ilk can completely destroy thousands of items if they happen to break a drawer.
Code analysis
The drawers' drops are managed by an onBreak method in BlockAbstractDrawer.java, but this method seems to only be called when a player breaks the drawer. This method could be replaced with an onStateReplaced method to match the vanilla barrel, but then players in Creative mode would receive the drawer drop. To fix this, you would need to make the drawers' dropping of themselves be managed by loot tables instead of hard-coded functions, as this inherently handles Creative mode players.
Suggested solution
If you know the exact tag names that are applied to drawer items, the set_nbt function in loot tables can apply these tags to drawers' drops. Then you can make all drawers use loot tables instead of hard-coded drops, which would [1] let explosions drop the drawers, and [2] remove the roadblock to replacing onBreak with onStateReplaced to allow the drawers to drop their inventory when broken by explosions as well.