description | cover | coverY |
---|---|---|
The "events" section of a block or item's YAML allows you to execute Minecraft commands when certain interactions are performed. |
0 |
{% hint style="info" %}
Both blocks and items use some events by the same name, with them behaving differently depending on the context: for example, onBroken
is used for both when a block is broken and for when an item breaks as a result of running out of durability.
{% endhint %}
# "events" is formatted as a list of event objects:
events:
- onRightClick: # <-- event name
commands:
- say block right clicked!
cooldown: 20 # <-- cooldown in ticks
- onBroken:
commands:
# this is a list of Minecraft commands, with or without the slash
- say block broken!
- say goodbye world!
# adding a cooldown is optional
onRightClick
:- Function: Triggered when a block or item is right-clicked.
onLeftClick
:- Function: Triggered when a block or item is left-clicked.
onRightClickAir
:- Function: Triggered when an item is right-clicked while looking at air.
onLeftClickAir
:- Function: Triggered when an item or block is left-clicked while looking at air.
onRightClickBlock
:- Function: Triggered when the player is looking at a block and a right-click is performed.
onLeftClickBlock
:- Function: Triggered when the player is looking at a block and a left-click is performed.
onPlaced
:- Function: Triggered when a block is placed.
onBroken
:- Function: Triggered when a block or item is broken.
onDamaged
:- Function: Triggered when an item or block is damaged.
onPushed
:- Function: Triggered when a block is pushed by a piston.