Jump to content

Recommended Posts

Posted

Over the last couple of days I've been attempting to figure out how ore generation is working in 1.8. I've read a few tutorials and many forum threads here and I'm a bit stuck. It might be something obvious that I've just missing, but any help would be much appreciated.

 

I'm not getting any errors or crashes. The or simply isn't generating. I've changed all of the values to pretty extreme settings to be that I wouldn't be missing the ore. I also installed x-ray mod to hunt for it, just to be 100% certain that it isn't there. The mod is loading and everything as well. I can grab the block from the creative menu.

 

Calling the generator from the preInit event:

GameRegistry.registerWorldGenerator(new SixPointOhGenerator(), 0);

 

The code of the generator.

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

	switch(world.provider.getDimensionId()) {
		case 0:
			generateOverworld(random, world, chunkX, chunkZ);
			break;
		default:
			generateOverworld(random, world, chunkX, chunkZ);
	}

}

private void generateOverworld(Random random, World world, int x, int z) {
	addOres(SixPointOhBlocks.PlayBlock, world, random, x, z, 10, 15, 0, 250);
}

private void addOres(Block block, World world, Random random, int blockXpos, int blockZpos,
		int MaxVein, int spawnChance, int minY, int maxY) {

	WorldGenMinable minable = new WorldGenMinable(block.getDefaultState(), random.nextInt(MaxVein), BlockHelper.forBlock(Blocks.stone));
	for (int i = 0; i < spawnChance; i++) {
		int posX = blockXpos + random.nextInt(16);
		int posZ = blockZpos + random.nextInt(16);
		int posY = minY + random.nextInt(maxY - minY);
		minable.generate(world, random, new BlockPos(posX, posZ, posY));
	}

}

 

Thanks much for the help!

- Nikc-Nack

Posted

It's only a small thing, that can make a big difference:

 

But the

GameRegistry.registerWorldGenerator(new SixPointOhGenerator(), 0);

in the Init Event (FMLInitializationEvent), you put it in PreInit.

 

 

Posted

The X,Z coordinates which Forge passes to generate() are in units of chunks, whereas the X,Z coordinates which WorldGenMinable takes in are in units of blocks.  Your code isn't doing the translation, so odds are that the ore is getting generated, but somewhere else in the world far away.

 

Inside your for loop, try to multiply your blockXPos and blockZPos by 16, see if that fixes it.

 

A couple other minor longshots:

 

1.  As Brickfix said, try registering your WorldGenerator from the main Init event; that's where I have mine (currently working in 1.8).

 

2.  For the "priority" of the generator submitted when registering it, all the code examples I've run across use 1, and I notice you have 0.  0 probably still works, but who knows, maybe try 1 just in case.

 

good luck!

Posted

@jhogan42

Thank you very much for your help! You were absolutely correct about multiplying by 16. I went ahead and set the WorldGenerator to 1 and put it in the init event first. That didn't seem to have any effect initially, but I'll take your word for it! I'm sure you have much more experience with this than I do, haha!

 

Thanks much for your help, both of you!

- Nikc

Posted

Haha, not that much more experience actually.  I'm new to Minecraft modding, but just happened to spend yesterday evening writing ore generation code right before I saw your post :-)

 

Glad it worked!!

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.