How do I code a command block so that it checks for if a player is wearing a specific Helmet called "☀ Disco Helm ☀"?

Solution 1:

here is the working command. For an explaination, see below.

/execute as @s[nbt={Inventory:[{Slot:103b,id:"minecraft:leather_helmet",tag:{display:{Name:"{\"name\":\"☀ \",\"color\":\"gold\","italic":"false"},\"name\":\"D\",\"color\":\"dark_red\"},{\"name\":\"i\",\"color\":\"red\"},{\"name\":\"s\",\"color\":\"gold\"},{\"name\":\"c\",\"color\":\"yellow\"},{\"name\":\"o \",\"color\":\"green\"},{\"name\":\"H\",\"color\":\"aqua\"},{\"name\":\"e\",\"color\":\"blue\"},{\"name\":\"l\",\"color\":\"light_purple\"},{\"name\":\"m\",\"color\":\"purple\"},{\"name\":\" ☀\",\"color\":\"yellow\"}"}}}]}] run setblock 1 4 4 minecraft:redstone_block replace`

You need to specify the color for each change in color. That was the only error in your command. I have to admit, it is painstaking. If the above command doesn't work, please tell me what color you set the spaces to in the comments. (Yes, spaces have a color)

You're welcome, ShadeOfLight