Skip to content

Update Migration Guide

JavidPack edited this page Oct 12, 2019 · 9 revisions

This page contains guides for migrating your code to new methods and functionality of newer tModLoader versions. When a tModLoader update requires rewriting code, we will present the information here.


v0.11.5 introduced ContentInstance, a faster and simpler way to access IDs and instances of modded classes.

Do I need to Update

No, all mods should still work, but if you wish to publish on v0.11.5, you will have to update.


If you previously used the generic Mod.XType<T>() methods, you'll need to change. mod.ItemType<ExampleBlock>() and this.ItemType<ExampleBlock>() are now simply ItemType<ExampleBlock>(), provided you write using static Terraria.ModLoader.ModContent; at the top of each .cs file. If you don't, it will be ModContent.ItemType<ExampleBlock>(). You'll need to keep the ModContent.XType approach for method calls located in your Mod class because there will be a namespace conflict otherwise. If you are still using the string versions, you do not need to update, but the new approach is faster, and the generic approach is less error prone. Examples

Regex Auto-Fix

You can migrate your whole mod easily with the following Find and Replace command in Visual Studio. Make sure Use Regular Expressions is enabled.

Find: (this|mod)\.(.*)Type<(.*)>\(\)
Replace: ModContent.$2Type<$3>()

If you'd prefer the using static Terraria.ModLoader.ModContent; approach, do the following Find and Replace commands instead. These also require that Use Regular Expressions is enabled. You'll need to fix the calls in your Mod class to use ModContent.XType<>() manually:

Find: using Terraria.ModLoader;
Replace: using Terraria.ModLoader;\nusing static Terraria.ModLoader.ModContent;
Find: mod\.(.*)Type<(.*)>\(\)
Replace: $1Type<$2>()

Mod.GetModX and Instance fields

Similar to above, generic Mod.GetModX<T>() methods such as GetModWorld are now no longer invoked from an instance of the Mod class. Replace mod.GetModWorld<ExampleWorld>(); with GetInstance<ExampleWorld>();, provided you write using static Terraria.ModLoader.ModContent; at the top of each .cs file. If you don't, it will be ModContent.GetInstance<ExampleWorld>(). Also, static instance variables are no longer recommended. Remove things like public static ExampleConfigServer Instance; and simply call GetInstance<ExampleConfigServer>() instead. Another example: ExampleMod.Instance -> GetInstance<ExampleMod>(). Examples


ModTile.RightClick is now ModTile.NewRightClick. NewRightClick returns a bool indicating if an interaction has occurred, preventing weapon usage. To migrate, replace public override void RightClick(int i, int j) with public override bool NewRightClick(int i, int j) and add return true; if an interaction has occurred. Examples

Iterating over Buffs

v0.11.5 adds Player.MaxBuffs. If you previously iterated over buffs using for (int n = 0; n < 22; n++), you'll want to update the code to for (int n = 0; n < Player.MaxBuffs; n++).


As always, your reflection might have broken, so double check that. Many internal classes and fields have changed namespaces and identifiers.

For example, here are the changes needed for reflection into the load mods progress bar.

//var type = assembly.GetType("Terraria.ModLoader.Interface");
//FieldInfo loadModsField = type.GetField("loadModsProgress", BindingFlags.Static | BindingFlags.NonPublic);
//Type UILoadModsProgressType = assembly.GetType("Terraria.ModLoader.UI.DownloadManager.UILoadModsProgress");

var type = assembly.GetType("Terraria.ModLoader.UI.Interface");
FieldInfo loadModsField = type.GetField("loadMods", BindingFlags.Static | BindingFlags.NonPublic);
Type UILoadModsProgressType = assembly.GetType("Terraria.ModLoader.UI.UILoadMods");


v0.11 introduced many changes. Here is the migration guide.


Here is the migration guide

Clone this wiki locally
You can’t perform that action at this time.