Skip to content

EntityDamageEvent ​

class · pocketmine\event\entity\EntityDamageEvent · source

Extends EntityEvent
Implements Cancellable

Called when an entity takes damage.

Constants ​

CAUSE_BLOCK_EXPLOSION ​

php
public const CAUSE_BLOCK_EXPLOSION = 9

CAUSE_CONTACT ​

php
public const CAUSE_CONTACT = 0

CAUSE_CUSTOM ​

php
public const CAUSE_CUSTOM = 14

CAUSE_DROWNING ​

php
public const CAUSE_DROWNING = 8

CAUSE_ENTITY_ATTACK ​

php
public const CAUSE_ENTITY_ATTACK = 1

CAUSE_ENTITY_EXPLOSION ​

php
public const CAUSE_ENTITY_EXPLOSION = 10

CAUSE_FALL ​

php
public const CAUSE_FALL = 4

CAUSE_FALLING_BLOCK ​

php
public const CAUSE_FALLING_BLOCK = 16

CAUSE_FIRE ​

php
public const CAUSE_FIRE = 5

CAUSE_FIRE_TICK ​

php
public const CAUSE_FIRE_TICK = 6

CAUSE_FLY_INTO_WALL 5.46.0 ​

php
public const CAUSE_FLY_INTO_WALL = 17

Flying into a wall while gliding with an elytra (kinetic energy).

CAUSE_FREEZE 5.46.0 ​

php
public const CAUSE_FREEZE = 19

Freezing in powder snow.

CAUSE_LAVA ​

php
public const CAUSE_LAVA = 7

CAUSE_LIGHTNING 5.46.0 ​

php
public const CAUSE_LIGHTNING = 18

Struck by a lightning bolt.

CAUSE_MAGIC ​

php
public const CAUSE_MAGIC = 13

CAUSE_PROJECTILE ​

php
public const CAUSE_PROJECTILE = 2

CAUSE_STARVATION ​

php
public const CAUSE_STARVATION = 15

CAUSE_SUFFOCATION ​

php
public const CAUSE_SUFFOCATION = 3

CAUSE_SUICIDE ​

php
public const CAUSE_SUICIDE = 12

CAUSE_VOID ​

php
public const CAUSE_VOID = 11

MODIFIER_ABSORPTION ​

php
public const MODIFIER_ABSORPTION = 5

MODIFIER_ARMOR ​

php
public const MODIFIER_ARMOR = 1

MODIFIER_ARMOR_ENCHANTMENTS ​

php
public const MODIFIER_ARMOR_ENCHANTMENTS = 6

MODIFIER_ARMOR_HELMET ​

php
public const MODIFIER_ARMOR_HELMET = 11

MODIFIER_CRITICAL ​

php
public const MODIFIER_CRITICAL = 7

MODIFIER_PREVIOUS_DAMAGE_COOLDOWN ​

php
public const MODIFIER_PREVIOUS_DAMAGE_COOLDOWN = 10

MODIFIER_RESISTANCE ​

php
public const MODIFIER_RESISTANCE = 4

MODIFIER_SMASH 5.46.0 ​

php
public const MODIFIER_SMASH = 12

Extra damage of a mace smash attack (fall distance and Density).

MODIFIER_STRENGTH ​

php
public const MODIFIER_STRENGTH = 2

MODIFIER_TOTEM ​

php
public const MODIFIER_TOTEM = 8

MODIFIER_WEAKNESS ​

php
public const MODIFIER_WEAKNESS = 3

MODIFIER_WEAPON_ENCHANTMENTS ​

php
public const MODIFIER_WEAPON_ENCHANTMENTS = 9

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Entity $entity, int $cause, float $damage, array $modifiers = [])

canBeReducedByArmor() ​

php
public function canBeReducedByArmor() : bool

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

getAttackCooldown() ​

php
public function getAttackCooldown() : int

Returns the cooldown in ticks before the target entity can be attacked again.

getBaseDamage() ​

php
public function getBaseDamage() : float

Returns the base amount of damage applied, before modifiers.

getCause() ​

php
public function getCause() : int

getFinalDamage() ​

php
public function getFinalDamage() : float

getModifier() ​

php
public function getModifier(int $type) : float

getModifiers() ​

php
public function getModifiers() : array

getOriginalBaseDamage() ​

php
public function getOriginalBaseDamage() : float

Returns the original base amount of damage applied, before alterations by plugins.

getOriginalModifier() ​

php
public function getOriginalModifier(int $type) : float

getOriginalModifiers() ​

php
public function getOriginalModifiers() : array

isApplicable() ​

php
public function isApplicable(int $type) : bool

setAttackCooldown() ​

php
public function setAttackCooldown(int $attackCooldown) : void

Sets the cooldown in ticks before the target entity can be attacked again.

NOTE: This value is not used in non-Living entities

setBaseDamage() ​

php
public function setBaseDamage(float $damage) : void

Sets the base amount of damage applied, optionally recalculating modifiers.

TODO: add ability to recalculate modifiers when this is set

setModifier() ​

php
public function setModifier(float $damage, int $type) : void

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.