Using a command to replace wool blocks with command blocks which contain a command
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.
Best Answer
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:
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:
fill ~2 ~1 ~ ~7 ~1 ~ minecraft:redstone_block(set the stone to redstone blocks)setblock ~-3 ~ ~ stone_button 2 replace(quick reset the button, located on the right side of command block 1)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)fill ~-1 ~ ~2 ~2 ~3 ~5 air 0 replace wool 5(replace green wool with air)fill ~-2 ~ ~2 ~1 ~3 ~5 command_block 0 keep {Command:"setblock ~ ~ ~ wool 5 replace"}(replace the air with command blocks)fill ~-3 ~ ~2 ~ ~3 ~5 air 0 replace barrier 0(replace the barriers with air)fill ~-5 ~1 ~ ~ ~1 ~ stone(reset the redstone blocks back to stone)
After hitting the button on block 1, we see the following:
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.
Pictures about "Using a command to replace wool blocks with command blocks which contain a command"



How do you replace a block with another block in Minecraft with commands?
In Minecraft, you can use the /fill command to replace a specific type of block with another.Is there a command to replace blocks in Minecraft?
Once cheats are enabled, Minecraft: Bedrock Edition players can open their chat console in-game and type out their command. The syntax of the command to replace blocks (in Bedrock Edition specifically) is currently: /fill <from> <to> <tilename> [tiledata] replace <replacetilename> <replacedatavalue>How do you replace a block with another block in Minecraft bedrock?
Type the command in the chat window and press the Enter key to run the command. This /fill command would replace all blocks in the fill region, including air. The replaced blocks will be dropped and can then be collected as if they were mined with a pickaxe or shovel.HOW TO USE COMMANDS TO MASS FILL/DESTROY/REPLACE BLOCKS in Minecraft Bedrock (MCPE/Xbox/PS4/PC)
More answers regarding using a command to replace wool blocks with command blocks which contain a command
Answer 2
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.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Anete Lusina, Sora Shimazaki, Vanessa Loring, Ivan Babydov


