How do you use /setblock to make a conditional command block?

I am trying to figure out how to use /setblock to create conditional/unconditional and needs redstone/always active command blocks. I saw other posts with the same question but I tried them and the answers didn't work.


This answer is for 1.13+. If you are in 1.12 or below, please use my other answer.


Here is a list of all the things you can change about a command block and how to do so.

Changing the command block type (impulse, chain, repeat):

Impulse: /setblock ~ ~ ~ minecraft:command_block
Chain:   /setblock ~ ~ ~ minecraft:chain_command_block
Repeat:  /setblock ~ ~ ~ minecraft:repeating_command_block

Use these values as the block ID to change the command block type.

Block States

The following items can be changed through the command block's block states.

Changing whether the command block is conditional:

/setblock ~ ~ ~ minecraft:command_block[conditional=true]

Changing which way the command block faces (important for command chains!):

/setblock ~ ~ ~ minecraft:command_block[facing=down|east|north|south|up|west]

Use the F3 debug screen to check which way you're facing.

NBT Data

The following items can be changed by specifying NBT data values:

Changing whether the command block is Always Active or Needs Redstone:

Always Active:  /setblock ~ ~ ~ minecraft:command_block{auto:1b}
Needs Redstone: /setblock ~ ~ ~ minecraft:command_block{auto:0b}

Changing whether the Previous Output is stored (the X/O button in the GUI):

Yes: /setblock ~ ~ ~ minecraft:command_block{TrackOutput:1b}
No:  /setblock ~ ~ ~ minecraft:command_block{TrackOutput:0b}

Final Notes

To combine block states and NBT values, you put the block states ([]s) before the NBT values ({}s):

/setblock ~ ~ ~ minecraft:command_block[conditional=true]{auto:1b}

This is also the command you'll need to make a conditional, always active command block!

Note: If you are using a chain command block, the auto tag is set to 1b by default, so you don't need to specify it.


This answer is for 1.12 or below. If you are in 1.13+, please use my other answer.


Here is a list of all the things you can change about a command block and how to do so.

Changing the command block type (impulse, chain, repeat):

Impulse: /setblock ~ ~ ~ minecraft:command_block
Chain:   /setblock ~ ~ ~ minecraft:chain_command_block
Repeat:  /setblock ~ ~ ~ minecraft:repeating_command_block

Use these values as the block ID to change the command block type.

Block States / Data Values

The following items can be changed through the command block's block states or data values. Block state support has only been added in 1.11. 1.10 and below only allows editing of data values, a number that represents a combination of block states.

Using Block States

This is the recommended way to change these values if you're on 1.11–1.12. If you are in an older version, please skip to the next section for Data Value editing.

Changing whether the command block is conditional:

/setblock ~ ~ ~ minecraft:command_block conditional=true

Changing which way the command block faces (important for command chains!):

/setblock ~ ~ ~ minecraft:command_block facing=north

Use the F3 debug screen to check which way you're facing.

Using Data Values

The data value is the 0 that you put between the block ID and the NBT data. Each possible value represents a combination of different block states:

/setblock ~ ~ ~ minecraft:command_block YOUR_NUMBER_HERE

Data value editing has been supported since the addition of /setblock. However, if you are in 1.11+, it is recommended to use block states to change these properties. See the previous section.

Here are the steps to calculating the number to use for your data value:

  1. Choose a number depending on which way you want your command block to face:
    • 0: Down
    • 1: Up
    • 2: North
    • 3: South
    • 4: West
    • 5: East
  2. Add 8 to that number if you would like the command block to be conditional.

This number is your entry for the block's data value.

NBT Data

The following items can be changed by specifying NBT data values:

Changing whether the command block is Always Active or Needs Redstone:

Always Active:  /setblock ~ ~ ~ minecraft:command_block 0 {auto:1b}
Needs Redstone: /setblock ~ ~ ~ minecraft:command_block 0 {auto:0b}

Changing whether the Previous Output is stored (the X/O button in the GUI):

Yes: /setblock ~ ~ ~ minecraft:command_block 0 {TrackOutput:1b}
No:  /setblock ~ ~ ~ minecraft:command_block 0 {TrackOutput:0b}

Final Notes

To combine block states and NBT values, you exclude the 0 between the block ID and the NBT area:

/setblock ~ ~ ~ minecraft:command_block conditional=true {auto:1b}

This is also the command you'll need to make a conditional, always active command block!

To include multiple block states in your command, use a comma , to separate them. Do not put a space after the comma or an error is registered:

/setblock ~ ~ ~ minecraft:command_block conditional=true,facing=north

Note: If you are using a chain command block, the auto tag is set to 1b by default, so you don't need to specify it.