Jump to content

Recommended Posts

Posted

This may sound like a really basic question, but I can't seem to find anything with google searches, multiple different keywords going several pages deeper then I care to admit.

 

In short, how do I change the games base terrain generation? I would like to change the ore spawn frequency and vein size. My first issue is I can not seem to find how to interact with that code via forge. I feel what I want to do is straight forward and shouldn't be too hard once I know how to interact with the ore generation code; or am I just being extremely naive?

 

Thanks!

Posted

One question: Is this for your own ores, or for vanilla/other modded ores?

 

If the latter:

If you want to influence other's ores, look at the GenerateMinable event. It passes the WorldGenerator, which you can cast to WorldGenMinable, and get the state, number and predicate from.

 

  • Like 1

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted
5 hours ago, jeffryfisher said:

I might just be stupid 

 

3 hours ago, Matryoshika said:

If you want to influence other's ores, look at the GenerateMinable event. It passes the WorldGenerator, which you can cast to WorldGenMinable, and get the state, number and predicate from.

I am trying to hastily ask this question before class, but from a few quick google searches these functions will allow me to change vein size, if they appear in a chunk, and how many veins appear in a chunk, correct?

Posted

OK, so I managed to do everything I wanted to do, for the most part. I am generating Iron in large single veins. Now I would like to be able to tell the terrain generator to skip certain chunks and to not generate a resource type in every chunk, maybe more like one in every sixty-four chunks

public class oreWorldGen implements IWorldGenerator {

	private WorldGenerator gen_iron;
	@Override
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkprovider){
		switch (world.provider.getDimension()){
		case 0: //Overworld
			this.runGenerator(this.gen_iron, world, random, chunkX, chunkZ, 1, 10, 50);
			break;
		case -1: //nether
			
			break;
		case 1: //end
			
			break;
		}
	}
	
	public oreWorldGen(){
		this.gen_iron = new WorldGenMinable(Blocks.IRON_ORE.getDefaultState(), 64);
	}
	
	private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight){
		if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
			throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
		
		int heightdiff = maxHeight - minHeight +1;
		for (int i=0; i<chancesToSpawn; i++){
			int x =chunk_X * 16 +rand.nextInt(16);
			int y = minHeight + rand.nextInt(heightdiff);
			int z = chunk_Z * 16 + rand.nextInt(16);
			generator.generate(world, rand, new BlockPos(x, y, z));
		}
	}

}

 This is the code I have so far. Thoughts? 

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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