Documentation

EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent
in package

Called when an entity takes damage from an entity sourced from another entity, for example being hit by a snowball thrown by a Player.

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
$childEntityEid  : 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
getChild()  : Entity|null
Returns the entity which caused the damage, or null if the entity has been killed or closed.
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

MODIFIER_PREVIOUS_DAMAGE_COOLDOWN

public mixed MODIFIER_PREVIOUS_DAMAGE_COOLDOWN = 10

MAX_EVENT_CALL_DEPTH

private mixed MAX_EVENT_CALL_DEPTH = 50

Properties

$eventName

protected string|null $eventName = null

$eventCallDepth

private static int $eventCallDepth = 1

Methods

__construct()

public __construct(Entity $damager, Entity $childEntity, Entity $entity, int $cause, float $damage[, array<string|int, float> $modifiers = [] ]) : mixed
Parameters
$damager : Entity
$childEntity : Entity
$entity : Entity
$cause : int
$damage : float
$modifiers : array<string|int, float> = []
Return values
mixed

call()

Calls event handlers registered for this event.

public call() : void
Tags
throws
RuntimeException

if event call recursion reaches the max depth limit

Return values
void

canBeReducedByArmor()

Returns whether an entity can use armour points to reduce this type of damage.

public canBeReducedByArmor() : bool
Return values
bool

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

getEventName()

public final getEventName() : string
Return values
string

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

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

Search results