out of block event||doc135421

September 20, 2022


  • The class to which the function belongs:Block


The event is fired when the solid object breaks out of contact with the block.


The context content of the event

name type Description
obj1 Entity entity object
blockPos Vector3 the coordinates of the block

Code Samples

on the server sideglobal script, register when the grass block is detached from the entity objectCallback, remove the block

local cfg = Block.GetNameCfg("myplugin/grass")         --Get the grass block config
Trigger.RegisterHandler(cfg, "BLOCK_APART", function(context)
    local entity = context.obj1
    local pos =  context.pos
    local map = entity.map                             --Get the current object location map
    map:removeBlock(pos)                               --Remove block