/execute if entity @p[nbt={Inventory:[{tag:{Name:"{\"text\":\"Talk001\"}"}}]}] run say hi
I this this command is broken... Why isn't it working?
?!?
Comments 5
I believe that is just an issue with the way you formatted it. Try
/execute at @p if entity @p[nbt={Inventory:[{tag:{Name:"
{\"text\":\"Talk001\"}
"}}]}] run say hi
if you would like it to actually execute from the command, try /execute at/as @s
(This formatting still applies)
After some testing this is the best I have... and it still doesn't work when it probably should
/execute at @p if entity @e[type=player,limit=1,nbt={Inventory:{Slot: 20b, id: "minecraft:name_tag", Count: 1b, tag: {RepairCost: 0, display: {Name: "
{\"text\":\"Talk001\"}
"}}}}] run say hi
/execute at @s if entity @p[nbt={Inventory:{tag:{display:{Name:"
{\"text\":\"Talk001\"}
"}}}}] run tellraw @p "hi"
There are some redundancies, but I wanted to be sure it wasn't an issue with the one entity limit. Unfortunately, the command itself does not show any errors.
Update The brackets also can be arranged differently to be more accurate to what the player nbt shows, but it does not fix the problem
I hope you see this, because I've fixed your problem.
/tellraw @p[nbt={Inventory:[{Slot: 31b, id: "minecraft:totem_of_undying", Count: 1b, tag: {RepairCost: 0, display: {Name: "{\"text\":\"Talk001\"}"}}}]}] "Hello"
This provides the function to specific slots and items (count as well)
/tellraw @p[nbt={Inventory:[{tag: {display: {Name: "{\"text\":\"Talk001\"}"}}}]}] "Hello"
This simply tests for if the named item is in the players inventory (including hotbar)
These provide the function you were looking for without having to use the execute command
I hope this was helpful
The last one that is the only one that helped.
/tellraw @p[nbt={Inventory:[{tag: {display: {Name: "
{\"text\":\"Talk001\"}
"}}}]}] "Hello"
I don't really understand what was wrong with what I wrote 😞.
Could you explain me what was the issue?
Was it a bug?
Hello!
Okay, so to explain...
This is what you wrote:
/execute if entity @p[nbt={Inventory:[{tag:{Name:"
{\"text\":\"Talk001\"}
"}}]}] run say hi
What's good is that at first glance your square ([]) and curly ({}) brackets are balanced. The issue really lies in the lack of information for the command to work. To be fair execute used to work differently where you did not need to include as many specifics. In this case, you would need to write: /execute as/at (preferably at) @p[nbt={Information here}] run say hi
Although this would work, you can simplify it a bit using a selector for the actual command you want to run:
(I'll use tellraw for this one; it is cleaner)
This is an alteration on one of the ones I made yesterday for some commands.
/tellraw @a[nbt={Inventory:[{Slot: 31b, id: "minecraft:sunflower", Count: 1b, tag: {RepairCost: 500, display: {Name: "{\"text\":\"Ring of Invisibility\"}"},Enchantments: [{lvl: 5s, id: "minecraft:"}]}}]}] "Test Message"
I suggest copying this command into a command block and then removing the tags (specifiers) and their respective brackets from the command until you have only the specifiers you want. If it comes up red (since I actually just happen to have the command on clipboard) mess around with the last two brackets, but it seems sound to me.
So to clarify, the command you wrote wasn't wrong, it just didn't include enough information to go off of for it to work correctly. Let me know if you have any questions.
Thank you for your report!
However, this issue is Invalid.
This is a technical support issue; this site is for bug reports only. We do not have the resources to provide you with technical support.
Please contact the community support, linked below.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki