I'm working on adding some custom tools using commands. I would like one tool to allow the player to "fly", but after some research I've decided to try and settle for just allowing the player to freeze his y coord. I've tried tp-ing the player up just a little bit to counter the gravity, but couldn't find the right amount to keep the player at a constant level. I have also tried using effects such as levitation, which didn't work even at its lowest level, and slow falling, which seems to have no difference with an amplifier of 1 or 255. When I looked into it, I found a post made on the Minecraft bug site with a response that they don't support effects achieved only by commands. I've heard about putting a barrier under the player which would be ok, but I don't know what I'd do if there is lava or water below the player.

I'm using Java Edition PC in Minecraft 1.13.


You can grant players with levitation that keeps them hovered in the air with this command:

/effect give @p levitation <seconds, goes up to 1000000> 255 true

To remove the effect:

/effect clear @p levitation