minecraft:interact
Defines interactions with this entity.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
interactions | List of object | [] | |
cooldown | Decimal | 0 | Time in seconds before this entity can be interacted with again. |
cooldown_after_being_attacked | Decimal | 0 | Time in seconds before this entity can be interacted with after being attacked. |
swing | Boolean | true | If true, the player will do the 'swing' animation when interacting with this entity. |
use_item | Boolean | false | If true, the interaction will use an item. |
barter | Boolean | false | If true, the mob that's interacted with will try to do a barter action after interaction. For this to be successful the mob has to have a Barter component and a Barter goal in place. |
admire | Boolean | false | If true, the mob that's interacted with will try to do an admire action after interaction. For this to be successful the mob has to have an Admire component and an Admire goal in place. |
give_item | Boolean | false | If true, the mob that's interacted with will try to replace its current main-hand item with the interactable item after interaction. |
take_item | Boolean | false | If true, the mob that's interacted with will try to replace its current main-hand item with an empty item, and its current main-hand item will occupy the empty selected slot of the player. |
hurt_item | Integer | 0 | The amount of damage the item will take when used to interact with this entity. A value of 0 means the item won't lose durability. |
health_amount | Integer | 0 | The amount of health this entity will recover or lose when interacting with this item. Negative values will harm the entity. |
equip_item_slot | Text | — | The entity's slot to equip the item to, if any, upon successful interaction. Inventory slots are denoted by positive numbers. Equipment slots are denoted by 'slot.weapon.mainhand', 'slot.weapon.offhand', 'slot.armor.head', 'slot.armor.chest', 'slot.armor.legs', 'slot.armor.feet' and 'slot.armor.body'. |
drop_item_slot | Text | — | The entity's slot to remove and drop the item from, if any, upon successful interaction. Inventory slots are denoted by positive numbers. Equipment slots are denoted by 'slot.weapon.mainhand', 'slot.weapon.offhand', 'slot.armor.head', 'slot.armor.chest', 'slot.armor.legs', 'slot.armor.feet' and 'slot.armor.body'. |
drop_item_y_offset | Decimal | 0 | Will offset the item drop position this amount in the y direction. Requires "drop_item_slot" to be specified. |
repair_entity_item | Object | {"amount": 1, "slot": null} | Allows to repair one of the entity's items. |
slot | Text | — | The entity's slot containing the item to be repaired. Inventory slots are denoted by positive numbers. Equipment slots are denoted by 'slot.weapon.mainhand', 'slot.weapon.offhand', 'slot.armor.head', 'slot.armor.chest', 'slot.armor.legs', 'slot.armor.feet' and 'slot.armor.body'. |
amount | Integer | 1 | How much of the item durability should be restored upon interaction. |
transform_to_item | Text | — | The item used will transform to this item upon successful interaction. Format: itemName:auxValue |
interact_text | Text | "" | Text to show when the player is able to interact in this way with this entity when playing with touch-screen controls. |
add_items | Object | {"table": ""} | Loot table with items to add to the player's inventory upon successful interaction. |
table required | Text | — | File path, relative to the Behavior Pack's path, to the loot table file. |
spawn_items | Object | {"table": "", "y_offset": 1} | Loot table with items to drop on the ground upon successful interaction. |
table | Text | — | File path, relative to the Behavior Pack's path, to the loot table file. |
y_offset | Decimal | 1 | Will offset the items spawn position this amount in the y direction. |
particle_on_start | Object | {"copper_event": "none", "particle_offset_towards_interac… | Particle effect that will be triggered at the start of the interaction. |
particle_type | Textnone, bubble, bubblemanual, crit, blockforcefield, smoke, explode, evaporation, flame, candleflame, lava, largesmoke, reddust, risingborderdust, iconcrack, snowballpoof, largeexplode, hugeexplosion, breezewindexplosion, mobflame, heart, terrain, townaura, portal … | "none" | The type of particle that will be spawned. |
particle_offset_towards_interactor | Boolean | false | Whether or not the particle will appear closer to who performed the interaction. |
particle_y_offset | Decimal | 0 | Will offset the particle this amount in the y direction. |
copper_event | Textnone, wax_on, wax_off, scrape | "none" | |
vibration | Textnone, entity_act, entity_die, entity_interact, shear | "entity_interact" | Vibration to emit when the interaction occurs. |
play_sounds | List of text | [] | List of sounds to play when the interaction occurs. |
spawn_entities | List of text | [] | List of entities to spawn when the interaction occurs. |
on_interact | Object | {"event": "", "filters": {"AND": null, "NOT": null, "OR":… | Event to fire when the interaction occurs. |
event | Text | "" | |
target | Textself, other, player, target, parent, baby, block, damager, holder, item | "self" | |
filters | Object or List of object | {"AND": null, "NOT": null, "OR": null, "all": null, "all_… | Filters allow data objects to specify test criteria which allows their use. Filters can be defined by a single object of type (Filter Test), an array of tests, collection groups, or a combination of these objects. |
Example from the game files
This is how vanilla Sheep uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:interact": {
"interactions": [
{
"cooldown": 2.5,
"use_item": false,
"swing": true,
"hurt_item": 1,
"spawn_items": {
"table": "loot_tables/entities/sheep_shear.json"
},
"play_sounds": [
"shear"
],
"interact_text": "action.interact.shear",
"vibration": "shear",
"on_interact": {
"filters": {
"all_of": [
{
"test": "has_equipment",
"subject": "other",
"domain": "hand",
"value": "shears"
},
{
"test": "is_family",
"subject": "other",
"value": "player"
},
{
"test": "has_component",
"operator": "!=",
"value": "minecraft:is_baby"
},
{
"test": "has_component",
"value": "minecraft:is_dyeable"
}
]
},
"event": "minecraft:on_sheared",
"target": "self"
}
}
]
}
}Used by 32
Vanilla entities with minecraft:interact in their definition:
Related components
damage_sensorenvironment_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_equipment_changedon_start_landingon_start_takeoffon_wake_with_owner