block breaking event||doc135415

September 20, 2022


  • The class to which the function belongs:Block


Triggers an event when a block is broken on the map.


  • Destruction here refers to manually knocking out the block during the game, and removing the block directly will not trigger this event.


The context content of the event

name type Description
obj1 Object object of destruction
pos Vector3 the coordinates of the block
map Map block location map

Code Samples

on the server sideglobal script, register when the grass block is destroyedCallbackbroadcast tipsGrass blocks are destroyed

local cfg = Block.GetNameCfg("myplugin/grass")                 --Get the grass block config
Trigger.RegisterHandler(cfg, "BLOCK_BREAK", function(context)
    local player = context.obj1
    World.CurWorld.SystemNotice(1, "player break block !", 40) --Broadcast