Wizards of Lua

The Art of Spell Crafting


UseItemTickEvent - While an Entity Uses an Item

The UseItemTickEvent class is fired every gametick while a Mob or Player uses an Item. Setting the duration to zero or less cancels this event.

Example

Print messages while the player is eating a golden apple.

Events.on('UseItemTickEvent'):call(function(event)
  if event.item.id == 'golden_apple' then
    print('Om nom '..event.duration)
  end
end)

The UseItemTickEvent class is a subtype of the UseItemEvent class and inherits all its properties and functions.