The UseItemEvent class is the base class of events about Item usage.
The UseItemEvent is fired when a Mob or Player uses an Item.
Typical scenarios are:
Setting the duration to zero or less cancels this event.
The UseItemEvent class is a subtype of the LivingEvent class and inherits all its properties and functions.
Here is an overview of the UseItemEvent properties:
Property | Type | read / write |
---|---|---|
duration | number (int) | r/w |
item | Item | r |
Below you find short descriptions about each of the properties and some examples about how to use them in your spells.
The ‘duration’ is the number of remaining game ticks until this event will terminate normally and the use is finished.
Increase the time it takes to eat a golden apple to 5 seconds (100 gameticks), gold is pretty hard to chew anyway.
Events.on('UseItemStartEvent'):call(function(event)
if event.item.id == 'golden_apple' then
event.duration = 100
end
end)
This is the used item.