How do I generate a custom biome?

Trodgy

Terrarian
I've been digging for info for a bit now but I can't quite figure it out aaaa

I've followed through some of the bits with Example Mod's biomes but I can't figure out what I'm meant to write to turn the biome into a generation pass
how do I go about doing that?

(my code is practically identical to the example mod surface biome)
 
turns out I misunderstood how biomes function despite literally making use of how they work 100s of times

I'll leave some info here on how they work to hopefully make someone's life easier cuz the documentation on actually getting a biome ingame is a little scarce:

in order to get a biome ingame you need to assign a set of tiles to it that act as the biome blocks (think ebonstone for the corruption for instance)
to do this you need three (or more) classes:

- A ModBiome
- A ModSystem
- At least one ModTile (might even just be possible to use one of the existing vanilla tiles, I haven't tested this personally)

the part that took me forever to figure out was the ModSystem being used to count the tile types used by the biome. a ModBiome can look at this and go "oh ok there are X number of biome tiles in range of the player right now", and if it fulfills the count needed for the biome to exist then the biome will exist.

Code:
using [YOUR MOD HERE].Content.Tiles;
using System;
using Terraria.ModLoader;

namespace [YOUR MOD HERE].Common.Systems
{
    public class NewTileCount : ModSystem
    {
        public int TileCount;

        public override void TileCountsAvailable(ReadOnlySpan<int> tileCounts)
        {
            TileCount = tileCounts[ModContent.TileType<[TILE NAME HERE]>()];
        }
    }
}

Example Mod has pretty good examples of all of these built in:

ExampleSurfaceBiome found in ExampleMod\Content\Biomes
ExampleBlock found in ExampleMod\Content\Tiles
ExampleBiomeTileCount found in ExampleMod\Common\Systems

I found it helped to look at them being applied in an actual mod (in my case I went and found the public calamity repository on github)

once you have those three types, you then either need to write world generation or make an item of the tile(s) (typically known as a Placeable) and have the tile(s) placed in the world

this probably isn't very good info especially cuz I'm uncertain about a lot of bits but it worked for me so hopefully this helps someone!
 
Last edited:
Back
Top Bottom