Forumskeyboard_arrow_right Help keyboard_arrow_right Java Edition

Create Forum Thread
2

Execute players holding renamed item

2 emeralds8 replies156 views
created 09/15/2019 2:25 pm by macandcheese271 history
last reply 10/07/2019 6:45 pm
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.
Posted by avatar
macandcheese271
Level 1 : New Miner
0

comment Login or register to post a reply.

8 replies

4
09/15/2019 4:05 pm
Level 64 : High Grandmaster Hero
Captain_JEK
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".
2
09/16/2019 5:58 pm
Level 1 : New Miner
macandcheese271
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.
1
09/17/2019 10:24 am
Level 64 : High Grandmaster Hero
Captain_JEK
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".
2
09/17/2019 4:09 pm
Level 1 : New Miner
macandcheese271
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
1
09/18/2019 10:43 am
Level 64 : High Grandmaster Hero
Captain_JEK
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 ^^
2
09/18/2019 9:57 pm
Level 1 : New Miner
macandcheese271
Ok. Any idea on how to make it work when given with commands?

Planet Minecraft

Browse

Site

© 2010 - 2019
www.planetminecraft.com

Welcome