API reference / @jsprismarine/prismarine / Events / EntityDamageEvent
Class: EntityDamageEvent
Defined in: prismarine/src/events/entity/EntityDamageEvent.ts:14
Fired just before an entity is hurt, and before anything has been taken off its health.
Cancellable, and the amount is writable, so a plugin can make a region safe or a mob tougher without having to intercept every source of damage separately. The amount here is the raw blow: armor, enchantments and resistance have not been applied yet, which is what makes it the useful number to change - doubling it doubles the hit as a player would understand it, rather than undoing whatever their armor was about to do.
Extends
Constructors
Constructor
new EntityDamageEvent(
entity,amount,source):EntityDamageEvent
Defined in: prismarine/src/events/entity/EntityDamageEvent.ts:19
Parameters
entity
amount
number
source
DamageSource
Returns
EntityDamageEvent
Overrides
Methods
getAmount()
getAmount():
number
Defined in: prismarine/src/events/entity/EntityDamageEvent.ts:33
The blow, before any reduction.
Returns
number
getEntity()
getEntity():
Entity
Defined in: prismarine/src/events/entity/EntityDamageEvent.ts:28
Who is being hurt.
Returns
getSource()
getSource():
DamageSource
Defined in: prismarine/src/events/entity/EntityDamageEvent.ts:46
What did it, and who is answerable for it.
Returns
DamageSource
isCanceled()
isCanceled():
boolean
Defined in: prismarine/src/events/Event.ts:12
Is the event canceled
Returns
boolean
Whether the event is canceled
Inherited from
preventDefault()
preventDefault():
void
Defined in: prismarine/src/events/Event.ts:19
Cancel the event
Returns
void
Inherited from
setAmount()
setAmount(
amount):void
Defined in: prismarine/src/events/entity/EntityDamageEvent.ts:41
Change the blow.
Parameters
amount
number
The new amount; anything at or below zero cancels the hit outright.
Returns
void