hopperelec / RandomEventsPlugin

A Spigot/PaperMC plugin that causes random events to occur in the world and block/entity drops to be randomised
Creative Commons Attribution Share Alike 4.0 International
1 stars 0 forks source link

Fix BlockDropItemEvent checks #18

Closed hopperelec closed 1 year ago

hopperelec commented 1 year ago

Currently, the only check that BlockDropItemEvent does is if the player is in creative mode. I previously incorrectly assumed that the event wasn't triggered if the player uses the wrong tool, but then it would be very strange for it to still be called by creative players lol. Also, a player in creative mode can still cause a block to drop an item, such as if they break a block with a torch attached to it. I can't just check for items in event.getItems() because some item drops are randomised (such as crops) and it would also allow players to mine containers such as dispensers with their fist since they still drop their contents. I'm really unsure what the easiest solution to this would be.

hopperelec commented 1 year ago

Other things I need to take into account are explosions, leaf decay, pistons and liquid flow

hopperelec commented 1 year ago

And the doTileDrops gamerule

hopperelec commented 1 year ago

Turns out there are no loottables which never drop an item, so crops isn't an issue, and containers should be fixable, so we can check for event.getItems() being empty. However, it also turns out that while I thought BlockDropItemEvent was called separately for each part of a multi-block structure, all the drops from the multi-block structure are actually grouped together into one event meaning there isn't much reason anymore to use BlockDropItemEvent at all