I wrote a command-block flying base (using this approach
) and it works (in Minecraft 1.15.2 vanilla). The main problem is that it will happily plow through and obliterate any obstacle. I want to put in proximity detection as a safeguard.
If I use the following inside a command block:
execute if block ~-1 ~ ~ minecraft:air run clone ~7 ~ ~-5 ~-3 ~10 ~6 ~-9 ~ ~-5 replace move
It will move the 11x11x11 volume that contains it 6 blocks westward as long as there is a block of empty space behind it. The problem is that it only detects empty space directly behind it and only to a depth of 1 block.
How do I insure that all blocks that would be occupied by the structure in its new location are air prior to cloning it to that location without resorting to a huge chained command like…
execute if block ~-1 ~ ~ minecraft:air if block ~-2 ~ ~ minecraft:air if block ~-3 ~ ~ minecraft:air if block ~-4 ~ ~ minecraft:air... etc. ... run clone ~7 ~ ~-5 ~-3 ~10 ~6 ~-9 ~ ~-5 replace move
Best Answer
You can use
/execute if blocks
: https://minecraft.gamepedia.com/Commands/execute#Condition_subcommands. That compares two areas, so you can have a prepared area that's guaranteed to be only air and compare to that.This command executes if the area from x,y,z to x2,y2,z2 is the same as the area at block_x,block_y,block_z, with the same size as the first area.