Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

How do Minecraft save files work? Is there a Python interface?

share|improve this question
    
Just for the record, the Minecraft level file format is documented on the official Minecraft site. Spec includes an example of how to parse. –  sjohnston Oct 19 '10 at 17:52
    
@sjohnston: Ah yes, I knew it existed there as well but I couldn't find it today - I'll include that in my answer if that's already with you –  BlueRaja - Danny Pflughoeft Oct 19 '10 at 18:05
    
@Blue Go for it. –  sjohnston Oct 19 '10 at 18:13
    
Now that this thread's been necro-bumped, I don't feel bad adding a comment. Notch recently said on his blog that the first priority on Mojang's roadmap is a better save file format. As such, most tools currently used will break until (if) an update is released. –  Dave McClelland Jan 9 '11 at 22:59
1  
Just a note... The link to the documentation in sjohnston is now Not Found. –  Denilson Sá Jan 16 '11 at 21:01
add comment

3 Answers

You're looking for mclevel.py. This (as the name hints at) allows python to manipulate Minecraft levels. I don't know if it also does minecarts, but I suppose so.

It can be found at http://www.minecraftforum.net/viewtopic.php?f=25&t=28518&p=507974&hilit=pymclevel#p507974

An example of what you can do with it: http://www.minecraftforum.net/viewtopic.php?f=25&t=52183

share|improve this answer
add comment

Information about the world-file format can be found here and here.

share|improve this answer
add comment

This Minepedia page has some documentation; here's a simple overview.

  • World<x> holds the data for the world in the xth slot.
    • level.dat contains information about your spawn point, time of day, inventory.
    • A number of folders used to organize data into at most 64 groups of chunks.
      • A second level of folder used to organize data into at most 4,096 smaller groups of chunks
        • The chunk files themselves, each storing terrain, item and monster data for the corresponding 16×16 slice of the world.

The folder hashing has been added because some systems had trouble handling folders with huge amounts of files.

For the curious, the path for the chunk at position (x,y) for the world in slot w is calculated as follows, using this base36 function and the % modulus operation:

world<w>/<base36(x % 64)>/<base36(y % 64)>/c.<base36(x)>.<base36(y)>.dat

Each chunk is as large as this hole:

a 16×16 meters large hole all the way down to the void. Image courtesy of Raven Dreamer, say hello to the creeper.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.