TransWikia.com

Why am I getting an 'unexpected token' error with this Minecraft /give command?

Arqade Asked by rainbowlack on December 30, 2020

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]).

2 Answers

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"}}

Correct answer by Skylinerw on December 30, 2020

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"}}

Answered by Aaron Franke on December 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP