Thisarticle was co-authored by Yaffet Meshesha and by wikiHow staff writer, Nicole Levine, MFA. Yaffet Meshesha is a Computer Specialist and the Founder of Techy, a full-service computer pickup, repair, and delivery service. With over eight years of experience, Yaffet specializes in computer repairs and technical support. Techy has been featured on TechCrunch and Time.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
This article has been viewed 366,412 times.
Files that end with the .dat extension are generic data files that store content like plain text, game data, or user-level data. If the contents of the DAT file are plain text, you can open and edit it in a text editor like Notepad or TextEdit.[1]XResearch source If the DAT file contains special characters, such as Minecraft level.dat files, you'll need to use a special editor. This wikiHow teaches you how to use a text editor, or one of two NBT editors (NBTExplorer and webNBT) to modify the contents of a DAT file.
I'm currently working on a NBT reader and writer to edit Minecraft maps (both the player data and the chunks themselves). I've got the reading of NBTData all done and I was able to write a level.dat file to edit some player data.
Unfortunately I am still unable to write my NBT binary data to a region file because Minecraft isn't accepting my compression method. Whenever I try to load in my edited chunks it gives me the error that it couldn't find the end of the ZLib compression or that it's a invalid compression method (I caught these error by launching minecraft via the Terminal).
When you create a Minecraft world, you select your game mode, and that mode is fixed for the lifetime of the world. Or is it? Read on as we show you how to sidestep the game mode lock to temporarily or permanently change your game's mode.
When you create a new world, you select your game mode. You can choose from creative, survival, and hardcore modes. Under normal circumstances, this selection is fixed, and a permanent flag is set within the world file.
Minecraft lends itself to creativity and changing playstyles, however, and you may find that the map you intended to make a creative map feels like it would be a perfect survival map or vice versa. Or perhaps you want to start in creative mode to build your home base and then switch to survival mode to take on the world from the comfort of your freshly built castle. Or perhaps you're doing so well in your hardcore mode world that you're now anxious at the thought of losing it should you die.
Whatever your motivation for changing the world type, it's a pretty straightforward process. Let's look at two techniques you can use to change the game modes: first a temporary one for those times you need a quick fix, and then a permanent one.
The world was flagged as survival when we made it, and it will stay survival. However, we can temporarily skirt those rules by opening the game to the LAN for network play (even if we have no intention of playing it with other players).
If you have never used the "Open to LAN" function before, don't be surprised if you get a firewall popup. On Windows you'll get a "Windows Security Alert" box, indicating that Windows Defender Firewall has blocked Minecraft (or, more specifically, the Java platform binary Minecraft runs on) from accessing the network. Click "Allow access" to save yourself from future Minecraft multiplayer troubleshooting headaches.
As the header implies, these are the settings for other players, and if you change the game mode here it only changes the game mode for incoming players to your LAN world. If you toggled the cheats on, however, it applies to all players in the game (including you). Click "Start LAN World" when you have toggled the cheats on.
Back in the game, press the "t" key to bring up the in-game command console box. Now you can use the /gamemode command to toggle the game mode for your player character. You can use the following flags:
The motivation for switching between survival and creative mode (or vice versa) is pretty self evident. There's no practical reason for someone outside of a specialy map to use adventure mode. And spectator mode, in a single-player game or small group play setting, is really only useful if you want to fly around like a ghost and take a peek underground or sneak up on your friends.
You can use this trick to temporarily alter the game mode of both survival and creative mode games. This trick can also be used to turn a hardcore mode game into a creative mode game. What's interesting about this trick and hardcore mode, however, is that hardcore mode (even though we refer to it as a game mode) is actually a separate game flag.
Hardcore mode is just survival mode wherein death leads to world deletion (in the older versions of Minecraft) and permanent spectator mode (in the newer versions). So you have only one life to live in your hardcore world.
Turning a hardcore game into a creative game creates a weird sort of hybrid wherein you get all the powers that come with creative mode, but if you were to die in creative mode (either by falling into the void or using the /kill command on yourself) you'd lose your world just like you would in regular hardcore mode. We'll show you how to toggle this later in the tutorial.
When you use this trick, you toggle your game mode, but you don't permanently toggle the state of the entire world save (and using the multiplayer command /defaultgamemode doesn't work correctly on single-player worlds).
In order to make permanent changes to the game mode state, you need to edit the game file, the level.dat, and use the same formatting Minecraft uses: Named Binary Tag (NBT). Here's how to do that and which flags are important for our game mode/hardcore mode edits.
Because of the NBT formatting, unfortunately, you can't just pop the level.dat file into a text editor and make a quick edit (the way you might edit the server.properties of your Minecraft server to disable PVP damage).
To edit the level.dat and related files without corrupting them, we'll need to use one of the available Minecraft-friendly NBT editors to do so. For the purposes of this tutorial, we're using NBT Studio on a Windows PC, but we'll list other options here in case you're using a different operating system or don't want to install an app at all.
For this tutorial, we're using NBT Studio. The data structure of the Minecraft level.dat file will be the same regardless of what tool you load the level.dat file into, however, so feel free to follow along using webNBT or other tools.
To begin editing and follow along with any of the following steps, run NBT Studio, open the location of your Minecraft save files using File > Open Folder, and navigate to the location of your Minecraft save files. For Windows users, the default location is:
There are tons of NBT tags inside the level.dat file, and it's best to leave things alone unless you know exactly what the tag you're looking at is and what values you can change it to. If you're curious about what they all do, you can check out the tag breakdown at the official Minecraft wiki to learn more.
First, let's look at changing the game mode of a given Minecraft game save. Select the name of your world, in our case "Test World I" and expand it. Within the directory you'll see multiple entries. The on which contains the world rules, including the game mode, is the level.dat entry at the bottom of the list.
Our goal is to switch the world we created from survival to creative, so we would switch the 0 to a 1. Double-click on the value and replace it with the game mode value you desire from the list above. Press CTRL+S or the save icon to save your edited tags.
If you've never logged into the world you're editing, you can skip this step. If you have logged into the world before, you must make one more edit. The save file remembers the state your player was in, so even if you change the world to a different mode, your player will stay in the old mode.
Navigate in NBT Studio to your world save and then to the sub-category of "playerdata." Select the UUID of your player. If you're the only one that plays on your world, it will be the only entry. If there are multiple players you'll need to know your UUID (or you can edit all the player files to the new game mode).
Change the value in "playerGame Type" using the same 0-4 values outlined in the previous section. To switch our player mode to creative without using the in-game workaround, we need to edit the "playerGame Type" value to 1. Again, make sure to CTRL+S or click the save icon to save your work.
In the earlier section focused on using the Open-to-LAN workaround, we noted that if you used the survival-to-creative mode trick on a world that had been created with hardcore mode turned on, you'd end up in a sort of strange limbo where you had creative powers but would still lose your world if you died.
Let's take a look at how you can toggle hardcore mode off (if you want to turn that world into a regular survival or creative world) or on (if you want to add a little thrill to your life and turn a becoming-dull survival world into a one-life-to-live thrill ride).
If we open up the world's level.dat file in NBT Studio and scroll down, we see the "hardcore" tag on our hardcore test world is set to "1" indicating that the world is in hardcore mode even though we set our player's game mode (using the Open-to-LAN cheat) to creative.
We can leave this setting as it is (and opt to switch the player back to survival mode, recreating the experience of hardcore mode), or we can toggle this setting from a "1" to a "0" at which point the game will not be deleted or set to spectator mode upon the death of the player (regardless of whether the player dies in survival or creative mode).
Although the point of hardcore mode is that, well, it's hardcore, we certainly understand if you've grown so attached to a world that you can't stand the thought of losing it and want to convert it to a regular survival or creative world.
3a8082e126