I'm trying to place a sign that places a command block in itself for some effects, but trying to activate the command block, I get the error:

Data tag parsing failed: Expected '}' but got 'H' at: ...1,CustomNameVisible:1,CustomName:"H<--[HERE]


/setblock ~ ~ ~ minecraft:standing_sign 0 replace {Text1: "{\"text\":\"right click\"}",Text2: "{\"text\":\"\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"setblock ~ ~ ~ command_block 0 replace {Command:/summon armor_stand ~ ~ ~ {Unbreaking:1,Invisible:1,Invulnerable:1,NoGravity:1,Marker:1,CustomNameVisible:1,CustomName:"Hi"}}\"}}"}

Any help? I tried adding \" and such, but it didn't help. Note, I'm in 1.12.1

Thanks in advance!

  • Firstly: Leave out the spaces after the colons. They are not needed and will likely break the command. – Fabian Röling Dec 12 '17 at 12:38
  • 1
    Don't just randomly add \" somewhere. If you don't know how your command even works, you shouldn't make random changes, but instead try to understand it. Build it up from smaller commands. – Fabian Röling Dec 12 '17 at 13:25

You have several problems with your command. The biggest one is escaping of the special characters which gets a little complicated when you have quotes inside quotes inside quotes which you do. It will be a long read as I will try to explain each step.

First, lets start at the end. The command that you want the sign to run. This is what Fabian was getting at with his comment. Start small to make sure everything works and move on to the next step. Here is the command:

setblock ~ ~ ~ command_block 0 replace {Command:/summon armor_stand ~ ~ ~ {Unbreaking:1,Invisible:1,Invulnerable:1,NoGravity:1,Marker:1,CustomNameVisible:1,CustomName:"Hi"}}

Run in a command block gives:

Data tag parsing failed: Expected value at: {Command:<--[HERE]

Your command will not run on it's own. The Command portion has to be contained in quotes. The CustomName value contains quotation marks which are within a set of quotation marks so they need to be escaped. (\") This gives us:

setblock ~ ~ ~ command_block 0 replace {Command:"summon armor_stand ~ ~ ~ {Unbreaking:1,Invisible:1,Invulnerable:1,NoGravity:1,Marker:1,CustomNameVisible:1,CustomName:\"Hi\"}"}

Next, we need to contain this entire command in another set of quotation marks as it is part of the value portion of the clickEvent requires it. This means that all the special characters of the last command need to be escaped. Any characters already escaped need to be escaped again. In the case of \" which are around Hi, there are two characters to escape which means you need two more \\ which gives you \\\" Here is that portion properly escaped:

"value":"setblock ~ ~ ~ command_block 0 replace {Command:\"summon armor_stand ~ ~ ~ {Unbreaking:1,Invisible:1,Invulnerable:1,NoGravity:1,Marker:1,CustomNameVisible:1,CustomName:\\\"Hi\\\"}\"}"

I was not quite sure why you had Text2 as it contained no text so I just moved the clickEvent into the Text1 portion. The Text1 portion requires another set of quotation marks which means you get to escape all those special characters. The one worth mentioning is the quotation marks around CustomName value. They are already double escaped (\\\") and need to be escaped again for triple escapement. There are 4 characters to escape which gives you: \\\\\\\".

Here is a command which will successfully execute:

/setblock ~ ~ ~ minecraft:standing_sign 0 replace {Text1:"{\"text\":\"Right Click\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"setblock ~ ~ ~ command_block 0 replace {Command:\\\"summon armor_stand ~ ~ ~ {Unbreaking:1,Invisible:1,Invulnerable:1,NoGravity:1,Marker:1,CustomNameVisible:1,CustomName:\\\\\\\"Hi\\\\\\\"}\\\"}\"}}"}

It's a weird command. When executed, it will destroy the original command block and place the custom sign. When the sign is clicked, it will replace the sign with another command block. When the command block is executed is summons an invisible armor stand so all you see is the nametag inside the command block:

Command block

I used: /kill @e[type=armor_stand,name=Hi] to get rid of it.

  • Thanks! coming from 1.11.2, this \ thing is new for me. But, it is very nicely explained and makes sense. Thanks, again! – Jace Dec 13 '17 at 19:16

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