Skip to content

Instantly share code, notes, and snippets.

@maxanier
Last active December 12, 2021 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxanier/8ab96ff98fde0e88b8b80fe7197f01ea to your computer and use it in GitHub Desktop.
Save maxanier/8ab96ff98fde0e88b8b80fe7197f01ea to your computer and use it in GitHub Desktop.

Biomes are selected based on 6 Climate.Parameter

  • Temperature
  • Humidity
  • Continentalness
  • Errosion
  • Depth
  • Weirdness

These parameters can be between -1 and 1 (OverworldBiomeBuilder#FULL_RANGE) (except for depth which is always 0 or 1). Internally these values are multiplied by 10000 and stored as long (Climate#quantizeCoord).

When generating a normal world a MultiNoiseBiomeSource is used. This noise source can calculate a parameter value for each of the climate parameters for every block/chunk in the world. The parameter values transistion smoothly and can be seen in the F3 debug overlay. For every chunk (which has one set of climate parameter values (Climate.TargetPoint)) the biome source queries its Climate.ParameterList for a biome that fits to the target point.

This Climate.ParameterList contains a very long list of Climate.ParameterPoint to Biome supplier pairs. One ParameterPoint represents an area/volume within the range/dimensions of possible values of each Parameter. So for example one point represents (0< Temperature < 0.1 && 0.4 < Humidity < 0.5 && -0.1 < Continentalness < 0.323 && Depth == 0 && ...). For a given TargetPoint the ParameterList then tries to find the ParameterPoint to which the target point is mathematically (in the 6D space) closest to (usually inside). This biome is then generated at that chunk.

The Climate.ParameterList can probably be created by datapacks. For the vanilla overworld dimension it is built in MultiNoiseBiomeSource.Preset#OVERWORLD and filled by OverworldBiomeBuilder. In confusing way OverworldBiomeBuilder generates ~7000 ParameterPoint -> Biome ResourceKey (used for supplier later on) Pairs supplier, which probably cover the entire 6D space (not verified). The algorithm assigns biomes to suitable parameter points.

Altogether this means the only random aspect in this system is the parameter layer noise (so which value each parameter has at a XZ coordinate). This presents a difficulty for adding modded biomes to the Overworld. It is possible to just "claim" certain parameter spaces for your own modded biome (thereby replacing a vanilla biome at these places). You just have to take care to choose "consistent" parameter ranges, so you get biomes of desired size. However, this will probably cause conflicts when another mod wants to generate in the same parameter range.

I am not sure how best solve this. Two ideas:

  • Some system that accepts rough parameter ranges (or something like biome location tags/types) and then assigns specific ParamterPoints that are subranges of these rough ranges/location types. Depending on how many modded biomes are desired in the same type they will get smaller. Also vanilla biomes will get smaller in that area.
  • A Forge Climate.Parameter (probably requires a lot of patching) that varies much less over XZ than the other parameters. Then every biome mod could get a ParameterPoint assigned. In the respective area of the world (parameter space) the mod can then provide its own biomes (for the desired temp/hum/cont/erro/... parameter space).

Both ideas are not great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment