2
Execute players holding renamed item
How do I execute players holding a renamed item? I've checked for hours and on other forums when people say it works for them, it seems to never work for me.
I'm trying to detect for a carrot on a stick with the name "USP". I'm doing /give @p carrot_on_a_stick{display:{Name:"\"USP\""}} to get it.
I've done things like
/execute if entity @s[{SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"USP"}}}}]
and
/execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"{\"text\":\"USP\"}"}}}}]
but nothing works.
You gotta help me, please. I'm desperate. C'mon, please.
I'm trying to detect for a carrot on a stick with the name "USP". I'm doing /give @p carrot_on_a_stick{display:{Name:"\"USP\""}} to get it.
I've done things like
/execute if entity @s[{SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"USP"}}}}]
and
/execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"{\"text\":\"USP\"}"}}}}]
but nothing works.
You gotta help me, please. I'm desperate. C'mon, please.
Create an account or sign in to comment.
8
4
The second command works if you replace the s in @s with an a:
/execute if entity @a[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"{\"text\":\"USP\"}"}}}}]
@s checks for the current entity. So, @s only works when you're executing this command yourself. I put it in a command block and therefore had to change @s to @a. This way it checks for every player if they hold a carrot on a stick named "USP".
/execute if entity @a[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"{\"text\":\"USP\"}"}}}}]
@s checks for the current entity. So, @s only works when you're executing this command yourself. I put it in a command block and therefore had to change @s to @a. This way it checks for every player if they hold a carrot on a stick named "USP".
2
I'm executing the command, but it still says "Test Failed" when I hold the carrot on a stick
Maybe I've been cursed? Who knows.
Maybe I've been cursed? Who knows.
1
Yes, the "test failed" message is the sign that the command was executed successfully xD
You have to put another command behind this first one that will be executed if the first command was successful.
But here there is no other command. It only checks if a player is holding a carrot on a stick named "USP".
You have to put another command behind this first one that will be executed if the first command was successful.
But here there is no other command. It only checks if a player is holding a carrot on a stick named "USP".
2
But when I do that, the command behind it won't run.
Am I doing it wrong?
the command: /execute if entity @a[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"{\"text\":\"USP\"}"}}}}] run say 1
Am I doing it wrong?
the command: /execute if entity @a[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"{\"text\":\"USP\"}"}}}}] run say 1
1
Yes, your command is correct. I just tried it myself and for whatever reason the command only says "1" if your carrot on a stick's name was changed to "USP" in an anvil.
It didn't work with the carrot on a stick I gave myself with a command even though the displayed name is "USP" as well.
No idea why that is, but your command works if you change the item's name in an anvil ^^
It didn't work with the carrot on a stick I gave myself with a command even though the displayed name is "USP" as well.
No idea why that is, but your command works if you change the item's name in an anvil ^^
2
Ok. Any idea on how to make it work when given with commands?
view more replies ( 1 )