use an enhanced for loop to iterate over Direction.values()
use BlockPos#offset(Direction) to get the block pos that is offset 1 block in the given Direction
use World#getBlockState(BlockPos) and BlockState#isOf(Block) to check if its air
use World#setBlockState(BlockState) to set the block at that position