Jump to content

Recommended Posts

Posted

hey guys back again, so im able to generate my structure quite fine and im able to generate it randomly quite fine but ideally i want to generate it specifically at the spawn point (and only one structure per world)

 

im able to make it generate at the spawn point but due to:

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

parameter "random" theres only a chance of it spawning per map, i need it to be absolute but im a bit stuck on how to do this, any ideas :/

 

 

EDIT this is my gen code just in case youre wondering :) i know it works because like one in every 3-8 worlds so far generate the structure at the spawn but like i said i have the issue of it being random

 

 	@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

	switch(world.provider.dimensionId){
	case 0 : generateOverWorld(world, random, chunkX*16, chunkZ*16);

	}	
}

private void generateOverWorld(World world, Random random, int x, int z) 
{

	  int Xcoord1 = world.getSpawnPoint().posX;
	  int Ycoord1 = world.getTopSolidOrLiquidBlock(x, z);
	  int Zcoord1 = world.getSpawnPoint().posZ;
	   
	  (new WorldGenHouse()).generate(world, random, Xcoord1, Ycoord1, Zcoord1);
} 

 

EDIT: if theres no way around this is there another way to spawn the structure in world? eg, an onworld created event or something if one even exists

 

Posted

You can just make a public static boolean field in your mod's main class, called something like structureAlreadySpawned.

 

Initialize it to false, and then whenever you call your generate function check the value and only proceed if false.  Set it to true once the random chance happens and you spawn it.

 

Make sure to save and load the field in your world save data.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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