Skip to content

Population

The population phase is done a little differently when compared to terrain generation, as it relies on adjacent chunks already existing, due to the generated features being capable of generating across chunk boundaries. This page covers both overworld and nether population.

MISSING

A huge chunk of info is still missing!!

Initialization

Before any population is done, the chunk populator prepares a few things to make subsequent generation easier.

  • Get the current biome of the chunk (offset by +16 blocks on the x/z axes)
  • The PRNG seed is set to the world seed
  • This is then used to generate a random x/z offset (rand.nextLong() / 2L * 2L + 1L)
  • This is then used to generate a new, chunk position dependent seed
cpp
rand.setSeed((
        (int64_t(chunkPos.x) * xOffset) +
        (int64_t(chunkPos.y) * zOffset)
    ) ^ worldSeed
);

Generation order

Features attempt to generate in the following order.

  1. Water lakes
  2. Lava lakes
  3. Dungeons
  4. Clay patches
  5. Dirt blobs
  6. Gravel blobs
  7. Coal ore veins
  8. Iron ore veins
  9. Gold ore veins
  10. Redstone ore veins
  11. Diamond ore veins
  12. Lapis lazuli ore veins
  13. Trees
  14. Yellow flowers (Dandelions)
  15. Tallgrass
  16. Deadbushes
  17. Red flowers (Roses)
  18. Brown mushrooms
  19. Red mushrooms
  20. Reeds (Sugarcane)
  21. Pumpkins
  22. Cacti
  23. Singular Fluid Source (Water)
  24. Singular Fluid Source (Lava)
  25. Snow layer

Each of them have their own unique generator object that's responsible for placing them in, though some are shared. Thus the only distinct feature generators that exist are presented here.

Before generation

Before actually being placed into the world, each feature does a bit of extra stuff. This can be as simple as having its generation be attempted multiple times, or as complex as having to fulfill specific conditions before generation is even attempted.

Chances/Ranges

NOTE

The initial coordinates for each feature are always generated in the order (X,Y,Z). It's only ordered as (X/Z,Y) here, as X and Z always share the same ranges.

NOTE

These offset coordinates are relative to the chunks block coordinate, i.e. chunkPos / 16.

NOTE

Offset coordinates marked with ~ use multiple PRNG passes. The depicted number is the total chance if both of those random numbers attained their lowest/highest possible value.

FeatureChanceAttemptsX/ZY
Lakes (Water)1/418 - 230 - 127
Lakes (Lava)1/818 - 230 - ~126
Dungeons-88 - 230 - 127
Clay Patches-100 - 150 - 127
Dirt Blobs-200 - 150 - 127
Gravel Blobs-100 - 150 - 127
Coal Vein-200 - 150 - 127
Iron Vein-200 - 150 - 63
Gold Vein-20 - 150 - 31
Redstone Vein-80 - 150 - 15
Diamond Vein-10 - 150 - 15
Lapis Lazuli Vein-10 - 150 - ~30
Trees-*[1]8 - 23*[2]
Dandelions-*[1]8 - 230 - 127
Tallgrass-*[1]8 - 230 - 127
Deadbushes-*[1]8 - 230 - 127
Roses1/218 - 230 - 127
Brown Mushrooms1/418 - 230 - 127
Red Mushrooms1/818 - 230 - 127
Sugarcane-108 - 230 - 127
Pumpkins1/3218 - 230 - 127
Cacti-*[1]8 - 230 - 127
SBS (Water)-508 - 238 - ~127
SBS (Lava)-208 - 238 - ~127

Biome-dependent attempts

Some features have the number of generation attempts tied to the chunks biome

BiomeTreesDandelionsGrassDeadbushesCacti
ForesttreeDensity + 52200
RainforesttreeDensity + 501000
TaigatreeDensity + 52000
Seasonal ForesttreeDensity + 24200
Desert-2000210
Tundra-200100
Plains-2031000

The treeDensity is taken from the tree density noise, see more about this in the Tree Generation section

Generation

Lakes

Water and lava lakes share the same logic, the only differences between them are what blocks generate, and the fact lava lakes generate a stone border around their edge.

Dungeon

Generates a dungeon made of cobble and mossy cobble, alongside a spawner at the center and chests with loot in them.

Dungeon Loot

When a chest is generated in a dungeon, an integer with a bound of 11 is generated, resulting in the loot table below. Up to 8 items can be generated.

ItemChanceAmount
Saddle1/111
Iron Ingot1/111-5
Bread1/111
Wheat1/111-5
Gunpowder1/111-5
String1/111-5
Bucket1/111
Golden Apple1/11001
Redstone Dust1/221-5
Record1/1101
Lapis Lazuli1/111

Anything else results in an empty slot.

Mob Spawner mobs

When a Mob Spawner is placed by the Dungeon generator, an integer with a bound of 4 is generated, resulting in the following table below.

MonsterChance
Skeleton1/4
Zombie1/2
Spider1/4

Clay

Clay patches.

Minable

Anything you'd find underground, such as dirt/gravel blocks and coal, iron, gold, redstone, diamond and lapis lazuli veins. Ore Generation Attempt Chart

Trees

This section will discuss how its decided if a tree should generate and how those trees generate.

  1. The tree density noise is sampled according to the current block position
  2. The initial number of trees is set to 0
  3. It has a 1/10 chance to be incremented

From here, the following values are added onto the number of trees.

BiomeTree chance change
ForesttreeDensity + 5
RainforesttreeDensity + 5
Seasonal ForesttreeDensity + 2
TaigatreeDensity + 5
Desert-20
Tundra-20
Plains-20

From there, depending on the biome, one of four kinds of trees can be generated.

BiomeChanceTree Type if winTree type if fail
-1/10Big TreeOak Tree
Forest1/5Birch Tree(see birch fail)
Forest (birch fail)1/3Big TreeOak Tree
Rainforest1/3Big TreeOak Tree
Taiga1/3Big Taiga TreeOak Taiga Tree

This is repeated for whatever number of trees that was calculated is.

Oak Tree

TODO

Birch Tree

Birch trees employ the exact same generator as Oak Trees, except that their maximum height is one block more, and that their Metadata is different (2 instead of 0).

Big Tree

TODO

Small Taiga Tree

TODO

Big Taiga Tree

TODO

Flowers

Dandelions, Roses and Mushrooms rely on this generator.

Tallgrass

Tallgrass

Deadbush

Deadbushes

Reeds

Sugarcane

Pumpkins

Pumpkins

Cacti

Cacti

Singular Fluid Source

Singular Fluid Sources can only generate if the chosen position fulfills the following conditions:

  • The block above and below are stone (Y axis)
  • The block at the chosen position is stone or air
  • There are exactly 3 stone and 1 air blocks around it (X/Z axes) If all of these are met, the specified fluid can generate.

Snow

Snow generates on the highest solid block, except ice, where the temperature value is <0.5. The placement of these may look different if you're implementing your own system, due to snow and ice placed by random ticks. See the quirks page for more info!

Nether

The Nether has its own population generators and steps, unique to it.

Generation order

Features attempt to generate in the following order.

  1. Singular Lava Sources
  2. Fire
  3. Glowstone
  4. Glowstone (again?)
  5. Brown mushrooms
  6. Red mushrooms

Further reading