Paper
Paper copied to clipboard
PlayerItemDamageEvent cause
Is your feature request related to a problem?
PlayerItemDamageEvent should have some of getCause method.
That way you could e.g. cancel axe damage for PvP, but not for mining.
Describe the solution you'd like.
The solution would be to just add an enum ItemDamageCause with the possible causes for item damage.
Causes would be ENTITY, BLOCK, CUSTOM, PLUGIN, UNKNOWN.
Describe alternatives you've considered.
You can achieve something similar using EntityDamageByEntityEvent, BlockBreakEvent and a map, but that seems hacky.
Other
No response
Somewhat related to https://github.com/PaperMC/Paper/issues/8751, idk if we need both issues open.
I think they can both remain open as they are asking for different things, but like the other issue, this would require a rather large refactor of how itemstack's are damaged, as currently that info isn't available where the event is called.