I want to detect the name and color of the stuff I'm holding. But I can't. Please help me [closed]

Solution 1:

Your command looks correct. It’s probably something with your setup.

Here is a very common problem with your setup that you should consider taking a look into.

When checking if the item’s custom name matches the one in NBT, the system is performing a plain text check of the raw JSON text before it is interpreted. It does not care about what the text looks like after it is interpreted. So you need to make sure that your JSON source are exactly the same in the check and the item.

The easiest things to mess up are spacing and order.

  • Spacing: Make sure that extra spaces are the same in both references. So, the following examples render the same, but are considered different:

    {"text": "Test"}
    

    and

    {"text":"Test"}
    
  • Order: Make sure the order of components is the same. The following two examples render the same, but are different:

    {"text":"Test","color":"white"}
    

    and

    {"color":"white","text":"Test"}