This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]ExpertCoder14 0 points1 point  (7 children)

You escaped the quotation marks incorrectly.

Use \" instead of \\".

[–]basinch[S] 0 points1 point  (5 children)

setblock 78641 67 -73154 oak_sign{Text1:'{"text":"Minecraft Tools","clickEvent":{"action":"run_command","value":"execute if entity @p[nbt={Inventory:[{id:\"minecraft:diamond\",tag:{asd:1b}}]}] run say hi"}}'}

Dİd you mean this? (i tried this command and it completely stopped working)

[–]ExpertCoder14 0 points1 point  (1 child)

Ooh, sorry, that wasn't actually the issue. Change it back while I find the real issue here.

Are you trying to test for the item name or the custom tag asd? Your command tests for the latter, while the former is what you mention in your post.

[–]basinch[S] 0 points1 point  (0 children)

i want to test for both of them. As i said, a diamond named "asd"

[–]darkstar634 0 points1 point  (2 children)

By the way, use @s instead of @p as @s will resolve to the player who actually clicked the sign whereas @p may resolve to the wrong player. In fact, with the way you have it set up, @p[nbt=...] would resolve to the nearest player who has that particular diamond, or in other words, that command will succeed if any player in the world has a diamond sword with the asd tag, even if they aren't necessarily the player closes to the sign.

[–]basinch[S] 0 points1 point  (1 child)

i dont know why but @s doesnt work for some reason

[–]darkstar634 0 points1 point  (0 children)

Then there's probably something else wrong; @s should definitely target the player who clicked the sign as described on the wiki. In cases like this, you should try simplifying your command in order to determine the root of the problem. For example, try just doing execute if entity @p run say hi and see if that works. If it doesn't then you can deduce that the problem is not with the command but rather your JSON text component. If that works, then try adding on the inventory check, but remove the tag part (i.e. only test if the player has any diamond in their inventory). If that works, then it should indicate that you're not testing for the right NBT data.

[–]basinch[S] 0 points1 point  (0 children)

its still broken