2using Microsoft.Xna.Framework.Audio;
 
    3using Microsoft.Xna.Framework.Graphics;
 
    6using System.Collections.Generic;
 
    8using System.Reflection;
 
   11using Terraria.Localization;
 
   13using Terraria.ModLoader.Core;
 
   17using Terraria.ModLoader.UI;
 
   24    public abstract partial class Mod 
   29        internal TmodFile File { 
get; 
set; }
 
   33        public Assembly 
Code { 
get; 
internal set; }
 
   37        public ILog 
Logger { 
get; 
internal set; }
 
   42        public virtual string Name => File.name;
 
   62        internal short netID = -1;
 
   71        public virtual void Load() {
 
  115            var skipCache = 
new HashSet<string>();
 
  116            foreach (var entry 
in File) {
 
  117                Interface.loadMods.SubProgressText = entry.Name;
 
  119                Stream _stream = 
null;
 
  120                Stream GetStream() => _stream = File.GetStream(entry);
 
  123                    skipCache.Add(entry.Name);
 
  127            File.CacheFiles(skipCache);
 
  138            if (File != 
null && File.IsOpen)
 
  139                throw new IOException($
"TModFile has open handles: {File.path}");
 
  149        public virtual bool LoadResource(
string path, 
int length, Func<Stream> getStream) {
 
  153            string extension = Path.GetExtension(path).ToLower();
 
  154            path = Path.ChangeExtension(path, 
null);
 
  159                        LoadTexture(path, getStream(), extension == 
".rawimg");
 
  165                    if (Main.dedServ || Main.waveBank == 
null) { }
 
  166                    else if (path.Contains(
"Music/"))
 
  167                        musics[path] = 
LoadMusic(path, extension);
 
  169                        sounds[path] = 
LoadSound(getStream(), length, extension);
 
  172                    if (Main.dedServ) { }
 
  173                    else if (path.StartsWith(
"Fonts/"))
 
  174                        fonts[path] = Main.instance.OurLoad<DynamicSpriteFont>(
"tmod:"+
Name+
"/"+path);
 
  175                    else if (path.StartsWith(
"Effects/"))
 
  176                        effects[path] = Main.ShaderContentManager.Load<Effect>(
"tmod:"+
Name+
"/"+path);
 
  178                        throw new ResourceLoadException(Language.GetTextValue(
"tModLoader.LoadErrorUnknownXNBFileHint", path));
 
  187            using (var stream = getStream()) {
 
  189                return stream.Position > 0;
 
  193        [Obsolete(
"Use LoadResource instead", 
true)]
 
  197        internal void AutoloadConfig()
 
  203            foreach (Type type 
in Code.GetTypes().OrderBy(type => type.FullName))
 
  209                if (type.IsSubclassOf(typeof(
ModConfig)))
 
  211                    var mc = (
ModConfig)Activator.CreateInstance(type);
 
  214                        throw new Exception($
"The ModConfig {mc.Name} can't be loaded because the config is ServerSide but this Mods ModSide isn't Both or Server");
 
  216                        throw new Exception($
"The ModConfig {mc.Name} can't be loaded because the config is ClientSide but this Mods ModSide is Server");
 
  218                    var name = type.Name;
 
  219                    if (mc.Autoload(ref name))
 
  242                throw new Exception(Language.GetTextValue(
"tModLoader.LoadErrorAddItemOnlyInLoad"));
 
  244            if (items.ContainsKey(name))
 
  245                throw new Exception(Language.GetTextValue(
"tModLoader.LoadError2ModItemSameName", name));
 
  249            item.DisplayName = GetOrCreateTranslation(
string.Format(
"Mods.{0}.ItemName.{1}", 
Name, name));
 
  250            item.Tooltip = GetOrCreateTranslation(
string.Format(
"Mods.{0}.ItemTooltip.{1}", 
Name, name), 
true);
 
  253            item.item.modItem = item;
 
  265        public ModItem GetItem(
string name) => items.TryGetValue(name, out var item) ? item : 
null;
 
  272        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  297                throw new Exception(
"AddGlobalItem can only be called from Mod.Load or Mod.Autoload");
 
  301            globalItem.mod = 
this;
 
  302            globalItem.Name = name;
 
  304            globalItems[name] = globalItem;
 
  305            globalItem.index = 
ItemLoader.globalItems.Count;
 
  307            if (
ItemLoader.globalIndexesByType.ContainsKey(globalItem.GetType())) {
 
  308                ItemLoader.globalIndexesByType[globalItem.GetType()] = -1;
 
  346            string armTexture = "", 
string femaleTexture = "") {
 
  364            string armTexture = 
"", 
string femaleTexture = 
"") {
 
  366                throw new Exception(
"AddEquipTexture can only be called from Mod.Load or Mod.Autoload");
 
  370            equipTexture.Texture = texture;
 
  371            equipTexture.mod = 
this;
 
  372            equipTexture.Name = name;
 
  373            equipTexture.Type = type;
 
  374            equipTexture.item = item;
 
  375            int slot = equipTexture.Slot = 
EquipLoader.ReserveEquipID(type);
 
  377            EquipLoader.equipTextures[type][slot] = equipTexture;
 
  378            equipTextures[Tuple.Create(name, type)] = equipTexture;
 
  382                    femaleTexture = texture;
 
  389                IDictionary<EquipType, int> slots;
 
  391                    EquipLoader.idToSlot[item.
item.type] = slots = 
new Dictionary<EquipType, int>();
 
  407            equipTextures.TryGetValue(Tuple.Create(name, type), out var texture) ? texture : 
null;
 
  433                throw new Exception(
"AddPrefix can only be called from Mod.Load or Mod.Autoload");
 
  435            if (prefixes.ContainsKey(name))
 
  436                throw new Exception(
"You tried to add 2 ModPrefixes with the same name: " + name + 
". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddPrefix with 2 prefixes of the same name.");
 
  440            prefix.DisplayName = GetOrCreateTranslation(
string.Format(
"Mods.{0}.Prefix.{1}", 
Name, name));
 
  441            prefix.Type = 
ModPrefix.ReservePrefixID();
 
  443            prefixes[name] = prefix;
 
  454        public ModPrefix GetPrefix(
string name) => prefixes.TryGetValue(name, out var prefix) ? prefix : 
null;
 
  461        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  487                throw new Exception(
"AddDust can only be called from Mod.Load or Mod.Autoload");
 
  491            dust.Type = 
ModDust.ReserveDustID();
 
  492            dust.Texture = !
string.IsNullOrEmpty(texture) ? 
ModContent.
GetTexture(texture) : Main.dustTexture;
 
  504        public ModDust GetDust(
string name) => dusts.TryGetValue(name, out var dust) ? dust : 
null;
 
  511        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  537                throw new Exception(
"AddItem can only be called from Mod.Load or Mod.Autoload");
 
  539            if (tiles.ContainsKey(name))
 
  540                throw new Exception(
"You tried to add 2 ModTile with the same name: " + name + 
". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddTile with 2 tiles of the same name.");
 
  544            tile.Type = (ushort)
TileLoader.ReserveTileID();
 
  545            tile.texture = texture;
 
  557        public ModTile GetTile(
string name) => tiles.TryGetValue(name, out var tile) ? tile : 
null;
 
  564        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  589                throw new Exception(
"AddGlobalTile can only be called from Mod.Load or Mod.Autoload");
 
  591            globalTile.mod = 
this;
 
  592            globalTile.Name = name;
 
  594            globalTiles[name] = globalTile;
 
  611        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  619                throw new Exception(
"AddTileEntity can only be called from Mod.Load or Mod.Autoload");
 
  625            entity.type = (byte)
id;
 
  627            tileEntities[name] = entity;
 
  638            tileEntities.TryGetValue(name, out var tileEntity) ? tileEntity : 
null;
 
  645        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  671                throw new Exception(
"AddWall can only be called from Mod.Load or Mod.Autoload");
 
  675            wall.Type = (ushort)
WallLoader.ReserveWallID();
 
  676            wall.texture = texture;
 
  688        public ModWall GetWall(
string name) => walls.TryGetValue(name, out var wall) ? wall : 
null;
 
  690        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  715                throw new Exception(
"AddGlobalWall can only be called from Mod.Load or Mod.Autoload");
 
  717            globalWall.mod = 
this;
 
  718            globalWall.Name = name;
 
  720            globalWalls[name] = globalWall;
 
  732        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  742                throw new Exception(
"AddProjectile can only be called from Mod.Load or Mod.Autoload");
 
  744            if (projectiles.ContainsKey(name))
 
  745                throw new Exception(
"You tried to add 2 ModProjectile with the same name: " + name + 
". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddProjectile with 2 projectiles of the same name.");
 
  747            projectile.mod = 
this;
 
  748            projectile.Name = name;
 
  750            projectile.DisplayName = GetOrCreateTranslation(
string.Format(
"Mods.{0}.ProjectileName.{1}", 
Name, name));
 
  752            projectiles[name] = projectile;
 
  764        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  789                throw new Exception(
"AddGlobalProjectile can only be called from Mod.Load or Mod.Autoload");
 
  793            globalProjectile.mod = 
this;
 
  794            globalProjectile.Name = name;
 
  796            globalProjectiles[name] = globalProjectile;
 
  799            if (
ProjectileLoader.globalIndexesByType.ContainsKey(globalProjectile.GetType())) {
 
  816        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  826                throw new Exception(
"AddNPC can only be called from Mod.Load or Mod.Autoload");
 
  828            if (npcs.ContainsKey(name))
 
  829                throw new Exception(
"You tried to add 2 ModNPC with the same name: " + name + 
". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddNPC with 2 npcs of the same name.");
 
  834            npc.DisplayName = GetOrCreateTranslation(
string.Format(
"Mods.{0}.NPCName.{1}", 
Name, name));
 
  846        public ModNPC GetNPC(
string name) => npcs.TryGetValue(name, out var npc) ? npc : 
null;
 
  848        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  873                throw new Exception(
"AddGlobalNPC can only be called from Mod.Load or Mod.Autoload");
 
  877            globalNPC.mod = 
this;
 
  878            globalNPC.Name = name;
 
  880            globalNPCs[name] = globalNPC;
 
  881            globalNPC.index = 
NPCLoader.globalNPCs.Count;
 
  883            if (
NPCLoader.globalIndexesByType.ContainsKey(globalNPC.GetType())) {
 
  884                NPCLoader.globalIndexesByType[globalNPC.GetType()] = -1;
 
  900        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  911                throw new Exception(
"AddNPCHeadTexture can only be called from Mod.Load or Mod.Autoload");
 
  933                throw new Exception(
"AddBossHeadTexture can only be called from Mod.Load or Mod.Autoload");
 
  950                throw new Exception(
"AddPlayer can only be called from Mod.Load or Mod.Autoload");
 
  955            players[name] = player;
 
  965        public ModPlayer GetPlayer(
string name) => players.TryGetValue(name, out var player) ? player : 
null;
 
  967        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
  978                throw new Exception(
"AddBuff can only be called from Mod.Load or Mod.Autoload");
 
  980            if (buffs.ContainsKey(name))
 
  981                throw new Exception(
"You tried to add 2 ModBuff with the same name: " + name + 
". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddBuff with 2 buffs of the same name.");
 
  986            buff.texture = texture;
 
  987            buff.DisplayName = GetOrCreateTranslation(
string.Format(
"Mods.{0}.BuffName.{1}", 
Name, name));
 
  988            buff.Description = GetOrCreateTranslation(
string.Format(
"Mods.{0}.BuffDescription.{1}", 
Name, name));
 
 1000        public ModBuff GetBuff(
string name) => buffs.TryGetValue(name, out var buff) ? buff : 
null;
 
 1002        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1026            globalBuff.mod = 
this;
 
 1027            globalBuff.Name = name;
 
 1029            globalBuffs[name] = globalBuff;
 
 1041        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1054                throw new Exception(
"AddMount can only be called from Mod.Load or Mod.Autoload");
 
 1056            if (Mount.mounts == 
null || Mount.mounts.Length == MountID.Count)
 
 1062            mount.texture = texture;
 
 1064            mountDatas[name] = mount;
 
 1068            if (extraTextures == 
null)
 
 1071            foreach (var entry 
in extraTextures) {
 
 1076                switch (entry.Key) {
 
 1078                        mount.mountData.backTexture = extraTexture;
 
 1081                        mount.mountData.backTextureGlow = extraTexture;
 
 1084                        mount.mountData.backTextureExtra = extraTexture;
 
 1087                        mount.mountData.backTextureExtraGlow = extraTexture;
 
 1090                        mount.mountData.frontTexture = extraTexture;
 
 1093                        mount.mountData.frontTextureGlow = extraTexture;
 
 1096                        mount.mountData.frontTextureExtra = extraTexture;
 
 1099                        mount.mountData.frontTextureExtraGlow = extraTexture;
 
 1110        public ModMountData GetMount(
string name) => mountDatas.TryGetValue(name, out var modMountData) ? modMountData : 
null;
 
 1112        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1137                throw new Exception(
"AddModWorld can only be called from Mod.Load or Mod.Autoload");
 
 1139            modWorld.mod = 
this;
 
 1140            modWorld.Name = name;
 
 1142            worlds[name] = modWorld;
 
 1159        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1169                throw new Exception(
"AddUgBgStyle can only be called from Mod.Load or Mod.Autoload");
 
 1171            ugBgStyle.mod = 
this;
 
 1172            ugBgStyle.Name = name;
 
 1175            ugBgStyles[name] = ugBgStyle;
 
 1187        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1197                throw new Exception(
"AddSurfaceBgStyle can only be called from Mod.Load or Mod.Autoload");
 
 1199            surfaceBgStyle.mod = 
this;
 
 1200            surfaceBgStyle.Name = name;
 
 1203            surfaceBgStyles[name] = surfaceBgStyle;
 
 1215        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1234                throw new Exception(
"AddGlobalBgStyle can only be called from Mod.Load or Mod.Autoload");
 
 1236            globalBgStyle.mod = 
this;
 
 1237            globalBgStyle.Name = name;
 
 1239            globalBgStyles[name] = globalBgStyle;
 
 1240            GlobalBgStyleLoader.globalBgStyles.Add(globalBgStyle);
 
 1251        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1263                throw new Exception(
"AddWaterStyle can only be called from Mod.Load or Mod.Autoload");
 
 1265            waterStyle.mod = 
this;
 
 1266            waterStyle.Name = name;
 
 1268            waterStyle.texture = texture;
 
 1269            waterStyle.blockTexture = blockTexture;
 
 1271            waterStyles[name] = waterStyle;
 
 1283        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1294                throw new Exception(
"AddWaterfallStyle can only be called from Mod.Load or Mod.Autoload");
 
 1296            waterfallStyle.mod = 
this;
 
 1297            waterfallStyle.Name = name;
 
 1299            waterfallStyle.texture = texture;
 
 1301            waterfallStyles[name] = waterfallStyle;
 
 1313        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1332                throw new Exception(
"AddGore can only be called from Mod.Load or Mod.Autoload");
 
 1334            int id = 
ModGore.ReserveGoreID();
 
 1336            if (modGore != 
null) {
 
 1337                ModGore.modGores[id] = modGore;
 
 1364                throw new Exception(
"AddSound can only be called from Mod.Load or Mod.Autoload");
 
 1367            if (modSound != 
null) {
 
 1395                throw new Exception(
"AddBackgroundTexture can only be called from Mod.Load or Mod.Autoload");
 
 1415                throw new Exception(
"AddGlobalRecipe can only be called from Mod.Load or Mod.Autoload");
 
 1417            globalRecipe.mod = 
this;
 
 1418            globalRecipe.Name = name;
 
 1420            globalRecipes[name] = globalRecipe;
 
 1432        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
 1440                throw new Exception(
"AddCommand can only be called from Mod.Load or Mod.Autoload");
 
 1475        public void AddMusicBox(
int musicSlot, 
int itemType, 
int tileType, 
int tileFrameY = 0) {
 
 1477                throw new Exception(
"AddMusicBox can only be called from Mod.Load or Mod.Autoload");
 
 1479            if (Main.waveBank == 
null)
 
 1482            if (musicSlot < Main.maxMusic) {
 
 1483                throw new ArgumentOutOfRangeException(
"Cannot assign music box to vanilla music ID " + musicSlot);
 
 1486                throw new ArgumentOutOfRangeException(
"Music ID " + musicSlot + 
" does not exist");
 
 1488            if (itemType < ItemID.Count) {
 
 1489                throw new ArgumentOutOfRangeException(
"Cannot assign music box to vanilla item ID " + itemType);
 
 1492                throw new ArgumentOutOfRangeException(
"Item ID " + itemType + 
" does not exist");
 
 1494            if (tileType < TileID.Count) {
 
 1495                throw new ArgumentOutOfRangeException(
"Cannot assign music box to vanilla tile ID " + tileType);
 
 1498                throw new ArgumentOutOfRangeException(
"Tile ID " + tileType + 
" does not exist");
 
 1500            if (
SoundLoader.musicToItem.ContainsKey(musicSlot)) {
 
 1501                throw new ArgumentException(
"Music ID " + musicSlot + 
" has already been assigned a music box");
 
 1503            if (
SoundLoader.itemToMusic.ContainsKey(itemType)) {
 
 1504                throw new ArgumentException(
"Item ID " + itemType + 
" has already been assigned a music");
 
 1506            if (!
SoundLoader.tileToMusic.ContainsKey(tileType)) {
 
 1507                SoundLoader.tileToMusic[tileType] = 
new Dictionary<int, int>();
 
 1509            if (
SoundLoader.tileToMusic[tileType].ContainsKey(tileFrameY)) {
 
 1510                string message = 
"Y-frame " + tileFrameY + 
" of tile type " + tileType + 
" has already been assigned a music";
 
 1511                throw new ArgumentException(message);
 
 1513            if (tileFrameY % 36 != 0) {
 
 1514                throw new ArgumentException(
"Y-frame must be divisible by 36");
 
 1518            SoundLoader.tileToMusic[tileType][tileFrameY] = musicSlot;
 
 1529                throw new Exception(
"RegisterHotKey can only be called from Mod.Load or Mod.Autoload");
 
 1531            return HotKeyLoader.RegisterHotKey(
new ModHotKey(
this, name, defaultKey));
 
 1545            translations[translation.
Key] = translation;
 
 1548        internal ModTranslation GetOrCreateTranslation(
string key, 
bool defaultEmpty = 
false) {
 
 1549            key = key.Replace(
" ", 
"_");
 
 1550            return translations.TryGetValue(key, out var translation) ? translation : 
new ModTranslation(key, defaultEmpty);
 
 1565        public Stream 
GetFileStream(
string name, 
bool newFileStream = 
false) => File?.GetStream(name, newFileStream);
 
 1572        public bool FileExists(
string name) => File != 
null && File.HasFile(name);
 
 1579            if (!textures.TryGetValue(name, out var t))
 
 1603                throw new Exception(
"Texture already exist: " + name);
 
 1605            textures[name] = texture;
 
 1615            if (!sounds.TryGetValue(name, out var sound))
 
 1635            if (!musics.TryGetValue(name, out var music))
 
 1653            if (!fonts.TryGetValue(name, out var font))
 
 1669            if (!effects.TryGetValue(name, out var effect))
 
 1683        public virtual object Call(params 
object[] args) {
 
 1695                throw new Exception(
"Cannot get packet for " + 
Name + 
" because it does not exist on the other side");
 
 1697            var p = 
new ModPacket(MessageID.ModPacket, capacity + 5);
 
 1699                p.Write((
byte)netID);
 
 1709            List<ModConfig> configs;
 
 1712                return configs.Single(x => x.Name == name);
 
 1717        [Obsolete(
"Use ModContent.GetInstance<T> instead", 
true)]
 
This is the class that keeps track of all modded background textures and their slots/IDs.
 
static int GetBackgroundSlot(string texture)
Returns the slot/ID of the background texture with the given name.
 
This serves as the central class from which buff-related functions are supported and carried out.
 
This serves as the central class from which ModCommand functions are supported and carried out.
 
ModConfig provides a way for mods to be configurable. ModConfigs can either be Client specific or Ser...
 
static void Register(object obj)
 
This serves as a central place to store equipment slots and their corresponding textures....
 
This serves as a place for you to program behaviors of equipment textures. This is useful for equipme...
 
int Slot
The slot (internal ID) of this equipment texture.
 
This class serves to collect functions that operate on any kind of background style,...
 
This class allows you to modify the behavior of any buff in the game.
 
This class allows you to modify and use hooks for all items, including vanilla items....
 
This class allows you to modify and use hooks for all NPCs, including vanilla mobs....
 
This class allows you to modify and use hooks for all projectiles, including vanilla projectiles....
 
This class provides hooks that control all recipes in the game.
 
This class allows you to modify the behavior of any tile in the game. Create an instance of an overri...
 
This class allows you to modify the behavior of any wall in the game (although admittedly walls don't...
 
This serves as the central class from which item-related functions are carried out....
 
static ModItem GetItem(int type)
Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the...
 
This class serves as a place for you to define a new buff and how that buff behaves.
 
This class represents a chat or console command. Use the CommandType to specify the scope of the comm...
 
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...
 
static bool TextureExists(string name)
Returns whether or not a texture with the specified name exists.
 
static SoundEffect GetSound(string name)
Gets the sound with the specified name. The name is in the same format as for texture names....
 
static Texture2D GetTexture(string name)
Gets the texture with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNa...
 
This class represents a type of dust that is added by a mod. Only one instance of this class will eve...
 
This class allows you to customize the behavior of a custom gore. Create a new instance of this and p...
 
static int GetGoreSlot(string texture)
Gets the type of the custom gore corresponding to the given texture. Returns 0 if the texture does no...
 
Represents a loaded hotkey. It is suggested to access the hotkey status only in ModPlayer....
 
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
 
void AddGlobalTile(string name, GlobalTile globalTile)
Adds the given GlobalTile instance to this mod with the provided name.
 
void AddGlobalItem(string name, GlobalItem globalItem)
Adds the given GlobalItem instance to this mod with the provided name.
 
T GetWaterfallStyle< T >()
 
virtual void PostSetupContent()
Allows you to load things in your mod after its content has been setup (arrays have been resized to f...
 
int GetSurfaceBgStyleSlot(string name)
Returns the Slot of the surface background style corresponding to the given name.
 
int BuffType(string name)
Gets the type of the ModBuff of this mod corresponding to the given name. Returns 0 if no ModBuff wit...
 
virtual bool LoadResource(string path, int length, Func< Stream > getStream)
Hook for pre-loading resources
 
void AddGore(string texture, ModGore modGore=null)
Adds the given texture to the game as a custom gore, with the given custom gore behavior....
 
T GetTileEntity< T >()
Same as the other GetTileEntity, but assumes that the class name and internal name are the same.
 
ILog Logger
A logger with this mod's name for easy logging.
 
void AddGlobalBgStyle(string name, GlobalBgStyle globalBgStyle)
Adds the given global background style with the given name to this mod.
 
ModWall GetWall(string name)
Gets the ModWall of this mod corresponding to the given name. Returns null if no ModWall with the giv...
 
virtual object Call(params object[] args)
Used for weak inter-mod communication. This allows you to interact with other mods without having to ...
 
void AddNPCHeadTexture(int npcType, string texture)
Assigns a head texture to the given town NPC type.
 
int MountType(string name)
Gets the ID of the ModMountData instance corresponding to the given name. Returns 0 if no ModMountDat...
 
void AddPlayer(string name, ModPlayer player)
Adds a type of ModPlayer to this mod. All ModPlayer types will be newly created and attached to each ...
 
T GetGlobalTile< T >()
Same as the other GetGlobalTile, but assumes that the class name and internal name are the same.
 
ModWaterfallStyle GetWaterfallStyle(string name)
Returns the waterfall style with the given name from this mod.
 
virtual Version Version
This version number of this mod.
 
int GetBackgroundSlot(string name)
Gets the texture slot corresponding to the specified texture name. Shorthand for calling BackgroundTe...
 
T GetPrefix< T >()
Same as the other GetPrefix, but assumes that the class name and internal name are the same.
 
void AddMusicBox(int musicSlot, int itemType, int tileType, int tileFrameY=0)
Allows you to tie a music ID, and item ID, and a tile ID together to form a music box....
 
void AddGlobalWall(string name, GlobalWall globalWall)
Adds the given GlobalWall instance to this mod with the provided name.
 
bool SoundExists(string name)
Shorthand for calling ModLoader.SoundExists(this.FileName(name)).
 
ModPrefix GetPrefix(string name)
Gets the ModPrefix instance corresponding to the name. Because this method is in the Mod class,...
 
void AddDust(string name, ModDust dust, string texture="")
Adds a type of dust to your mod with the specified name. Create an instance of ModDust normally,...
 
string DisplayName
The display name of this mod in the Mods menu.
 
SoundEffect GetSound(string name)
Shorthand for calling ModContent.GetSound(this.FileName(name)).
 
void AddNPC(string name, ModNPC npc)
Adds a type of NPC to the game with the specified name and texture. Also allows you to give the NPC a...
 
void AddWaterfallStyle(string name, ModWaterfallStyle waterfallStyle, string texture)
Adds the given waterfall style to the game with the given name and texture path.
 
int GetGoreSlot< T >()
Same as the other GetGoreSlot, but assumes that the class name and internal name are the same.
 
void AddBossHeadTexture(string texture, int npcType=-1)
Assigns a head texture that can be used by NPCs on the map.
 
byte PrefixType(string name)
Gets the internal ID / type of the ModPrefix corresponding to the name. Returns 0 if no ModPrefix wit...
 
GlobalBgStyle GetGlobalBgStyle(string name)
Returns the global background style corresponding to the given name.
 
T GetGlobalProjectile< T >()
 
ModWorld GetModWorld(string name)
Gets the ModWorld instance with the given name from this mod.
 
Version tModLoaderVersion
The version of tModLoader that was being used when this mod was built.
 
int AddEquipTexture(ModItem item, EquipType type, string name, string texture, string armTexture="", string femaleTexture="")
Adds an equipment texture of the specified type, internal name, and associated item to your mod....
 
Music GetMusic(string name)
Shorthand for calling ModContent.GetMusic(this.FileName(name)).
 
DynamicSpriteFont GetFont(string name)
Gets a SpriteFont loaded from the specified path.
 
void AddBuff(string name, ModBuff buff, string texture)
Adds a type of buff to the game with the specified internal name and texture.
 
T GetGlobalItem< T >()
Same as the other GetGlobalItem, but assumes that the class name and internal name are the same.
 
int TileEntityType(string name)
Gets the type of the ModTileEntity of this mod with the given name. Returns -1 if no ModTileEntity wi...
 
void AddPrefix(string name, ModPrefix prefix)
Adds a prefix to your mod with the specified internal name. This method should be called in Load....
 
int GetGoreSlot(string name)
Shorthand for calling ModGore.GetGoreSlot(this.Name + '/' + name).
 
ModProjectile GetProjectile(string name)
Gets the ModProjectile of this mod corresponding to the given name. Returns null if no ModProjectile ...
 
GlobalItem GetGlobalItem(string name)
Gets the GlobalItem instance with the given name from this mod.
 
ModBuff GetBuff(string name)
Gets the ModBuff of this mod corresponding to the given name. Returns null if no ModBuff with the giv...
 
void AddCommand(string name, ModCommand mc)
Manually add a Command during Load
 
EquipTexture GetEquipTexture(string name, EquipType type)
Gets the EquipTexture instance corresponding to the name and EquipType. Returns null if no EquipTextu...
 
int TileType(string name)
Gets the type of the ModTile of this mod with the given name. Returns 0 if no ModTile with the given ...
 
T GetModWorld< T >()
Same as the other GetModWorld, but assumes that the class name and internal name are the same.
 
virtual void LoadResourceFromStream(string path, int len, BinaryReader reader)
 
GlobalProjectile GetGlobalProjectile(string name)
Gets the GlobalProjectile instance with the given name from this mod.
 
virtual void AddRecipeGroups()
Override this method to add recipe groups to this mod. You must add recipe groups by calling the Reci...
 
int AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, string name, string texture, string armTexture="", string femaleTexture="")
Adds an equipment texture of the specified type, internal name, and associated item to your mod....
 
ModTranslation CreateTranslation(string key)
Creates a ModTranslation object that you can use in AddTranslation.
 
byte[] GetFileBytes(string name)
Retrieve contents of files within the tmod file
 
void AddSound(SoundType type, string soundPath, ModSound modSound=null)
Adds the given sound file to the game as the given type of sound and with the given custom sound play...
 
void AddBackgroundTexture(string texture)
Adds a texture to the list of background textures and assigns it a background texture slot.
 
ModWaterStyle GetWaterStyle(string name)
Returns the water style with the given name from this mod.
 
virtual void LoadResources()
 
ModDust GetDust(string name)
Gets the ModDust of this mod corresponding to the given name. Returns null if no ModDust with the giv...
 
void AddTranslation(ModTranslation translation)
Adds a ModTranslation to the game so that you can use Language.GetText to get a LocalizedText.
 
void LoadTexture(string path, Stream stream, bool rawimg)
 
int ItemType(string name)
Gets the internal ID / type of the ModItem corresponding to the name. Returns 0 if no ModItem with th...
 
void AddTexture(string name, Texture2D texture)
Shorthand for calling ModLoader.AddTexture(this.FileName(name), texture).
 
T GetSurfaceBgStyle< T >()
 
T GetDust< T >()
Same as the other GetDust, but assumes that the class name and internal name are the same.
 
bool EffectExists(string name)
Used to check if a custom Effect exists
 
void AddTile(string name, ModTile tile, string texture)
Adds a type of tile to the game with the specified name and texture.
 
ModItem GetItem(string name)
Gets the ModItem instance corresponding to the name. Because this method is in the Mod class,...
 
bool TextureExists(string name)
Shorthand for calling ModLoader.TextureExists(this.FileName(name)).
 
ModMountData GetMount(string name)
Gets the ModMountData instance of this mod corresponding to the given name. Returns null if no ModMou...
 
void AddGlobalNPC(string name, GlobalNPC globalNPC)
Adds the given GlobalNPC instance to this mod with the provided name.
 
virtual string Name
Stores the name of the mod. This name serves as the mod's identification, and also helps with saving ...
 
void AddGlobalBuff(string name, GlobalBuff globalBuff)
Adds the given GlobalBuff instance to this mod using the provided name.
 
GlobalNPC GetGlobalNPC(string name)
Gets the GlobalNPC instance with the given name from this mod.
 
void AddWall(string name, ModWall wall, string texture)
Adds a type of wall to the game with the specified name and texture.
 
int DustType(string name)
Gets the type of the ModDust of this mod with the given name. Returns 0 if no ModDust with the given ...
 
T GetItem< T >()
Same as the other GetItem, but assumes that the class name and internal name are the same.
 
T GetGlobalBgStyle< T >()
 
void AddUgBgStyle(string name, ModUgBgStyle ugBgStyle)
Adds the given underground background style with the given name to this mod.
 
ModUgBgStyle GetUgBgStyle(string name)
Returns the underground background style corresponding to the given name.
 
void AddMount(string name, ModMountData mount, string texture, IDictionary< MountTextureType, string > extraTextures=null)
Adds the given mount to the game with the given name and texture. The extraTextures dictionary should...
 
void AddProjectile(string name, ModProjectile projectile)
Adds a type of projectile to the game with the specified name.
 
sbyte GetAccessorySlot(string name, EquipType type)
Same as GetEquipSlot, except returns the number as an sbyte (signed byte) for your convenience.
 
virtual void PostAddRecipes()
This provides a hook into the mod-loading process immediately after recipes have been added....
 
ModTile GetTile(string name)
Gets the ModTile of this mod corresponding to the given name. Returns null if no ModTile with the giv...
 
ModNPC GetNPC(string name)
Gets the ModNPC of this mod corresponding to the given name. Returns null if no ModNPC with the given...
 
ModConfig GetConfig(string name)
 
void AddModWorld(string name, ModWorld modWorld)
Adds a ModWorld to this mod with the given name.
 
ModPlayer GetPlayer(string name)
Gets the ModPlayer of this mod corresponding to the given name. Returns null if no ModPlayer with the...
 
Music LoadMusic(string path, string extension)
 
GlobalBuff GetGlobalBuff(string name)
Gets the GlobalBuff with the given name from this mod.
 
ModSurfaceBgStyle GetSurfaceBgStyle(string name)
Returns the surface background style corresponding to the given name.
 
virtual void Close()
Close is called before Unload, and may be called at any time when mod unloading is imminent (such as ...
 
GlobalRecipe GetGlobalRecipe(string name)
Gets the global recipe corresponding to the specified name.
 
bool FileExists(string name)
Shorthand for calling ModLoader.FileExists(this.FileName(name)). Note that file extensions are used h...
 
void AddTileEntity(string name, ModTileEntity entity)
Manually add a tile entity during Load.
 
int GetSoundSlot(SoundType type, string name)
Shorthand for calling SoundLoader.GetSoundSlot(type, this.Name + '/' + name).
 
SoundEffect LoadSound(Stream stream, int length, string extension)
 
void AddGlobalProjectile(string name, GlobalProjectile globalProjectile)
Adds the given GlobalProjectile instance to this mod with the provided name.
 
void AddGlobalRecipe(string name, GlobalRecipe globalRecipe)
Manually add a Global Recipe during Load
 
void AddConfig(string name, ModConfig mc)
 
void AddWaterStyle(string name, ModWaterStyle waterStyle, string texture, string blockTexture)
Adds the given water style to the game with the given name, texture path, and block texture path.
 
ModSide Side
The ModSide that controls how this mod is synced between client and server.
 
void AddItem(string name, ModItem item)
Adds a type of item to your mod with the specified internal name. This method should be called in Loa...
 
virtual void AddRecipes()
Override this method to add recipes to the game. It is recommended that you do so through instances o...
 
bool FontExists(string name)
Used to check if a custom SpriteFont exists
 
ModHotKey RegisterHotKey(string name, string defaultKey)
Registers a hotkey with a name and defaultKey. Use the returned ModHotKey to detect when buttons are ...
 
bool LoadResourceLegacy(string path, int length, Func< Stream > getStream)
 
Stream GetFileStream(string name, bool newFileStream=false)
Retrieve contents of files within the tmod file
 
Assembly Code
The assembly code this is loaded when tModLoader loads this mod.
 
Effect GetEffect(string name)
Gets an Effect loaded from the specified path.
 
void AddSurfaceBgStyle(string name, ModSurfaceBgStyle surfaceBgStyle)
Adds the given surface background style with the given name to this mod.
 
GlobalWall GetGlobalWall(string name)
Gets the GlobalWall instance with the given name from this mod.
 
LegacySoundStyle GetLegacySoundSlot(SoundType type, string name)
Shorthand for calling SoundLoader.GetLegacySoundSlot(type, this.Name + '/' + name).
 
Texture2D GetTexture(string name)
Shorthand for calling ModContent.GetTexture(this.FileName(name)).
 
int WallType(string name)
Gets the type of the ModWall of this mod with the given name. Returns 0 if no ModWall with the given ...
 
int ProjectileType(string name)
Gets the type of the ModProjectile of this mod with the given name. Returns 0 if no ModProjectile wit...
 
T GetTile< T >()
Same as the other GetTile, but assumes that the class name and internal name are the same.
 
int NPCType(string name)
Gets the type of the ModNPC of this mod with the given name. Returns 0 if no ModNPC with the given na...
 
ModTileEntity GetTileEntity(string name)
Gets the ModTileEntity of this mod corresponding to the given name. Returns null if no ModTileEntity ...
 
virtual void Unload()
This is called whenever this mod is unloaded from the game. Use it to undo changes that you've made i...
 
bool MusicExists(string name)
Shorthand for calling ModLoader.MusicExists(this.FileName(name)).
 
GlobalTile GetGlobalTile(string name)
Gets the GlobalTile instance with the given name from this mod.
 
virtual void Load()
Override this method to add most of your content to your mod. Here you will call other methods such a...
 
ModPacket GetPacket(int capacity=256)
Creates a ModPacket object that you can write to and then send between servers and clients.
 
int GetWaterfallStyleSlot(string name)
Returns the waterfall style corresponding to the given name.
 
virtual uint ExtraPlayerBuffSlots
The amount of extra buff slots this mod desires for Players. This value is checked after Mod....
 
int GetEquipSlot(string name, EquipType type)
Gets the slot/ID of the equipment texture corresponding to the given name. Returns -1 if no EquipText...
 
This class serves as a place for you to place all your properties and hooks for each item....
 
Item item
The item object that this ModItem controls.
 
This class serves as a place for you to place all your properties and hooks for each mount....
 
This class serves as a place for you to place all your properties and hooks for each NPC....
 
This class inherits from BinaryWriter. This means that you can use all of its writing functions to se...
 
A ModPlayer instance represents an extension of a Player instance. You can store fields in the ModPla...
 
virtual PrefixCategory Category
The category your prefix belongs to, PrefixCategory.Custom by default
 
This class serves as a place for you to place all your properties and hooks for each projectile....
 
This class allows you to customize how a sound you add is played. To use this, pass an instance to Mo...
 
Each background style determines in its own way how exactly the background is drawn....
 
Tile Entities are Entities tightly coupled with tiles, allowing the possibility of tiles to exhibit c...
 
This class represents a type of tile that can be added by a mod. Only one instance of this class will...
 
Each background style determines in its own way how exactly the background is drawn....
 
This class represents a type of wall that can be added by a mod. Only one instance of this class will...
 
Represents a style of water that gets drawn, based on factors such as the background....
 
Represents a style of waterfalls that gets drawn. This is mostly used to determine the color of the w...
 
A ModWorld instance represents an extension of a World. You can store fields in the ModWorld classes ...
 
This serves as the central place from which mounts are stored and mount-related functions are carried...
 
This class serves as a central place from which NPC head slots are stored and NPC head textures are a...
 
This serves as the central class from which NPC-related functions are carried out....
 
This is where all ModPlayer hooks are gathered and called.
 
This serves as the central class from which projectile-related functions are carried out....
 
This is where all ModRecipe and GlobalRecipe hooks are gathered and called.
 
This class is used to keep track of and support the existence of custom sounds that have been added t...
 
static int GetSoundSlot(SoundType type, string sound)
Returns the style (last parameter passed to Main.PlaySound) of the sound corresponding to the given S...
 
static int SoundCount(SoundType type)
 
This serves as the central class from which tile-related functions are supported and carried out.
 
static ModTile GetTile(int type)
Gets the ModTile instance with the given type. If no ModTile with the given type exists,...
 
This serves as the central class from which ModUgBgStyle functions are supported and carried out.
 
This serves as the central class from which wall-related functions are supported and carried out.
 
This serves as the central class from which WaterStyle functions are supported and carried out.
 
This is where all ModWorld hooks are gathered and called.
 
ConfigScope
Each ModConfig class has a different scope. Failure to use the correct mode will lead to bugs.
 
ModSide
A ModSide enum defines how mods are synced between clients and servers. You can set your mod's ModSid...
 
MountTextureType
This is an enum of all possible types of extra mount textures for custom mounts. Use these as keys in...
 
SoundType
This is an enum of the types of sound you can add to the game. This is used for determining whether a...
 
EquipType
This is an enum of all the types of equipment that exist. An equipment type is defined as a type or l...
 
This is a struct that stores the properties of a mod. Without setting it in your Mod constructor,...
 
static ModProperties AutoLoadAll
Automatically return a ModProperties object which has all AutoLoad values set to true.