minecraft:interact

Defines interactions with this entity.

Properties

PropertyTypeDefaultWhat it does
interactionsList of object[]
cooldownDecimal0Time in seconds before this entity can be interacted with again.
cooldown_after_being_attackedDecimal0Time in seconds before this entity can be interacted with after being attacked.
swingBooleantrueIf true, the player will do the 'swing' animation when interacting with this entity.
use_itemBooleanfalseIf true, the interaction will use an item.
barterBooleanfalseIf 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.
admireBooleanfalseIf 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_itemBooleanfalseIf true, the mob that's interacted with will try to replace its current main-hand item with the interactable item after interaction.
take_itemBooleanfalseIf 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_itemInteger0The 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_amountInteger0The amount of health this entity will recover or lose when interacting with this item. Negative values will harm the entity.
equip_item_slotText—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_slotText—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_offsetDecimal0Will offset the item drop position this amount in the y direction. Requires "drop_item_slot" to be specified.
repair_entity_itemObject{"amount": 1, "slot": null}Allows to repair one of the entity's items.
slotText—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'.
amountInteger1How much of the item durability should be restored upon interaction.
transform_to_itemText—The item used will transform to this item upon successful interaction. Format: itemName:auxValue
interact_textText""Text to show when the player is able to interact in this way with this entity when playing with touch-screen controls.
add_itemsObject{"table": ""}Loot table with items to add to the player's inventory upon successful interaction.
table requiredText—File path, relative to the Behavior Pack's path, to the loot table file.
spawn_itemsObject{"table": "", "y_offset": 1}Loot table with items to drop on the ground upon successful interaction.
tableText—File path, relative to the Behavior Pack's path, to the loot table file.
y_offsetDecimal1Will offset the items spawn position this amount in the y direction.
particle_on_startObject{"copper_event": "none", "particle_offset_towards_interac…Particle effect that will be triggered at the start of the interaction.
particle_typeTextnone, 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_interactorBooleanfalseWhether or not the particle will appear closer to who performed the interaction.
particle_y_offsetDecimal0Will offset the particle this amount in the y direction.
copper_eventTextnone, wax_on, wax_off, scrape"none"
vibrationTextnone, entity_act, entity_die, entity_interact, shear"entity_interact"Vibration to emit when the interaction occurs.
play_soundsList of text[]List of sounds to play when the interaction occurs.
spawn_entitiesList of text[]List of entities to spawn when the interaction occurs.
on_interactObject{"event": "", "filters": {"AND": null, "NOT": null, "OR":…Event to fire when the interaction occurs.
eventText""
targetTextself, other, player, target, parent, baby, block, damager, holder, item"self"
filtersObject 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