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