items:item_events
This is an old revision of the document!
Table of Contents
Item Events
Sometimes you want to do something that an item component alone cannot achieve.
So, this is why item events exist!
With item events you can act upon something happening to an item yourself.
All events and their handlers are found in a list in the events
field on an item.
Below is a table with all item events and when they occur.
Fields
Example
{ "base": { "translation_key": "item.minecraft.milk_bucket" }, // ... "events": [ { "event": "minecraft:consume_item", "entry": { "action": { "type": "minecraft:clear_status_effects", "entity": "this" } } } ] }
Events
Event | Occurs when |
---|---|
minecraft:use | A player used the item. |
minecraft:stopped_using | A player stopped using the item before its use duration was reached. |
minecraft:finished_using | A player used the item for its use duration. |
minecraft:consume_item | The item with the minecraft:consumable item component is consumed. Runs after minecraft:finished_using . |
minecraft:eat_item | The item with the minecraft:food item component is consumed. Runs before minecraft:finished_using and minecraft:consume_item . |
minecraft:use_on_block | The item is used on a block after its original usage on the block failed. |
minecraft:broke_block | The item is used to break a block. |
minecraft:placed_block | A block from the item with the minecraft:block item component is placed. |
minecraft:use_on_entity | The item it used on an entity after its original usage on the entity failed. |
minecraft:hit_entity | The item is used to hit an entity. |
minecraft:spawn_entity | The item placed an entity. |
minecraft:damage_item | The item with the minecraft:damageable item component was damaged. |
minecraft:break_item | The item with the minecraft:damageable item component reached its maximum damage and broke. Runs after the item stack size is decremented, but before the minecraft:damage data component is set back to 0. |
minecraft:use_tool | The item with the minecraft:tool item component is used to break a block. Runs before minecraft:damage_item and minecraft:broke_block . |
minecraft:use_weapon | The item with the minecraft:weapon item component is used to hit an entity. Runs before minecraft:damage_item and minecraft:hit_entity . |
minecraft:equip_item | The item with the minecraft:equipment item component is equipped by swapping. Runs before minecraft:use . |
minecraft:throw_projectile | The item with the minecraft:throwable item component is thrown. |
items/item_events.1714403308.txt.gz · Last modified: 2024/04/29 15:08 by errorcraft