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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

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