To turn cheats on minecraft do the following.
Download the program which is called NBTExplorer, which will help you to edit the required file to allow commands on your game.
Enable or Disable Cheats without opening to LAN. A mod, should work on all versions between 1.10.2 and 1.12.2.
You can download this program at: https://github.com/jaquadro/NBTExplorer/releases/
Once NBTExplorer is finished downloading, you can open it by clicking on NBTExplorer.exe (the icon is a small dead shrub). You should then see a list of your singleplayer maps:
Then double click on the map for which you want to enable cheats.
Head ball 2 game cheat spot. Once this is done, double click on level.dat [1 entries], then Data: 24 Entries, and finally on AllowCommands: 0
This will open a small text box titled “Edit value…” in which you need to type 1
You can then click on Ok and save your changes by going to File -> Save (or by pressing Ctrl+S). You should now be able to use cheats on your Minecraft map!
I hope this article helped you out and, as always, have a nice day!