When running any of these commands, you see a message in the chat, meaning the block detection is successful.
/execute @a ~ ~ ~ detect ~ 500 ~ air 0 say a
/execute @a ~ ~ ~ detect ~ -1 ~ air 0 say b
/execute @a ~ ~ ~ detect ~ ~300 ~ air 0 say c
But since the detection is made outside of the world it should not confirm the detection and not execute the say command. Others commands like testforblock, blockdata just return an error message :
/testforblock ~ 300 ~ air
=>The number you have entered (300.0) is too big, it must be at most 256
/testforblock ~ -1 ~ air
=>The number you have entered (-1.0) is too small, it must be at least 0
Comments 4
"air block does not exist in Minecraft", you are confusing blocks and items : yes you can't get an "air block" as an Item, but there is an "air" block with an ID of 0, you can find something like this in the code :
registerBlock(0, AIR_ID, (new BlockAir()).setUnlocalizedName("air"));
Then you are confusing absolute and relative coordinate : in any case, it doesn't matter whether you specify absolute or relative coordinate since the position will be converted to absolute when the command is executed at a fixed position.
/testforblock ~ 300 ~ air
/testforblock ~ ~50 ~ air
Assuming the player is at Y=250 and execute the command, the result is the same.
Then, the question is not why do I testfor a block with such coordinate, but rather why minecraft say on one case(with execute detect) that there is an air block at X -1 Z, and on the other hand (with testforblock) it says X -1 Z is not a correct coordinate.
This is most likely an issue due to the fact execute returns the status of the command running, not the commands output.
Really, a "air" block does not exist in Minecraft, but it is used the represent a empty block in command blocks, which therefore is basically anything above 256 and below 0.
The actual problem here is that the /testforblock function is programmed to error when the coordinates entered are incorrect.
Which makes sense, because, why would you want to test whether a block with such coordinates is a empty block, while it is already known it is?
Note that this does not apply to /execute, as it is possible for an entity to be at -10, making a test for the block ~266 sensible.