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

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.

/execute if blocks <x> <y> <z> <x2> <y2> <z2> <block_x> <block_y> <block_z> all run clone ~7 ~ ~-5 ~-3 ~10 ~6 ~-9 ~ ~-5 replace move

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.

| improve this answer | |
  • Please check first what the command actually does before you answer. /execute if blocks compares two areas, not one area and a single block. The wiki also says that. I edited the answer accordingly, since I was just about to write an answer with the same command anyway, it just works differently than you think. – Fabian Röling May 17 at 21:55
  • Hmm, that would explain why some of my experiments didn't work. Thanks for the correction! – MegaCrafter10 May 17 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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