Skip to content
On this page

๐ŸŽˆ Entity Related Events

"onMobDie" - Mob/Player Death Event

  • Listener function prototype function(mob,source,cause)
  • Parameters:
    • mob : Entity
      Dead entity object.
    • source : Entity
      The entity object that dealt the last damage (may be Null).
    • cause : Integer
      Cause of injury
  • Intercept event: cannot be intercepted.

Note that when the player dies, in addition to triggering onPlayerDie event, this event will also be triggered once.

"onMobHurt" - Mob/Player Hurt Event

  • Listener function prototype function(mob,source,damage,cause)

  • Parameters:

    • mob : Entity
      The damaged entity.
    • source : Entity
      The entity that dealt the damage (may be Null).
    • damage : Float
      The amount of damage dealt.
    • cause : ActorDamageCause
      Cause of injury
  • Intercept events: function returns false

Here are values of ActorDamageCause:

ActorDamageCause ENUMValue
ActorDamageCause.None-1
ActorDamageCause.Override0
ActorDamageCause.Contact1
ActorDamageCause.EntityAttack2
ActorDamageCause.Projectile3
ActorDamageCause.Suffocation4
ActorDamageCause.Fall5
ActorDamageCause.Fire6
ActorDamageCause.FireTick7
ActorDamageCause.Lava8
ActorDamageCause.Drowning9
ActorDamageCause.BlockExplosion10
ActorDamageCause.EntityExplosion11
ActorDamageCause.Void12
ActorDamageCause.SelfDestruct13
ActorDamageCause.Magic14
ActorDamageCause.Wither15
ActorDamageCause.Starve16
ActorDamageCause.Anvil17
ActorDamageCause.Thorns18
ActorDamageCause.FallingBlock19
ActorDamageCause.Piston20
ActorDamageCause.FlyIntoWall21
ActorDamageCause.Magma22
ActorDamageCause.Fireworks23
ActorDamageCause.Lightning24
ActorDamageCause.Charging25
ActorDamageCause.Temperature26
ActorDamageCause.Freezing27
ActorDamageCause.Stalactite28
ActorDamageCause.Stalagmite29
ActorDamageCause.RamAttack30
ActorDamageCause.SonicBoom31
ActorDamageCause.Campfire32
ActorDamageCause.SoulCampfire33
ActorDamageCause.MaceSmash34
ActorDamageCause.All35

"onEntityExplode" - Entity Explosion Event

  • Listener function prototype function(source,pos,radius,maxResistance,isDestroy,isFire)

  • Parameters:

    • source : Entity
      The entity object that caused the explosion.
    • pos : FloatPos
      The coordinates of the explosion.
    • radius : Float
      Blast radius.
    • maxResistance : Float
      The maximum resistance of blocks that will break.
    • isDestroy : Boolean
      Does the explosion destroy blocks.
    • isFire : Boolean
      Does the explosion produce flames.
  • Intercept events: function returns false

"onMobTrySpawn" - Mob try Naturally Spawn Event

  • Listener function prototype function(typeName,pos)

  • Parameters:

    • typeName : String
      Entity Name
    • pos : FloatPos
      The coordinates of the spawn.
  • Intercept events: function returns false

"onMobSpawned" - Mob Naturally Spawn Finished Event

  • Listener function prototype function(entity,pos)

  • Parameters:

    • entity: Entity
      The entity that spawned.
    • pos : FloatPos
      The coordinates of the spawn.
  • Intercept events: cannot be intercepted.

You can use entity.despawn() or entity.remove() to intercept this event.

"onPortalTrySpawnPigZombie" - Nether Portal Try Spawn Zombified Piglin Event

  • Listener function prototype function(pos,axis)

  • Parameters:

    • pos : IntPos The portal block coordinates where the spawn attempt happened.
    • axis : Integer Portal axis enum value (0 = Unknown, 1 = X, 2 = Z).
  • Intercept events: function returns false

"onProjectileHitEntity" - Entity Hit by Projectile Event

  • Listener function prototype function(entity,source)
  • Parameters:
    • entity: Entity
      The entity that was hit with a projectile.
    • source : Entity
      The projecticle entity (like arrows).
  • Intercept event: cannot be intercepted.

"onWitherBossDestroy" - Block Broken by Wither Event

  • Listener function prototype function(witherBoss,AAbb,aaBB)

  • Parameters:

    • witherBoss: Entity
      The Wither entity object.
    • AAbb: IntPos The area that the wither will destroy (box), the A coordinate of the diagonal point.
    • aaBB: IntPos The area that the wither will destroy (box), the B coordinate of the diagonal point.
  • Intercept events: function returns false

Note that this event does not include wither explosion damage.

"onRide" - Mob Ride Event

  • Listener function prototype function(entity1,entity2)
  • Parameters:
    • entity1 : Entity
      The entity that is riding the other entity.
    • entity2 : Entity
      The entity that is being ridden.
  • Intercept events: function returns false

Note: Riding includes minecart, boat, horse, pig, etc.

"onStepOnPressurePlate" - Pressure Plate Step Event

  • Listener function prototype function(entity,pressurePlate)
  • Parameters:
    • entity : Entity
      The entity that stepped on the plate.
    • pressurePlate : Block
      The pressed pressure plate block.
  • Intercept events: function returns false

Note: When a creature steps on a pressure plate, this event will be triggered repeatedly.

"onSpawnProjectile" - Projectile Spawn Event

  • Listener function prototype function(shooter,type)

  • Parameters:

    • shooter : Entity
      The entity that fired the projectile.
    • type : String
      Projectile Standard Type Name.
  • Intercept events: function returns false

Note: Projectiles known to be intercepted are eggs, ender pearls, snowballs, tridents, arrows, and fishing rods (fish hooks).

"onProjectileCreated" - Projectile Created Event

  • Listener function prototype function(shooter,entity)

  • Parameters:

    • shooter : Entity
      The entity that created the projectile.
    • entity : Entity
      The projectile entity object being created.
  • Intercept event: cannot be intercepted.

"onNpcCmd" - NPC Command Execution Event

Warning

This event is only available in 0.9.6 and later versions.

  • Listener function prototype function(npc,pl,cmd)
  • Parameters:
    • npc : Entity
      The NPC entity that executed the command.
    • pl : Player
      The player that triggered the execution of the NPC command.
    • cmd : String
      The command being executed by NPCs. If there are multiple commands, they are separated by ;.
  • Intercept events: function returns false

"onChangeArmorStand" - Armor Stand Change Event

  • Listener function prototype function(as,pl,slot)

  • Parameters:

    • as: Entity
      Manipulated Armor Stand entity object.
    • pl : Player
      The player that manipulated the armor stand.
    • slot : Number Equipment slot number.
  • Intercept events: function returns false

"onEntityTransformation" - Entity Transformation Event

  • Listener function prototype function(uniqueId,entity)

  • Parameters:

    • uniqueId: String Unique identifer of the pre-transformed entity.
    • entity : Entity The transformed entity.
  • Intercept event: cannot be intercepted.

Note: This event is triggered when the TransformationComponent of the entity in Addons is activated, and is mostly used for the interaction between the engine and the Addon. Only UniqueId is provided since the entity pointer before the transition is destroyed quickly.

"onEndermanTakeBlock" - Enderman Take Block Event

Warning

This event is only available in 0.11.3 and later versions.

  • Listener function prototype function(entity, block, pos)
  • Parameters
    • entity : Entity
      Enderman entity.
    • block : Block
      Pick up the Block
    • pos : BlockPos
      The coordinates of the block.
  • Intercept events: function returns false