In its current state, using the minecraft:component property does not allow you to check individual values inside of a component.
This prevents you from using certain components like minecraft:custom_data inside of resource packs, since they can contain multiple values that have to all be checked at once instead of individually.
For example, a sword with minecraft:custom_data={id:"COOL_SWORD",extra_data:"yes"} will return false when checked using "when": "{id:\"COOL_SWORD\"}"
This is not the same behavior observed when using commands such as /execute if data, which will return true in this case.
Give yourself this sword:
/give @s minecraft:golden_sword[minecraft:custom_data={id:"COOL_SWORD",extra_data:"yes"}]
Drop it on the ground, then run this command:
/execute if data entity @n[type=minecraft:item] {Item:{components:{"minecraft:custom_data":{id:"COOL_SWORD"}}}}
Notice the command's test passes
This single change would make the minecraft:component select property way more usable inside of resource packs, especially in cases where the player does not have the ability to modify the nbt of the items they are texturing.
Please sign in to leave a comment.
0 Comments