Minecraft Commands – Using /clone to Only Replace Air Blocks in Minecraft Java Edition

minecraft-commandsminecraft-java-edition

As the title asks, Is there any way to use the clone command to only replace air blocks, such as breaking a floor and it being replaced by other blocks?

I know that this can be done using /fill, but I wanted to know if it can be done using /clone

Best Answer

There isn't one command to do this and there's a bug report about that: https://bugs.mojang.com/browse/MC-126514

But what you can do is cloning your target area somewhere else, then cloning your source to the target and then cloning the temporary area back to the target using the "masked" mode of /clone. This first makes the target identical to the source and then places back all blocks except for air.