Interaction

| Health points |
None |
|---|---|
| Behavior |
None |
| Hitbox size |
Customizable |
{
"title": "Interaction",
"rows": [
{
"field": "None",
"label": "(link to Health article, displayed as Health points)"
},
{
"field": "None",
"label": "Behavior"
},
{
"field": "Customizable",
"label": "(link to Hitbox article, displayed as Hitbox size)"
}
],
"invimages": [],
"images": [
"Blank.png"
]
}
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 boundary 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.
Advancement triggers
- Interacting with (right-clicking) an interaction entity triggers
player_interacted_with_entity. - Attacking (left-clicking) an interaction entity triggers
player_hurt_entity.
Commands
The interaction entity targets the player who last interacted with it. That makes the following possible:
/execute on attackerexecute as the last player who attacked (left-clicked) the entity./execute on targetexecute as the last player who interacted with (right-clicked) the entity.
Data values
ID
| Entity | Identifier | Translation key |
|---|---|---|
interaction | entity |
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.4 | 23w07a | Added interaction entities. | |||||