Interaction

Minecraft Wiki article. Categories: Minecraft_Work_in_progress, Minecraft_Work_in_progress_without_a_note, Java_Edition, Entities

📌 Mirrored from Minecraft Wiki

This article is reproduced from Interaction on the Minecraft Wiki. Mirrored from revision 3719373. It is licensed CC BY-NC-SA 3.0 by the Minecraft Wiki contributors — not under the Codex’s CC BY-SA 4.0, and it may not be used commercially. Edits belong upstream, not here.

This article is a work in progress.
 
Please help expand and improve it. The talk page may contain suggestions.
This feature is exclusive to Java Edition.
 
Interaction
Blank.png: Infobox image for Minecraft entity 'Interaction'

Interaction entities are a technical entity, useful for map or data pack creators to see who the last player to click on a certain spot is. They can only be created with the /summon or /execute summon commands. Interaction entities are invisible, invincible and of a custom size. Their bounding box can be viewed via the F3 + B debug shortcut.

Behavior

Interaction entities record the UUID of the last player that left-clicked and right-clicked them, and the time at which the interaction happened. If response is set to true, left-clicking an interaction entity plays a punching sound, and right-clicking it makes the player's arm swing.

Usage

You can check information on who last left-clicked and right-clicked on the interaction entity with the /data get entity command. This information can be useful in datapack and map creation. You can also change their size to match the area you want to be checked. Although there is seemingly no limit on the size that may be specified, there still appears to be an effective limit of 22.6 blocks in each dimension. Interactions and attacks will not be detected on the part of the hitbox beyond 3.3 blocks away from the entity's position (which is at the center of the hitbox) in the negative X and Z directions, and the same is true in the positive directions beyond 19.3 blocks away. In the Y direction, the bottom of the hitbox is always at the Y coordinate of the entity's position, so interactions and attacks are not detected beyond 22.6 blocks above the Y coordinate.

Advancement triggers

Commands

The interaction entity targets the player who last interacted with it. That makes the following possible:

  • /execute on attacker execute as the last player who attacked (left-clicked) the entity.
  • /execute on target execute as the last player who interacted with (right-clicked) the entity.

Data values

ID

EntityIdentifier Translation key
BlockSprite air.png: Sprite image for air in Minecraft Interactioninteraction entity.minecraft.interaction

Entity data

Interaction entities have entity data associated with them that contain various properties of the entity.

  • [NBT Compound / JSON Object] Entity data
    • Tags common to all entities see Template:Nbt inherit/entity/template
    • [Float] width: The width of the entity's bounding box. Defaults to 1.
    • [Float] height: The height of the entity's bounding box. Defaults to 1.
    • [Byte] response: 1 or 0 (true/false). Specifies whether an interaction should trigger a response (hand animation). Defaults to 0 (false).
    • [NBT Compound / JSON Object] attack: The last attack (left click) to hit the entity.
      • [Int Array] player: The UUID of the player that attacked the entity. The 128-bit UUID is stored as four 32-bit integers, ordered from most to least significant.
      • [Long] timestamp: When the attack took place.
    • [NBT Compound / JSON Object] interaction: The last interaction (right click) to hit the entity.
      • [Int Array] player: The UUID of the player that interacted with the entity. The 128-bit UUID is stored as four 32-bit integers, ordered from most to least significant.
      • [Long] timestamp: When the interaction took place.

History

Java Edition
1.19.423w07aAdded interaction entities.

Sources