Command blocks can be spawned in with the /setblock command. The basic format used is the following:

/setblock ~ ~1 ~ minecraft:command_block 0 replace {Command:"COMMAND GOES HERE",TrackOutput:0}

With the COMMAND GOES HERE being replaced with whatever command you want in the command block.

Exceptions/add-ons: Edit

There are a few commands that you cannot simply put in between the quotes without changing them a bit in order for the command to work. **Any command that has quotes in it requires a \ before each quote in the command.** This is so that the setblock command does not read the quotation mark as the quote that is supposed to signal the end of the command. Thus the only 2 quotes without a \ before them are the ones that surround the whole command. The new command block that is created from the original command will not have the slashes in the command. They are only for the command to actually setblock them.A complex example of this is as follows:

*Note that the slash you are using \ is different than the forward slash (/) that you use to start a command. It is instead located normally on the far right of the keyboard, somewhere below the backspace or delete key.

*Another note. setblock is a verb now, by decree of zakriboss, founder and admin of the technical minecraft wiki.

More examples Edit

Some examples of commands that use quotation marks in the commands:

  • s
  • tellraw
  • title
  • There are many others, but these are just so you can get the idea.
Community content is available under CC-BY-SA unless otherwise noted.