For Minecraft 1.17+
Datapack Features:
Enables anyone to put any item on their head!
Typing “/trigger Hat” will move one item from your hand to your head!
Admins may type “/function hats:replace” to forcefully copy all items they’re holding to their head, even if they are already wearing an item.
Survival & Multiplayer friendly