Fenixin/Minecraft-Region-Fixer

Suggested relocation fix algorithm

Closed this issue · 5 comments

A pattern I observed from two servers that suffer a power loss is that

  • Chunk data are mostly intact (zlib stream)
  • Chunks have correct xPos and zPos in their NBT.
  • Chunks have incorrect offset in the region file.
    image
    Shown here is an example. This chunk is placed at offset for [2,1] from r.0.0.mca, but its correct location is [4,1] as indicated in the NBT. It will be relocated to chunk [2, 1] by the Minecraft server.
    Could you include such a switch for the program, that relocates it to [4,1]? Many appreciations.

Hello!

So, as far as I know this example would be detected as a wrong located chunk by regionfixer. Could you confirm that?

What you are asking for is a new option in regionfixer to relocate the chunk where the chunk data is pointing at. This could be a pretty good idea, because it's tempting to think that the data in the chunk, if not corrupted, will contain the correct place of the chunk.

Have you ever seen the opposite to happen? I mean, a chunk that is wrong placed having the coords in the region header pointing to the right position?

Could you please send one or more region files with this problems so I can test and implement this? I can't promise that is going to be implemented but it might be.

Well no, I haven't seen the opposite. The NBT data are zlib-compressed which contains an integrity check, so I guess a corrupted NBT will be un-decompressable and identified as corrupted.

Several days ago I tried hand-fixing a region file head (using hex editor) and it worked out perfectly. I'll find somewhere to drop it asap.

Sorry for taking ridiculously long. I have to work for the final...

Here it is. https://drive.google.com/file/d/1a0BV4AJu72_Z9lOaj2fLrzEYeWv_JFq9/view?usp=sharing.

I ended up fixing the map with a binary editor by changing pointers in the file header. There are about 20 chunks missing, but most chunks worked out.

Thank you very much for your time and the test file. No problem with the timing!

Although I don't know when is going to be finished, I have a new branch with this half-done, I will test it and tell you how it goes.

The file is downloaded, feel free to remove it.

This feature has been implemented in the branch bugfix.

I have tested it using your region file and it seems to work. After fixing the 37 wrong located chunks, a new scan reports no wrong located chunks, but I haven't really run minecraft over the world (because I don't have one with wrong located chunk to test). I will make a new release in master soon (tm).

If you could test this and confirm that works it would be great.

Thanks again for your idea.