Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Tutorial: How to restore missing world after system crash

  • Please log in to reply
63 replies to this topic



Posted 07 October 2010 - 09:17 PM

Oh Noes! Your cat just ran behind your computer, dislodged the power cable, and now your Minecraft save is gone!

Life is over. Or is it?

This exact thing happened to me (seriously; my cat is a dick). I wasn't about to give up so easily though.

I spent an hour or two researching, and after pulling together data from several sources; I found a way to (almost) fully restore my world.

Let's talk about what happens first. When the game shuts down unexpectedly, a file called level.dat will become corrupted. In my case, it was full of null bytes. In other cases i suppose it would be possible to have partial data in there. This is no matter though.

There is another file called level_old.dat. This is supposed to be a backup of some sort. Many people suggest using it by renaming it to level.dat; restoring your world. This did not work for me as it had ALSO been nulled out. That is when the responses I found basically amounted to "you're fucked". But you know what?

You are not.

It is entirely possible to create a level.dat "template", which can be used to restore your world almost entirely (minus your inventory, but there is a way around this too)

level.dat stores current state information about the player. Health, inventory being carried, position on map, direction facing, etc. The rest of your map is stored elsewhere. This means that we can use a vanilla level.dat file to help us gain access to our world!

DISCLAIMER: This works for Alpha (single player), but I have no idea if it works for other releases (or multi player).

Tools you will need:
    [*:3rz1ijbd]level.dat file attached to this post. NOTE: I was unable to attach the file, so you will need to manually create it using NBTedit and the data below. =/

    [*:3rz1ijbd]Navigate to the location of your Minecraft saves. In Windows 7, the path is "C:\Users\\AppData\Roaming\.minecraft\saves\".
    [*:3rz1ijbd]In this folder you will see subfolders for each world (world1, world2, etc.). Find the world you wish to restore and make a backup copy of the folder, just in case.
    [*:3rz1ijbd]Open the folder containing your world. You should see a plethora of sub directories. Ignore these. Scroll down and you will see three files:
    [*:3rz1ijbd]If you want, you may try renaming level.dat to level.dat.corrupt, then renaming level_old.dat to level.dat. This tutorial assumes that this option did not work for you though. Skip to the next step if you already tried this and it didn't work.
    [*:3rz1ijbd]replace the level.dat file in your world folder with the level.dat file attached to the post.
    [*:3rz1ijbd]Open it up in NBTedit.
    [*:3rz1ijbd]You should see something similar to the following:
      [*:3rz1ijbd]root: 1 entry
        [*:3rz1ijbd]Data: 9 entries
          [*:3rz1ijbd]SnowCovered: 0
          [*:3rz1ijbd]SpawnX: 0
          [*:3rz1ijbd]SpawnY: 64
          [*:3rz1ijbd]SpawnZ: 0
          [*:3rz1ijbd]LastPlayed: 0
          [*:3rz1ijbd]RandomSeed: 0
          [*:3rz1ijbd]SizeOnDisk: 0
          [*:3rz1ijbd]Time: 6000
          [*:3rz1ijbd]Player: 1 entry
            [*:3rz1ijbd]Score: 0
    This is a very rudimentary version of a level.dat file, but it is almost enough to restore your world. We simply need to make a few edits. NOTE: It is assumed you know how to use NBTedit. It's very simple to use, and shouldn't take longer than 5 minutes to figure out.
    [*:3rz1ijbd] Did you have a winter wonderland? If so, set SnowCovered to 1
    [*:3rz1ijbd] LastPlayed is the UNIX timestamp of the last time you played. Get the UNIX timestamp of shortly before you crashed. This does not have to be exact (and in fact, i am not sure if it needs to be filled in, but I did so I suggest you do). http://www.unixtimestamp.com should make this simple.
    [*:3rz1ijbd]SizeOnDisk should be set to the approximate size of your world, in bytes. You can get this by finding the size of the world folder you are restoring, then converting from megabytes to bytes. 1 megabyte = 1,048,576 bytes. Again, this does not have to be exact. Just make it a close as possible.
    [*:3rz1ijbd]Time defines time of day in the world. This can range from 0 to 24000. I set this to 6000 in the sample level.dat as  convenience. This will start you with the sun high in the sky. You can play with this if you want to start at a different time of day.
    [*:3rz1ijbd]After making these edits, save the file, and start Minecraft.
    [*:3rz1ijbd]When you get to the world selection screen, you should now see your world. select it.
    [*:3rz1ijbd]Something very strange might happen. When I did this, I fell right through the geometry, and died. When I respawned though, I was back on land, somewhat near my spawn point. You might experience strange things too. Don't worry, you still have that backup we made before we started in case things are rockier for you than I.
    [*:3rz1ijbd]Optionally, you might want to walk around and make sure your structures are still there. They should be.
    [*:3rz1ijbd]Once you are alive and on land and the game isn't freaking out, you'll notice your inventory is gone! We can't restore this, but we CAN rebuild an inventory list of our liking. grab some dirt. I'm serious. One piece will do.
    [*:3rz1ijbd]Save world and exit Minecraft.

Done! You may now continue wasting your life on Minecraft. But wait, what about my items!? If you do not feel like going through the trouble of collecting more resources, then follow the directions below (keep in mind though that items you stored in treasure chests will still be there!):

    [*:3rz1ijbd]Open level.dat in NBTedit again.
    [*:3rz1ijbd]You'll notice the file is much more robust now. We gave Minecraft just enough data to fix the rest of the file on it's own.
    [*:3rz1ijbd]Expand the Inventory list.
    [*:3rz1ijbd]Each item in here represents something in your inventory. You will have one item; the dirt you collected previously. Expand it. It has 4 data points. They are as follows:
    We are only concerned with id, slot, and count
    [*:3rz1ijbd] Highlight the item block (not inventory, but just the one item)
    [*:3rz1ijbd] Ctrl-C
    [*:3rz1ijbd] Highlight the Inventory list
    [*:3rz1ijbd] Ctrl-V
    [*:3rz1ijbd] Now we have two dirt items. Who wants dirt though? You need to change the values as such:
      [*:3rz1ijbd]id: This is the id of the item within the game. change this to the id of the item you want. you can get the ids here: http://www.minecraft...iki/Data_values. Use the decimal values, not the hex ones
      [*:3rz1ijbd]Damage: I advise keeping this 0 unless you are hell bent on giving yourself damaged items.
      [*:3rz1ijbd]Slot: A number between 0 and 35 defining where in your inventory the item lives. The important thing is to make sure you do not use the same slot twice!
      [*:3rz1ijbd]Count: How many of this item you have. 64 is max. A funny thing about using this editor is that you can assign a high count to items that normally have only 1 per slot restrictions (like minecarts). Don't think of it as cheating, think of it as a little bonus for going through this BS because of this massive corruption bug.
    [*:3rz1ijbd] simply rinse and repeat these steps for each type of item you want.

Well there you have it. Not all is lost! I hope this helps others who freaked out like I did when my world turned up empty. I suppose as a game in Alpha, fixes like this must be expected.

Happy Mining!

UPDATE: It appears that the forums will not play nice with my file uploads, so unfortunately, you will need to manually create the vanilla level.dat file as I have described it above. Use the information @ http://www.minecraft...evel.dat_Format to get the data types of the variables defined above (and of some other stuff I left out not pertaining to level recovery).

Register or log in to remove.



    Out of the Water

  • Members
  • 9 posts

Posted 10 October 2010 - 08:58 PM

Does this work even if I accidentally made another file in world 1 slot after the original was deleted? I followed your steps and spawned in a world the same size as my old one, but not even remotely close to the previous spawn point, and I have no idea how to find where that was, or even confirm if this is the same world at all.... help?



    Out of the Water

  • Members
  • 3 posts

Posted 13 October 2010 - 10:49 PM

Greetings. First time poster, long time (since April) lurker.I followed your tutorial and was able to recover a map. The problem is: It's the wrong map. Instead of my save with an awesome half-built fortress in the middle of a huge lake, what I recover is an even older save that was corrupted. I'm afraid that the backup I made of my World1 folder is also the same older map. I can hack the resources, but I can't hack back the sweet location I had. Is all lost?


ETA: I downloaded Cartographer, and as it turns out my spawn point just got shifted around. Instead of two separate maps they were actually the same one. If I had crossed the next mountain ridge I would have seen my fortress.



    Redstone Miner

  • Members
  • 650 posts

Posted 22 October 2010 - 01:43 AM

Hey, you should try uploading a level.dat template to MediaFire.

Nice guide, by the way, but it would simplify it a lot if you managed to upload a template.



    Out of the Water

  • Members
  • 2 posts

Posted 22 October 2010 - 03:07 AM

So I read through this tutorial, and I couldn't manage to get the level.dat to go into NBTedit at all. When I tried to open my save in there it just said "Error when Loading the File: The magic number in the GZip header is not correct. Make sure you are passing in a GZip stream". Anyone have any advice with how to deal with this?



    Out of the Water

  • Members
  • 2 posts

Posted 22 October 2010 - 01:04 PM

As I found out, you don't actually need to 'create' a new level.dat file. You can simply make a new world (make sure it isn't in the slot of the one you want to recover), and then copy the newly created level.dat file to the world you want to recover. It saves a lot of time as you don't have to enter any values.

Then open that file in NBT, and change random seed to 0. (I'm not sure whether you need to or not, but I did and it worked, so......). You don't need to change any other value.

It took me about 30 minutes to find where I had been building, but once you have found it you can easily change the spawn point to an area near there, or in your building if you wish.

Note: You can use the 'SpawnX, SpawnY, SpawnZ' values if you can't be bothered walking around the map. However this requires you to die and can be quite tedious so I don't recommend it.

To change your spawn, stand where you want your spawn to be, save to title; and then open the level.dat file.

Under 'Player' it will have an entry names 'Pos'. In here there are three values (X,Y,Z respectivly). Copy these values (note you can only have up to 3 number so ignore all of the values after the decimal point), to the SpawnX, SpawnY, and SpawnZ under 'data'.

Since you don't technically need to change any data at all, you don't really need to download NBT, that is supposing of course you don't want to change your spawn location. It's really up to you.



    Out of the Water

  • Members
  • 2 posts

Posted 22 October 2010 - 01:08 PM

Drmeow8 said:

So I read through this tutorial, and I couldn't manage to get the level.dat to go into NBTedit at all. When I tried to open my save in there it just said "Error when Loading the File: The magic number in the GZip header is not correct. Make sure you are passing in a GZip stream". Anyone have any advice with how to deal with this?

You are trying to open the corrupted version of level.dat. Follow what I have said and you should be able to make it work. Just to clarify again, create a new level (different slot then the level you want to recover), and copy the level.dat from this new world into the world you want to recover.



Posted 29 October 2010 - 12:55 AM

i miss the old game...



    Out of the Water

  • Members
  • 3 posts

Posted 30 October 2010 - 05:34 AM

this thread saved me tonight, thanks!



    Nether Resident

  • Curse Premium
  • Curse Premium
  • 2034 posts

Posted 30 October 2010 - 06:48 PM

sorted - post deleted
SsssssssssssssssssssssssssSURPRISE!  "What the FUUUU..."  BOOM

Cue song: "Don't Fear The Creeper...."



    Tree Puncher

  • Members
  • 17 posts

Posted 06 November 2010 - 01:20 AM

I am trying this method of recovery but I loaded up minecraft and clicked on the world I wanted to recover creating a new world there. Am I screwed? I have been searching around but if anyone can help me I'd truly appreciate it.
Posted Image



    Out of the Water

  • Members
  • 9 posts

Posted 08 November 2010 - 04:12 PM

This just happened to me again, but thankfully I didn't overwrite the world...

I managed to get my world back, but exactly where my base used to be there is just empty space... a huge empty pit from bedrock to sky. And that is uh, not quite ideal. Any idea on how to fix this? should I just try it again?

EDIT: Dyren, sorry buddy but you're out of luck, I did the same thing the first time this happened, and just had to bite the bullet and start over... unfortunately it is now happening again!  :)



Posted 13 November 2010 - 08:25 AM

Wow! This just happened to me!

Somehow this mangy feline fur bucket managed to hit the tiny little switch on my power strip! GRRRRrrrrrrr!

The bad part initially was thinking that i had been playing about three or four hours without even pausing so much as to let the game auto save. Yeah that is pretty stupid in its own right. The worst of it also is I was on a loooong journey to the coast to hunt the elusive clay that is nowhere near my spawn far inland. So after five full slots/blocks of compressed 64ct clay blocks i figured it was time to trek back with my booty.....

Also crazy was i really had no idea where i was or where my spawn location and main establishment was. So i found a small cave then started digging... digging deep! To finally uncover a redstone or two and a really nice stack of iron so as to make a compass. I started towards home and then POP! Blank screen... I pause and let out a loud "WTF!" then an orange and white streak across the floor and out the door. Then came the FFFFFUUUUUUU!!!

So rebooting and seeing no save added to the sinking gravitational black hole in the chest feeling I had, realizing I may not have just lost the past 3-4 hours but EVERYTHING Ive done in this world for the past nearly 2 months!!!

Anyway I am really very hopeful that this tutorial works. It seems the most informative and thorough I've come across after multiple web searches so thanks for the post and all the informative replies!

I've got my fingers crossed this at least saves my home establishment in my world that I put countless(or should I say a RIDICULOUS amount of) hours mining, building, fighting f'n creepers(then rebuilding), and extensive time plotting plans onto graph paper etc. into. I can only really laugh about it now really, cuz yeah, I know this game is still in alpha, and I can recall Notch's words regarding current stability of save states... ~Immense humble sigh~


I had a game save size of about 16-17MB before this trek and after reaching my far destination I saved and it was closer to 20-22MB the day before all the clay hunting as i recall. The file that i found and copied in the world save folder is now around 32MB and says its 42MB 'size on disk' whatever those figures mean. 32Mb could be accurate I guess.

It took forever to copy to the new destination for whatever reason(compressed files or smth maybe?)
Also I tried to go back to the now unnamed world(world2) from the minecraft save/load menu in the off-chance it was still there and it appears to have just created a new save there(good thing thing I copied it right?)

Im hopeful in how this turns out and will post any related results.



    Zombie Killer

  • Members
  • 196 posts

Posted 29 November 2010 - 05:30 AM

Drmeow8 said:

So I read through this tutorial, and I couldn't manage to get the level.dat to go into NBTedit at all. When I tried to open my save in there it just said "Error when Loading the File: The magic number in the GZip header is not correct. Make sure you are passing in a GZip stream". Anyone have any advice with how to deal with this?

I get this also. How can I fix this?


Posted Image



Posted 12 December 2010 - 12:33 AM

To everyone getting the GZip error: You're trying to open the corrupted version of the level.dat. You need to borrow one from another level, if nothing else.

Just go and start a new world, then steal the level.dat off that one. Open that, and continue.

May I just say, you've saved me months of work here with this thread. I am so goddamn glad right now, that I've just saved all of my worlds in duplicate!


  • Minecraft: Strengthfizz

Posted 13 January 2011 - 05:01 PM

bump, This still works for beta, Helps a lot!
Posted Image



Posted 14 January 2011 - 05:55 AM

Any idea if this works for SMP?
Live Stream
Twitter: @DrakeGaming    Youtube: youtube.com/MaleDuckGaming



Posted 28 January 2011 - 02:32 AM

I didn't try this yet, but what I did discover by opening my level in NBTForge was that, after the crash, it had spawned me in a new area adjacent to zones I'd already explored.
I could see in the editor which direction I had to walk to get back to my original spawn point, and reset my spawn point there again. A major annoyance, to be sure, but far from fatal.



Posted 28 January 2011 - 05:42 PM

Thanks for this, trying to play minecraft in the middle of a snowstorm that causes power outages every 20 minutes is a pain in the ass.

You sir, get a diamond, which is equal to near infinite internets.  :D
Wolves and cliffs are an inseparable pair. Also, this wallpaper is pretty cool.



    Tree Puncher

  • Members
  • 14 posts

Posted 30 January 2011 - 03:19 AM

Saved my freaking world...thank you so much!!!!!!!!!!!!!!!!!!!!