tAPI [Tutorial] How to create biome

Dradonhunter11

Official Terrarian
hi everyone,

Today, I will show you how to make a biome!

but first of all you probably have question like is it hard to make or why I can use it. So I will start by answering those question.

Is it hard to make?

Actually, a biome is probably one easy thing to do, but it need lot of file.

Why I can use it

You can use it for making mob spawning in certain tile that you made or even make alt with it. The main goal of it is actually for making mob spawning on certain tile.

What I need first?

you need a world file in your mod, a modNPC, modPlayer and a modBase

Now I answer to all the question it time to attack the main tutorial

1) Setup a modBase with biome

First of all, you need to create your biome variable in your modBase so there is an exemple

Code:
using Exemple.World; //You need it for making it work just replace Exemple with your namespace
public static Biome ExempleBiome // this your variable, replace ExempleBiome with the name of your biome
        {
            get;
            private set;
        }

after that you need to make it load when you start your, this is the 2 thing you need in your modBase

Code:
public override void OnLoad()
        {
            (ExempleBiome = new ExempleBiome()).AddToGame(); //for this part, you need to create the world file, wich is in part 2

            if (!Main.dedServ) //this part need know how to make dust, but I think that optional
            {
                ExempleDust.Load(this);
            }
        }

this all for your modBase

2) Setup a world file

A world file is not a modWorld but something that allow tro have modBiome and multiple modWorld

So now you need to creates a file name (your biome name).cs, in this case it will be ExempleBiome.cs

so there is the entire code you need:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace ExempleMod.World //this is a modWorld, put it in World file (capital important)
{
    public sealed class ExempleBiome : Biome
    {
        public const int minTile = 180; //replace 180 with the minimal tile required for creating the biome
        public Meteoridon()
            : base("ExempleMod:ExempleBiome", new List<int>() //this actually setup what tile is required
            {
                TileDef.byName["ExempleMod:ExempleGrass"],
                TileDef.byName["ExempleMod:ExempleStone"],
                TileDef.byName["ExempleMod:ExempleIce"],
                TileDef.byName["ExempleMod:ExempleSand"]
            }, Exemple.IntList, minTile)
        {
        }
    }
}

this is all for this part

3) Setup the ModPlayer (more complex stuff)

So this is the most important part because it set the variable for your biome

The first thing you need to add in your Mod player is these two variable

Code:
public static bool zoneExemple; //for creating your zone, work like Main.zoneHoly or Main.zoneEvil
public static int meteoridonTiles = 0; //this actually what make everything work in your (Your biome name).cs

after that you need these line of code

Code:
apocTiles = Biome.Biomes["ExempleMod:ExempleBiome"].CountNum();
            if (apocTiles > 180) //if it have more than 180 exemple tile, it will turn true your biome
            {
                zoneExemple = true;
                Main.liquidTexture[0] = Main.goreTexture[GoreDef.gores["Exemple:Liquid_13_2"]]; //this line is purely optional, can make crash
            }
            else //if less than 180 exemple tile, it will turn false your biome, it work like vanilla biome
            {
                zoneExemple = false;
            
            }

it already the end of this part, but now the next and final is seting your modNPC

4) Setup the modNPC (might have bug for this part)

Now it's the final part of the tutorial, the modNPC file

it actually make your mob spawning in your biome

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;


namespace ExempleMod
{
    [GlobalModAttribute] //You need it for making it work
    class ExempleNPC : ModNPC
    {
        public override List<int> EditSpawnPool(int x, int y, List<int> pool, Player player)
        {
            if (ExemplePlayer.zoneExemple)
            {
                pool.Clear();
                if (!Main.dayTime) //set the mob spawn at night in your biome
                {
                    pool.Add(NPCDef.byName["Exemple:ExempleZombie"].type);
                }
                else //if it the day, the Exemple slime will spawn
                {
                    pool.Add(NPCDef.byName["Exemple:ExempleSlime"].type);
                }
                return pool;
            }
            else
            {
                return pool;
            }

this is everything you need for your biome but you can do more thing with your biome like adding drop (keymold or soul) and lot more, but this is for future

usefull tutorial that will help with creating your biome

The aspect of world generation - By TheGamingBoffin
The tile spread - by me
Custom dust - by Bluemagic123

Credit:
TheGamingBoffin for making some of the code (almost entirely) and the apo mod team
Thanks!
 
Last edited:
reserved for future
Optional thing:
5) Making biome drop:
So there is the the first optional thing that you can add to your biome, biome drop are drop like keymold or soul.

so there is an exemple for keymold drop:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace ExempleMod
{
   public void postNPCLoot()
   {
       if (ExempleMod.ExempleBiome)
       {
           int rand = Main.rand.Next(2500);
           if (rand == 0)
           {
                  Item.NewItem((int)npc.Center.X, (int)npc.Center.Y, (int)npc.width, (int)npc.height, ItemDef.byName(ExempleMod:ExempleBiomeKeymold).type);
           
         }
            }

         
        }
 }´
the second part is coming soon
note: Use vanilla code for making your biome gen
 
Last edited:
hi everyone,

Today, I will show you how to make a biome!

but first of all you probably have question like is it hard to make or why I can use it. So I will start by answering those question.

Is it hard to make?

Actually, a biome is probably one easy thing to do, but it need lot of file.

Why I can use it

You can use it for making mob spawning in certain tile that you made or even make alt with it. The main goal of it is actually for making mob spawning on certain tile.

What I need first?

you need a world file in your mod, a modNPC, modPlayer and a modBase

Now I answer to all the question it time to attack the main tutorial

1) Setup a modBase with biome

First of all, you need to create your biome variable in your modBase so there is an exemple

Code:
using Exemple.World; //You need it for making it work just replace Exemple with your namespace
public static Biome ExempleBiome // this your variable, replace ExempleBiome with the name of your biome
        {
            get;
            private set;
        }

after that you need to make it load when you start your, this is the 2 thing you need in your modBase

Code:
public override void OnLoad()
        {
            (ExempleBiome = new ExempleBiome()).AddToGame(); //for this part, you need to create the world file, wich is in part 2

            if (!Main.dedServ) //this part need know how to make dust, but I think that optional
            {
                ExempleDust.Load(this);
            }
        }

this all for your modBase

2) Setup a world file

A world file is not a modWorld but something that allow tro have modBiome and multiple modWorld

So now you need to creates a file name (your biome name).cs, in this case it will be ExempleBiome.cs

so there is the entire code you need:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace ExempleMod.World //this is a modWorld, put it in World file (capital important)
{
    public sealed class ExempleBiome : Biome
    {
        public const int minTile = 180; //replace 180 with the minimal tile required for creating the biome
        public Meteoridon()
            : base("ExempleMod:ExempleBiome", new List<int>() //this actually setup what tile is required
            {
                TileDef.byName["ExempleMod:ExempleGrass"],
                TileDef.byName["ExempleMod:ExempleStone"],
                TileDef.byName["ExempleMod:ExempleIce"],
                TileDef.byName["ExempleMod:ExempleSand"]
            }, Exemple.IntList, minTile)
        {
        }
    }
}

this is all for this part

3) Setup the ModPlayer (more complex stuff)

So this is the most important part because it set the variable for your biome

The first thing you need to add in your Mod player is these two variable

Code:
public static bool zoneExemple; //for creating your zone, work like Main.zoneHoly or Main.zoneEvil
public static int meteoridonTiles = 0; //this actually what make everything work in your (Your biome name).cs

after that you need these line of code

Code:
apocTiles = Biome.Biomes["ExempleMod:ExempleBiome"].CountNum();
            if (apocTiles > 180) //if it have more than 180 exemple tile, it will turn true your biome
            {
                zoneExemple = true;
                Main.liquidTexture[0] = Main.goreTexture[GoreDef.gores["Exemple:Liquid_13_2"]]; //this line is purely optional, can make crash
            }
            else //if less than 180 exemple tile, it will turn false your biome, it work like vanilla biome
            {
                zoneExemple = false;
             
            }

it already the end of this part, but now the next and final is seting your modNPC

4) Setup the modNPC (might have bug for this part)

Now it's the final part of the tutorial, the modNPC file

it actually make your mob spawning in your biome

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;


namespace ExempleMod
{
    [GlobalModAttribute] //You need it for making it work
    class ExempleNPC : ModNPC
    {
        public override List<int> EditSpawnPool(int x, int y, List<int> pool, Player player)
        {
            if (ExemplePlayer.zoneExemple)
            {
                pool.Clear();
                if (!Main.dayTime) //set the mob spawn at night in your biome
                {
                    pool.Add(NPCDef.byName["Exemple:ExempleZombie"].type);
                }
                else //if it the day, the Exemple slime will spawn
                {
                    pool.Add(NPCDef.byName["Exemple:ExempleSlime"].type);
                }
                return pool;
            }
            else
            {
                return pool;
            }

this is everything you need for your biome but you can do more thing with your biome like adding drop (keymold or soul) and lot more, but this is for future

usefull tutorial that will help with creating your biome

The aspect of world generation - By TheGamingBoffin
The tile spread - by me
Custom dust - by Bluemagic123

Thanks!
Nice Tutorial
 
I Made A Custom Wall That Spawns Dungeon Enemies
upload_2015-5-30_21-4-44.png
 
Back
Top Bottom