In Lua you could use this. I'm sure you can translate it somehow to C++
local DistanceFromGround = 0 for Y=Player:GetPosY(), 1, -1 if World:GetBlock(X, Y, Z) ~= E_BLOCK_AIR then DistanceFromGround = Player:GetPosY() - Y -- We found land end end