Place on Head [Datapack Edition]
by LegopitstopCommands
Swap the item that you are holding to place it on your head.
/trigger head
tested on 1.17 snapshot 20w46ashould work on any version 20w56a and up unless future versions change the /item command.
Overview
You can apply custom NBT tags to an item so it shows any text when a player places it on their head via the trigger command. Below you can find an example item "Space Helmet". There are multiple pre-set formats as well as full customizability to the text, even more than v1.0.0
Version System
v1.1.0+ will now require the head item to have its builder version. For example, if you made an item from v1.0.0 you will have to add the version 1.0.0, it should look something like this Version:"[1.0.0]" This will load the older builder meaning you will not need the Type as that was added in v1.1.0. You can also just define the latest and it will load the latest builder version. The code should look like this Version:"{latest-version}". If you put an invalid version it will tell you when you do /trigger head. If there is a part of the code that is missing that the builder needs it will most likely not display anything depending on what type you selected.
Type System
Type:"renamed"
This will automaticly make the text italic and add single quotes around the text, (Does not except RAW JSON/Formating)
{head:{Version:"[1.1.0]",Type:"renamed",Name:"<Text to show up>"}}
Swapped head item with 'Renamed Item Format'
Type:"identifier"
This will use a custom item id. Note that "id" is not located inside the "head" object. (I use this custom ID for all my current/new data packs that add "new" items, It makes things easier.) (Does not except RAW JSON/Formatting)
{id:"custom:custom_item_identifier",head:{Version:"[1.1.0]"},Type:"identifier"}}
Swapped head item with custom:custom_item_identifier
Type:"custom_name"
This is similar to the old code from v1.0.0 but has the new Version and Type systems. (Excepts RAW JSON/Formatting)
{head:{Version:[1.1.0],Type:"custom_name",Name:'{"text":"Custom Name Text","color":"aqua"}'}}
Swapped head item with Custom Name Text
Type:"custom_all"
This is where you can completely customize the text that is displayed when you do /trigger head. (Excepts RAW JSON/Formatting)
{head:{Version:"[1.1.0]",Type:"custom_all",Name:'[{"text":"Begin: ","color":"dark_aqua"},{"text":"Custom Name text","color":"aqua"}]'}}
Begin: Custom Name Text
EXAMPLE ITEM
Get "Space Helmet" Item
give @p minecraft:tinted_glass{id:"custom:space_helmet",head:{Version:"{latest-version}",Type:"identifier"}},display:{Name:'{"text":"Space Helmet","italic":false}',Lore:['{"translate":"Use %s to place on head","color":"dark_gray","italic":false,"with":[{"text":"/trigger head","color":"gray","italic":true}]}']}}