PocketMine-MP 5.14.2 git-50e2c469a547a16a23b2dc691e70a51d34e29395
pocketmine\event\entity\EntityDamageEvent Class Reference
+ Inheritance diagram for pocketmine\event\entity\EntityDamageEvent:
+ Collaboration diagram for pocketmine\event\entity\EntityDamageEvent:

Public Member Functions

 __construct (Entity $entity, private int $cause, float $damage, private array $modifiers=[])
 
 call ()
 
 canBeReducedByArmor ()
 
 getAttackCooldown ()
 
 getBaseDamage ()
 
 getCause ()
 
 getEntity ()
 
 getEventName ()
 
 getFinalDamage ()
 
 getModifier (int $type)
 
 getModifiers ()
 
 getOriginalBaseDamage ()
 
 getOriginalModifier (int $type)
 
 getOriginalModifiers ()
 
 isApplicable (int $type)
 
 isCancelled ()
 
 setAttackCooldown (int $attackCooldown)
 
 setBaseDamage (float $damage)
 
 setModifier (float $damage, int $type)
 

Static Public Member Functions

static hasHandlers ()
 

Public Attributes

const CAUSE_BLOCK_EXPLOSION = 9
 
const CAUSE_CONTACT = 0
 
const CAUSE_CUSTOM = 14
 
const CAUSE_DROWNING = 8
 
const CAUSE_ENTITY_ATTACK = 1
 
const CAUSE_ENTITY_EXPLOSION = 10
 
const CAUSE_FALL = 4
 
const CAUSE_FALLING_BLOCK = 16
 
const CAUSE_FIRE = 5
 
const CAUSE_FIRE_TICK = 6
 
const CAUSE_LAVA = 7
 
const CAUSE_MAGIC = 13
 
const CAUSE_PROJECTILE = 2
 
const CAUSE_STARVATION = 15
 
const CAUSE_SUFFOCATION = 3
 
const CAUSE_SUICIDE = 12
 
const CAUSE_VOID = 11
 
const MODIFIER_ABSORPTION = 5
 
const MODIFIER_ARMOR = 1
 
const MODIFIER_ARMOR_ENCHANTMENTS = 6
 
const MODIFIER_ARMOR_HELMET = 11
 
const MODIFIER_CRITICAL = 7
 
const MODIFIER_PREVIOUS_DAMAGE_COOLDOWN = 10
 
const MODIFIER_RESISTANCE = 4
 
const MODIFIER_STRENGTH = 2
 
const MODIFIER_TOTEM = 8
 
const MODIFIER_WEAKNESS = 3
 
const MODIFIER_WEAPON_ENCHANTMENTS = 9
 

Protected Attributes

Entity $entity
 
string $eventName = null
 

Detailed Description

Called when an entity takes damage. @phpstan-extends EntityEvent<Entity>

Definition at line 36 of file EntityDamageEvent.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\event\entity\EntityDamageEvent::__construct ( Entity  $entity,
private int  $cause,
float  $damage,
private array  $modifiers = [] 
)
Parameters
float[]$modifiers

Definition at line 79 of file EntityDamageEvent.php.

References pocketmine\event\entity\EntityEvent\$entity.

Member Function Documentation

◆ call()

pocketmine\event\Event::call ( )
inherited

Calls event handlers registered for this event.

Exceptions

RuntimeException if event call recursion reaches the max depth limit

Definition at line 49 of file Event.php.

◆ canBeReducedByArmor()

pocketmine\event\entity\EntityDamageEvent::canBeReducedByArmor ( )

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

Definition at line 154 of file EntityDamageEvent.php.

◆ getAttackCooldown()

pocketmine\event\entity\EntityDamageEvent::getAttackCooldown ( )

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

Definition at line 174 of file EntityDamageEvent.php.

◆ getBaseDamage()

pocketmine\event\entity\EntityDamageEvent::getBaseDamage ( )

Returns the base amount of damage applied, before modifiers.

Definition at line 97 of file EntityDamageEvent.php.

Referenced by pocketmine\entity\Living\applyDamageModifiers(), and pocketmine\entity\Living\applyPostDamageEffects().

+ Here is the caller graph for this function:

◆ getCause()

pocketmine\event\entity\EntityDamageEvent::getCause ( )

Definition at line 90 of file EntityDamageEvent.php.

◆ getEntity()

◆ getEventName()

pocketmine\event\Event::getEventName ( )
finalinherited

Definition at line 40 of file Event.php.

◆ getFinalDamage()

pocketmine\event\entity\EntityDamageEvent::getFinalDamage ( )

Definition at line 147 of file EntityDamageEvent.php.

◆ getModifier()

pocketmine\event\entity\EntityDamageEvent::getModifier ( int  $type)

Definition at line 135 of file EntityDamageEvent.php.

◆ getModifiers()

pocketmine\event\entity\EntityDamageEvent::getModifiers ( )
Returns
float[]

Definition at line 131 of file EntityDamageEvent.php.

◆ getOriginalBaseDamage()

pocketmine\event\entity\EntityDamageEvent::getOriginalBaseDamage ( )

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

Definition at line 113 of file EntityDamageEvent.php.

◆ getOriginalModifier()

pocketmine\event\entity\EntityDamageEvent::getOriginalModifier ( int  $type)

Definition at line 124 of file EntityDamageEvent.php.

◆ getOriginalModifiers()

pocketmine\event\entity\EntityDamageEvent::getOriginalModifiers ( )
Returns
float[]

Definition at line 120 of file EntityDamageEvent.php.

◆ hasHandlers()

static pocketmine\event\Event::hasHandlers ( )
staticinherited

Returns whether the current class context has any registered global handlers. This can be used in hot code paths to avoid unnecessary event object creation.

Usage: SomeEventClass::hasHandlers()

Definition at line 77 of file Event.php.

◆ isApplicable()

pocketmine\event\entity\EntityDamageEvent::isApplicable ( int  $type)

Definition at line 143 of file EntityDamageEvent.php.

◆ isCancelled()

pocketmine\event\Cancellable::isCancelled ( )
inherited

Returns whether this instance of the event is currently cancelled.

If it is cancelled, only downstream handlers that declare @handleCancelled will be called with this event.

◆ setAttackCooldown()

pocketmine\event\entity\EntityDamageEvent::setAttackCooldown ( int  $attackCooldown)

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

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

Definition at line 183 of file EntityDamageEvent.php.

◆ setBaseDamage()

pocketmine\event\entity\EntityDamageEvent::setBaseDamage ( float  $damage)

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

TODO: add ability to recalculate modifiers when this is set

Definition at line 106 of file EntityDamageEvent.php.

◆ setModifier()

pocketmine\event\entity\EntityDamageEvent::setModifier ( float  $damage,
int  $type 
)

Definition at line 139 of file EntityDamageEvent.php.

Member Data Documentation

◆ $entity

◆ $eventName

string pocketmine\event\Event::$eventName = null
protectedinherited

Definition at line 38 of file Event.php.

◆ CAUSE_BLOCK_EXPLOSION

const pocketmine\event\entity\EntityDamageEvent::CAUSE_BLOCK_EXPLOSION = 9

Definition at line 60 of file EntityDamageEvent.php.

◆ CAUSE_CONTACT

const pocketmine\event\entity\EntityDamageEvent::CAUSE_CONTACT = 0

Definition at line 51 of file EntityDamageEvent.php.

◆ CAUSE_CUSTOM

const pocketmine\event\entity\EntityDamageEvent::CAUSE_CUSTOM = 14

Definition at line 65 of file EntityDamageEvent.php.

◆ CAUSE_DROWNING

const pocketmine\event\entity\EntityDamageEvent::CAUSE_DROWNING = 8

Definition at line 59 of file EntityDamageEvent.php.

◆ CAUSE_ENTITY_ATTACK

const pocketmine\event\entity\EntityDamageEvent::CAUSE_ENTITY_ATTACK = 1

Definition at line 52 of file EntityDamageEvent.php.

◆ CAUSE_ENTITY_EXPLOSION

const pocketmine\event\entity\EntityDamageEvent::CAUSE_ENTITY_EXPLOSION = 10

Definition at line 61 of file EntityDamageEvent.php.

◆ CAUSE_FALL

const pocketmine\event\entity\EntityDamageEvent::CAUSE_FALL = 4

Definition at line 55 of file EntityDamageEvent.php.

◆ CAUSE_FALLING_BLOCK

const pocketmine\event\entity\EntityDamageEvent::CAUSE_FALLING_BLOCK = 16

Definition at line 67 of file EntityDamageEvent.php.

◆ CAUSE_FIRE

const pocketmine\event\entity\EntityDamageEvent::CAUSE_FIRE = 5

Definition at line 56 of file EntityDamageEvent.php.

◆ CAUSE_FIRE_TICK

const pocketmine\event\entity\EntityDamageEvent::CAUSE_FIRE_TICK = 6

Definition at line 57 of file EntityDamageEvent.php.

◆ CAUSE_LAVA

const pocketmine\event\entity\EntityDamageEvent::CAUSE_LAVA = 7

Definition at line 58 of file EntityDamageEvent.php.

◆ CAUSE_MAGIC

const pocketmine\event\entity\EntityDamageEvent::CAUSE_MAGIC = 13

Definition at line 64 of file EntityDamageEvent.php.

◆ CAUSE_PROJECTILE

const pocketmine\event\entity\EntityDamageEvent::CAUSE_PROJECTILE = 2

Definition at line 53 of file EntityDamageEvent.php.

◆ CAUSE_STARVATION

const pocketmine\event\entity\EntityDamageEvent::CAUSE_STARVATION = 15

Definition at line 66 of file EntityDamageEvent.php.

◆ CAUSE_SUFFOCATION

const pocketmine\event\entity\EntityDamageEvent::CAUSE_SUFFOCATION = 3

Definition at line 54 of file EntityDamageEvent.php.

◆ CAUSE_SUICIDE

const pocketmine\event\entity\EntityDamageEvent::CAUSE_SUICIDE = 12

Definition at line 63 of file EntityDamageEvent.php.

◆ CAUSE_VOID

const pocketmine\event\entity\EntityDamageEvent::CAUSE_VOID = 11

Definition at line 62 of file EntityDamageEvent.php.

◆ MODIFIER_ABSORPTION

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_ABSORPTION = 5

Definition at line 43 of file EntityDamageEvent.php.

◆ MODIFIER_ARMOR

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_ARMOR = 1

Definition at line 39 of file EntityDamageEvent.php.

◆ MODIFIER_ARMOR_ENCHANTMENTS

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_ARMOR_ENCHANTMENTS = 6

Definition at line 44 of file EntityDamageEvent.php.

◆ MODIFIER_ARMOR_HELMET

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_ARMOR_HELMET = 11

Definition at line 49 of file EntityDamageEvent.php.

◆ MODIFIER_CRITICAL

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_CRITICAL = 7

Definition at line 45 of file EntityDamageEvent.php.

◆ MODIFIER_PREVIOUS_DAMAGE_COOLDOWN

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_PREVIOUS_DAMAGE_COOLDOWN = 10

Definition at line 48 of file EntityDamageEvent.php.

◆ MODIFIER_RESISTANCE

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_RESISTANCE = 4

Definition at line 42 of file EntityDamageEvent.php.

◆ MODIFIER_STRENGTH

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_STRENGTH = 2

Definition at line 40 of file EntityDamageEvent.php.

◆ MODIFIER_TOTEM

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_TOTEM = 8

Definition at line 46 of file EntityDamageEvent.php.

◆ MODIFIER_WEAKNESS

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_WEAKNESS = 3

Definition at line 41 of file EntityDamageEvent.php.

◆ MODIFIER_WEAPON_ENCHANTMENTS

const pocketmine\event\entity\EntityDamageEvent::MODIFIER_WEAPON_ENCHANTMENTS = 9

Definition at line 47 of file EntityDamageEvent.php.


The documentation for this class was generated from the following file: