block hit event||doc135418

September 20, 2022


  • The class to which the function belongs:Block


Triggers an event when a block is hit by a projectile.


  • Only triggers the hit event when the projectile's properties are set to hit a block will only take effect.


The context content of the event

name type Description
pos Vector3 the coordinates of the block
obj1 Entity the object instance that fires the projectile
missile Missile projectile example

Code Samples

on the server sideglobal script, register when a grass block is hit by a projectileCallback, remove the block

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