Force Generate chunks within a radius

Discussion in 'Archived: Plugin Requests' started by Zalastri, May 18, 2011.

  1. Offline

    Zalastri

    Hi guys.

    I've noticed the single worst cause of lag on my server is people walking out in an unexplored direction and causing chunks to generate. I'd like to force all the chunks within my borders (5,000 radius from spawn) to generate all at once, so I don't need to deal with this crap. Is there a way to do this? If not, can someone make it so? Would be willing to pay 20 bucks.
     
  2. Offline

    Coffox

    Yes there is a way.

    I just made a method that accesses a lot of blocks within a certain radius.
    because if you try to modify a block from a chunk that isn generated yet, the chunk will be automatically generated when accessing it

    heres my example method:

    Code:
    static void generateWorld(int rad, World world) {
        for(int x = 0 - rad ; x < rad ; x = x + 15)
        for(int z = 0 - rad ; z < rad ; z = z + 15)
            if(Math.sqrt(x*x + z*z) < (double) rad) {
                world.getBlockAt(x, 127, z).setTypeId(5);
                world.getBlockAt(x, 127, z).setTypeId(0);
            }
        }
        }
    }
    
    there might be a better way but this should also work
     

Share This Page