I want to make a command that, when used, detects how high above the ground I'm floating and then teleports me to the ground.
But I'm not sure how to detect how high the player is above ground.

  • Welcome to Arqade! What have you tried so far?
    – pinckerman
    Aug 1 at 17:34
  • well I haven't tried anything really as the only thing I could find is how to detect y value which would be useful only if I know the ground y value
    – Yuval52
    Aug 1 at 17:37
  • Are datapack annswers fine? Also, what happens if they are above void?
    – BunnyMerz
    Aug 1 at 22:40
  • datapack answer is fine, if they are above void just do nothing it doesnt really matter
    – Yuval52
    Aug 2 at 14:34

1 Answer 1


I tried a few versions and this one seems the best. As datapack called tp and function ground.mcfunction, do:


execute align y unless block ~ ~-1 ~ air run tp @s ~ ~ ~
execute positioned ~ ~-1 ~ if block ~ ~ ~ air run function tp:ground

It basically moves a block down, if it is grounded, tp the player, if not, move one block down and run the function from those coordinates.

If you want to run the command for a player/entity, just do:

/execute as [YourTarger] at @s run function tp:ground

You must log in to answer this question.

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