minecraft:on_equipment_changed
Allows to specify events to execute when equipment is set in the entity's default equipment slots. Doesn't apply to "minecraft:inventory", use "minecraft:equippable" instead.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
slots | List of object | [] | A list of slot-specific events to execute when the entity's equipment changes in those slots. |
slot | Textslot.weapon.mainhand, slot.weapon.offhand, slot.armor.head, slot.armor.chest, slot.armor.legs, slot.armor.feet, slot.armor.body | "slot.weapon.mainhand" | The equipment slot to monitor for changes. |
on_equip | Text | "" | Event to execute when the slot is changed to a non-empty item. |
on_unequip | Text | "" | Event to execute when the slot is changed to an empty item. |
Example from the game files
This is how vanilla Sulfur Cube uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:on_equipment_changed": {
"slots": [
{
"slot": "slot.weapon.mainhand",
"on_equip": "minecraft:on_block_absorbed",
"on_unequip": "minecraft:on_block_ejected"
}
]
}
}Used by 1
Vanilla entities with minecraft:on_equipment_changed in their definition:
Related components
damage_sensorinteractenvironment_sensoron_target_acquiredtimeron_target_escapegame_event_movement_trackingentity_sensorrail_sensortarget_nearby_sensorbody_rotation_blockedon_friendly_angeron_hurtblock_sensorinside_block_notifierlooked_aton_hurt_by_playerschedulervibration_listenerbody_rotation_always_follows_headon_deathon_start_landingon_start_takeoffon_wake_with_owner