block removal event||doc135417

September 20, 2022


  • The class to which the function belongs:Block


Triggers an event when a block is removed from the map.


  • The removal here is only triggered when a single block is removed, and does not include removing blocks from regions.
  • The removal here is mainlyremoveBlockRemoving a block triggers, breaking a block does not.


The context content of the event

name type Description
pos Vector3 the coordinates of the block
map Map block location map

Code Samples

on the server sideglobal script, register when the brush block is removedCallback, which prints the coordinates where the square was removed

local cfg = Block.GetNameCfg("myplugin/grass")                   --Get the grass block config
Trigger.RegisterHandler(cfg, "BLOCK_REMOVED", function(context)
    local map =
    local pos =  context.pos
    print(" block  removed!",pos)
local map = World.CurWorld:getMap("map001")
map:createBlock({ x = 1, y = 1, z = 1 }, "myplugin/grass")        --Generate blocks
map:removeBlock({ x = 1, y = 1, z = 1 })                          --Remove the block and trigger the removal logic