EntityDamageByEntityEvent
extends EntityDamageEvent
in package
Called when an entity takes damage from another entity.
Table of Contents
- CAUSE_BLOCK_EXPLOSION = 9
- CAUSE_CONTACT = 0
- CAUSE_CUSTOM = 14
- CAUSE_DROWNING = 8
- CAUSE_ENTITY_ATTACK = 1
- CAUSE_ENTITY_EXPLOSION = 10
- CAUSE_FALL = 4
- CAUSE_FIRE = 5
- CAUSE_FIRE_TICK = 6
- CAUSE_LAVA = 7
- CAUSE_MAGIC = 13
- CAUSE_PROJECTILE = 2
- CAUSE_STARVATION = 15
- CAUSE_SUFFOCATION = 3
- CAUSE_SUICIDE = 12
- CAUSE_VOID = 11
- MODIFIER_ABSORPTION = 5
- MODIFIER_ARMOR = 1
- MODIFIER_ARMOR_ENCHANTMENTS = 6
- MODIFIER_CRITICAL = 7
- MODIFIER_PREVIOUS_DAMAGE_COOLDOWN = 10
- MODIFIER_RESISTANCE = 4
- MODIFIER_STRENGTH = 2
- MODIFIER_TOTEM = 8
- MODIFIER_WEAKNESS = 3
- MODIFIER_WEAPON_ENCHANTMENTS = 9
- MAX_EVENT_CALL_DEPTH = 50
- $entity : Entity
- $eventName : string|null
- $attackCooldown : int
- $baseDamage : float
- $cause : int
- $damagerEntityId : int
- $eventCallDepth : int
- $isCancelled : bool
- $knockBack : float
- $modifiers : array<string|int, float>
- $originalBase : float
- $originals : array<string|int, float>
- __construct() : mixed
- call() : void
- Calls event handlers registered for this event.
- canBeReducedByArmor() : bool
- Returns whether an entity can use armour points to reduce this type of damage.
- cancel() : void
- getAttackCooldown() : int
- Returns the cooldown in ticks before the target entity can be attacked again.
- getBaseDamage() : float
- Returns the base amount of damage applied, before modifiers.
- getCause() : int
- getDamager() : Entity|null
- Returns the attacking entity, or null if the attacker has been killed or closed.
- getEntity() : Entity
- getEventName() : string
- getFinalDamage() : float
- getKnockBack() : float
- getModifier() : float
- getModifiers() : array<string|int, float>
- getOriginalBaseDamage() : float
- Returns the original base amount of damage applied, before alterations by plugins.
- getOriginalModifier() : float
- getOriginalModifiers() : array<string|int, float>
- isApplicable() : bool
- isCancelled() : bool
- setAttackCooldown() : void
- Sets the cooldown in ticks before the target entity can be attacked again.
- setBaseDamage() : void
- Sets the base amount of damage applied, optionally recalculating modifiers.
- setKnockBack() : void
- setModifier() : void
- uncancel() : void
- addAttackerModifiers() : void
Constants
CAUSE_BLOCK_EXPLOSION
public
mixed
CAUSE_BLOCK_EXPLOSION
= 9
CAUSE_CONTACT
public
mixed
CAUSE_CONTACT
= 0
CAUSE_CUSTOM
public
mixed
CAUSE_CUSTOM
= 14
CAUSE_DROWNING
public
mixed
CAUSE_DROWNING
= 8
CAUSE_ENTITY_ATTACK
public
mixed
CAUSE_ENTITY_ATTACK
= 1
CAUSE_ENTITY_EXPLOSION
public
mixed
CAUSE_ENTITY_EXPLOSION
= 10
CAUSE_FALL
public
mixed
CAUSE_FALL
= 4
CAUSE_FIRE
public
mixed
CAUSE_FIRE
= 5
CAUSE_FIRE_TICK
public
mixed
CAUSE_FIRE_TICK
= 6
CAUSE_LAVA
public
mixed
CAUSE_LAVA
= 7
CAUSE_MAGIC
public
mixed
CAUSE_MAGIC
= 13
CAUSE_PROJECTILE
public
mixed
CAUSE_PROJECTILE
= 2
CAUSE_STARVATION
public
mixed
CAUSE_STARVATION
= 15
CAUSE_SUFFOCATION
public
mixed
CAUSE_SUFFOCATION
= 3
CAUSE_SUICIDE
public
mixed
CAUSE_SUICIDE
= 12
CAUSE_VOID
public
mixed
CAUSE_VOID
= 11
MODIFIER_ABSORPTION
public
mixed
MODIFIER_ABSORPTION
= 5
MODIFIER_ARMOR
public
mixed
MODIFIER_ARMOR
= 1
MODIFIER_ARMOR_ENCHANTMENTS
public
mixed
MODIFIER_ARMOR_ENCHANTMENTS
= 6
MODIFIER_CRITICAL
public
mixed
MODIFIER_CRITICAL
= 7
MODIFIER_PREVIOUS_DAMAGE_COOLDOWN
public
mixed
MODIFIER_PREVIOUS_DAMAGE_COOLDOWN
= 10
MODIFIER_RESISTANCE
public
mixed
MODIFIER_RESISTANCE
= 4
MODIFIER_STRENGTH
public
mixed
MODIFIER_STRENGTH
= 2
MODIFIER_TOTEM
public
mixed
MODIFIER_TOTEM
= 8
MODIFIER_WEAKNESS
public
mixed
MODIFIER_WEAKNESS
= 3
MODIFIER_WEAPON_ENCHANTMENTS
public
mixed
MODIFIER_WEAPON_ENCHANTMENTS
= 9
MAX_EVENT_CALL_DEPTH
private
mixed
MAX_EVENT_CALL_DEPTH
= 50
Properties
$entity
protected
Entity
$entity
Tags
$eventName
protected
string|null
$eventName
= null
$attackCooldown
private
int
$attackCooldown
= 10
$baseDamage
private
float
$baseDamage
$cause
private
int
$cause
$damagerEntityId
private
int
$damagerEntityId
$eventCallDepth
private
static int
$eventCallDepth
= 1
$isCancelled
private
bool
$isCancelled
= false
$knockBack
private
float
$knockBack
$modifiers
private
array<string|int, float>
$modifiers
$originalBase
private
float
$originalBase
$originals
private
array<string|int, float>
$originals
Methods
__construct()
public
__construct(Entity $damager, Entity $entity, int $cause, float $damage[, array<string|int, float> $modifiers = [] ][, float $knockBack = 0.4 ]) : mixed
Parameters
- $damager : Entity
- $entity : Entity
- $cause : int
- $damage : float
- $modifiers : array<string|int, float> = []
- $knockBack : float = 0.4
Return values
mixed —call()
Calls event handlers registered for this event.
public
call() : void
Tags
Return values
void —canBeReducedByArmor()
Returns whether an entity can use armour points to reduce this type of damage.
public
canBeReducedByArmor() : bool
Return values
bool —cancel()
public
cancel() : void
Return values
void —getAttackCooldown()
Returns the cooldown in ticks before the target entity can be attacked again.
public
getAttackCooldown() : int
Return values
int —getBaseDamage()
Returns the base amount of damage applied, before modifiers.
public
getBaseDamage() : float
Return values
float —getCause()
public
getCause() : int
Return values
int —getDamager()
Returns the attacking entity, or null if the attacker has been killed or closed.
public
getDamager() : Entity|null
Return values
Entity|null —getEntity()
public
getEntity() : Entity
Tags
Return values
Entity —getEventName()
public
final getEventName() : string
Return values
string —getFinalDamage()
public
getFinalDamage() : float
Return values
float —getKnockBack()
public
getKnockBack() : float
Return values
float —getModifier()
public
getModifier(int $type) : float
Parameters
- $type : int
Return values
float —getModifiers()
public
getModifiers() : array<string|int, float>
Return values
array<string|int, float> —getOriginalBaseDamage()
Returns the original base amount of damage applied, before alterations by plugins.
public
getOriginalBaseDamage() : float
Return values
float —getOriginalModifier()
public
getOriginalModifier(int $type) : float
Parameters
- $type : int
Return values
float —getOriginalModifiers()
public
getOriginalModifiers() : array<string|int, float>
Return values
array<string|int, float> —isApplicable()
public
isApplicable(int $type) : bool
Parameters
- $type : int
Return values
bool —isCancelled()
public
isCancelled() : bool
Return values
bool —setAttackCooldown()
Sets the cooldown in ticks before the target entity can be attacked again.
public
setAttackCooldown(int $attackCooldown) : void
NOTE: This value is not used in non-Living entities
Parameters
- $attackCooldown : int
Return values
void —setBaseDamage()
Sets the base amount of damage applied, optionally recalculating modifiers.
public
setBaseDamage(float $damage) : void
TODO: add ability to recalculate modifiers when this is set
Parameters
- $damage : float
Return values
void —setKnockBack()
public
setKnockBack(float $knockBack) : void
Parameters
- $knockBack : float
Return values
void —setModifier()
public
setModifier(float $damage, int $type) : void
Parameters
- $damage : float
- $type : int
Return values
void —uncancel()
public
uncancel() : void
Return values
void —addAttackerModifiers()
protected
addAttackerModifiers(Entity $damager) : void
Parameters
- $damager : Entity