Skip to content

DamageSource

Represents the origin and cause of damage in the game, including involved entities and the impact location.

Example: Report who killed whom

local queue = spell:collect("AfterLivingEntityDeathEvent")
while true do
  local evt = queue:next() --[[@as AfterLivingEntityDeathEvent]]
  local killer = evt.damageSource.attacker
  if killer then
    print(killer.name .. " killed " .. evt.entity.name)
  end
end

Fields

attacker?: Entity — Read-Only

A reference to the entity responsible for causing the damage (e.g., a Blaze).

name: string — Read-Only

The description or message associated with the damage source.

pos?: Vec3 — Read-Only

A copy of the position where the damage occurred, or if not applicable, the source entity’s position.

source?: Entity — Read-Only

A reference to the entity that delivered the damage (e.g., a Fireball).