tModLoader Biome Library - A ModBiome implementation with evil and hallow alt implementation!

Dradonhunter11

Official Terrarian
Hello everyone, have you ever found that creating a biome in tmod was hard? That it involve a lot of time to implement and you feel kinda lazy. Well say no more! Dradon created for you a new mod to simplify the process!

The BiomeLibs mod v0.4

So before I start talking in deep of this mod, I'm gonna say why I created it.
While working on Terraria Ultra Apocalypse, I saw that you had no real way to make biome in a simple way, you have to sync it and everything (wich involve messing with mainly 2 file, ModPlayer and ModWorld). What this do is rather simple, it basically allow you to make biome without messing with those! Currently there is 3 function you can use, but I planned to add more! It also use Strong reference, so you gotta extract it or use the dll provided in the download.

so now let's go on the method you'll need to use to make a new biome:

(OUTDATED, MAKING A GITHUB WIKI)

Code:
public override void Initialize()
{
       BiomeLibs.RegisterNewBiome("Meteoridon", 50, mod);
       BiomeLibs.AddBlockInBiome("Meteoridon", new String[] { "MeteoridonStone", "MeteoridonGrass", "BrownIce" });
       BiomeLibs.addHallowAltBiome("Meteoridon");
       //Totally not taken from TUA
}

so lemme explain what is happening here:

This method is probably the most important in this mod, as it allow to register your biome. When a new biome is created, it register a new BiomeSkeleton object and will contain all the information for your biome.
Code:
RegisterNewBiome(String biomeName, int minTileRequirement, Mod mod)
biomeName is basically the name of your biome, the name you'll use when you want to verify condition. This could in theory allow cross biome content (still need test)
minTileRequirement is the minimum of tile required to make a biome
Mod is basically your mod, normally since it's in ModWorld you just send mod and it work


This method is also really important as it allow you to add tile to your biome.
Code:
AddBlockInBiome(biomeName, String[] blockList);
biomeName is used here to get in the biome dictionnary the biome with that specific name.
blockList[] is where you send the list of block for your biome, in the exemple I used there was 3 tile.

Sicne version 0.3, you can make your biome exist if certain condition are met other than tile requirement.
Code:
BiomeLibs.setCondition(String biomeName, Func<bool> condition);

For exemple, you make a biome that will only register if moon lord is dead, well you can! I'll show an exemple of code here:
Code:
public override void Initialize()
{
       Func<bool> condition = () => NPC.downedMoonlord;
       BiomeLibs.RegisterNewBiome("Meteoridon", 50, mod);
       BiomeLibs.AddBlockInBiome("Meteoridon", new String[] { "MeteoridonStone", "MeteoridonGrass", "BrownIce" });
       BiomeLibs.addHallowAltBiome("Meteoridon");
       BiomeLibs.setCondition("Meteoridon", condition);
       //Totally not taken from TUA
}

This method is rather simple as it add your biome name to the hallow alt list, but there is actually more than that involved. When you trigger hardmode, the mod itself will an alt that been added and then will search in the block list of the biome. There is a function called block finder that will search for block name in the list containing these string: Grass, Stone, Ice, Dirt and Sand (Gonna add more later, but nor now)

Currently do note that it doesn't support wall as I'm not there yet in TUA (wich is my testing mod for this).
Code:
addHallowAltBiome(String biomeName);
biomeName is the name of the biome you wanna add to the list.
SkPoT5G.png

So now that the registery part is done, let's go on the detection method (currently only, maybe gonna add more?)
Code:
[code]InBiome(String biomeName)
Well, I don't think i need to explain what does biomeName here as it same as int the other method :D

public override void UpdateMusic(ref int music)
{
if (Main.myPlayer != -1 && !Main.gameMenu && Main.LocalPlayer.active)
{
if (BiomeLibs.InBiome("Meteoridon"))
{
music = MusicID.TheHallow;
}
}
}
[/code]

Here an example of how you mod world would look :
The following code is taken directly from TUA

Code:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using BiomeLibrary;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.GameContent.Generation;
using Terraria.World;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.World.Generation;
using Terraria.ID;

namespace TerrariaUltraApocalypse
{
    class TUAWorld : ModWorld
    {
        public override void Initialize()
        {
            //Those register method are only there to make the code clean, you can honestly include everything in here (but it won't be as clean)
            RegisterPlagues();
            RegisterMeteoridon();
        }

        private void RegisterPlagues()
        {
            BiomeLibs.RegisterNewBiome("Plagues", 50, mod);
            BiomeLibs.AddBlockInBiome("Plagues", new String[] { "ApocalypseDirt" });
        }

        private void RegisterMeteoridon()
        {
            Func<bool> c = () => Main.hardMode;
            BiomeLibs.RegisterNewBiome("Meteoridon", 50, mod);
            BiomeLibs.AddBlockInBiome("Meteoridon", new String[] { "MeteoridonStone", "MeteoridonGrass", "BrownIce" });
            BiomeLibs.addHallowAltBiome("Meteoridon", "The world is getting fiery...");
            BiomeLibs.SetCondition("Meteoridon", c);
        }
    }
}

This is probably the best exemple I can give right here as for now. It's really simple as it go by biome name.

So now that the explanation are done, here something you need to know as it's really important: you must use strong reference or it won't work, so add the following line.
Code:
modReferences = BiomeLibrary



As of v0.3.1, the mod now give you access to easily detect vanilla biome.

Code:
Biomelibs.InBiome("hell");
Biomelibs.InBiome("granite");
Biomelibs.InBiome("marble");

To do:
- Adding AddMobToSpawnPool(string biomeName, int[] mobID, int[] mobSpawnChance)
- Adding EditSpawnRate(string biomeName, int maxEnemySpawn, int spawnrate)

To do list:
- Clean code (yeah, really need to clean this mess I made, but it work :D)
- Add Sandstone, Snow and wall support for hallow alt
- Add Wall support for biome
- Add GlobalNPC edit spawn pool (v0.4, drawing board phase)
- Add background support (v0.5)

---------------------------------------------------
Credit:
- Me, for making this mod :D
- My friend @jsx542 , for making a better block detection code, this saved me a lot of time :D
- Re-Logic for making this awesome game
- My friend @blushiemagic , for making tmod, this wouldn't be possible without you!
--------------------------------------------------
You may use this "mod" as long you provide the proper credit
--------------------------------------------------
Download link v0.4: To be updated

Source : TUA-Team/BiomeLibrary

Discord (TUA team discord) : Join the Realm of Infinity (TUA) Discord Server!

PS: Sorry that you had to read trough this terrible grammar, I'm trying to improve everyday
 
Last edited:
Reserving in case I need it, but I doubt

--- Changelog --
v.0.1
- Initial Release
- Easy way to make biome with only 2 line!

v.0.1.1 (Does not require to update)
- Updated mod descruption

v.0.2 (Currently in progress)
- Hallow alt generator (AddHallowAtBiome(String name))
-- This function only add the name of your biome in the Hallow Alt name list
-- When entering in hardmode, a function will check if there is block that contain Dirt, Stone, Grass, Sand and Ice. If a block is not detected then it won't be changed. So be sure you write the right block name.
- Fixed an issue where biome where not checked in registery in the InBiome function (my bad here)
I apparently forgot to remove debug, so this version might not work. Will be fixed on next release :D

v.0.2.0.1
- Removed accidental debug, sorry if it made the mod impossible to use, should be fixed now :p

v.0.2.0.2
- Fixed a really nasty crash when spawning and getting near world border

v.0.3
- You can now assign condition to your biome, for exemple if you want your biome to exist only after moon lord is defeated, you can! (I'll provide an exemple of that)
- Setting minimum tile requirement is now working!

v.0.3.1
- Hell, Granite and Marble are now included by default in the biome registery! So it's no longer needed to do over complicated code for that!
Code:
Biomelibs.InBiome("hell");
Biomelibs.InBiome("granite");
Biomelibs.InBiome("marble");
- Added tile registery with ID, in case you wanna add tile with ID instead of block name (note that this won't work with hallow alt generator)
- Removed accidental debug that was breaking hallow alt generator, sorry on that again...

v.0.4
- Changed completly how the mod work, now you need to extends the modbiome class
-- An easy to use API, to be closer to what tML would use
- Added evil alt gen (refer to ModBiome doc)
- Modified how Hallow alt gen work
- Rewrote the entirety of the mod
- Remade the evil selection screen, it look great!
-- Support banner preview!
-- Credit to imkSushi for helping at simplifying the vanilla gen, because my original code was a bit over the top!

If you find any bug, pls report on this thread!

-----------
Could be nice if someone could make an icon ^^
 
Last edited:
Will you provide any videos showing off your mod?
Well, I don't know how I can really do a video on this lol (Apart from showing code)
It doesn't add directly content to game, it's just a biome manager for those that want a more universal support for they custom biome.
 
Welp, after Idk many month, I'm starting to work on this again lol Anyway, accidental debug removed, sorry if it made the mod impossible to use ^^
 
Update v.0.2.0.2 is out! Fixing a really important crash ^^
- Fixed a really nasty crash when spawning and getting near world border

In theory mod should be stable now ^^
 
v.0.3 is out
- You can now assign condition to your biome, for exemple if you want your biome to exist only after moon lord is defeated, you can! (I'll provide an exemple of that)
- Setting minimum tile requirement is now working!
 
Can you provide a example of ModWorld.cs code with biome libs please, i didn't completely understand if i need to put only the code up there or if i can put other code like for ores.
 
This looks really cool! I’m looking into making a mod soon with a few new biomes, so this should be a big help! Also, I could try making you a pixel art logo if you want.
 
This looks really cool! I’m looking into making a mod soon with a few new biomes, so this should be a big help! Also, I could try making you a pixel art logo if you want.
That would be nice ^^ I'm already planning next update moment at the time we speak. It will allow easier management of spawn pool (and maybe spawn rate!)
 
That would be nice ^^ I'm already planning next update moment at the time we speak. It will allow easier management of spawn pool (and maybe spawn rate!)
Cool! Also, does it have support for modded blocks? I feel like that could probably a neat feature for more modern, but it’s ok if you can’t do it at the moment. Good work though!
 
Cool! Also, does it have support for modded blocks? I feel like that could probably a neat feature for more modern, but it’s ok if you can’t do it at the moment. Good work though!
It does actually, all the biome I have in TUA use modded block (and the hallow alt generator allow to generate modded block to).

here an exemple
Code:
BiomeLibs.AddBlockInBiome("Meteoridon", new String[] { "MeteoridonStone", "MeteoridonGrass", "BrownIce" });
 
It does actually, all the biome I have in TUA use modded block (and the hallow alt generator allow to generate modded block to).

here an exemple
Code:
BiomeLibs.AddBlockInBiome("Meteoridon", new String[] { "MeteoridonStone", "MeteoridonGrass", "BrownIce" });
Ah, noice. I look foreward to using this in the future!
 
Back
Top Bottom