Jump to content

Recommended Posts

Posted

Hey everyone!

I want to change the amount of vanilla ore is generated in the world based on an amount put in the minecraft configuration. I think I need to use an event to catch right before the ore is about to be spawned in, but I don't know what event it would be. Am I even using the right approach? Any help is appreciated.

Thanks!

Posted

Yes there is a whole event bus dedicated to ore generation with the following events:

GenerateMinable

OreGenEvent.Pre

OreGenEvent.Post

 

Also, you can do block replacements during chunk loading events as well.

 

I'm not sure how familiar you are with event handling, so if you are new to it you might want to check out my tutorial: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

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

Posted

Yes there is a whole event bus dedicated to ore generation with the following events:

GenerateMinable

OreGenEvent.Pre

OreGenEvent.Post

 

Also, you can do block replacements during chunk loading events as well.

 

I'm not sure how familiar you are with event handling, so if you are new to it you might want to check out my tutorial: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

I actually learned about events from your tutorials. Thank you for making them!

I think I know what I need to do but how exactly do I find the blocks being populated since the event only gives an X and Z coord and .getBlock() requires a Y? I thought of doing a random but figured it wouldn't work out well.

Posted

I don't know that much about ore generation actually.  I concentrate most of my modding on entities and items.

 

From briefly looking at the code, I think the idea is that the BiomeDecorator class has a method called generateOres() which posts the OreGenEvent.Pre event and then calls the TerrainGen.generateOre() method for each mineable type.  This generateOre() method takes a WorldGenMineable parameter for each mineable type such as dirtGen, gravelGen, coalGen, ironGen, etc as well as the X and Z position.  The WorldGenMineable has a generate() function which uses a bunch of loops to create clusters of the mineable type.

 

The TerrainGen.generatOre() method is pretty much just a hook into the events.  It creates the GenerateMineable event and posts it.  The event is not cancelable, however it does have a result -- this means that it is possible for your event handler to give a Result.DENY to prevent the generation.  I'm not certain but I think this would allow you to substitute your own ore generation -- give a DENY result but also call your own generation method.

 

I'm sure there are good ore generation tutorials out there but I think you could try the following:

1) if you just want to add your own extra ore generation, you can just handle the OreGenEvent.Pre or .Post and call your own WorldGenMineable. 

2) if you want to substitute your own and prevent some vanilla gen, then you'd handle the GenerateMineable event and send a DENY result, and also call your own WorldGenMineable.

 

Anyway, look at the code in the classes and methods I mention above and it should give you some idea.

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

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.