跳转至

Interact

文档版本:1.21.0.24

Defines interactions with this entity.

架构

interact:
{
  object "interactions" : opt
  {
    object "add_items" : opt
    {
      identifier "table"
    }
    number "cooldown" : opt
    boolean "admire" : opt
    boolean "barter" : opt
    number "cooldown_after_being_attacked" : opt
    integer "health_amount" : opt
    integer "hurt_item" : opt
    string "interact_text" : opt
    trigger "on_interact"
    object "particle_on_start" : opt
    {
      boolean "particle_offset_towards_interactor" : opt
      string "particle_type" : opt
      number "particle_y_offset" : opt
    }
    sound_event "play_sounds"
    string "spawn_entities" : opt
    object "spawn_items" : opt
    {
      identifier "table"
    }
    boolean "swing" : opt
    string "transform_to_item" : opt
    boolean "use_item" : opt
    string "vibration" : opt
    boolean "give_item" : opt
    boolean "take_item" : opt
    string "drop_item_slot" : opt
    string "equip_item_slot" : opt
    object "repair_entity_item" : opt
    {
      integer "amount" : opt
      string "slot" : opt
    }
  }
  array "interactions" : opt
  {
    object "<any array element>" : opt
    {
    }
  }
}
interactionsobject
The interactions.
interactions
add_itemsobject
Loot table with items to add to the player's inventory upon successful interaction.
add_items
tableidentifier
File path, relative to the Behavior Pack's path, to the loot table file.
identifier:
string
cooldownnumber
Time in seconds before this entity can be interacted with again.
admireboolean
Allows entity to admire the item. Requires "minecraft:admire_item" and "minecraft:behavior.admire_item" to work.
barterboolean
Allows entity to barter with the item. Requires "minecraft:barter" to work.
cooldown_after_being_attackednumber
Time in seconds before this entity can be interacted with after being attacked.
health_amountinteger
The amount of health this entity will recover or hurt when interacting with this item. Negative values will harm the entity.
hurt_iteminteger
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.
interact_textstring
Text to show when the player is able to interact in this way with this entity when playing with Touch-screen controls.
on_interacttrigger
Event to fire when the interaction occurs.
trigger:
string
trigger:
{
  string "event" : opt
  filters "filters"
  subject "target"
}
eventstring
The event to run when the conditions for this trigger are met.
filtersfilters
一个过滤器组。The list of conditions for this trigger to execute.
targetsubject
The target of the event.
subject:
string
trigger:
array
{
  object "<any array element>" : opt
  {
    string "event" : opt
    filters "filters"
    subject "target"
  }
}
<any array element>object
<any array element>
particle_on_startobject
Particle effect that will be triggered at the start of the interaction.
particle_on_start
particle_offset_towards_interactorboolean
Whether or not the particle will appear closer to who performed the interaction.
particle_typestring
The type of particle that will be spawned.
particle_y_offsetnumber
Will offset the particle this amount in the y direction.
play_soundssound_event
List of sounds to play when the interaction occurs.
sound_event:
string
spawn_entitiesstring
List of entities to spawn when the interaction occurs.
spawn_itemsobject
Loot table with items to drop on the ground upon successful interaction.
spawn_items
tableidentifier
File path, relative to the Behavior Pack's path, to the loot table file.
swingboolean
If true, the player will do the "swing" animation when interacting with this entity.
transform_to_itemstring
The feed item used will transform to this item upon successful interaction. Format: itemName:auxValue
use_itemboolean
If true, the interaction will use an item.
vibrationstring
Vibration to emit when the interaction occurs. Admitted values are entity_interact (used by default), shear, and none (no vibration emitted).
give_itemboolean
UNDOCUMENTED Item to give to the player upon successful interaction.
take_itemboolean
UNDOCUMENTED Takes an item from the player.
drop_item_slotstring
The entity's equipment slot to remove and drop the item from, if any, upon successful interaction.
equip_item_slotstring
The entity's equipment slot to equip the item to, if any, upon successful interaction.
repair_entity_itemobject
Allows to repair one of the entity's items.
repair_entity_item
amountinteger
How much of the item durability should be restored upon interaction.
slotstring
The entity's slot containing the item to be repaired.
interactionsarray
The interactions.
interactions
<any array element>object
<any array element>