So basically I'm doing a minecraft datapack for my server, but being really new to that I'm stuck on a problem and I don't know how to solve it:
I've got this line detecting if there is an item frame containing a leather helmet, and then executes a command:
execute as @s if entity @e[type=minecraft:item_frame,nbt={Item:{id:"minecraft:leather_helmet"}}] run command
And the caller of the command, the @s
is another item_frame, a leather_boots, but with a certain coloration.
So what I would like to do is to take the color into account in my execute
line: I'd like to test if the @s
entity's color is the same than the @e
's one…
It would look like that so I'm sure you understand :
execute as @s if entity @e[type=minecraft:item_frame,nbt={Item:{id:"minecraft:leather_helmet",tag:{display:{color=<@s_Color>}}}}] run command
With <@s_Color>
being the color of @s
Maybe I could achieve this by storing the color of @s
in the first place? But then again, I'm just a beginner with minecraft commands and don't know if it is possible…
I searched all over the internet but didn't found something similar.
Edit: I'm using colored leather armors because it offers me a high number of variations so I have many [boots – helmets] pairs in order to do what I need. But there could be another way, maybe with a specific block or a named entity? Anyway, I would need a way to compare them
Best Answer
You need to store the NBT field in a scoreboard with
execute store
anddata get
, then subtract one from the other and check for 0.