feat: Add BlockDropResourcesEvent#14009
Open
EggAllocationService wants to merge 3 commits into
Open
Conversation
Contributor
|
Can confirm an event like this would fill a huge gap in the existing API, I actually brought up making this exact kind of event, though slightly differently, in the paper discord (and made the changes locally) but I never opened the PR because I wasn't sure it would be accepted. (I didn't much of a response from the paper team in the discord server.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A drawback of
BlockDropItemEventis that the list of drops provided covers all items produced during the entire neighbor update phase. As a result, if you break a block with a torch on top you get oneBlockDropItemEventwith both the block's drop and the torch.If you want to replace the dropped item, this usually wouldn't be an issue since most blocks only drop one item. If you wanted to replace what torches drop via a plugin you'd just replace all instances of
Material.TORCHin allBlockDropItemsEvent.A problem arises if vanilla loot tables have been modified via a datapack: It may not be possible to look at the list of drops from the entire update chain and determine what blocks dropped items and which drops belong to which block. For example, a block may drop multiple items picked from a random list.
BlockDropResourcesEventis called from withinBlock.dropResourcesand so will capture the exact list of drops generated for each individual block being broken, whether it was broken directly by a player or indirectly. Without this event, the best a plugin could do would be replacing all of the drops in an update chain with the replacement(s) for just the initial block that was broken.