Jump to content

Multipile Structures are generating


Recommended Posts

Im having a little problem with my structure generation.

it generates fine but i only want 1 structure to generate and there are more structres generating.

most of the time 3 or 4 and sometimes even 5.

here is the code that generates my structure

public class WorldGenerator implements IWorldGenerator{

private boolean alreadyRendered = false;

public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	System.out.println("generating called");
	generateWatchtower(world, random, chunkX*16, chunkZ*16);


private void generateWatchtower(World world, Random random, int i, int j) {
	while(alreadyRendered == false){
		int startX = world.getWorldInfo().getSpawnX();
		int startZ = world.getWorldInfo().getSpawnZ();
		int Xcoord1 = startX + random.nextInt(30) + 20;
		int Zcoord1 = startZ + random.nextInt(30) + 20;
		int blocks[] = new int[]{Block.grass.blockID, Block.sand.blockID, Block.stone.blockID};
		int iii;
	    for (int ii = 0; ii < 128; ii++){
	    	if(world.canBlockSeeTheSky(Xcoord1, ii+1, Zcoord1) == true){
	    		iii = world.getBlockId(Xcoord1, ii, Zcoord1);
	    		if(iii == blocks[0] || iii == blocks[1] || iii == blocks[2]){
		    		new WorldGenWatchtower().generate(world, random, Xcoord1, ii+1, Zcoord1);
		    		alreadyRendered = true;


sometimes there arent structures generating at all.

when i generate a superflat map most of the time the structures wont generate.


im really hoping someone can help me with this because i really dont know a solution.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.