Issues on Chunk Regeneration.

Discussion in 'Plugin Development' started by dannycrafts, Feb 3, 2012.

Thread Status:
Not open for further replies.
  1. Offline


    Hello guys,

    I'm working on a plugin that needs to save the chunk data into an 'extra' file. The data in this file represents the state the chunk was in when it was just generated (+ populated). With this I will always be able to return chunks to their original state at any time.

    My problem is that I don't know what to do in the situation where this fails. What if an I/O error occurs or I run out of memory or something, the chunk might be generated (and saved) but I don't have its original state written in that extra file.

    It would be great if I could somehow remove the chunk from the world when I detect an error so that it would attempt to generate it again another time, which might succeed, or might fail again at which I could detect the error and fix it manually.

    Assuming that isn't possible, I want to be to stop 'failed' chunk from loading, but ChunkPopulate and ChunkLoad events are not cancellable. I want to stop it from loading because I don't want players to put their time into building on a chunk that has to be repaired. An alternative might be to warn players when they walk into those 'failed' chunks.

    Second of all, I don't know if I will be able to get back that original state again, so that I could fix the problem. Because when I regenerate a chunk (with another plugin), it seems that the terrain is regenerated fine, but the population (like trees and structures) in the chunk and sometimes surrounding chunks change and leave behind ugly artifacts (like floating leaves and cut-off trees). I think this is weird, is the population not based on the world seed? If it is based on the world seed, why doesn't generate exactly the same thing the second time?

    Anyway, if anyone can help me with these points, I would be so grateful!
  2. Offline


    It's supposed to be based on the world seed, but the terrain generation changes in almost every version of Minecraft, so that a seed that produces one type of land in, for example, Beta 1.7.3 will not generate the same land in, for example, 1.1.
  3. Offline


    Don't worry about that, I won't update the world generator until I got every chunk fixed.
    I thought it was supposed to be based on the world seed to, but try regenerating a chunk and you'll see the awkward changes.
  4. Offline


    Ok, since nobody was able to help me so far, this will be my solution:

    Whenever the chunk will not be able to be saved on disk, the server will automatically shut down and write the chunk and error information down somewhere. Then as server administrator I can try to find and fix the issue if there is one. Next up, to 'fix' the unsaved chunk, I'll revert the server back to a backup so that next time the chunk is generated, it will probably go right.

    There seems to be no other way, but it works.
Thread Status:
Not open for further replies.

Share This Page