I'm interested in negating fall damage with command blocks by giving players Resistance as they're falling. How can I use /testfor to tell whether a player is on the ground or in the air?

  • While I haven't worked with Minecraft commands much, could you get the coordinates of the player, then check which block is present in the space directly below them?
    – SaintWacko
    Mar 11, 2015 at 17:05
  • 2
    @SaintWacko I think... you can, probably. Maybe like an excute @p testforblock air ~ ~-1 ~ or something?
    – Unionhawk
    Mar 11, 2015 at 17:30

5 Answers 5


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)

  • 1
    Very good catch with this tag! But why wouldn't you just test for {OnGround:0b} instead of inverting the output?
    – MrLemon
    May 27, 2015 at 10:01
  • 1
    Another thing I'd add is that you can use NBT data for assigning scoreboard objectives, which can be utilized in target selectors for commands that do not natively support data tags. I.e. /scoreboard players set @a grounded 1 {OnGround:1b}
    – MrLemon
    May 27, 2015 at 10:04

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


/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]

  • 1
    I suggest setting the detect range to ~ ~-2 ~, otherwise, you might affect people who are simply jumping around rather than falling.
    – MrLemon
    Apr 20, 2015 at 9:13
  • 1
    @MrLemon That would work, but the people might want to affect jumping players as well.
    – xornob
    Apr 20, 2015 at 21:47

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)

  • This looks really cool when you kill a player with the effect. They go flying in the air.
    – user88078
    Oct 12, 2015 at 19:44

testing if in air:

execute @a[parameters] ~ ~ ~ detect ~ ~-1 ~ air 0 <command>

testing if on ground:

scoreboard objectives add onGround dummy
scoreboard players set @a onGround 1 {onGround:1b}
execute @a[score_onGround_min=1] ~ ~ ~ <command>
scoreboard players set @a[score_onGround_min=1] onGround 1
/execute at @a if block ~ ~-3 ~ air run effect give @a minecraft:slow_falling 1 1

I'm using this for 1.16.5 and it works in just one line (the effect can be different)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .