Interface in @minecraft/server
Extends ItemUseAfterEvent, CancellableEvent
The held item used in the air, before it’s eaten, drawn or thrown.
import type { ItemUseBeforeEvent } from '@minecraft/server';Subscribe to it with world.beforeEvents.itemUse.
Example
Section titled “Example”import { world, type ItemUseBeforeEvent } from '@minecraft/server';
world.beforeEvents.itemUse.subscribe((event: ItemUseBeforeEvent) => { console.log('itemUse', event.source.name, event.itemStack.typeId);
// Uncomment to stop it from happening. // event.cancel = true;});import { world } from '@minecraft/server';
world.beforeEvents.itemUse.subscribe((event) => { console.log('itemUse', event.source.name, event.itemStack.typeId);
// Uncomment to stop it from happening. // event.cancel = true;});Used by
Section titled “Used by”WorldBeforeEvents.itemUse, ItemUseBeforeEventSignal.subscribe, ItemUseBeforeEventSignal.unsubscribe
Inherited
Section titled “Inherited”From ItemUseAfterEvent: source, itemStack
From CancellableEvent: cancel