I am trying to replace certain blocks in this case lime wool with a command block that contains a certain command.

The following command to replace lime blocks with stone works:

/fill ~-15 ~0 ~-15 ~15 ~10 ~15 minecraft:stone 0 replace minecraft:wool 5

However the following to replace with command blocks doesn't work:

/fill ~-15 ~0 ~-15 ~15 ~10 ~15 minecraft:command_block 0 replace minecraft:wool 5

Command blocks aren't set and I am unable to figure out if it is even possible to add a command to the command block with the replacing specific blocks command.

  • I think this is possible in a two step process, first by replacing the wool blocks with air, and then using keep to replace the air with the command blocks. Hopefully I'll have time to try this out tonight in order to write an answer.
    – MBraedley
    Jan 5, 2015 at 22:17
  • Fantastic tool: mcstacker.bimbimma.com
    – Mutantoe
    Jun 8, 2015 at 21:41

2 Answers 2


This is pretty easy to do with 4 fill commands in command blocks: 2 for a fill clock (either a 20Hz clock or a single shot pair), and 2 to actually replace the wool. Add one more command block for a single tick button, and 2 more command blocks if your fill area contains air that you don't want command blocks in. I'll assume the latter, since it won't make a difference if there isn't any air blocks to fill initially. So, seven command blocks. This is what it looks like:

Command Block setup

I'm using tilda notation in my command blocks to reference the 4x4x4 area with the wool, but it may be desirable to use absolute coordinates for production purposes. In any case, the commands in the command blocks are as follows:

  1. fill ~2 ~1 ~ ~7 ~1 ~ minecraft:redstone_block (set the stone to redstone blocks)
  2. setblock ~-3 ~ ~ stone_button 2 replace (quick reset the button, located on the right side of command block 1)
  3. fill ~ ~ ~2 ~3 ~3 ~5 barrier 0 replace air 0 (replace the air with barriers, but there may be a better block to use, especially if players will be in the area)
  4. fill ~-1 ~ ~2 ~2 ~3 ~5 air 0 replace wool 5 (replace green wool with air)
  5. fill ~-2 ~ ~2 ~1 ~3 ~5 command_block 0 keep {Command:"setblock ~ ~ ~ wool 5 replace"} (replace the air with command blocks)
  6. fill ~-3 ~ ~2 ~ ~3 ~5 air 0 replace barrier 0 (replace the barriers with air)
  7. fill ~-5 ~1 ~ ~ ~1 ~ stone (reset the redstone blocks back to stone)

After hitting the button on block 1, we see the following:

Green wool replaced with command blocks

As I said earlier, if your target area doesn't contain air blocks, then you can forego the two command blocks that set and reset the barriers. Simply remove them in that case.


Interesting problem, i can't get it to work either. Placing command blocks with a command i do know, but it doesn't seem to want to replace only certain blocks.

Here is the command for filling it with command blocks with a certain command, without the block specific:

/fill ~-15 ~0 ~-15 ~15 ~10 ~15 command_block 0 replace {Command:"say hi"}

This might actually be a bug.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .