Server Timeout on World Generator

Discussion in 'Spigot Plugin Development' started by Eyrian, Jan 9, 2020.

  1. Hello,

    I'm trying my first simple World Generator, trying to understand the concept behind it, but so far I'm stuck because the server keeps timing out.

    I'm trying to generate a 128x128 grid which has 3-block wide walls, more specifically water encapsuled by barriers, top to bottom.

    When I generate it being only 1-block high, it works. However, when scaling it up near to max height, my server always throws an error.

    Code Snippet of Generator:
    Code (Java):
    @Override
        public ChunkData generateChunkData(World w, Random r, int cX, int cZ, BiomeGrid b) {
           
            ChunkData chunk = createChunkData(w);
           
                if(cX % 8 == 0) {
                    for(int z = 0; z < 16; z++) {
                        for(int y = 0; y < 244; y++) {
                            chunk.setBlock(0, y, z, Material.BARRIER);
                            chunk.setBlock(2, y, z, Material.BARRIER);
                        }
                    }
                }
                if(cZ % 8 == 0) {
                    for(int x = 0; x < 16; x++) {
                        for(int y = 0; y < 244; y++) {
                            chunk.setBlock(x, y, 0, Material.BARRIER);
                            chunk.setBlock(x, y, 2, Material.BARRIER);
                        }
                    }
                }
                if(cX % 8 == 0) {
                    for(int z = 0; z < 16; z++) {
                        for(int y = 0; y < 244; y++) {
                            chunk.setBlock(1, y, z, Material.WATER);
                        }
                    }
                }
                if(cZ % 8 == 0) {
                    for(int x = 0; x < 16; x++) {
                        for(int y = 0; y < 244; y++) {
                            chunk.setBlock(x, y, 1, Material.WATER);
                        }
                    }
                }
            return chunk;
        }
    Error:

    Code (Text):
    [22:05:17] [Spigot Watchdog Thread/ERROR]: ------------------------------
    [22:05:17] [Spigot Watchdog Thread/ERROR]: The server has stopped responding! This is (probably) not a Spigot bug.
    [22:05:17] [Spigot Watchdog Thread/ERROR]: If you see a plugin in the Server thread dump below, then please report it to that author
    [22:05:17] [Spigot Watchdog Thread/ERROR]:       *Especially* if it looks like HTTP or MySQL operations are occurring
    [22:05:17] [Spigot Watchdog Thread/ERROR]: If you see a world save or edit, then it means you did far more than your server can handle at once
    [22:05:17] [Spigot Watchdog Thread/ERROR]:       If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes
    [22:05:17] [Spigot Watchdog Thread/ERROR]: If you are unsure or still think this is a Spigot bug, please report to https://www.spigotmc.org/
    [22:05:18] [Spigot Watchdog Thread/ERROR]: ------------------------------
     
    My plugin wasn't listed in the dump.

    Probably some of you will cringe, but please, keep it calm, and try to explain to me, I'm always eager to learn.

    Thanks,
    Eyrian
     
  2. I'm not quite sure if this might be the error, but if If I have it correctly in mind, the water will start flowing and thus creating a huge mess when it has the chance to. Can you try replacing the water by some stationary block like blue wool and see if the watchdog still triggers and if not whether or not there are vertical spaces of air that might allow the water to flow?
     
  3. I tried simple as it can be now: Dirt. Sadly with the same result... The server gets timed out. I had that idea with the water too, which is why I started creating the blocks bottom to top, to reduce or negate flow.
     
  4. md_5

    Administrator Developer

    Pass false to setblock to prevent physics
     
  5. I don't see setBlock taking any boolean argument. Can you explain to me how to do it?
     
  6. After some more testing, it seems that iterating from floor to max height, to generate walls, just takes too long, which is why the server watchdog kills my testserver. Is there anyone, who can point me in the right direction of generating those walls more quickly / efficiently?

    Edit: Currently I'm generating plain dirt walls.
     
  7. I have heard that ChunkGenerator#setRegion is supposed to work pretty efficiently. Maybe you can try this.
    Other than that, I just think that‘s just how it is. Maybe you can try to decrease the amount of chunks loaded at the same time (I don‘t know exactly, where to set that value but it might be equivalent to setting the view distance)