Skip to content

ChunkUnloadEvent

Triggered whenever a chunk is unloaded from memory. This event cannot be canceled.

When this event is fired, the chunk is still valid but will be removed from the world immediately after the event processing completes.

Example

local queue = spell:collect("ChunkUnloadEvent")
while true do
    local evt = queue:next() --[[@as ChunkUnloadEvent]]
    print("Chunk " .. evt.chunkX .. ", " .. evt.chunkZ .. " unloaded.")
end

Fields

chunkX: number — Read-Only

The x-coordinate of the unloaded chunk (in chunk space).

chunkZ: number — Read-Only

The z-coordinate of the unloaded chunk (in chunk space).

name: string — Read-Only

The name of the event.

world: World — Read-Only

A reference to the world where the chunk is being unloaded.