Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does someone know how to set a command block with a command inside using the setblock command?

I have created this code /setblock <x> <y> <z> command_block {TileEntityData:{Command:"testfor @p[_=1]"}} but it doesn't works.

Do someone know how to do that?

share|improve this question
up vote 5 down vote accepted

You will need to do two things:

  • Firstly, there are two other parts to the /setblock command that need to be present; the datavalue, and the method of handling the existing block, if any.
  • Secondly, the data tag at the end should just be {Command: "testfor @p[_=1]"}, without the TileEntityData bit.

Thus, the resulting command should be along the lines of

/setblock <x> <y> <z> command_block 0 replace {Command:"testfor @p[_=1]"}

As proof, here's a shot of me using that command:

Typing the command

And here's the result:

The resulting command block

share|improve this answer

protected by Frank Jan 27 '15 at 23:21

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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