The Headpat is a tool that can be used to pet any mob.
Items:
| item | loot table |
|---|---|
Headpat |
headpat:headpat |
Advancements:
| title | description |
|---|---|
Headpats! |
Headpat any mob. |
Ain't She a Beaut |
Headpat a mob that wants to kill you. |
Friend of all Living Things |
Headpat one mob of every type. |
The Headpat can be used on any entity to pet them; they will emit heart particles and make an entity-dependant sound.
Using the Headpat on a player will show a message to that player about being patted on the head by you.
Uses an advancement to detect if a player has used the headpat item on a nameable mob.
Uses a different advancement to detect if a player has used the headpat item on something that's not a nameable mob, and if so, raycasts to check if there's an actual player under the cursor.
Headpatting a player (or the Ender Dragon) is slightly fiddlier than headpatting a regular mob, and it can be done through solid blocks.
Renaming a Headpat item breaks it, because the game searches for the entity
that was just renamed {"translate":"item.wishlist,headpat"} as its target.
The problem is moot if Headpat is used via Hand, though.