| Name | player tries to attack entity |
| Event Lines | player tries to attack <entity> |
| Triggers | when the player tries to attack an entity. This occurs before any of the damage logic, so cancelling this event will prevent any sort of sounds from being played when attacking. |
| Generated Examples | after player tries to attack entity:
on player tries to attack entity: |
| Has Player | Always. - this adds switches 'flagged:<flag name>' + 'permission:<node>', in addition to the '<player>' link. |
| Switches | with:<item> to only process the event if the player attacks the entity with the specified item. |
| Contexts | <context.entity> returns the entity that was attacked in this event.
<context.will_attack> returns whether this entity would be attacked normally.
Entities like falling sand will return false because their entity type does not allow them to be attacked.
Note: there may be other factors (invulnerability, etc.) that will prevent this entity from being attacked that this event does not cover.
|
| Cancellable | True - This adds <context.cancelled> and determine 'cancelled' or 'cancelled:false' |
| Group | Paper |
| Requires | Paper |
| Source | https://github.com/DenizenScript/Denizen/blob/dev/paper/src/main/java/com/denizenscript/denizen/paper/events/PrePlayerAttackEntityScriptEvent.java#L16 |