Paper icon indicating copy to clipboard operation
Paper copied to clipboard

PlayerItemDamageEvent cause

Open Vrganj opened this issue 2 years ago • 1 comments

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

Vrganj avatar Jun 09 '23 12:06 Vrganj

Somewhat related to https://github.com/PaperMC/Paper/issues/8751, idk if we need both issues open.

lynxplay avatar Jun 09 '23 15:06 lynxplay

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.

Machine-Maker avatar Jun 12 '23 02:06 Machine-Maker