Jump to content

[1.10.2] World Generation


Ugdhar

Recommended Posts

So I've mostly got my head wrapped around using an IWorldGenerator to generate ores, but I'm wondering about more information on how minecraft does world generation (dimensions/biomes/etc), and how all the classes relate to each other. I've tried looking at the vanilla code, but honestly there are so many classes I get lost and confused. Most of the "tutorials" I've found are basically just code, nothing actually explaining how things fit together and/or how they work.

 

I'm not looking specifically for code, but more of a breakdown/explanation of how the different classes fit together and can be added/changed for custom world generation.

 

Any advice or links would be greatly appreciated!

Link to comment
Share on other sites

Well, here's a breakdown of what I've managed to make sense of at least. (World-Generation only, as wanted. Keeping calculateCelestialAngle etc out)

Very basic, and all from, as stated, what I've been able to make heads or tails of. If anyone sees a flaw, or something missing, don't be hesitant to yell at me, and state what it actually does  :)

 

1) Dimension

Each Dimension is registered in the DimensionManager with ID & DimensionType(name, suffix, id, WorldProvider*, keepLoaded boolean)

2) WorldProvider

The WorldProvider gets the BiomeProvider*, terrainType* & the ChunkProvider*. Also has methods getBiomeForCoords(BlockPos) & canDropChunk(can be unloaded?)

3) BiomeProvider

The BiomeProvider, in simplified terms, sets the selected chunk to a certain biome. Yes, biomes are chunk-based, but it makes use of a byte[256] (16*16 block count) to set the blocks individually to a biome with desired size of width*depth.

4) terrainType

The terrainType is an instance of the WorldType* being used for the active dimension.

The terrainType, called from the WorldProvider, defaults to WorldType.DEFAULT, which is the very basic, first vanilla type you can create when making a world. As said, it defaults, meaning that unless specified somewhere else, it will be WorldType.DEFAULT.

5) ChunkProvider

The ChunkProvider is where the block are actually placed. It makes use of NoiseGeneratorOctaves/Perlin.

It gets the BiomeProvider's biomesForGeneration, and sets them unto each block using the mentioned byte[]. It gets the Sealevel of the world, and then it starts to place blocks. Do note, on the size of worldgen as is done here, it does not use world.setBlockState, rather it actually just makes use of pure numbers, representing the BlockPos, and setting to a blockstate, which has an enormous resource-cost decrease, comparably. The shape and form of the basic terrain is made by the mentioned perlin & octave noise.

The ChunkProvider also has a populate method which fires the DecorateBiomeEvent. This is where IWorldGenerators are fired, once the event is called. It also calls the BiomeDecorator#decorate, which places dirt, gravel, clay, the ores etc in the world.

6) WorldType

The WorldType changes how the previously mentioned classes act: Vanilla Minecraft makes use of Default, Superflat, Large Biomes, AMPLIFIED & Customized, all of which make use of various booleans etc in the mentioned classes, to significantly edit the overall worldgen. This is where the BiomeProvider & ChunkProvider originates from, as the WorldProvider gets them from the terrainType, which as said, is the WorldType in use.

 

I have a GitHub project for 1.10.2, called Underworld, a Cave-World dimension that replaces the Overworld dimension, which makes use of all of these classes, and implements custom IWorldGenerators, though none for actual ores. Feel free to look through if you want: https://github.com/Matryoshika/Underworld

 

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.

Link to comment
Share on other sites

Awesome thanks for the info and link! Hopefully it'll help my understanding more!

 

Any other info you or anyone else has is welcome! Aside from most tutorials out there being for 1.7.10 (I hate that version so bad), most of them are code with little to no explanation, and I'm not big on cutting & pasting code I don't understand at least mostly. :)

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.

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.