User Tools

Site Tools


items:item_events

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
items:item_events [2024/04/29 18:24] – make empty lines consistent errorcraftitems:item_events [2024/05/07 22:51] (current) – split item events to make room for tables errorcraft
Line 5: Line 5:
 With item events you can act upon something happening to an item yourself. 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. 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.+Below is a list with all item events describing when they occur.
  
  
Line 37: Line 37:
  
 ===== Events ===== ===== Events =====
-^  Event  ^  Occurs when  ^ +This is a list with all item events describing when they occur. 
-| ''minecraft:use''player used the item. | +It also contains a table with its appropriate [[actions:action_contexts|Action Context]]. 
-| ''minecraft:stopped_using''player stopped using the item before its use duration was reached. | + 
-| ''minecraft:finished_using''player used the item for its use duration. | + 
-| ''minecraft:consume_item'' | The item with the [[items:item_components:consumable]] item component is consumed. Runs after ''minecraft:finished_using''. | +==== minecraft:use ==== 
-| ''minecraft:eat_item'' | The item with the [[items:item_components:food]] item component is consumed. Runs before ''minecraft:finished_using'' and ''minecraft:consume_item''. | +Occurs when a player used the 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. | +^  Parameter  ^  Description  ^ 
-| ''minecraft:placed_block''block from the item with the [[items:item_components:block]] item component is placed. | +^  Entity  | ''this''The player holding the item stack. | 
-| ''minecraft:use_on_entity'' | The item it used on an entity after its original usage on the entity failed. | +^  Position  | ''this''The position of the player holding the item stack. | 
-| ''minecraft:hit_entity'' | The item is used to hit an entity. | +^  Item Stack  | | The item stack held by the player. | 
-| ''minecraft:spawn_entity'' | The item placed an entity. | + 
-| ''minecraft:damage_item'' | The item with the [[items:item_components:damageable]] item component was damaged. | +---- 
-| ''minecraft:break_item'' | The item with the [[items:item_components:damageable]] item component reached its maximum damage and broke. Runs after the item stack size is decremented, but before the [[mc>Data_component_format#damage|minecraft:damage]] data component is set back to 0. | + 
-| ''minecraft:use_tool'' | The item with the [[items:item_components:tool]] item component is used to break a block. Runs before ''minecraft:damage_item'' and ''minecraft:broke_block''. | +==== minecraft:stopped_using ==== 
-| ''minecraft:use_weapon'' | The item with the [[items:item_components:weapon]] item component is used to hit an entity. Runs before ''minecraft:damage_item'' and ''minecraft:hit_entity''. | +Occurs when a player stopped using the item before its use duration was reached. 
-| ''minecraft:equip_item'' | The item with the [[items:item_components:equipment]] item component is equipped by swapping. Runs before ''minecraft:use''. | + 
-| ''minecraft:throw_projectile'' | The item with the [[items:item_components:throwable]] item component is thrown. |+^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this''The player holding the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +^  Item Stack  | | The item stack held by the player. | 
 + 
 +---- 
 + 
 +==== minecraft:finished_using ==== 
 +Occurs when a player used the item for its use duration. 
 + 
 +^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this'' | The player holding the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +^  Item Stack  | | The item stack held by the player. | 
 + 
 +---- 
 + 
 +==== minecraft:consume_item ==== 
 +Occurs when the item with the [[items:item_components:consumable]] item component is consumed. 
 +Runs after [[#minecraft:finished_using]]. 
 + 
 +| ^  Parameter  ^  Description 
 +^  Entity ''this'' | The player holding the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +^  Item Stack  | | The item stack about to be consumed by the player. | 
 + 
 +---- 
 + 
 +==== minecraft:eat_item ==== 
 +Occurs when the item with the [[items:item_components:food]] item component is consumed. 
 +Runs before [[#minecraft:finished_using]] and [[#minecraft:consume_item]]. 
 + 
 +| ^  Parameter  ^  Description 
 +^  Entity ''this'' | The player holding the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +^  Item Stack  | | The item stack about to be eaten by the player. | 
 + 
 +---- 
 + 
 +==== minecraft:use_on_block ==== 
 +Occurs when the item is used on a block after its original usage on the block failed. 
 + 
 +^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this'' | The player holding the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +::: | ''target'' | The position of the block the player used the item stack on. | 
 +^  Side  | | The side of the block the player used the item stack on. | 
 +^  Item Stack  | | The item stack used on the block. | 
 + 
 +---- 
 + 
 +==== minecraft:broke_block ==== 
 +Occurs when the item is used to break a block. 
 + 
 +^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this'' | The player holding the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +::: | ''target''The position of the block the player broke. | 
 +^  Item Stack  | | The item stack used to break the block. | 
 + 
 +---- 
 + 
 +==== minecraft:placed_block ==== 
 +Occurs when a block from the item with the [[items:item_components:block]] item component is placed. 
 + 
 +^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this'' | The player holding the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +::: | ''target'' | The position the block was placed at. | 
 +^  Item Stack  | | The item stack used to place the block. | 
 + 
 +---- 
 + 
 +==== minecraft:use_on_entity ==== 
 +Occurs when the item it used on an entity after its original usage on the entity failed. 
 + 
 +^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this'' | The player holding the item stack. | 
 +::: | ''target'' | The entity the item stack was used on. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +^ ::: | ''target'' | The position of the entity the item stack was used on. | 
 +^  Item Stack  | | The item stack used on the entity. | 
 + 
 +---- 
 + 
 +==== minecraft:hit_entity ==== 
 +Occurs when the item is used to hit an entity. 
 + 
 +^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this'' | The player holding the item stack. | 
 +::: | ''target'' | The entity the item stack was used to hit with. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +^ ::: | ''target'' | The position of the entity the item stack was used to hit with. | 
 +^  Item Stack  | | The item stack used to hit the entity with. | 
 + 
 +---- 
 + 
 +==== minecraft:spawn_entity ==== 
 +Occurs when the item placed an entity. 
 + 
 +^  Parameter  ^  Description  ^ 
 +^  Entity  | ''this'' | The player holding the item stack. | 
 +::: | ''target'' | The entity that was spawned. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +^ ::: | ''target'' | The position of the spawned entity. | 
 +^  Side  | | The side of the block the item stack was used on to spawn the entity. | 
 +^  Item Stack  | | The item stack used to spawn the entity. | 
 + 
 +---- 
 + 
 +==== minecraft:damage_item ==== 
 +Occurs when the item with the [[items:item_components:damageable]] item component was damaged. 
 +The specific context depends on the origin the item stack was damaged from, but the item stack in the context is always the item stack that was damaged. 
 + 
 +---- 
 + 
 +==== minecraft:break_item ==== 
 +Occurs when the item with the [[items:item_components:damageable]] item component reaches its maximum damage and breaks. 
 +Runs after the item stack size is decremented, but before the [[mc>Data_component_format#damage|minecraft:damage]] data component is set back to 0. 
 +The specific context depends on the origin the item stack was broken from, but the item stack in the context is always the item stack that was broken. 
 + 
 +---- 
 + 
 +==== minecraft:use_tool ==== 
 +Occurs when the item with the [[items:item_components:tool]] item component is used to break a block. 
 +Runs before [[#minecraft:damage_item]] and [[#minecraft:broke_block]]. 
 + 
 +| ^  Parameter  ^  Description 
 +^  Entity ''this'' | The player using the item stack to break a block. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +::: | ''target'' | The position of the block the tool was used on. | 
 +^  Item Stack  | | The item stack used as a tool. | 
 + 
 +---- 
 + 
 +==== minecraft:use_weapon ==== 
 +Occurs when the item with the [[items:item_components:weapon]] item component is used to hit an entity. 
 +Runs before [[#minecraft:damage_item]] and [[#minecraft:hit_entity]]. 
 + 
 +| ^  Parameter  ^  Description 
 +^  Entity ''this'' | The player using the item stack to hit an entity. | 
 +::: | ''target'' | The entity that was damaged with the item stack. | 
 +^  Position  | ''this'' | The position of the player holding the item stack. | 
 +::: | ''target'' | The position of the entity that was damaged with the item stack. | 
 +^  Item Stack  | | The item stack used as a weapon. | 
 + 
 +---- 
 + 
 +==== minecraft:equip_item ==== 
 +Occurs when the item with the [[items:item_components:equipment]] item component is equipped by swapping. 
 +Runs before [[#minecraft:use]]. 
 + 
 +| ^  Parameter  ^  Description 
 +^  Entity ''this'' | The player equipping the item stack. | 
 +^  Position  | ''this'' | The position of the player equipping the item stack. | 
 +^  Item Stack  | | The item stack to be equipped. | 
 + 
 +---- 
 + 
 +==== minecraft:throw_projectile ==== 
 +Occurs when the item with the [[items:item_components:throwable]] item component is thrown. 
 + 
 +| ^  Parameter  ^  Description 
 +^  Entity  | ''this'' | The player throwing the projectile. | 
 +^ ::: | ''target'' | The projectile that was created. | 
 +^  Position  | ''this'' | The position of the player throwing the projectile. | 
 +^ ::: | ''target'' | The position of the projectile that was created. | 
 +^  Item Stack  | | The item stack that was thrown. |
items/item_events.1714415051.txt.gz · Last modified: 2024/04/29 18:24 by errorcraft