Minecraft – How to test if a player has an air block underneath their feet? (1.14)

minecraft-commandsminecraft-java-edition

I'm attempting to make a "midas touch"-eqsue system where the block underneath the player's feet will turn to a gold block. However, I found that'll be troublesome if I don't detect for air blocks, since that will basically allow for the player to jump and walk in mid-air.

My command is currently this;
execute as @a at @s unless block ~ ~-1 ~ air run fill ~ ~-1 ~ ~ ~-1 ~ gold_block

Oddly, it's not looking for any (or simply isn't finding) any air blocks at all. It will detect other blocks and refuse to run there, eg. I replaced "air" with "diamond_block" and it worked in not turning diamond blocks, but it refuses to work with air.

Is this a known bug, or am I missing something?

Best Answer

You probably have this problem, because you test the command in a cave. Minecraft has air and cave air, they are considered to be two different blocks.

To solve this problem you can use this command:

/execute at @a unless block ~ ~-1 ~ minecraft:air unless block ~ ~-1 ~ minecraft:cave_air run setblock ~ ~-1 ~ minecraft:gold_block