How can I check if a player is in the air with /testfor?

Solution 1:

Try this:

testfor <player> {OnGround:1b}

Tests for specified player on the ground, then make a comparator to a NOT gate (Block with a redstone torch on it)

Solution 2:

Let's make an objective to track this, and call it 'ground'.

/scoreboard objectives add ground dummy

This command needs to be executed only once.

Then, on a fast clock, run

/scoreboard players set @a ground 1

and

/execute @a ~ ~ ~ detect ~ ~-1 ~ air scoreboard set @p ground 0

in that order.

The first command sets all player to 'being on the ground', and the second command sets those who are in the air to not be on the ground.

To affect players in the air, use @a[score_ground_min=0]

To affect players on the ground, use @a[score_ground=1]

Solution 3:

You only need 1 command: hook this up to a redstone clock:

/execute @a ~ ~ ~ detect ~ ~-3 ~ air 0 effect @p jump_boost 1 255 true 

It gives them infinite jump boost whilst in the air which prevents fall damage (they can still take fire damage, wither, etc)