How to turn cheats on or off

Solution 1:

On a multiplayer server:

To turn on cheats:

  1. Type op <Your username> in the console.
  2. Done.

To turn off cheats:

  1. Type /deop <Your username>
  2. Done.

On a singleplayer world:

To turn on cheats:

Using the built-in LAN server:

  1. Pause the game.
  2. Click on Open to LAN.
  3. In the options, change Allow Cheats: false to true (click on it).
  4. Open the server.

Changing your save file:

  1. Close your world.
  2. Using NBTEdit, open your save file (%AppData%/.minecraft/saves/<World Name>/save.dat)
  3. Change the NBT node AllowCommands from 0 to 1.
  4. Save and reopen the world.

To turn off cheats:

Using the built-in LAN server:
Note: This only works on players who connect to this world, not you.

  1. Pause the game.
  2. Click on Open to LAN.
  3. In the options, change Allow Cheats: true to false (click on it, if it already displays Allow Cheats: false, obviously don't click).
  4. Open the server.

Changing your save file:

  1. Close your world.
  2. Using NBTEdit, open your save file (%AppData%/.minecraft/saves/<World Name>/save.dat)
  3. Change the NBT node AllowCommands from 1 to 0.
  4. Save and reopen the world.

Solution 2:

You can simply deop yourself. /deop {PlayerName} and boom, no more commands like /gamemode 1

Solution 3:

If you're wondering how to make it so that no one can use any commands, then...

  1. Make the map open to LAN
  2. Turn cheats to "Off"
  3. End the LAN server and you won't be able to use cheats.

This works the other way around if you wish to turn the cheats back on.