This repository was archived by the owner on Jun 3, 2024. It is now read-only.
Implement the LivingDropsEvent event #96
Merged
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.
Required for Curios, see #84.
This PR is largely comprised of two parts:
Firstly, it implements
Entity.captureDrops
in thepatchwork-extensions
module. This is a collection that can be set on an entity that will redirect all theItemEntity
s it would otherwise drop on the ground into said collection.The second part (in the second commit) adds to
LivingEntity
to use this mechanism to catch all the items the LivingEntity drops when it dies, and pass it through an event to let mods alter the dropped items. Finally it spawns them if the event wasn't cancelled.Note that the second part creates a dependency from
patchwork-events-entity
topatchwork-extensions
, however it seemed like the most logical place to put both parts.The second part does involve some hackery to access the looting level after the local variable has been dropped, passing it through a field (described in a JavaDoc comment). I could just call
EnchantmentHelper.getLooting
again, but we'd have to use this method anyway when we implementLootingLevelEvent
.