Getting started - Glitchfiend/TerraBlender Wiki

Concepts

TerraBlender provides compatibility between biome mods by assigning each mod its own region in which they can define the biomes they wish to generate. On a technical level, this is achieved by introducing a new climate parameter called uniqueness. Each mod has its own uniqueness value, which will allow it to generate biomes in its own region without interfering with other mods.

Regions are selected randomly during world generation according to their weight. Mods that weight their regions highly will have them occur more frequently than those with a low weight.

Gradle setup

To configure your build.gradle to use TerraBlender you should:

  1. Ensure you have the Forge Maven in your buildscript -> repositories block:
buildscript {
    repositories {
        maven { url = 'https://maven.minecraftforge.net/' }
    }
    dependencies {
        <...>
    }
}
  1. Add TerraBlender to your dependencies block, ensuring you replace x.x.x with your Minecraft version and y.y.y.y with your mod version as appropriate:

Forge

dependencies {
    implementation fg.deobf('com.github.glitchfiend:TerraBlender-forge:x.x.x-y.y.y.y')
}

Fabric

dependencies {
    modImplementation 'com.github.glitchfiend:TerraBlender-fabric:x.x.x-y.y.y.y'
}
  1. If using Forge, you may potentially need to include Mixins in your build.gradle for them to function correctly in your dev environment. This can be done by adjusting your buildscript block and apply plugin: section to include the following:
buildscript {
    repositories {
        <...>
        maven { url = 'https://maven.minecraftforge.net/' }
        maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
    }
    dependencies {
        <...>
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
        classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
    }
}

apply plugin: 'org.spongepowered.mixin'

After doing this, you may need to re-run gradlew idea and regenerate your run configurations.

An alternative approach to doing the same thing is to add the following to your run configurations:

property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile',"${buildDir}/createSrgToMcp/output.srg"

Fabric setup

On Fabric, it is advised that you perform all TerraBlender-related actions inside a class which implements the TerraBlenderApi entrypoint and overrides onTerraBlenderInitialized as follows:

public class TestMod implements TerraBlenderApi
{
    @Override
    public void onTerraBlenderInitialized() 
    {
        // Your code here.
    }
}

You will also need to modify the entrypoints section of your fabric.mod.json to include your terrablender entry point. For example:

    "entrypoints": {
      "terrablender": [
        "test.TestMod"
      ]
    },

API introduction

The TerraBlender api is centered on the use of a BiomeProvider. This is a class which consolidates most of the things modders seek to change when creating their own biomes. In most circumstances a given mod will only require a single biome provider. A basic example of a BiomeProvider is as follows:

public class TestBiomeProvider extends BiomeProvider
{
    public TestBiomeProvider(ResourceLocation name, int weight)
    {
        super(name, weight);
    }

    @Override
    public void addOverworldBiomes(Registry<Biome> registry, Consumer<Pair<TBClimate.ParameterPoint, ResourceKey<Biome>>> mapper)
    {
        // Your code to add biomes goes here.
    }
}

A BiomeProvider should be registered using BiomeProviders.register(provider) during your mod's initialization. The ResourceLocation name used when constructing your BiomeProvider can be of your own choosing. For example, Vanilla's biome provider uses the name minecraft:biome_provider. The weight is an arbitrary value used to determine how common regions from your mod are compared to those of other mods. By default, Vanilla biomes have a weight of 10. If you have a small number of biomes in your mod, it may be desirable to choose a low weight value such as 1 or 2. Similarly, if you have a large number of biomes in your mod you may wish to select a weight greater than Vanilla such as 15.

There are many approaches to adding biomes in addOverworldBiomes. The method this.addBiome is provided in each BiomeProvider to allow adding biomes with specific parameters to regions belonging to your mod. An example of this is shown below from Vanilla's Nether, however the same can be done for overworld biomes also:

    @Override
    public void addNetherBiomes(Registry<Biome> registry, Consumer<Pair<TBClimate.ParameterPoint, ResourceKey<Biome>>> mapper)
    {
        this.addBiome(mapper, Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), 0.0F, Biomes.NETHER_WASTES);
        this.addBiome(mapper, Climate.Parameter.point(0.0F), Climate.Parameter.point(-0.5F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), 0.0F, Biomes.SOUL_SAND_VALLEY);
        this.addBiome(mapper, Climate.Parameter.point(0.4F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), 0.0F, Biomes.CRIMSON_FOREST);
        this.addBiome(mapper, Climate.Parameter.point(0.0F), Climate.Parameter.point(0.5F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), 0.375F, Biomes.WARPED_FOREST);
        this.addBiome(mapper, Climate.Parameter.point(-0.5F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), Climate.Parameter.point(0.0F), 0.175F, Biomes.BASALT_DELTAS);
    }

Vanilla's complete approach to overworld biomes can be found in OverworldBiomeBuilder. Mods may choose to replicate this, replacing certain biomes for their own. Alternatively, mods may use this.addBiomeSimilar(mapper, similarVanillaBiome, biome) within their overridden addOverworldBiomes. This allows adding biomes that generate under the same circumstances as a given vanilla biome. For example, this.addBiomeSimilar(mapper, Biomes.PLAINS, MyModBiomes.SOME_BIOME) would allow SOME_BIOME to generate in the same locations as Vanilla's plains biome.

It's important to appreciate that biomes are normally designed to generate within specific climates. Knowing this, you may wish to fill up your region with Vanilla biomes in the climates that your mod doesn't use. For example, if your mod only adds desert biomes, you may wish to add snowy biomes from Vanilla to your region. For those that do not wish to worry about this, this.addModifiedVanillaOverworldBiomes exists, which allows using Vanilla's entire approach to overworld biomes except with certain biomes swapped for those in your mod. An example of this can be found here.