data modify entity @s[nbt={Item:{id:"minecraft:azalea",components:{"minecraft:custom_data":{bushhat:tag}}}}] Item.components."minecraft:custom_data" set value {hat:tag,bushhat:tag,specialhat:tag}
data modify entity @s[nbt={Item:{id:"minecraft:azalea",components:{"minecraft:custom_data":{bushhat:tag}}}}] Item.id set value iron_helmet
data modify entity @s[nbt={Item:{id:"minecraft:white_banner",components:{"minecraft:custom_data":{illagerhat:tag}}}}] Item.components."minecraft:custom_data" set value {hat:tag,illagerhat:tag,specialhat:tag}
data modify entity @s[nbt={Item:{id:"minecraft:white_banner",components:{"minecraft:custom_data":{illagerhat:tag}}}}] Item.id set value iron_helmet
data modify entity @s[nbt={Item:{id:"minecraft:glass",components:{"minecraft:custom_data":{spacehat:tag}}}}] Item.components."minecraft:custom_data" set value {hat:tag,spacehat:tag}
data modify entity @s[nbt={Item:{id:"minecraft:glass",components:{"minecraft:custom_data":{spacehat:tag}}}}] Item.id set value iron_helmet
data modify entity @s[nbt={Item:{id:"minecraft:emerald",components:{"minecraft:custom_data":{tradehat:tag}}}}] Item.components."minecraft:custom_data" set value {hat:tag,tradehat:tag}
data modify entity @s[nbt={Item:{id:"minecraft:emerald",components:{"minecraft:custom_data":{tradehat:tag}}}}] Item.id set value iron_helmet