I'm trying to make a one command creation, so I need a /setblock command to set a command block with a /summon command. This is the command I'm using:

/setblock ~ ~1 ~ minecraft:command_block 4 replace {auto:0b,powered:0b,conditionMet:0b,Command:"/execute @e[type=Wolf,name=MiniMe] ~ ~ ~ /summon Wolf ~ ~ ~ {Owner:PLAYER_NAME,CustomName:"Mini"}",TrackOutput:0}

It keeps saying:

"Data tag parsing failed: Unexpected token 'M' at: Mini"}",TrackOutput:0"

When I use the /summon command normally it works fine! Please help.


The first quotation mark you use opens the string, and thus the very next un-escaped quotation mark will close it, which happens for your CustomName value. In order to avoid using a quotation mark to close the string, you must escape it by prepending it with a backslash (\").

If you need to use more quotation marks as part of the value at a deeper nesting within quotation marks, you'd need to apply more backslashes. The equation for the number of backslashes is 2n+1 where n is the current number of backslashes. For example, if you need quotation marks within an already-escaped set of quotation marks that have 1 backslash, you would need 2*1+1 backslashes (3).

Fixed command applying the backslash:

/setblock ~ ~1 ~ minecraft:command_block 4 replace {auto:0b,powered:0b,conditionMet:0b,Command:"/execute @e[type=Wolf,name=MiniMe] ~ ~ ~ /summon Wolf ~ ~ ~ {Owner:PLAYER_NAME,CustomName:\"Mini\"}",TrackOutput:0}
| improve this answer | |

The problem is, that you are basically closing the command that would go into the command block with the " preceding Mini. Since you don't have any spaces in the custom name you can do this:

/setblock ~ ~1 ~ minecraft:command_block 4 replace {auto:0b,powered:0b,conditionMet:0b,Command:"/execute @e[type=Wolf,name=MiniMe] ~ ~ ~ /summon Wolf ~ ~ ~ {Owner:PLAYER_NAME,CustomName:Mini}",TrackOutput:0}
| improve this answer | |
  • "Since you don't have any spaces in the custom name you can do this" This implies that you need quotation marks if you have spaces, which is not the case. The main purpose of quotation marks as far as the parser is concerned is to allow commas as the value. Its secondary purpose is to ensure that the tag cannot be parsed as any other type, as strings are only used when no other type could match. It would be good practice to use quotation marks for strings for that purpose. – Skylinerw Feb 7 '16 at 13:28

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