1

I'm trying to make a sign that you can right click and it will clear cacti from your inventory, then give you 18 cookies named "$100 Cookie" with the lore "$100". But when I put it in a command block and power it, the command block says this:

[04:23:51] Data tag parsing failed: Unexpected token '$' at: $100 Cookie\",Lore:[$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"

The command I'm using is:

/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p[name=rainbowlack,r=3] cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p[name=rainbowlack,r=3] minecraft:cookie 18 0 {display:{Name:\"$100 Cookie\",Lore:[$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}

What's wrong with this command? I've tried backslashes and stuff. Can you please try to fix the command and test out your potential fix in-game? Thank you!

You'll have to change the [name=rainbowlack,r=3] parts to whatever your username is (example: [name=playerplayer123,r=3]).

3

You need to add more escape characters to deeper-nested quotation marks. You open the Text1 tag with a ", thus the very next " character closes it. You open the value tag for the click event with \", meaning the next \" you use will close it, which occurs in your nested /give command's NBT data (specifically just after the Name tag). That it what's causing your issue.

The formula to determine the number of backslashes required is: 2n+1, where n is the number of current backslashes. For the nested NBT data, you need 3 backslashes per quotation mark (\\\").

Fixed command:

/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p[name=rainbowlack,r=3] cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p[name=rainbowlack,r=3] minecraft:cookie 18 0 {display:{Name:\\\"$100 Cookie\\\",Lore:[$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}
0

Place backslashes in front of the $ symbols. If the rest of the command is correct, this should work:

/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p[name=rainbowlack,r=3] cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p[name=rainbowlack,r=3] minecraft:cookie 18 0 {display:{Name:\"\$100 Cookie\",Lore:[\$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}

Also, including the username shouldn't be necessary as far as I can tell. Why not:

/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p minecraft:cookie 18 0 {display:{Name:\"\$100 Cookie\",Lore:[\$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}
  • The sign is visible, but the 2nd row says {"text":"2304 and doesn't give me the cookies! – rainbowlack Nov 5 '16 at 3:52
  • What is the desired output of the 2nd line? – Aaron Franke Nov 5 '16 at 4:02
  • I want it to say "2304 Cacti" in red and for it to give me 18 cookies with the name "$100 Cookie" and lore "$100" – rainbowlack Nov 5 '16 at 4:06
  • Dollar signs do not require escaping and will not fix the issue. – Skylinerw Nov 5 '16 at 5:00
  • 1
    Then why does @rainbowlack receive this error, which is fixed (or at least the command block accepts it) when adding escape characters? The evidence doesn't support your statement. I feel sad that people downvote me for providing a valid answer (regarldess of the fact that a 2nd problem appeared when this was fixed). – Aaron Franke Nov 5 '16 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.