How to make toggleable flight with a key press

Started by healedpack on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make toggleable flight with a key press

I want to make a mod with superpowers with the ability to fly. How could I make it where I press a key to start flying then press it again to stop flying. I have been working on it for hours and can’t figure it out still. 

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use the allow fly procedure…
Fri, 05/01/2026 - 07:51

Use the allow fly procedure block. Additionally use a variable, eg allowFlight, on player. Now on key pressed, if allowFlight=false, set variable allowFlight to true, else set allowFlight to false.

Then on player tick update, allow flight if [allowFlight=true] otherwise don’t.

Joined May 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I dont understand
Mon, 05/25/2026 - 17:04

I dont understand