square sign||doc135661

September 20, 2022

Format

 item:is_block() 
  • The class to which the function belongs:item

Description

Determine if the item is a block.


Value Returned

type Description
boolean Is it a block


Code Samples

On the server side of the player entity templatemount script, add the error when the registered player switches hand-held itemCallback, if the new item is not empty, determine whether it is a block

Trigger.addHandler(this:cfg(), "HAND_ITEM_CHANGED", function(context)
      local entity = context.obj1
      local newItem = context.item
      print(newItem and newItem:is_block())     
end)