EntityEvent base class.
EntityEvent Base Class
All entity events inherit from this class:Returns the entity involved in the event
Damage Events
EntityDamageEvent
EntityDamageEvent
Cancellable: YesCalled when an entity takes damage from any source.Damage Causes:
CAUSE_CONTACT(0) - Contact with cactus, etc.CAUSE_ENTITY_ATTACK(1) - Entity melee attackCAUSE_PROJECTILE(2) - Projectile hitCAUSE_SUFFOCATION(3) - Suffocating in blocksCAUSE_FALL(4) - Fall damageCAUSE_FIRE(5) - Standing in fireCAUSE_FIRE_TICK(6) - Being on fireCAUSE_LAVA(7) - Standing in lavaCAUSE_DROWNING(8) - DrowningCAUSE_BLOCK_EXPLOSION(9) - Block explosion (TNT)CAUSE_ENTITY_EXPLOSION(10) - Entity explosion (Creeper)CAUSE_VOID(11) - Void damageCAUSE_SUICIDE(12) - /kill commandCAUSE_MAGIC(13) - Magic/potion damageCAUSE_CUSTOM(14) - Custom damageCAUSE_STARVATION(15) - HungerCAUSE_FALLING_BLOCK(16) - Hit by falling block
MODIFIER_ARMOR(1) - Armor protectionMODIFIER_STRENGTH(2) - Strength effectMODIFIER_WEAKNESS(3) - Weakness effectMODIFIER_RESISTANCE(4) - Resistance effectMODIFIER_ABSORPTION(5) - Absorption heartsMODIFIER_ARMOR_ENCHANTMENTS(6) - Protection enchantmentsMODIFIER_CRITICAL(7) - Critical hitMODIFIER_TOTEM(8) - Totem of UndyingMODIFIER_WEAPON_ENCHANTMENTS(9) - Sharpness, etc.MODIFIER_PREVIOUS_DAMAGE_COOLDOWN(10) - Damage cooldownMODIFIER_ARMOR_HELMET(11) - Helmet specific
getCause()- Returns the damage causegetBaseDamage()- Returns base damage before modifierssetBaseDamage(float $damage)- Sets base damagegetOriginalBaseDamage()- Returns original base damagegetModifiers()- Returns all damage modifiersgetModifier(int $type)- Returns specific modifiersetModifier(float $damage, int $type)- Sets a modifierisApplicable(int $type)- Checks if modifier is applicablegetFinalDamage()- Returns final damage after modifierscanBeReducedByArmor()- Returns whether armor can reduce this damagegetAttackCooldown()- Returns attack cooldown in tickssetAttackCooldown(int $cooldown)- Sets attack cooldown
EntityDamageByEntityEvent
EntityDamageByEntityEvent
Cancellable: YesCalled when an entity takes damage from another entity. Extends Methods:
EntityDamageEvent.getDamager()- Returns the attacking entity (or null if dead)getKnockBack()- Returns knockback forcesetKnockBack(float $force)- Sets knockback forcegetVerticalKnockBackLimit()- Returns max upward velocitysetVerticalKnockBackLimit(float $limit)- Sets max upward velocity- All methods from
EntityDamageEvent
EntityDamageByChildEntityEvent
EntityDamageByChildEntityEvent
Cancellable: YesCalled when an entity takes damage from a child entity (e.g., arrow shot by skeleton).Methods:
getChild()- Returns the child entity (e.g., arrow)- All methods from
EntityDamageByEntityEvent
EntityDamageByBlockEvent
EntityDamageByBlockEvent
Cancellable: YesCalled when an entity takes damage from a block (cactus, magma).Methods:
getDamager()- Returns the damaging block- All methods from
EntityDamageEvent
Life Cycle Events
EntitySpawnEvent
EntitySpawnEvent
Cancellable: YesCalled when an entity spawns in the world.
EntityDespawnEvent
EntityDespawnEvent
Cancellable: NoCalled when an entity is despawned (removed from the world).Methods:
getEntityType()- Returns the EntityTypeInterface
EntityDeathEvent
EntityDeathEvent
Cancellable: NoCalled when an entity dies.Methods:
getDrops()- Returns array of dropped itemssetDrops(array $drops)- Sets dropped itemsgetXpDropAmount()- Returns XP to dropsetXpDropAmount(int $amount)- Sets XP to drop
Movement Events
EntityTeleportEvent
EntityTeleportEvent
Cancellable: YesCalled when an entity teleports.Methods:
getFrom()- Returns origin positiongetTo()- Returns destination positionsetTo(Position $to)- Sets destination position
EntityMotionEvent
EntityMotionEvent
Cancellable: YesCalled when an entity’s motion changes.Methods:
getVector()- Returns the motion vectorsetVector(Vector3 $motion)- Sets the motion vector
Status Effects
EntityEffectAddEvent
EntityEffectAddEvent
Cancellable: YesCalled when an effect is added to an entity.Methods:
getEffect()- Returns the EffectInstancegetOldEffect()- Returns previous effect (or null)
EntityEffectRemoveEvent
EntityEffectRemoveEvent
Cancellable: YesCalled when an effect is removed from an entity.Methods:
getEffect()- Returns the EffectInstance being removed
Combat Events
EntityRegainHealthEvent
EntityRegainHealthEvent
Cancellable: YesCalled when an entity regains health.Causes:
CAUSE_SATURATION- Saturation effectCAUSE_EATING- Eating foodCAUSE_MAGIC- Instant Health potionCAUSE_REGEN- Regeneration effectCAUSE_CUSTOM- Custom healing
getAmount()- Returns health regainedsetAmount(float $amount)- Sets health regainedgetRegainReason()- Returns the cause
EntityShootBowEvent
EntityShootBowEvent
Cancellable: YesCalled when an entity shoots a bow.Methods:
getBow()- Returns the bow itemgetProjectile()- Returns the projectile entitygetForce()- Returns shot force (0.0-1.0)
Combustion Events
EntityCombustEvent
EntityCombustEvent
Cancellable: YesCalled when an entity catches fire.Methods:
getDuration()- Returns burn duration in secondssetDuration(int $duration)- Sets burn duration
EntityCombustByBlockEvent
EntityCombustByBlockEvent
Cancellable: YesCalled when an entity is set on fire by a block (lava, fire).Methods:
getCombustor()- Returns the block causing combustion
EntityCombustByEntityEvent
EntityCombustByEntityEvent
Cancellable: YesCalled when an entity is set on fire by another entity.Methods:
getCombustor()- Returns the entity causing combustion
EntityExtinguishEvent
EntityExtinguishEvent
Cancellable: YesCalled when an entity’s fire is extinguished.
Explosion Events
EntityExplodeEvent
EntityExplodeEvent
Cancellable: YesCalled when an entity explodes (Creeper, TNT, etc.).Methods:
getBlockList()- Returns blocks that will be destroyedsetBlockList(array $blocks)- Sets blocks to destroygetYieldDrops()- Returns whether blocks drop itemssetYieldDrops(bool $yield)- Sets whether blocks drop items
EntityPreExplodeEvent
EntityPreExplodeEvent
Cancellable: YesCalled before an entity explosion, allows modifying affected blocks.Methods:
getAffectedBlocks()- Returns blocks that will be affectedsetAffectedBlocks(array $blocks)- Sets blocks to affect
Item Entity Events
ItemSpawnEvent
ItemSpawnEvent
Cancellable: YesCalled when an item entity spawns.
ItemDespawnEvent
ItemDespawnEvent
Cancellable: YesCalled when an item entity despawns after 5 minutes.
ItemMergeEvent
ItemMergeEvent
Cancellable: YesCalled when two item entities merge into one.Methods:
getTarget()- Returns the other item entity
EntityItemPickupEvent
EntityItemPickupEvent
Cancellable: YesCalled when an entity picks up an item.Methods:
getOrigin()- Returns the item entitygetItem()- Returns the item stackgetInventory()- Returns the receiving inventory
Projectile Events
ProjectileLaunchEvent
ProjectileLaunchEvent
Cancellable: YesCalled when a projectile is launched.
ProjectileHitEvent
ProjectileHitEvent
Cancellable: NoBase event called when a projectile hits something.Methods:
getRayTraceResult()- Returns the ray trace hit result
ProjectileHitBlockEvent
ProjectileHitBlockEvent
Cancellable: NoCalled when a projectile hits a block.Methods:
getBlockHit()- Returns the hit blockgetRayTraceResult()- Returns hit details
ProjectileHitEntityEvent
ProjectileHitEntityEvent
Cancellable: NoCalled when a projectile hits an entity.Methods:
getEntityHit()- Returns the hit entitygetRayTraceResult()- Returns hit details
Special Events
EntityBlockChangeEvent
EntityBlockChangeEvent
Cancellable: YesCalled when an entity changes a block (enderman picking up blocks, sheep eating grass).Methods:
getBlock()- Returns the affected blockgetTo()- Returns the new block state
EntityTrampleFarmlandEvent
EntityTrampleFarmlandEvent
Cancellable: YesCalled when an entity tramples farmland into dirt.Methods:
getBlock()- Returns the farmland block
EntityFrostWalkerEvent
EntityFrostWalkerEvent
Cancellable: YesCalled when an entity with Frost Walker creates ice.Methods:
getBlockPositions()- Returns positions that will turn to ice
AreaEffectCloudApplyEvent
AreaEffectCloudApplyEvent
Cancellable: YesCalled when an area effect cloud applies effects to entities.Methods:
getRecipients()- Returns affected entitiessetRecipients(array $entities)- Sets affected entities