execute at @s run summon armor_stand ~ ~ ~ {Tags:[equiphat],Invisible:1b,Small:1b,DisabledSlots:4144959,attributes:[{id:scale,base:.01}]}
execute at @s run data modify entity @n[tag=equiphat] equipment.head set from entity @s equipment.head

#bushhat
execute if entity @s[nbt={equipment:{head:{id:"minecraft:iron_helmet",components:{"minecraft:custom_data":{bushhat:tag}}}}}] run tag @e[tag=equiphat] add bushhat
execute as @e[tag=equiphat,tag=bushhat] run data modify entity @s equipment.head.id set value azalea
execute as @e[tag=equiphat,tag=bushhat] run data modify entity @s equipment.head.components."minecraft:equippable" set value {slot:head}
execute as @e[tag=equiphat,tag=bushhat] run data modify entity @s equipment.head.components."minecraft:custom_data" set value {bushhat:tag,replacehat:tag,specialhat:tag}
#illagerhat
execute if entity @s[nbt={equipment:{head:{id:"minecraft:iron_helmet",components:{"minecraft:custom_data":{illagerhat:tag}}}}}] run tag @e[tag=equiphat] add illagerhat
execute as @e[tag=equiphat,tag=illagerhat] run data modify entity @s equipment.head.id set value white_banner
execute as @e[tag=equiphat,tag=illagerhat] run data modify entity @s equipment.head.components."minecraft:equippable" set value {slot:head}
execute as @e[tag=equiphat,tag=illagerhat] run data modify entity @s equipment.head.components."minecraft:custom_data" set value {illagerhat:tag,replacehat:tag,specialhat:tag}
#spacehat
execute if entity @s[nbt={equipment:{head:{id:"minecraft:iron_helmet",components:{"minecraft:custom_data":{spacehat:tag}}}}}] run tag @e[tag=equiphat] add spacehat
execute as @e[tag=equiphat,tag=spacehat] run data modify entity @s equipment.head.id set value glass
execute as @e[tag=equiphat,tag=spacehat] run data modify entity @s equipment.head.components."minecraft:equippable" set value {slot:head}
execute as @e[tag=equiphat,tag=spacehat] run data modify entity @s equipment.head.components."minecraft:custom_data" set value {spacehat:tag,replacehat:tag}
#spacehat
execute if entity @s[nbt={equipment:{head:{id:"minecraft:iron_helmet",components:{"minecraft:custom_data":{tradehat:tag}}}}}] run tag @e[tag=equiphat] add tradehat
execute as @e[tag=equiphat,tag=tradehat] run data modify entity @s equipment.head.id set value emerald
execute as @e[tag=equiphat,tag=tradehat] run data modify entity @s equipment.head.components."minecraft:equippable" set value {slot:head}
execute as @e[tag=equiphat,tag=tradehat] run data modify entity @s equipment.head.components."minecraft:custom_data" set value {tradehat:tag,replacehat:tag}

item replace entity @s armor.head from entity @n[tag=equiphat] armor.head

kill @e[tag=equiphat]
advancement revoke @s only survivalplus:tools/armor/equiphat