This question already has an answer here:

I am making an adventure map that includes a sort of redstone clock. I want to set a command block connected to the clock and have it spawn items. Unfortunately, I am not very skilled in command blocks and could use a little help.

This is my command:

/setblock 138 93 254 minecraft:command_block 0 replace {Command:"/summon Item 140 115 245 {Item:{id:"minecraft:gold_nugget",Count:1}}"}

When I execute the command, it returns with this output:

Data tag parsing failed: Unexpected token 'm' at: minecraft:gold_nugget",Count:1}}"

Can anyone please help me? Thank you.

marked as duplicate by bearb001, Virusbomb, Gigazelle, arghtype, Nelson Jul 10 at 2:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You need to escape the middle set of quote marks around the ID by putting backslashes (\) before them, like this:

/setblock 138 93 254 minecraft:command_block 0 replace {Command:"/summon Item 140 115 245 {Item:{id:\"minecraft:gold_nugget\",Count:1}}"}

Otherwise the command parser thinks the block's command is "/summon Item 140 115 245 {Item:{id:" then seeing the word minecraft: when there should have been a close curly bracket (}). Backslashes tell programs to ignore the special function of a symbol and treat it like any other part of a string.
As an alternative, you could enter "/give @p minecraft:command_block" and input the summon command manually.

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