Mass chunk regeneration

Discussion in 'Plugin Development' started by Techy4198, Dec 13, 2014.

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

    Techy4198

    I'm trying to regenerate a large number of chunks, using two for loops, scheduling to regenerate each chunk with 2 ticks between them. The issue is, I will get a whole heap of 'Already decorating' errors and only some of the chunks get regenerated. I know the scheduler is working properly, as each chunk (after the first few, which go perfectly without errors) only reports its error once, and there is a noticeable delay between error messages if I increase the delay time.

    My chunk regeneration code (it's an int because it returns codes as 0:regenerated fine, 1:had to be created, 2:failed):
    Code:
    int recreateChunk(Chunk chunk,Player p){
            if(!chunkExists(chunk)){
                try{
                    chunk.load(true);
                    chunk.getWorld().save();
                }catch(Exception e){
                    Bukkit.getLogger().info("[ChunkFixer] Error generating at "+chunk.getX()+","+chunk.getZ()+": "+e.getMessage());
                    return 2;
                }
                return 1;
            } else {
                try{
                    chunk.getWorld().regenerateChunk(chunk.getX(),chunk.getZ());
                    chunk.getWorld().save();
                }catch(Exception e){
                    Bukkit.getLogger().info("[ChunkFixer] Error recreating at "+chunk.getX()+","+chunk.getZ()+": "+e.getMessage());
                    return 2;
                }
                return 0;
            }
        }
    I can just keep rescheduling them for a few ticks later any time I recieve the 'already decorating' error, ya?
    Also how many ticks exactly does it take for a chunk to generate, decorate, and fully load into memory? I tried waiting up to 8 ticks between them, that didn't help. I thought it would try to do a chunk all in one tick?...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 29, 2016
Thread Status:
Not open for further replies.

Share This Page