checkworld.py performs a deep scan of a world's files to check for corrupt chunk files. Not only does it check if the file format is correct, it also checks the contents of the chunks (entities, block types) as well. Currently it verifies everything in a chunk except entities (arrows, mobs, etc.), but it does check chests, furnaces, signs, and mob spawners. It currently will not work if you've modified your game to include new block types or new entity types as the tool will check for acceptable block and entity types.
To get started:
[*:m91twuy9]Download the program (click here for the raw file) and save it to your computer as checkworld.py.
[*:m91twuy9]Open your terminal or command prompt.
[*:m91twuy9]Use this:
That will check the specified world and write a list of bad chunks to bad_chunks.txt. To regenerate the chunks, delete the files listed in that generated file while your server is offline. The chunks get generated automatically when someone visits the area.
Format: [Current chunk/# chunks Progress% #Bad chunks so far]
At the moment, the program will make NO modifications to your world files and will not attempt to fix the files. I may add operations that also fix your world in the future.
If you find this useful, a donation can go a long way towards further development :smile.gif:
This worked great for me! Just a tip, I seemed to need to launch the command prompt as admin in Windows 7. Also, it saved the bad_chunks.txt file at C:\ (your base directory on the C: drive). Not a problem, because it was easily found with a quick file search. Great job on this script!!! It saved me a TON of work!
diff checkworld.py checkworld.py.org
180d179
< or name == 'Squid'\
193,194c192,195
< if id < 0 or (id >= 93 and id <= 255)\
< or (id >= 355 and id <= 2255)\
---
> if id < 0 or (id >= 21 and id <= 34)\
> or id == 36\
> or (id >= 92 and id <= 255)\
> or (id >= 351 and id <= 2255)\
288,291d288
< elif id == 'Trap':
< self.expect_child_value(tag, "Items", ListTag, self.expected_valid_chest_items)
< elif id == 'Music':
< self.expect_child_value(tag, "note", ByteTag)
301c298,299
< if block_id < 0 or block_id >= 93:
---
> if block_id < 0 or (block_id >= 21 and block_id <= 34)\
> or block_id == 36 or block_id >= 92:
I don't know what's at fault, but I can't get your code running properly. Running this on a Debian linux machine.
I patched it to python 3.1, but I still get a similar error to python 2.6. Running as
BAD CHUNK: 'GzipFile' object has no attribute 'readable'
which differs only from 2.6 which gets
BAD CHUNK: GzipFile instance has no attribute '_checkReadable'
The gzip module hasn't changed enough to explain this error. All the patch does is basically fix expected syntax (eg not writing a text file using binary mode).
ooh that's very handy. Do you mind if I integrate it into my Minecraft Launcher? (An application that backups saves, checks for updates, etc each time you run MC) It's for personal use only so I won't release it or anything, but I thought it'd be nice to ask. :smile.gif:
I'd change the code to emit a stack trace so you could trace down the problem.
Changing
reader = io.BufferedRead(f)
to
reader = io.BytesIO(f.read())
solves the problem for python 2.6. In python 3.1 that's only the start, you'd have to redesign the code to meet its stricter type checking in struct.Struct.
I just had a problem with a corrupt world causing the server to crash on start up. I ran checkworld.py, as included with MineOS, but it didn't find anything wrong, so I looked to other causes.
Much hair-pulling later, I discover that the root cause of the crash was a corrupt level.dat (it was zero-length). Besides that, several other chunks were zero-length, none of which were detected by this tool. (I found the chunks with c10t, and the level.dat with MCEdit)
Does this tool check for zero-length chunks/files? If not, it really should. I would contribute a patch, but I suck at python.
I've tried running this script on 2 SMP worlds that I know are (at least mostly) not corrupted, but every single one of the 80kish chunks are being flagged as corrupted. Did a recent update break it?
I'd change the code to emit a stack trace so you could trace down the problem.
Changing
reader = io.BufferedRead(f)
to
reader = io.BytesIO(f.read())
solves the problem for python 2.6. In python 3.1 that's only the start, you'd have to redesign the code to meet its stricter type checking in struct.Struct.
I just had to make this change to allow the script to work on my Ubuntu 10.10 headless server as well. (python 2.6.6)
It requires Python 2.7. You can download Python from the official site. It will work on Windows, *nix, BSD, and Mac OS X.
To get started:
[*:m91twuy9]Download the program (click here for the raw file) and save it to your computer as checkworld.py.
[*:m91twuy9]Open your terminal or command prompt.
[*:m91twuy9]Use this:
Or if you're on *nix/BSD/Mac OS X:
That will check the specified world and write a list of bad chunks to bad_chunks.txt. To regenerate the chunks, delete the files listed in that generated file while your server is offline. The chunks get generated automatically when someone visits the area.
Example output:
Format: [Current chunk/# chunks Progress% #Bad chunks so far]
At the moment, the program will make NO modifications to your world files and will not attempt to fix the files. I may add operations that also fix your world in the future.
If you find this useful, a donation can go a long way towards further development :smile.gif:
Check out my Minecraft server.
Check out my Let's Play Series:
http://pastebin.com/Ti5cDbPX
Direct DL (save as a .py)
Check out my Minecraft server.
I patched it to python 3.1, but I still get a similar error to python 2.6. Running as
I get
which differs only from 2.6 which gets
The gzip module hasn't changed enough to explain this error. All the patch does is basically fix expected syntax (eg not writing a text file using binary mode).
Check out my Minecraft server.
Changing
to
solves the problem for python 2.6. In python 3.1 that's only the start, you'd have to redesign the code to meet its stricter type checking in struct.Struct.
EDIT: Nevermind, I wrote a .bat file and it worked.
EDIT2: Can you make it compatible with the Nether? I am sure that there is a corrupted chunk in there as well.
DOOMFridge: It should work with Nether, at least AFAIK.
Check out my Minecraft server.
Much hair-pulling later, I discover that the root cause of the crash was a corrupt level.dat (it was zero-length). Besides that, several other chunks were zero-length, none of which were detected by this tool. (I found the chunks with c10t, and the level.dat with MCEdit)
Does this tool check for zero-length chunks/files? If not, it really should. I would contribute a patch, but I suck at python.
@KorbiT:
Check out my Minecraft server.
Check out my Minecraft server.
Check out my Minecraft server.
I just had to make this change to allow the script to work on my Ubuntu 10.10 headless server as well. (python 2.6.6)