tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.Mod Class Reference

Mod is an abstract class that you will override. It serves as a central place from which the mod's contents are stored. It provides methods for you to use or override. More...

+ Collaboration diagram for Terraria.ModLoader.Mod:

Public Member Functions

void AddBackgroundTexture (string texture)
 Adds a texture to the list of background textures and assigns it a background texture slot. More...
 
void AddBossHeadTexture (string texture, int npcType=-1)
 Assigns a head texture that can be used by NPCs on the map. More...
 
void AddBuff (string name, ModBuff buff, string texture)
 Adds a type of buff to the game with the specified internal name and texture. More...
 
void AddCommand (string name, ModCommand mc)
 Manually add a Command during Load More...
 
void AddConfig (string name, ModConfig mc)
 
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, preferably through the constructor of an overriding class. Leave the texture as an empty string to use the vanilla dust sprite sheet. More...
 
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. This method is different from the other AddEquipTexture in that you can specify the class of the equipment texture, thus allowing you to override EquipmentTexture's hooks. All other parameters are the same as the other AddEquipTexture. More...
 
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. (The item parameter may be null if you don't want to associate an item with the texture.) You can then get the ID for your texture by calling EquipLoader.GetEquipTexture, and using the EquipTexture's Slot property. If the EquipType is EquipType.Body, make sure that you also provide an armTexture and a femaleTexture. Returns the ID / slot that is assigned to the equipment texture. More...
 
void AddGlobalBgStyle (string name, GlobalBgStyle globalBgStyle)
 Adds the given global background style with the given name to this mod. More...
 
void AddGlobalBuff (string name, GlobalBuff globalBuff)
 Adds the given GlobalBuff instance to this mod using the provided name. More...
 
void AddGlobalItem (string name, GlobalItem globalItem)
 Adds the given GlobalItem instance to this mod with the provided name. More...
 
void AddGlobalNPC (string name, GlobalNPC globalNPC)
 Adds the given GlobalNPC instance to this mod with the provided name. More...
 
void AddGlobalProjectile (string name, GlobalProjectile globalProjectile)
 Adds the given GlobalProjectile instance to this mod with the provided name. More...
 
void AddGlobalRecipe (string name, GlobalRecipe globalRecipe)
 Manually add a Global Recipe during Load More...
 
void AddGlobalTile (string name, GlobalTile globalTile)
 Adds the given GlobalTile instance to this mod with the provided name. More...
 
void AddGlobalWall (string name, GlobalWall globalWall)
 Adds the given GlobalWall instance to this mod with the provided name. More...
 
void AddGore (string texture, ModGore modGore=null)
 Adds the given texture to the game as a custom gore, with the given custom gore behavior. If no custom gore behavior is provided, the custom gore will have the default vanilla behavior. More...
 
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 Load. You can obtain an instance of ModItem by overriding it then creating an instance of the subclass. More...
 
void AddModWorld (string name, ModWorld modWorld)
 Adds a ModWorld to this mod with the given name. More...
 
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 optionally map types of mount textures to the texture paths you want to include. More...
 
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. When music with the given ID is playing, equipped music boxes have a chance to change their ID to the given item type. When an item with the given item type is equipped, it will play the music that has musicSlot as its ID. When a tile with the given type and Y-frame is nearby, if its X-frame is >= 36, it will play the music that has musicSlot as its ID. More...
 
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 alternate textures. More...
 
void AddNPCHeadTexture (int npcType, string texture)
 Assigns a head texture to the given town NPC type. More...
 
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 player that is loaded. More...
 
void AddPrefix (string name, ModPrefix prefix)
 Adds a prefix to your mod with the specified internal name. This method should be called in Load. You can obtain an instance of ModPrefix by overriding it then creating an instance of the subclass. More...
 
void AddProjectile (string name, ModProjectile projectile)
 Adds a type of projectile to the game with the specified name. More...
 
virtual void AddRecipeGroups ()
 Override this method to add recipe groups to this mod. You must add recipe groups by calling the RecipeGroup.RegisterGroup method here. A recipe group is a set of items that can be used interchangeably in the same recipe. More...
 
virtual void AddRecipes ()
 Override this method to add recipes to the game. It is recommended that you do so through instances of ModRecipe, since it provides methods that simplify recipe creation. More...
 
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 playing. If no ModSound instance is provided, the custom sound will play in a similar manner as the default vanilla ones. More...
 
void AddSurfaceBgStyle (string name, ModSurfaceBgStyle surfaceBgStyle)
 Adds the given surface background style with the given name to this mod. More...
 
void AddTexture (string name, Texture2D texture)
 Shorthand for calling ModLoader.AddTexture(this.FileName(name), texture). More...
 
void AddTile (string name, ModTile tile, string texture)
 Adds a type of tile to the game with the specified name and texture. More...
 
void AddTileEntity (string name, ModTileEntity entity)
 Manually add a tile entity during Load. More...
 
void AddTranslation (ModTranslation translation)
 Adds a ModTranslation to the game so that you can use Language.GetText to get a LocalizedText. More...
 
void AddUgBgStyle (string name, ModUgBgStyle ugBgStyle)
 Adds the given underground background style with the given name to this mod. More...
 
void AddWall (string name, ModWall wall, string texture)
 Adds a type of wall to the game with the specified name and texture. More...
 
void AddWaterfallStyle (string name, ModWaterfallStyle waterfallStyle, string texture)
 Adds the given waterfall style to the game with the given name and texture path. More...
 
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. More...
 
int BuffType (string name)
 Gets the type of the ModBuff of this mod corresponding to the given name. Returns 0 if no ModBuff with the given name is found. More...
 
int BuffType< T > ()
 Same as the other BuffType, but assumes that the class name and internal name are the same. More...
 
virtual object Call (params object[] args)
 Used for weak inter-mod communication. This allows you to interact with other mods without having to reference their types or namespaces, provided that they have implemented this method. More...
 
virtual void Close ()
 Close is called before Unload, and may be called at any time when mod unloading is imminent (such as when downloading an update, or recompiling) Use this to release any additional file handles, or stop streaming music. Make sure to call base.Close() at the end May be called multiple times before Unload More...
 
ModTranslation CreateTranslation (string key)
 Creates a ModTranslation object that you can use in AddTranslation. More...
 
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 name is found. More...
 
int DustType< T > ()
 Same as the other DustType, but assumes that the class name and internal name are the same. More...
 
bool EffectExists (string name)
 Used to check if a custom Effect exists More...
 
bool FileExists (string name)
 Shorthand for calling ModLoader.FileExists(this.FileName(name)). Note that file extensions are used here. More...
 
bool FontExists (string name)
 Used to check if a custom SpriteFont exists More...
 
sbyte GetAccessorySlot (string name, EquipType type)
 Same as GetEquipSlot, except returns the number as an sbyte (signed byte) for your convenience. More...
 
int GetBackgroundSlot (string name)
 Gets the texture slot corresponding to the specified texture name. Shorthand for calling BackgroundTextureLoader.GetBackgroundSlot(this.Name + '/' + name). More...
 
ModBuff GetBuff (string name)
 Gets the ModBuff of this mod corresponding to the given name. Returns null if no ModBuff with the given name is found. More...
 
GetBuff< T > ()
 
ModConfig GetConfig (string name)
 
GetConfig< T > ()
 
ModDust GetDust (string name)
 Gets the ModDust of this mod corresponding to the given name. Returns null if no ModDust with the given name is found. More...
 
GetDust< T > ()
 Same as the other GetDust, but assumes that the class name and internal name are the same. More...
 
Effect GetEffect (string name)
 Gets an Effect loaded from the specified path. More...
 
int GetEquipSlot (string name, EquipType type)
 Gets the slot/ID of the equipment texture corresponding to the given name. Returns -1 if no EquipTexture with the given name is found. More...
 
EquipTexture GetEquipTexture (string name, EquipType type)
 Gets the EquipTexture instance corresponding to the name and EquipType. Returns null if no EquipTexture with the given name and EquipType is found. More...
 
byte[] GetFileBytes (string name)
 Retrieve contents of files within the tmod file More...
 
Stream GetFileStream (string name, bool newFileStream=false)
 Retrieve contents of files within the tmod file More...
 
DynamicSpriteFont GetFont (string name)
 Gets a SpriteFont loaded from the specified path. More...
 
GlobalBgStyle GetGlobalBgStyle (string name)
 Returns the global background style corresponding to the given name. More...
 
GetGlobalBgStyle< T > ()
 
GlobalBuff GetGlobalBuff (string name)
 Gets the GlobalBuff with the given name from this mod. More...
 
GetGlobalBuff< T > ()
 
GlobalItem GetGlobalItem (string name)
 Gets the GlobalItem instance with the given name from this mod. More...
 
GetGlobalItem< T > ()
 Same as the other GetGlobalItem, but assumes that the class name and internal name are the same. More...
 
GlobalNPC GetGlobalNPC (string name)
 Gets the GlobalNPC instance with the given name from this mod. More...
 
GetGlobalNPC< T > ()
 
GlobalProjectile GetGlobalProjectile (string name)
 Gets the GlobalProjectile instance with the given name from this mod. More...
 
GetGlobalProjectile< T > ()
 
GlobalRecipe GetGlobalRecipe (string name)
 Gets the global recipe corresponding to the specified name. More...
 
GetGlobalRecipe< T > ()
 
GlobalTile GetGlobalTile (string name)
 Gets the GlobalTile instance with the given name from this mod. More...
 
GetGlobalTile< T > ()
 Same as the other GetGlobalTile, but assumes that the class name and internal name are the same. More...
 
GlobalWall GetGlobalWall (string name)
 Gets the GlobalWall instance with the given name from this mod. More...
 
GetGlobalWall< T > ()
 
int GetGoreSlot (string name)
 Shorthand for calling ModGore.GetGoreSlot(this.Name + '/' + name). More...
 
int GetGoreSlot< T > ()
 Same as the other GetGoreSlot, but assumes that the class name and internal name are the same. More...
 
ModItem GetItem (string name)
 Gets the ModItem instance corresponding to the name. Because this method is in the Mod class, conflicts between mods are avoided. Returns null if no ModItem with the given name is found. More...
 
GetItem< T > ()
 Same as the other GetItem, but assumes that the class name and internal name are the same. More...
 
LegacySoundStyle GetLegacySoundSlot (SoundType type, string name)
 Shorthand for calling SoundLoader.GetLegacySoundSlot(type, this.Name + '/' + name). More...
 
ModWorld GetModWorld (string name)
 Gets the ModWorld instance with the given name from this mod. More...
 
GetModWorld< T > ()
 Same as the other GetModWorld, but assumes that the class name and internal name are the same. More...
 
ModMountData GetMount (string name)
 Gets the ModMountData instance of this mod corresponding to the given name. Returns null if no ModMountData has the given name. More...
 
GetMount< T > ()
 
Music GetMusic (string name)
 Shorthand for calling ModContent.GetMusic(this.FileName(name)). More...
 
ModNPC GetNPC (string name)
 Gets the ModNPC of this mod corresponding to the given name. Returns null if no ModNPC with the given name is found. More...
 
GetNPC< T > ()
 
ModPacket GetPacket (int capacity=256)
 Creates a ModPacket object that you can write to and then send between servers and clients. More...
 
ModPlayer GetPlayer (string name)
 Gets the ModPlayer of this mod corresponding to the given name. Returns null if no ModPlayer with the given name is found. More...
 
GetPlayer< T > ()
 
ModPrefix GetPrefix (string name)
 Gets the ModPrefix instance corresponding to the name. Because this method is in the Mod class, conflicts between mods are avoided. Returns null if no ModPrefix with the given name is found. More...
 
GetPrefix< T > ()
 Same as the other GetPrefix, but assumes that the class name and internal name are the same. More...
 
ModProjectile GetProjectile (string name)
 Gets the ModProjectile of this mod corresponding to the given name. Returns null if no ModProjectile with the given name is found. More...
 
GetProjectile< T > ()
 
SoundEffect GetSound (string name)
 Shorthand for calling ModContent.GetSound(this.FileName(name)). More...
 
int GetSoundSlot (SoundType type, string name)
 Shorthand for calling SoundLoader.GetSoundSlot(type, this.Name + '/' + name). More...
 
ModSurfaceBgStyle GetSurfaceBgStyle (string name)
 Returns the surface background style corresponding to the given name. More...
 
GetSurfaceBgStyle< T > ()
 
int GetSurfaceBgStyleSlot (string name)
 Returns the Slot of the surface background style corresponding to the given name. More...
 
int GetSurfaceBgStyleSlot< T > ()
 
Texture2D GetTexture (string name)
 Shorthand for calling ModContent.GetTexture(this.FileName(name)). More...
 
ModTile GetTile (string name)
 Gets the ModTile of this mod corresponding to the given name. Returns null if no ModTile with the given name is found. More...
 
GetTile< T > ()
 Same as the other GetTile, but assumes that the class name and internal name are the same. More...
 
ModTileEntity GetTileEntity (string name)
 Gets the ModTileEntity of this mod corresponding to the given name. Returns null if no ModTileEntity with the given name is found. More...
 
GetTileEntity< T > ()
 Same as the other GetTileEntity, but assumes that the class name and internal name are the same. More...
 
ModUgBgStyle GetUgBgStyle (string name)
 Returns the underground background style corresponding to the given name. More...
 
GetUgBgStyle< T > ()
 
ModWall GetWall (string name)
 Gets the ModWall of this mod corresponding to the given name. Returns null if no ModWall with the given name is found. More...
 
GetWall< T > ()
 
ModWaterfallStyle GetWaterfallStyle (string name)
 Returns the waterfall style with the given name from this mod. More...
 
GetWaterfallStyle< T > ()
 
int GetWaterfallStyleSlot (string name)
 Returns the waterfall style corresponding to the given name. More...
 
int GetWaterfallStyleSlot< T > ()
 
ModWaterStyle GetWaterStyle (string name)
 Returns the water style with the given name from this mod. More...
 
GetWaterStyle< T > ()
 
virtual void HandlePacket (BinaryReader reader, int whoAmI)
 Called whenever a net message / packet is received from a client (if this is a server) or the server (if this is a client). whoAmI is the ID of whomever sent the packet (equivalent to the Main.myPlayer of the sender), and reader is used to read the binary data of the packet. More...
 
virtual bool HijackGetData (ref byte messageType, ref BinaryReader reader, int playerNumber)
 Allows you to modify net message / packet information that is received before the game can act on it. More...
 
virtual bool HijackSendData (int whoAmI, int msgType, int remoteClient, int ignoreClient, NetworkText text, int number, float number2, float number3, float number4, int number5, int number6, int number7)
 Hijacks the send data method. Only use if you absolutely know what you are doing. If any hooks return true, the message is not sent. More...
 
virtual void HotKeyPressed (string name)
 Called when a hotkey is pressed. Check against the name to verify particular hotkey that was pressed. (Using the ModHotKey is more recommended.) More...
 
int ItemType (string name)
 Gets the internal ID / type of the ModItem corresponding to the name. Returns 0 if no ModItem with the given name is found. More...
 
int ItemType< T > ()
 Same as the other ItemType, but assumes that the class name and internal name are the same. More...
 
virtual void Load ()
 Override this method to add most of your content to your mod. Here you will call other methods such as AddItem. This is guaranteed to be called after all content has been autoloaded. More...
 
virtual bool LoadResource (string path, int length, Func< Stream > getStream)
 Hook for pre-loading resources More...
 
virtual void LoadResourceFromStream (string path, int len, BinaryReader reader)
 
virtual void LoadResources ()
 
virtual void MidUpdateDustTime ()
 Called after Dust got updated, but before Time (day/night, events, etc.) gets updated. More...
 
virtual void MidUpdateGoreProjectile ()
 Called after Gores got updated, but before any Projectiles get updated. More...
 
virtual void MidUpdateInvasionNet ()
 Called after Invasions got updated. The only thing that is updated after this is the Network. More...
 
virtual void MidUpdateItemDust ()
 Called after Items got updated, but before any Dust gets updated. More...
 
virtual void MidUpdateNPCGore ()
 Called after NPCs got updated, but before any Gores get updated. More...
 
virtual void MidUpdatePlayerNPC ()
 Called after Players got updated, but before any NPCs get updated. More...
 
virtual void MidUpdateProjectileItem ()
 Gets called immediately after all Projectiles are updated, but before any Items get updated. More...
 
virtual void MidUpdateTimeWorld ()
 Called after Time got updated, but before the World gets updated. More...
 
virtual void ModifyInterfaceLayers (List< GameInterfaceLayer > layers)
 Allows you to modify the elements of the in-game interface that get drawn. GameInterfaceLayer can be found in the Terraria.UI namespace. Check https://github.com/tModLoader/tModLoader/wiki/Vanilla-Interface-layers-values for vanilla interface layer names More...
 
virtual void ModifyLightingBrightness (ref float scale)
 Allows you to modify overall brightness of lights. Can be used to create effects similiar to what night vision and darkness (de)buffs give you. Values too high or too low might result in glitches. For night vision effect use scale 1.03 More...
 
virtual void ModifySunLightColor (ref Color tileColor, ref Color backgroundColor)
 Allows you to modify color of light the sun emits. More...
 
virtual void ModifyTransformMatrix (ref SpriteViewMatrix Transform)
 Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.) More...
 
int MountType (string name)
 Gets the ID of the ModMountData instance corresponding to the given name. Returns 0 if no ModMountData has the given name. More...
 
int MountType< T > ()
 Same as the other MountType, but assumes that the class name and internal name are the same. More...
 
bool MusicExists (string name)
 Shorthand for calling ModLoader.MusicExists(this.FileName(name)). More...
 
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 name is found. More...
 
int NPCType< T > ()
 Same as the other NPCType, but assumes that the class name and internal name are the same. More...
 
virtual void PostAddRecipes ()
 This provides a hook into the mod-loading process immediately after recipes have been added. You can use this to edit recipes added by other mods. More...
 
virtual void PostDrawFullscreenMap (ref string mouseText)
 Called while the fullscreen map is active. Allows custom drawing to the map. More...
 
virtual void PostDrawInterface (SpriteBatch spriteBatch)
 Called after interface is drawn but right before mouse and mouse hover text is drawn. Allows for drawing interface. More...
 
virtual void PostSetupContent ()
 Allows you to load things in your mod after its content has been setup (arrays have been resized to fit the content, etc). More...
 
virtual void PostUpdateEverything ()
 Called after the Network got updated, this is the last hook that happens in an update. More...
 
virtual void PostUpdateInput ()
 Called after the input keys are polled. Allows for modifying things like scroll wheel if your custom drawing should capture that. More...
 
byte PrefixType (string name)
 Gets the internal ID / type of the ModPrefix corresponding to the name. Returns 0 if no ModPrefix with the given name is found. More...
 
byte PrefixType< T > ()
 Same as the other PrefixType, but assumes that the class name and internal name are the same. More...
 
virtual void PreSaveAndQuit ()
 Called in SP or Client when the Save and Quit button is pressed. One use for this hook is clearing out custom UI slots to return items to the player.
More...
 
virtual void PreUpdateEntities ()
 Use this if you want to do something before anything in the World gets updated. Called after UI updates, but before anything in the World (Players, NPCs, Projectiles, Tiles) gets updated. More...
 
int ProjectileType (string name)
 Gets the type of the ModProjectile of this mod with the given name. Returns 0 if no ModProjectile with the given name is found. More...
 
int ProjectileType< T > ()
 Same as the other ProjectileType, but assumes that the class name and internal name are the same. More...
 
ModHotKey RegisterHotKey (string name, string defaultKey)
 Registers a hotkey with a name and defaultKey. Use the returned ModHotKey to detect when buttons are pressed. Do this in a ModPlayer.ProcessTriggers. More...
 
bool SoundExists (string name)
 Shorthand for calling ModLoader.SoundExists(this.FileName(name)). More...
 
bool TextureExists (string name)
 Shorthand for calling ModLoader.TextureExists(this.FileName(name)). More...
 
int TileEntityType (string name)
 Gets the type of the ModTileEntity of this mod with the given name. Returns -1 if no ModTileEntity with the given name is found. More...
 
int TileEntityType< T > ()
 Same as the other TileEntityType, but assumes that the class name and internal name are the same. More...
 
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 name is found. More...
 
int TileType< T > ()
 Same as the other TileType, but assumes that the class name and internal name are the same. More...
 
virtual void Unload ()
 This is called whenever this mod is unloaded from the game. Use it to undo changes that you've made in Load that aren't automatically handled (for example, modifying the texture of a vanilla item). Mods are guaranteed to be unloaded in the reverse order they were loaded in. More...
 
virtual void UpdateMusic (ref int music)
 A legacy hook that you should no longer use. Use the version with two parameters instead. More...
 
virtual void UpdateMusic (ref int music, ref MusicPriority priority)
 Allows you to determine what music should currently play. More...
 
virtual void UpdateUI (GameTime gameTime)
 Ran every update and suitable for calling Update for UserInterface classes More...
 
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 name is found. More...
 
int WallType< T > ()
 Same as the other WallType, but assumes that the class name and internal name are the same. More...
 

Properties

Assembly Code [get, set]
 The assembly code this is loaded when tModLoader loads this mod. More...
 
string DisplayName [get, set]
 The display name of this mod in the Mods menu. More...
 
virtual uint ExtraPlayerBuffSlots [get]
 The amount of extra buff slots this mod desires for Players. This value is checked after Mod.Load but before Mod.PostSetupContent. The actual number of buffs the player can use will be 22 plus the max value of all enabled mods. In-game use Player.MaxBuffs to check the maximum number of buffs. More...
 
bool IsNetSynced [get]
 
ILog Logger [get, set]
 A logger with this mod's name for easy logging. More...
 
virtual string Name [get]
 Stores the name of the mod. This name serves as the mod's identification, and also helps with saving everything your mod adds. By default this returns the name of the folder that contains all your code and stuff. More...
 
ModProperties Properties = ModProperties.AutoLoadAll [get, protected set]
 
ModSide Side [get, set]
 The ModSide that controls how this mod is synced between client and server. More...
 
Version tModLoaderVersion [get, set]
 The version of tModLoader that was being used when this mod was built. More...
 
virtual Version Version [get]
 This version number of this mod. More...
 

Private Member Functions

void AutoloadBackgrounds ()
 
void AutoloadBuff (Type type)
 
void AutoloadCommand (Type type)
 
void AutoloadDust (Type type)
 
void AutoloadGlobalBgStyle (Type type)
 
void AutoloadGlobalBuff (Type type)
 
void AutoloadGlobalItem (Type type)
 
void AutoloadGlobalNPC (Type type)
 
void AutoloadGlobalProjectile (Type type)
 
void AutoloadGlobalRecipe (Type type)
 
void AutoloadGlobalTile (Type type)
 
void AutoloadGlobalWall (Type type)
 
void AutoloadGores (IList< Type > modGores)
 
void AutoloadItem (Type type)
 
void AutoloadLocalization ()
 Loads .lang files More...
 
void AutoloadModWorld (Type type)
 
void AutoloadMountData (Type type)
 
void AutoloadNPC (Type type)
 
void AutoloadPlayer (Type type)
 
void AutoloadPrefix (Type type)
 
void AutoloadProjectile (Type type)
 
void AutoloadSounds (IList< Type > modSounds)
 
void AutoloadSurfaceBgStyle (Type type)
 
void AutoloadTile (Type type)
 
void AutoloadTileEntity (Type type)
 
void AutoloadUgBgStyle (Type type)
 
void AutoloadWall (Type type)
 
void AutoloadWaterfallStyle (Type type)
 
void AutoloadWaterStyle (Type type)
 
Music LoadMusic (string path, string extension)
 
bool LoadResourceLegacy (string path, int length, Func< Stream > getStream)
 
SoundEffect LoadSound (Stream stream, int length, string extension)
 
void LoadTexture (string path, Stream stream, bool rawimg)
 

Private Attributes

readonly Queue< Task > AsyncLoadQueue = new Queue<Task>()
 
IDisposable fileHandle
 

Detailed Description

Mod is an abstract class that you will override. It serves as a central place from which the mod's contents are stored. It provides methods for you to use or override.

Definition at line 24 of file Mod.cs.

Member Function Documentation

◆ AddBackgroundTexture()

void Terraria.ModLoader.Mod.AddBackgroundTexture ( string  texture)

Adds a texture to the list of background textures and assigns it a background texture slot.

Parameters
textureThe texture.

Definition at line 1393 of file Mod.cs.

1393 {
1394 if (!loading)
1395 throw new Exception("AddBackgroundTexture can only be called from Mod.Load or Mod.Autoload");
1396
1397 BackgroundTextureLoader.backgrounds[texture] = BackgroundTextureLoader.ReserveBackgroundSlot();
1398 ModContent.GetTexture(texture);
1399 }

References Terraria.ModLoader.ModContent.GetTexture().

Referenced by Terraria.ModLoader.Mod.AutoloadBackgrounds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddBossHeadTexture()

void Terraria.ModLoader.Mod.AddBossHeadTexture ( string  texture,
int  npcType = -1 
)

Assigns a head texture that can be used by NPCs on the map.

Parameters
textureThe texture.
npcTypeAn optional npc id for NPCID.Sets.BossHeadTextures

Definition at line 931 of file Mod.cs.

931 {
932 if (!loading)
933 throw new Exception("AddBossHeadTexture can only be called from Mod.Load or Mod.Autoload");
934
935 int slot = NPCHeadLoader.ReserveBossHeadSlot(texture);
936 NPCHeadLoader.bossHeads[texture] = slot;
937 ModContent.GetTexture(texture);
938 if (npcType >= 0) {
939 NPCHeadLoader.npcToBossHead[npcType] = slot;
940 }
941 }

References Terraria.ModLoader.ModContent.GetTexture().

Referenced by Terraria.ModLoader.Mod.AutoloadNPC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddBuff()

void Terraria.ModLoader.Mod.AddBuff ( string  name,
ModBuff  buff,
string  texture 
)

Adds a type of buff to the game with the specified internal name and texture.

Parameters
nameThe name.
buffThe buff.
textureThe texture.

Definition at line 976 of file Mod.cs.

976 {
977 if (!loading)
978 throw new Exception("AddBuff can only be called from Mod.Load or Mod.Autoload");
979
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.");
982
983 buff.mod = this;
984 buff.Name = name;
985 buff.Type = BuffLoader.ReserveBuffID();
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));
989
990 buffs[name] = buff;
991 BuffLoader.buffs.Add(buff);
992 ContentInstance.Register(buff);
993 }
virtual string Name
Stores the name of the mod. This name serves as the mod's identification, and also helps with saving ...
Definition: Mod.cs:42

References Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadBuff().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddCommand()

void Terraria.ModLoader.Mod.AddCommand ( string  name,
ModCommand  mc 
)

Manually add a Command during Load

Definition at line 1438 of file Mod.cs.

1438 {
1439 if (!loading)
1440 throw new Exception("AddCommand can only be called from Mod.Load or Mod.Autoload");
1441
1442 mc.mod = this;
1443 mc.Name = name;
1444 CommandManager.Add(mc);
1445 }

Referenced by Terraria.ModLoader.Mod.AutoloadCommand().

+ Here is the caller graph for this function:

◆ AddConfig()

void Terraria.ModLoader.Mod.AddConfig ( string  name,
ModConfig  mc 
)

Definition at line 225 of file Mod.cs.

226 {
227 mc.Name = name;
228 mc.mod = this;
229
230 ConfigManager.Add(mc);
231 ContentInstance.Register(mc);
232 }

References Terraria.ModLoader.ContentInstance< T >.Register().

+ Here is the call graph for this function:

◆ AddDust()

void Terraria.ModLoader.Mod.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, preferably through the constructor of an overriding class. Leave the texture as an empty string to use the vanilla dust sprite sheet.

Parameters
nameThe name.
dustThe dust.
textureThe texture.

Definition at line 485 of file Mod.cs.

485 {
486 if (!loading)
487 throw new Exception("AddDust can only be called from Mod.Load or Mod.Autoload");
488
489 dust.mod = this;
490 dust.Name = name;
491 dust.Type = ModDust.ReserveDustID();
492 dust.Texture = !string.IsNullOrEmpty(texture) ? ModContent.GetTexture(texture) : Main.dustTexture;
493
494 dusts[name] = dust;
495 ModDust.dusts.Add(dust);
496 ContentInstance.Register(dust);
497 }

References Terraria.ModLoader.ModContent.GetTexture(), and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadDust().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddEquipTexture() [1/2]

int Terraria.ModLoader.Mod.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. This method is different from the other AddEquipTexture in that you can specify the class of the equipment texture, thus allowing you to override EquipmentTexture's hooks. All other parameters are the same as the other AddEquipTexture.

Parameters
equipTextureThe equip texture.
itemThe item.
typeThe type.
nameThe name.
textureThe texture.
armTextureThe arm texture (for body slots).
femaleTextureThe female texture (for body slots), if missing the regular body texture is used.
Returns

Definition at line 363 of file Mod.cs.

364 {
365 if (!loading)
366 throw new Exception("AddEquipTexture can only be called from Mod.Load or Mod.Autoload");
367
368 ModContent.GetTexture(texture); //ensure texture exists
369
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);
376
377 EquipLoader.equipTextures[type][slot] = equipTexture;
378 equipTextures[Tuple.Create(name, type)] = equipTexture;
379
380 if (type == EquipType.Body) {
381 if (femaleTexture == null || !ModContent.TextureExists(femaleTexture))
382 femaleTexture = texture;
383 EquipLoader.femaleTextures[slot] = femaleTexture;
384
385 ModContent.GetTexture(armTexture); //ensure texture exists
386 EquipLoader.armTextures[slot] = armTexture;
387 }
388 if (item != null) {
389 IDictionary<EquipType, int> slots;
390 if (!EquipLoader.idToSlot.TryGetValue(item.item.type, out slots))
391 EquipLoader.idToSlot[item.item.type] = slots = new Dictionary<EquipType, int>();
392
393 slots[type] = slot;
394 if (type == EquipType.Head || type == EquipType.Body || type == EquipType.Legs)
395 EquipLoader.slotToId[type][slot] = item.item.type;
396 }
397 return slot;
398 }
EquipType
This is an enum of all the types of equipment that exist. An equipment type is defined as a type or l...
Definition: EquipType.cs:7

References Terraria.ModLoader.ModContent.GetTexture(), Terraria.ModLoader.ModItem.item, and Terraria.ModLoader.ModContent.TextureExists().

+ Here is the call graph for this function:

◆ AddEquipTexture() [2/2]

int Terraria.ModLoader.Mod.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. (The item parameter may be null if you don't want to associate an item with the texture.) You can then get the ID for your texture by calling EquipLoader.GetEquipTexture, and using the EquipTexture's Slot property. If the EquipType is EquipType.Body, make sure that you also provide an armTexture and a femaleTexture. Returns the ID / slot that is assigned to the equipment texture.

Parameters
itemThe item.
typeThe type.
nameThe name.
textureThe texture.
armTextureThe arm texture (for body slots).
femaleTextureThe female texture (for body slots), if missing the regular body texture is used.
Returns

Definition at line 345 of file Mod.cs.

346 {
347 return AddEquipTexture(new EquipTexture(), item, type, name, texture, armTexture, femaleTexture);
348 }
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....
Definition: Mod.cs:345

References Terraria.ModLoader.Mod.AddEquipTexture().

Referenced by Terraria.ModLoader.Mod.AddEquipTexture(), and Terraria.ModLoader.Mod.AutoloadItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalBgStyle()

void Terraria.ModLoader.Mod.AddGlobalBgStyle ( string  name,
GlobalBgStyle  globalBgStyle 
)

Adds the given global background style with the given name to this mod.

Parameters
nameThe name.
globalBgStyleThe global bg style.

Definition at line 1232 of file Mod.cs.

1232 {
1233 if (!loading)
1234 throw new Exception("AddGlobalBgStyle can only be called from Mod.Load or Mod.Autoload");
1235
1236 globalBgStyle.mod = this;
1237 globalBgStyle.Name = name;
1238
1239 globalBgStyles[name] = globalBgStyle;
1240 GlobalBgStyleLoader.globalBgStyles.Add(globalBgStyle);
1241 ContentInstance.Register(globalBgStyle);
1242 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalBgStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalBuff()

void Terraria.ModLoader.Mod.AddGlobalBuff ( string  name,
GlobalBuff  globalBuff 
)

Adds the given GlobalBuff instance to this mod using the provided name.

Parameters
nameThe name.
globalBuffThe global buff.

Definition at line 1025 of file Mod.cs.

1025 {
1026 globalBuff.mod = this;
1027 globalBuff.Name = name;
1028
1029 globalBuffs[name] = globalBuff;
1030 BuffLoader.globalBuffs.Add(globalBuff);
1031 ContentInstance.Register(globalBuff);
1032 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalBuff().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalItem()

void Terraria.ModLoader.Mod.AddGlobalItem ( string  name,
GlobalItem  globalItem 
)

Adds the given GlobalItem instance to this mod with the provided name.

Parameters
nameThe name.
globalItemThe global item.

Definition at line 295 of file Mod.cs.

295 {
296 if (!loading)
297 throw new Exception("AddGlobalItem can only be called from Mod.Load or Mod.Autoload");
298
299 ItemLoader.VerifyGlobalItem(globalItem);
300
301 globalItem.mod = this;
302 globalItem.Name = name;
303
304 globalItems[name] = globalItem;
305 globalItem.index = ItemLoader.globalItems.Count;
306 ItemLoader.globalIndexes[Name + ':' + name] = ItemLoader.globalItems.Count;
307 if (ItemLoader.globalIndexesByType.ContainsKey(globalItem.GetType())) {
308 ItemLoader.globalIndexesByType[globalItem.GetType()] = -1;
309 }
310 else {
311 ItemLoader.globalIndexesByType[globalItem.GetType()] = ItemLoader.globalItems.Count;
312 }
313 ItemLoader.globalItems.Add(globalItem);
314 ContentInstance.Register(globalItem);
315 }

References Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalNPC()

void Terraria.ModLoader.Mod.AddGlobalNPC ( string  name,
GlobalNPC  globalNPC 
)

Adds the given GlobalNPC instance to this mod with the provided name.

Parameters
nameThe name.
globalNPCThe global NPC.

Definition at line 871 of file Mod.cs.

871 {
872 if (!loading)
873 throw new Exception("AddGlobalNPC can only be called from Mod.Load or Mod.Autoload");
874
875 NPCLoader.VerifyGlobalNPC(globalNPC);
876
877 globalNPC.mod = this;
878 globalNPC.Name = name;
879
880 globalNPCs[name] = globalNPC;
881 globalNPC.index = NPCLoader.globalNPCs.Count;
882 NPCLoader.globalIndexes[Name + ':' + name] = NPCLoader.globalNPCs.Count;
883 if (NPCLoader.globalIndexesByType.ContainsKey(globalNPC.GetType())) {
884 NPCLoader.globalIndexesByType[globalNPC.GetType()] = -1;
885 }
886 else {
887 NPCLoader.globalIndexesByType[globalNPC.GetType()] = NPCLoader.globalNPCs.Count;
888 }
889 NPCLoader.globalNPCs.Add(globalNPC);
890 ContentInstance.Register(globalNPC);
891 }

References Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalNPC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalProjectile()

void Terraria.ModLoader.Mod.AddGlobalProjectile ( string  name,
GlobalProjectile  globalProjectile 
)

Adds the given GlobalProjectile instance to this mod with the provided name.

Parameters
nameThe name.
globalProjectileThe global projectile.

Definition at line 787 of file Mod.cs.

787 {
788 if (!loading)
789 throw new Exception("AddGlobalProjectile can only be called from Mod.Load or Mod.Autoload");
790
791 ProjectileLoader.VerifyGlobalProjectile(globalProjectile);
792
793 globalProjectile.mod = this;
794 globalProjectile.Name = name;
795
796 globalProjectiles[name] = globalProjectile;
797 globalProjectile.index = ProjectileLoader.globalProjectiles.Count;
798 ProjectileLoader.globalIndexes[Name + ':' + name] = ProjectileLoader.globalProjectiles.Count;
799 if (ProjectileLoader.globalIndexesByType.ContainsKey(globalProjectile.GetType())) {
800 ProjectileLoader.globalIndexesByType[globalProjectile.GetType()] = -1;
801 }
802 else {
803 ProjectileLoader.globalIndexesByType[globalProjectile.GetType()] = ProjectileLoader.globalProjectiles.Count;
804 }
805 ProjectileLoader.globalProjectiles.Add(globalProjectile);
806 ContentInstance.Register(globalProjectile);
807 }

References Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalProjectile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalRecipe()

void Terraria.ModLoader.Mod.AddGlobalRecipe ( string  name,
GlobalRecipe  globalRecipe 
)

Manually add a Global Recipe during Load

Parameters
nameThe name.
globalRecipeThe global recipe.

Definition at line 1413 of file Mod.cs.

1413 {
1414 if (!loading)
1415 throw new Exception("AddGlobalRecipe can only be called from Mod.Load or Mod.Autoload");
1416
1417 globalRecipe.mod = this;
1418 globalRecipe.Name = name;
1419
1420 globalRecipes[name] = globalRecipe;
1421 RecipeHooks.Add(globalRecipe);
1422 ContentInstance.Register(globalRecipe);
1423 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalRecipe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalTile()

void Terraria.ModLoader.Mod.AddGlobalTile ( string  name,
GlobalTile  globalTile 
)

Adds the given GlobalTile instance to this mod with the provided name.

Parameters
nameThe name.
globalTileThe global tile.

Definition at line 587 of file Mod.cs.

587 {
588 if (!loading)
589 throw new Exception("AddGlobalTile can only be called from Mod.Load or Mod.Autoload");
590
591 globalTile.mod = this;
592 globalTile.Name = name;
593
594 globalTiles[name] = globalTile;
595 TileLoader.globalTiles.Add(globalTile);
596 ContentInstance.Register(globalTile);
597 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalTile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalWall()

void Terraria.ModLoader.Mod.AddGlobalWall ( string  name,
GlobalWall  globalWall 
)

Adds the given GlobalWall instance to this mod with the provided name.

Parameters
nameThe name.
globalWallThe global wall.

Definition at line 713 of file Mod.cs.

713 {
714 if (!loading)
715 throw new Exception("AddGlobalWall can only be called from Mod.Load or Mod.Autoload");
716
717 globalWall.mod = this;
718 globalWall.Name = name;
719
720 globalWalls[name] = globalWall;
721 WallLoader.globalWalls.Add(globalWall);
722 ContentInstance.Register(globalWall);
723 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalWall().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGore()

void Terraria.ModLoader.Mod.AddGore ( string  texture,
ModGore  modGore = null 
)

Adds the given texture to the game as a custom gore, with the given custom gore behavior. If no custom gore behavior is provided, the custom gore will have the default vanilla behavior.

Parameters
textureThe texture.
modGoreThe mod gore.

Definition at line 1330 of file Mod.cs.

1330 {
1331 if (!loading)
1332 throw new Exception("AddGore can only be called from Mod.Load or Mod.Autoload");
1333
1334 int id = ModGore.ReserveGoreID();
1335 ModGore.gores[texture] = id;
1336 if (modGore != null) {
1337 ModGore.modGores[id] = modGore;
1338 ContentInstance.Register(modGore);
1339 }
1340 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadGores().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddItem()

void Terraria.ModLoader.Mod.AddItem ( string  name,
ModItem  item 
)

Adds a type of item to your mod with the specified internal name. This method should be called in Load. You can obtain an instance of ModItem by overriding it then creating an instance of the subclass.

Parameters
nameThe name.
itemThe item.
Exceptions
System.ExceptionYou tried to add 2 ModItems with the same name: " + name + ". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddItem with 2 items of the same name.

Definition at line 240 of file Mod.cs.

240 {
241 if (!loading)
242 throw new Exception(Language.GetTextValue("tModLoader.LoadErrorAddItemOnlyInLoad"));
243
244 if (items.ContainsKey(name))
245 throw new Exception(Language.GetTextValue("tModLoader.LoadError2ModItemSameName", name));
246
247 item.mod = this;
248 item.Name = 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);
251
252 item.item.ResetStats(ItemLoader.ReserveItemID());
253 item.item.modItem = item;
254
255 items[name] = item;
256 ItemLoader.items.Add(item);
257 ContentInstance.Register(item);
258 }

References Terraria.ModLoader.ModItem.item, Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddModWorld()

void Terraria.ModLoader.Mod.AddModWorld ( string  name,
ModWorld  modWorld 
)

Adds a ModWorld to this mod with the given name.

Parameters
nameThe name.
modWorldThe mod world.

Definition at line 1135 of file Mod.cs.

1135 {
1136 if (!loading)
1137 throw new Exception("AddModWorld can only be called from Mod.Load or Mod.Autoload");
1138
1139 modWorld.mod = this;
1140 modWorld.Name = name;
1141
1142 worlds[name] = modWorld;
1143 WorldHooks.Add(modWorld);
1144 ContentInstance.Register(modWorld);
1145 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadModWorld().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddMount()

void Terraria.ModLoader.Mod.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 optionally map types of mount textures to the texture paths you want to include.

Parameters
nameThe name.
mountThe mount.
textureThe texture.
extraTexturesThe extra textures.

Definition at line 1051 of file Mod.cs.

1052 {
1053 if (!loading)
1054 throw new Exception("AddMount can only be called from Mod.Load or Mod.Autoload");
1055
1056 if (Mount.mounts == null || Mount.mounts.Length == MountID.Count)
1057 Mount.Initialize();
1058
1059 mount.mod = this;
1060 mount.Name = name;
1061 mount.Type = MountLoader.ReserveMountID();
1062 mount.texture = texture;
1063
1064 mountDatas[name] = mount;
1065 MountLoader.mountDatas[mount.Type] = mount;
1066 ContentInstance.Register(mount);
1067
1068 if (extraTextures == null)
1069 return;
1070
1071 foreach (var entry in extraTextures) {
1072 if (!ModContent.TextureExists(entry.Value))
1073 continue;
1074
1075 Texture2D extraTexture = ModContent.GetTexture(entry.Value);
1076 switch (entry.Key) {
1077 case MountTextureType.Back:
1078 mount.mountData.backTexture = extraTexture;
1079 break;
1080 case MountTextureType.BackGlow:
1081 mount.mountData.backTextureGlow = extraTexture;
1082 break;
1083 case MountTextureType.BackExtra:
1084 mount.mountData.backTextureExtra = extraTexture;
1085 break;
1086 case MountTextureType.BackExtraGlow:
1087 mount.mountData.backTextureExtraGlow = extraTexture;
1088 break;
1089 case MountTextureType.Front:
1090 mount.mountData.frontTexture = extraTexture;
1091 break;
1092 case MountTextureType.FrontGlow:
1093 mount.mountData.frontTextureGlow = extraTexture;
1094 break;
1095 case MountTextureType.FrontExtra:
1096 mount.mountData.frontTextureExtra = extraTexture;
1097 break;
1098 case MountTextureType.FrontExtraGlow:
1099 mount.mountData.frontTextureExtraGlow = extraTexture;
1100 break;
1101 }
1102 }
1103 }
MountTextureType
This is an enum of all possible types of extra mount textures for custom mounts. Use these as keys in...

References Terraria.ModLoader.ModContent.GetTexture(), Terraria.ModLoader.ContentInstance< T >.Register(), and Terraria.ModLoader.ModContent.TextureExists().

Referenced by Terraria.ModLoader.Mod.AutoloadMountData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddMusicBox()

void Terraria.ModLoader.Mod.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. When music with the given ID is playing, equipped music boxes have a chance to change their ID to the given item type. When an item with the given item type is equipped, it will play the music that has musicSlot as its ID. When a tile with the given type and Y-frame is nearby, if its X-frame is >= 36, it will play the music that has musicSlot as its ID.

Parameters
musicSlotThe music slot.
itemTypeType of the item.
tileTypeType of the tile.
tileFrameYThe tile frame y.
Exceptions
System.ArgumentOutOfRangeExceptionCannot assign music box to vanilla music ID " + musicSlot or Music ID " + musicSlot + " does not exist or Cannot assign music box to vanilla item ID " + itemType or Item ID " + itemType + " does not exist or Cannot assign music box to vanilla tile ID " + tileType or Tile ID " + tileType + " does not exist </exception> <exception cref="System.ArgumentException"> Music ID " + musicSlot + " has already been assigned a music box or Item ID " + itemType + " has already been assigned a music or or Y-frame must be divisible by 36

Definition at line 1475 of file Mod.cs.

1475 {
1476 if (!loading)
1477 throw new Exception("AddMusicBox can only be called from Mod.Load or Mod.Autoload");
1478
1479 if (Main.waveBank == null)
1480 return;
1481
1482 if (musicSlot < Main.maxMusic) {
1483 throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla music ID " + musicSlot);
1484 }
1485 if (musicSlot >= SoundLoader.SoundCount(SoundType.Music)) {
1486 throw new ArgumentOutOfRangeException("Music ID " + musicSlot + " does not exist");
1487 }
1488 if (itemType < ItemID.Count) {
1489 throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla item ID " + itemType);
1490 }
1491 if (ItemLoader.GetItem(itemType) == null) {
1492 throw new ArgumentOutOfRangeException("Item ID " + itemType + " does not exist");
1493 }
1494 if (tileType < TileID.Count) {
1495 throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla tile ID " + tileType);
1496 }
1497 if (TileLoader.GetTile(tileType) == null) {
1498 throw new ArgumentOutOfRangeException("Tile ID " + tileType + " does not exist");
1499 }
1500 if (SoundLoader.musicToItem.ContainsKey(musicSlot)) {
1501 throw new ArgumentException("Music ID " + musicSlot + " has already been assigned a music box");
1502 }
1503 if (SoundLoader.itemToMusic.ContainsKey(itemType)) {
1504 throw new ArgumentException("Item ID " + itemType + " has already been assigned a music");
1505 }
1506 if (!SoundLoader.tileToMusic.ContainsKey(tileType)) {
1507 SoundLoader.tileToMusic[tileType] = new Dictionary<int, int>();
1508 }
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);
1512 }
1513 if (tileFrameY % 36 != 0) {
1514 throw new ArgumentException("Y-frame must be divisible by 36");
1515 }
1516 SoundLoader.musicToItem[musicSlot] = itemType;
1517 SoundLoader.itemToMusic[itemType] = musicSlot;
1518 SoundLoader.tileToMusic[tileType][tileFrameY] = musicSlot;
1519 }
SoundType
This is an enum of the types of sound you can add to the game. This is used for determining whether a...
Definition: SoundType.cs:13

References Terraria.ModLoader.ItemLoader.GetItem(), Terraria.ModLoader.TileLoader.GetTile(), and Terraria.ModLoader.SoundLoader.SoundCount().

+ Here is the call graph for this function:

◆ AddNPC()

void Terraria.ModLoader.Mod.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 alternate textures.

Parameters
nameThe name.
npcThe NPC.

Definition at line 824 of file Mod.cs.

824 {
825 if (!loading)
826 throw new Exception("AddNPC can only be called from Mod.Load or Mod.Autoload");
827
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.");
830
831 npc.mod = this;
832 npc.Name = name;
833 npc.npc.type = NPCLoader.ReserveNPCID();
834 npc.DisplayName = GetOrCreateTranslation(string.Format("Mods.{0}.NPCName.{1}", Name, name));
835
836 npcs[name] = npc;
837 NPCLoader.npcs.Add(npc);
838 ContentInstance.Register(npc);
839 }

References Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadNPC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddNPCHeadTexture()

void Terraria.ModLoader.Mod.AddNPCHeadTexture ( int  npcType,
string  texture 
)

Assigns a head texture to the given town NPC type.

Parameters
npcTypeType of the NPC.
textureThe texture.
Exceptions
MissingResourceException

Definition at line 909 of file Mod.cs.

909 {
910 if (!loading)
911 throw new Exception("AddNPCHeadTexture can only be called from Mod.Load or Mod.Autoload");
912
913 int slot = NPCHeadLoader.ReserveHeadSlot();
914 NPCHeadLoader.heads[texture] = slot;
915 if (!Main.dedServ) {
916 ModContent.GetTexture(texture);
917 }
918 /*else if (Main.dedServ && !(ModLoader.FileExists(texture + ".png") || ModLoader.FileExists(texture + ".rawimg")))
919 {
920 throw new MissingResourceException(texture);
921 }*/
922 NPCHeadLoader.npcToHead[npcType] = slot;
923 NPCHeadLoader.headToNPC[slot] = npcType;
924 }

References Terraria.ModLoader.ModContent.GetTexture().

Referenced by Terraria.ModLoader.Mod.AutoloadNPC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddPlayer()

void Terraria.ModLoader.Mod.AddPlayer ( string  name,
ModPlayer  player 
)

Adds a type of ModPlayer to this mod. All ModPlayer types will be newly created and attached to each player that is loaded.

Parameters
nameThe name.
playerThe player.

Definition at line 948 of file Mod.cs.

948 {
949 if (!loading)
950 throw new Exception("AddPlayer can only be called from Mod.Load or Mod.Autoload");
951
952 player.mod = this;
953 player.Name = name;
954
955 players[name] = player;
956 PlayerHooks.Add(player);
957 ContentInstance.Register(player);
958 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddPrefix()

void Terraria.ModLoader.Mod.AddPrefix ( string  name,
ModPrefix  prefix 
)

Adds a prefix to your mod with the specified internal name. This method should be called in Load. You can obtain an instance of ModPrefix by overriding it then creating an instance of the subclass.

Parameters
nameThe name.
prefixThe prefix.
Exceptions
System.ExceptionYou tried to add 2 ModItems with the same name: " + name + ". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddItem with 2 items of the same name.

Definition at line 431 of file Mod.cs.

431 {
432 if (!loading)
433 throw new Exception("AddPrefix can only be called from Mod.Load or Mod.Autoload");
434
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.");
437
438 prefix.mod = this;
439 prefix.Name = name;
440 prefix.DisplayName = GetOrCreateTranslation(string.Format("Mods.{0}.Prefix.{1}", Name, name));
441 prefix.Type = ModPrefix.ReservePrefixID();
442
443 prefixes[name] = prefix;
444 ModPrefix.prefixes.Add(prefix);
445 ModPrefix.categoryPrefixes[prefix.Category].Add(prefix);
446 ContentInstance.Register(prefix);
447 }

References Terraria.ModLoader.ModPrefix.Category, Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadPrefix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddProjectile()

void Terraria.ModLoader.Mod.AddProjectile ( string  name,
ModProjectile  projectile 
)

Adds a type of projectile to the game with the specified name.

Parameters
nameThe name.
projectileThe projectile.

Definition at line 740 of file Mod.cs.

740 {
741 if (!loading)
742 throw new Exception("AddProjectile can only be called from Mod.Load or Mod.Autoload");
743
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.");
746
747 projectile.mod = this;
748 projectile.Name = name;
749 projectile.projectile.type = ProjectileLoader.ReserveProjectileID();
750 projectile.DisplayName = GetOrCreateTranslation(string.Format("Mods.{0}.ProjectileName.{1}", Name, name));
751
752 projectiles[name] = projectile;
753 ProjectileLoader.projectiles.Add(projectile);
754 ContentInstance.Register(projectile);
755 }

References Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadProjectile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddRecipeGroups()

virtual void Terraria.ModLoader.Mod.AddRecipeGroups ( )
virtual

Override this method to add recipe groups to this mod. You must add recipe groups by calling the RecipeGroup.RegisterGroup method here. A recipe group is a set of items that can be used interchangeably in the same recipe.

Definition at line 94 of file Mod.cs.

94 {
95 }

◆ AddRecipes()

virtual void Terraria.ModLoader.Mod.AddRecipes ( )
virtual

Override this method to add recipes to the game. It is recommended that you do so through instances of ModRecipe, since it provides methods that simplify recipe creation.

Definition at line 100 of file Mod.cs.

100 {
101 }

◆ AddSound()

void Terraria.ModLoader.Mod.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 playing. If no ModSound instance is provided, the custom sound will play in a similar manner as the default vanilla ones.

Parameters
typeThe type.
soundPathThe sound path.
modSoundThe mod sound.

Definition at line 1362 of file Mod.cs.

1362 {
1363 if (!loading)
1364 throw new Exception("AddSound can only be called from Mod.Load or Mod.Autoload");
1365 int id = SoundLoader.ReserveSoundID(type);
1366 SoundLoader.sounds[type][soundPath] = id;
1367 if (modSound != null) {
1368 SoundLoader.modSounds[type][id] = modSound;
1369 modSound.sound = ModContent.GetSound(soundPath);
1370 }
1371 }

References Terraria.ModLoader.ModContent.GetSound().

Referenced by Terraria.ModLoader.Mod.AutoloadSounds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddSurfaceBgStyle()

void Terraria.ModLoader.Mod.AddSurfaceBgStyle ( string  name,
ModSurfaceBgStyle  surfaceBgStyle 
)

Adds the given surface background style with the given name to this mod.

Parameters
nameThe name.
surfaceBgStyleThe surface bg style.

Definition at line 1195 of file Mod.cs.

1195 {
1196 if (!loading)
1197 throw new Exception("AddSurfaceBgStyle can only be called from Mod.Load or Mod.Autoload");
1198
1199 surfaceBgStyle.mod = this;
1200 surfaceBgStyle.Name = name;
1201 surfaceBgStyle.Slot = SurfaceBgStyleLoader.ReserveBackgroundSlot();
1202
1203 surfaceBgStyles[name] = surfaceBgStyle;
1204 SurfaceBgStyleLoader.surfaceBgStyles.Add(surfaceBgStyle);
1205 ContentInstance.Register(surfaceBgStyle);
1206 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadSurfaceBgStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddTexture()

void Terraria.ModLoader.Mod.AddTexture ( string  name,
Texture2D  texture 
)

Shorthand for calling ModLoader.AddTexture(this.FileName(name), texture).

Parameters
nameThe name.
textureThe texture.
Exceptions
Terraria.ModLoader.Exceptions.ModNameExceptionTexture already exist: " + name

Definition at line 1598 of file Mod.cs.

1598 {
1599 if (Main.dedServ)
1600 return;
1601
1602 if (TextureExists(name))
1603 throw new Exception("Texture already exist: " + name);
1604
1605 textures[name] = texture;
1606 }
bool TextureExists(string name)
Shorthand for calling ModLoader.TextureExists(this.FileName(name)).

References Terraria.ModLoader.Mod.TextureExists().

+ Here is the call graph for this function:

◆ AddTile()

void Terraria.ModLoader.Mod.AddTile ( string  name,
ModTile  tile,
string  texture 
)

Adds a type of tile to the game with the specified name and texture.

Parameters
nameThe name.
tileThe tile.
textureThe texture.

Definition at line 535 of file Mod.cs.

535 {
536 if (!loading)
537 throw new Exception("AddItem can only be called from Mod.Load or Mod.Autoload");
538
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.");
541
542 tile.mod = this;
543 tile.Name = name;
544 tile.Type = (ushort)TileLoader.ReserveTileID();
545 tile.texture = texture;
546
547 tiles[name] = tile;
548 TileLoader.tiles.Add(tile);
549 ContentInstance.Register(tile);
550 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadTile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddTileEntity()

void Terraria.ModLoader.Mod.AddTileEntity ( string  name,
ModTileEntity  entity 
)

Manually add a tile entity during Load.

Definition at line 617 of file Mod.cs.

617 {
618 if (!loading)
619 throw new Exception("AddTileEntity can only be called from Mod.Load or Mod.Autoload");
620
621 int id = ModTileEntity.ReserveTileEntityID();
622 entity.mod = this;
623 entity.Name = name;
624 entity.Type = id;
625 entity.type = (byte)id;
626
627 tileEntities[name] = entity;
628 ModTileEntity.tileEntities.Add(entity);
629 ContentInstance.Register(entity);
630 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadTileEntity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddTranslation()

void Terraria.ModLoader.Mod.AddTranslation ( ModTranslation  translation)

Adds a ModTranslation to the game so that you can use Language.GetText to get a LocalizedText.

Definition at line 1544 of file Mod.cs.

1544 {
1545 translations[translation.Key] = translation;
1546 }

References Terraria.ModLoader.ModTranslation.Key.

Referenced by Terraria.ModLoader.Mod.AutoloadLocalization().

+ Here is the caller graph for this function:

◆ AddUgBgStyle()

void Terraria.ModLoader.Mod.AddUgBgStyle ( string  name,
ModUgBgStyle  ugBgStyle 
)

Adds the given underground background style with the given name to this mod.

Parameters
nameThe name.
ugBgStyleThe ug bg style.

Definition at line 1167 of file Mod.cs.

1167 {
1168 if (!loading)
1169 throw new Exception("AddUgBgStyle can only be called from Mod.Load or Mod.Autoload");
1170
1171 ugBgStyle.mod = this;
1172 ugBgStyle.Name = name;
1173 ugBgStyle.Slot = UgBgStyleLoader.ReserveBackgroundSlot();
1174
1175 ugBgStyles[name] = ugBgStyle;
1176 UgBgStyleLoader.ugBgStyles.Add(ugBgStyle);
1177 ContentInstance.Register(ugBgStyle);
1178 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadUgBgStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddWall()

void Terraria.ModLoader.Mod.AddWall ( string  name,
ModWall  wall,
string  texture 
)

Adds a type of wall to the game with the specified name and texture.

Parameters
nameThe name.
wallThe wall.
textureThe texture.

Definition at line 669 of file Mod.cs.

669 {
670 if (!loading)
671 throw new Exception("AddWall can only be called from Mod.Load or Mod.Autoload");
672
673 wall.mod = this;
674 wall.Name = name;
675 wall.Type = (ushort)WallLoader.ReserveWallID();
676 wall.texture = texture;
677
678 walls[name] = wall;
679 WallLoader.walls.Add(wall);
680 ContentInstance.Register(wall);
681 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadWall().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddWaterfallStyle()

void Terraria.ModLoader.Mod.AddWaterfallStyle ( string  name,
ModWaterfallStyle  waterfallStyle,
string  texture 
)

Adds the given waterfall style to the game with the given name and texture path.

Parameters
nameThe name.
waterfallStyleThe waterfall style.
textureThe texture.

Definition at line 1292 of file Mod.cs.

1292 {
1293 if (!loading)
1294 throw new Exception("AddWaterfallStyle can only be called from Mod.Load or Mod.Autoload");
1295
1296 waterfallStyle.mod = this;
1297 waterfallStyle.Name = name;
1298 waterfallStyle.Type = WaterfallStyleLoader.ReserveStyle();
1299 waterfallStyle.texture = texture;
1300
1301 waterfallStyles[name] = waterfallStyle;
1302 WaterfallStyleLoader.waterfallStyles.Add(waterfallStyle);
1303 ContentInstance.Register(waterfallStyle);
1304 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadWaterfallStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddWaterStyle()

void Terraria.ModLoader.Mod.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.

Parameters
nameThe name.
waterStyleThe water style.
textureThe texture.
blockTextureThe block texture.

Definition at line 1261 of file Mod.cs.

1261 {
1262 if (!loading)
1263 throw new Exception("AddWaterStyle can only be called from Mod.Load or Mod.Autoload");
1264
1265 waterStyle.mod = this;
1266 waterStyle.Name = name;
1267 waterStyle.Type = WaterStyleLoader.ReserveStyle();
1268 waterStyle.texture = texture;
1269 waterStyle.blockTexture = blockTexture;
1270
1271 waterStyles[name] = waterStyle;
1272 WaterStyleLoader.waterStyles.Add(waterStyle);
1273 ContentInstance.Register(waterStyle);
1274 }

References Terraria.ModLoader.ContentInstance< T >.Register().

Referenced by Terraria.ModLoader.Mod.AutoloadWaterStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AutoloadBackgrounds()

void Terraria.ModLoader.Mod.AutoloadBackgrounds ( )
private

Definition at line 532 of file ModInternals.cs.

532 {
533 foreach (string texture in textures.Keys.Where(t => t.StartsWith("Backgrounds/"))) {
534 AddBackgroundTexture(Name + '/' + texture);
535 }
536 }
void AddBackgroundTexture(string texture)
Adds a texture to the list of background textures and assigns it a background texture slot.
Definition: Mod.cs:1393

References Terraria.ModLoader.Mod.AddBackgroundTexture(), and Terraria.ModLoader.Mod.Name.

+ Here is the call graph for this function:

◆ AutoloadBuff()

void Terraria.ModLoader.Mod.AutoloadBuff ( Type  type)
private

Definition at line 490 of file ModInternals.cs.

490 {
491 ModBuff buff = (ModBuff)Activator.CreateInstance(type);
492 buff.mod = this;
493 string name = type.Name;
494 string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
495 if (buff.Autoload(ref name, ref texture)) {
496 AddBuff(name, buff, texture);
497 }
498 }
void AddBuff(string name, ModBuff buff, string texture)
Adds a type of buff to the game with the specified internal name and texture.
Definition: Mod.cs:976

References Terraria.ModLoader.Mod.AddBuff(), Terraria.ModLoader.ModBuff.Autoload(), and Terraria.ModLoader.ModBuff.Name.

+ Here is the call graph for this function:

◆ AutoloadCommand()

void Terraria.ModLoader.Mod.AutoloadCommand ( Type  type)
private

Definition at line 636 of file ModInternals.cs.

636 {
637 var mc = (ModCommand)Activator.CreateInstance(type);
638 mc.mod = this;
639 var name = type.Name;
640 if (mc.Autoload(ref name))
641 AddCommand(name, mc);
642 }
void AddCommand(string name, ModCommand mc)
Manually add a Command during Load
Definition: Mod.cs:1438

References Terraria.ModLoader.Mod.AddCommand().

+ Here is the call graph for this function:

◆ AutoloadDust()

void Terraria.ModLoader.Mod.AutoloadDust ( Type  type)
private

Definition at line 378 of file ModInternals.cs.

378 {
379 ModDust dust = (ModDust)Activator.CreateInstance(type);
380 dust.mod = this;
381 string name = type.Name;
382 string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
383 if (dust.Autoload(ref name, ref texture)) {
384 AddDust(name, dust, texture);
385 }
386 }
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,...
Definition: Mod.cs:485

References Terraria.ModLoader.Mod.AddDust(), Terraria.ModLoader.ModDust.Autoload(), and Terraria.ModLoader.ModDust.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalBgStyle()

void Terraria.ModLoader.Mod.AutoloadGlobalBgStyle ( Type  type)
private

Definition at line 556 of file ModInternals.cs.

556 {
557 GlobalBgStyle globalBgStyle = (GlobalBgStyle)Activator.CreateInstance(type);
558 globalBgStyle.mod = this;
559 string name = type.Name;
560 if (globalBgStyle.Autoload(ref name)) {
561 AddGlobalBgStyle(name, globalBgStyle);
562 }
563 }
void AddGlobalBgStyle(string name, GlobalBgStyle globalBgStyle)
Adds the given global background style with the given name to this mod.
Definition: Mod.cs:1232

References Terraria.ModLoader.Mod.AddGlobalBgStyle(), Terraria.ModLoader.GlobalBgStyle.Autoload(), and Terraria.ModLoader.GlobalBgStyle.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalBuff()

void Terraria.ModLoader.Mod.AutoloadGlobalBuff ( Type  type)
private

Definition at line 500 of file ModInternals.cs.

500 {
501 GlobalBuff globalBuff = (GlobalBuff)Activator.CreateInstance(type);
502 globalBuff.mod = this;
503 string name = type.Name;
504 if (globalBuff.Autoload(ref name)) {
505 AddGlobalBuff(name, globalBuff);
506 }
507 }
void AddGlobalBuff(string name, GlobalBuff globalBuff)
Adds the given GlobalBuff instance to this mod using the provided name.
Definition: Mod.cs:1025

References Terraria.ModLoader.Mod.AddGlobalBuff(), Terraria.ModLoader.GlobalBuff.Autoload(), and Terraria.ModLoader.GlobalBuff.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalItem()

void Terraria.ModLoader.Mod.AutoloadGlobalItem ( Type  type)
private

Definition at line 360 of file ModInternals.cs.

360 {
361 GlobalItem globalItem = (GlobalItem)Activator.CreateInstance(type);
362 globalItem.mod = this;
363 string name = type.Name;
364 if (globalItem.Autoload(ref name)) {
365 AddGlobalItem(name, globalItem);
366 }
367 }
void AddGlobalItem(string name, GlobalItem globalItem)
Adds the given GlobalItem instance to this mod with the provided name.
Definition: Mod.cs:295

References Terraria.ModLoader.Mod.AddGlobalItem(), Terraria.ModLoader.GlobalItem.Autoload(), and Terraria.ModLoader.GlobalItem.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalNPC()

void Terraria.ModLoader.Mod.AutoloadGlobalNPC ( Type  type)
private

Definition at line 472 of file ModInternals.cs.

472 {
473 GlobalNPC globalNPC = (GlobalNPC)Activator.CreateInstance(type);
474 globalNPC.mod = this;
475 string name = type.Name;
476 if (globalNPC.Autoload(ref name)) {
477 AddGlobalNPC(name, globalNPC);
478 }
479 }
void AddGlobalNPC(string name, GlobalNPC globalNPC)
Adds the given GlobalNPC instance to this mod with the provided name.
Definition: Mod.cs:871

References Terraria.ModLoader.Mod.AddGlobalNPC(), Terraria.ModLoader.GlobalNPC.Autoload(), and Terraria.ModLoader.GlobalNPC.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalProjectile()

void Terraria.ModLoader.Mod.AutoloadGlobalProjectile ( Type  type)
private

Definition at line 444 of file ModInternals.cs.

444 {
445 GlobalProjectile globalProjectile = (GlobalProjectile)Activator.CreateInstance(type);
446 globalProjectile.mod = this;
447 string name = type.Name;
448 if (globalProjectile.Autoload(ref name)) {
449 AddGlobalProjectile(name, globalProjectile);
450 }
451 }
void AddGlobalProjectile(string name, GlobalProjectile globalProjectile)
Adds the given GlobalProjectile instance to this mod with the provided name.
Definition: Mod.cs:787

References Terraria.ModLoader.Mod.AddGlobalProjectile(), Terraria.ModLoader.GlobalProjectile.Autoload(), and Terraria.ModLoader.GlobalProjectile.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalRecipe()

void Terraria.ModLoader.Mod.AutoloadGlobalRecipe ( Type  type)
private

Definition at line 627 of file ModInternals.cs.

627 {
628 GlobalRecipe globalRecipe = (GlobalRecipe)Activator.CreateInstance(type);
629 globalRecipe.mod = this;
630 string name = type.Name;
631 if (globalRecipe.Autoload(ref name)) {
632 AddGlobalRecipe(name, globalRecipe);
633 }
634 }
void AddGlobalRecipe(string name, GlobalRecipe globalRecipe)
Manually add a Global Recipe during Load
Definition: Mod.cs:1413

References Terraria.ModLoader.Mod.AddGlobalRecipe(), Terraria.ModLoader.GlobalRecipe.Autoload(), and Terraria.ModLoader.GlobalRecipe.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalTile()

void Terraria.ModLoader.Mod.AutoloadGlobalTile ( Type  type)
private

Definition at line 398 of file ModInternals.cs.

398 {
399 GlobalTile globalTile = (GlobalTile)Activator.CreateInstance(type);
400 globalTile.mod = this;
401 string name = type.Name;
402 if (globalTile.Autoload(ref name)) {
403 AddGlobalTile(name, globalTile);
404 }
405 }
void AddGlobalTile(string name, GlobalTile globalTile)
Adds the given GlobalTile instance to this mod with the provided name.
Definition: Mod.cs:587

References Terraria.ModLoader.Mod.AddGlobalTile(), Terraria.ModLoader.GlobalTile.Autoload(), and Terraria.ModLoader.GlobalTile.Name.

+ Here is the call graph for this function:

◆ AutoloadGlobalWall()

void Terraria.ModLoader.Mod.AutoloadGlobalWall ( Type  type)
private

Definition at line 426 of file ModInternals.cs.

426 {
427 GlobalWall globalWall = (GlobalWall)Activator.CreateInstance(type);
428 globalWall.mod = this;
429 string name = type.Name;
430 if (globalWall.Autoload(ref name)) {
431 AddGlobalWall(name, globalWall);
432 }
433 }
void AddGlobalWall(string name, GlobalWall globalWall)
Adds the given GlobalWall instance to this mod with the provided name.
Definition: Mod.cs:713

References Terraria.ModLoader.Mod.AddGlobalWall(), Terraria.ModLoader.GlobalWall.Autoload(), and Terraria.ModLoader.GlobalWall.Name.

+ Here is the call graph for this function:

◆ AutoloadGores()

void Terraria.ModLoader.Mod.AutoloadGores ( IList< Type >  modGores)
private

Definition at line 586 of file ModInternals.cs.

586 {
587 var modGoreNames = modGores.ToDictionary(t => t.Namespace + "." + t.Name);
588 foreach (var texture in textures.Keys.Where(t => t.StartsWith("Gores/"))) {
589 ModGore modGore = null;
590 Type t;
591 if (modGoreNames.TryGetValue(Name + "." + texture.Replace('/', '.'), out t))
592 modGore = (ModGore)Activator.CreateInstance(t);
593
594 AddGore(Name + '/' + texture, modGore);
595 }
596 }
void AddGore(string texture, ModGore modGore=null)
Adds the given texture to the game as a custom gore, with the given custom gore behavior....
Definition: Mod.cs:1330

References Terraria.ModLoader.Mod.AddGore(), and Terraria.ModLoader.Mod.Name.

+ Here is the call graph for this function:

◆ AutoloadItem()

void Terraria.ModLoader.Mod.AutoloadItem ( Type  type)
private

Definition at line 346 of file ModInternals.cs.

346 {
347 ModItem item = (ModItem)Activator.CreateInstance(type);
348 item.mod = this;
349 string name = type.Name;
350 if (item.Autoload(ref name)) {
351 AddItem(name, item);
352 var autoloadEquip = type.GetAttribute<AutoloadEquip>();
353 if (autoloadEquip != null)
354 foreach (var equip in autoloadEquip.equipTypes)
355 AddEquipTexture(item, equip, item.Name, item.Texture + '_' + equip,
356 item.Texture + "_Arms", item.Texture + "_FemaleBody");
357 }
358 }
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...
Definition: Mod.cs:240

References Terraria.ModLoader.Mod.AddEquipTexture(), Terraria.ModLoader.Mod.AddItem(), Terraria.ModLoader.ModItem.Autoload(), Terraria.ModLoader.ModItem.Name, and Terraria.ModLoader.ModItem.Texture.

+ Here is the call graph for this function:

◆ AutoloadLocalization()

void Terraria.ModLoader.Mod.AutoloadLocalization ( )
private

Loads .lang files

Definition at line 647 of file ModInternals.cs.

647 {
648 var modTranslationDictionary = new Dictionary<string, ModTranslation>();
649 foreach (var translationFile in File.Where(entry => Path.GetExtension(entry.Name) == ".lang")) {
650 // .lang files need to be UTF8 encoded.
651 string translationFileContents = System.Text.Encoding.UTF8.GetString(File.GetBytes(translationFile));
652 GameCulture culture = GameCulture.FromName(Path.GetFileNameWithoutExtension(translationFile.Name));
653
654 using (StringReader reader = new StringReader(translationFileContents)) {
655 string line;
656 while ((line = reader.ReadLine()) != null) {
657 int split = line.IndexOf('=');
658 if (split < 0)
659 continue; // lines witout a = are ignored
660 string key = line.Substring(0, split).Trim().Replace(" ", "_");
661 string value = line.Substring(split + 1); // removed .Trim() since sometimes it is desired.
662 if (value.Length == 0) {
663 continue;
664 }
665 value = value.Replace("\\n", "\n");
666 // TODO: Maybe prepend key with filename: en.US.ItemName.lang would automatically assume "ItemName." for all entries.
667 //string key = key;
668 if (!modTranslationDictionary.TryGetValue(key, out ModTranslation mt))
669 modTranslationDictionary[key] = mt = CreateTranslation(key);
670 mt.AddTranslation(culture, value);
671 }
672 }
673 }
674
675 foreach (var value in modTranslationDictionary.Values) {
676 AddTranslation(value);
677 }
678 }
ModTranslation CreateTranslation(string key)
Creates a ModTranslation object that you can use in AddTranslation.
void AddTranslation(ModTranslation translation)
Adds a ModTranslation to the game so that you can use Language.GetText to get a LocalizedText.
Definition: Mod.cs:1544
void AddTranslation(int culture, string value)

References Terraria.ModLoader.ModTranslation.AddTranslation(), Terraria.ModLoader.Mod.AddTranslation(), and Terraria.ModLoader.Mod.CreateTranslation().

+ Here is the call graph for this function:

◆ AutoloadModWorld()

void Terraria.ModLoader.Mod.AutoloadModWorld ( Type  type)
private

Definition at line 523 of file ModInternals.cs.

523 {
524 ModWorld modWorld = (ModWorld)Activator.CreateInstance(type);
525 modWorld.mod = this;
526 string name = type.Name;
527 if (modWorld.Autoload(ref name)) {
528 AddModWorld(name, modWorld);
529 }
530 }
void AddModWorld(string name, ModWorld modWorld)
Adds a ModWorld to this mod with the given name.
Definition: Mod.cs:1135

References Terraria.ModLoader.Mod.AddModWorld(), Terraria.ModLoader.ModWorld.Autoload(), and Terraria.ModLoader.ModWorld.Name.

+ Here is the call graph for this function:

◆ AutoloadMountData()

void Terraria.ModLoader.Mod.AutoloadMountData ( Type  type)
private

Definition at line 509 of file ModInternals.cs.

509 {
510 ModMountData mount = (ModMountData)Activator.CreateInstance(type);
511 mount.mod = this;
512 string name = type.Name;
513 string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
514 var extraTextures = new Dictionary<MountTextureType, string>();
515 foreach (MountTextureType textureType in Enum.GetValues(typeof(MountTextureType))) {
516 extraTextures[textureType] = texture + "_" + textureType.ToString();
517 }
518 if (mount.Autoload(ref name, ref texture, extraTextures)) {
519 AddMount(name, mount, texture, extraTextures);
520 }
521 }
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...
Definition: Mod.cs:1051

References Terraria.ModLoader.Mod.AddMount(), and Terraria.ModLoader.ModMountData.Name.

+ Here is the call graph for this function:

◆ AutoloadNPC()

void Terraria.ModLoader.Mod.AutoloadNPC ( Type  type)
private

Definition at line 453 of file ModInternals.cs.

453 {
454 ModNPC npc = (ModNPC)Activator.CreateInstance(type);
455 npc.mod = this;
456 string name = type.Name;
457 if (npc.Autoload(ref name)) {
458 AddNPC(name, npc);
459 var autoloadHead = type.GetAttribute<AutoloadHead>();
460 if (autoloadHead != null) {
461 string headTexture = npc.HeadTexture;
462 AddNPCHeadTexture(npc.npc.type, headTexture);
463 }
464 var autoloadBossHead = type.GetAttribute<AutoloadBossHead>();
465 if (autoloadBossHead != null) {
466 string headTexture = npc.BossHeadTexture;
467 AddBossHeadTexture(headTexture, npc.npc.type);
468 }
469 }
470 }
void AddNPCHeadTexture(int npcType, string texture)
Assigns a head texture to the given town NPC type.
Definition: Mod.cs:909
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...
Definition: Mod.cs:824
void AddBossHeadTexture(string texture, int npcType=-1)
Assigns a head texture that can be used by NPCs on the map.
Definition: Mod.cs:931

References Terraria.ModLoader.Mod.AddBossHeadTexture(), Terraria.ModLoader.Mod.AddNPC(), Terraria.ModLoader.Mod.AddNPCHeadTexture(), Terraria.ModLoader.ModNPC.Autoload(), Terraria.ModLoader.ModNPC.BossHeadTexture, Terraria.ModLoader.ModNPC.HeadTexture, Terraria.ModLoader.ModNPC.Name, and Terraria.ModLoader.ModNPC.npc.

+ Here is the call graph for this function:

◆ AutoloadPlayer()

void Terraria.ModLoader.Mod.AutoloadPlayer ( Type  type)
private

Definition at line 481 of file ModInternals.cs.

481 {
482 ModPlayer player = (ModPlayer)Activator.CreateInstance(type);
483 player.mod = this;
484 string name = type.Name;
485 if (player.Autoload(ref name)) {
486 AddPlayer(name, player);
487 }
488 }
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 ...
Definition: Mod.cs:948

References Terraria.ModLoader.Mod.AddPlayer(), Terraria.ModLoader.ModPlayer.Autoload(), and Terraria.ModLoader.ModPlayer.Name.

+ Here is the call graph for this function:

◆ AutoloadPrefix()

void Terraria.ModLoader.Mod.AutoloadPrefix ( Type  type)
private

Definition at line 369 of file ModInternals.cs.

369 {
370 ModPrefix prefix = (ModPrefix)Activator.CreateInstance(type);
371 prefix.mod = this;
372 string name = type.Name;
373 if (prefix.Autoload(ref name)) {
374 AddPrefix(name, prefix);
375 }
376 }
void AddPrefix(string name, ModPrefix prefix)
Adds a prefix to your mod with the specified internal name. This method should be called in Load....
Definition: Mod.cs:431

References Terraria.ModLoader.Mod.AddPrefix(), Terraria.ModLoader.ModPrefix.Autoload(), and Terraria.ModLoader.ModPrefix.Name.

+ Here is the call graph for this function:

◆ AutoloadProjectile()

void Terraria.ModLoader.Mod.AutoloadProjectile ( Type  type)
private

Definition at line 435 of file ModInternals.cs.

435 {
436 ModProjectile projectile = (ModProjectile)Activator.CreateInstance(type);
437 projectile.mod = this;
438 string name = type.Name;
439 if (projectile.Autoload(ref name)) {
440 AddProjectile(name, projectile);
441 }
442 }
void AddProjectile(string name, ModProjectile projectile)
Adds a type of projectile to the game with the specified name.
Definition: Mod.cs:740

References Terraria.ModLoader.Mod.AddProjectile(), Terraria.ModLoader.ModProjectile.Autoload(), and Terraria.ModLoader.ModProjectile.Name.

+ Here is the call graph for this function:

◆ AutoloadSounds()

void Terraria.ModLoader.Mod.AutoloadSounds ( IList< Type >  modSounds)
private

Definition at line 598 of file ModInternals.cs.

598 {
599 var modSoundNames = modSounds.ToDictionary(t => t.Namespace + "." + t.Name);
600 foreach (var sound in sounds.Keys.Where(t => t.StartsWith("Sounds/"))) {
601 string substring = sound.Substring("Sounds/".Length);
602 SoundType soundType = SoundType.Custom;
603 if (substring.StartsWith("Item/")) {
604 soundType = SoundType.Item;
605 }
606 else if (substring.StartsWith("NPCHit/")) {
607 soundType = SoundType.NPCHit;
608 }
609 else if (substring.StartsWith("NPCKilled/")) {
610 soundType = SoundType.NPCKilled;
611 }
612 ModSound modSound = null;
613 Type t;
614 if (modSoundNames.TryGetValue((Name + '/' + sound).Replace('/', '.'), out t))
615 modSound = (ModSound)Activator.CreateInstance(t);
616
617 AddSound(soundType, Name + '/' + sound, modSound);
618 }
619 foreach (var music in musics.Keys.Where(t => t.StartsWith("Sounds/"))) {
620 string substring = music.Substring("Sounds/".Length);
621 if (substring.StartsWith("Music/")) {
622 AddSound(SoundType.Music, Name + '/' + music);
623 }
624 }
625 }
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...
Definition: Mod.cs:1362

References Terraria.ModLoader.Mod.AddSound(), and Terraria.ModLoader.Mod.Name.

+ Here is the call graph for this function:

◆ AutoloadSurfaceBgStyle()

void Terraria.ModLoader.Mod.AutoloadSurfaceBgStyle ( Type  type)
private

Definition at line 547 of file ModInternals.cs.

547 {
548 ModSurfaceBgStyle surfaceBgStyle = (ModSurfaceBgStyle)Activator.CreateInstance(type);
549 surfaceBgStyle.mod = this;
550 string name = type.Name;
551 if (surfaceBgStyle.Autoload(ref name)) {
552 AddSurfaceBgStyle(name, surfaceBgStyle);
553 }
554 }
void AddSurfaceBgStyle(string name, ModSurfaceBgStyle surfaceBgStyle)
Adds the given surface background style with the given name to this mod.
Definition: Mod.cs:1195

References Terraria.ModLoader.Mod.AddSurfaceBgStyle(), Terraria.ModLoader.ModSurfaceBgStyle.Autoload(), and Terraria.ModLoader.ModSurfaceBgStyle.Name.

+ Here is the call graph for this function:

◆ AutoloadTile()

void Terraria.ModLoader.Mod.AutoloadTile ( Type  type)
private

Definition at line 388 of file ModInternals.cs.

388 {
389 ModTile tile = (ModTile)Activator.CreateInstance(type);
390 tile.mod = this;
391 string name = type.Name;
392 string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
393 if (tile.Autoload(ref name, ref texture)) {
394 AddTile(name, tile, texture);
395 }
396 }
void AddTile(string name, ModTile tile, string texture)
Adds a type of tile to the game with the specified name and texture.
Definition: Mod.cs:535

References Terraria.ModLoader.Mod.AddTile(), Terraria.ModLoader.ModTile.Autoload(), and Terraria.ModLoader.ModTile.Name.

+ Here is the call graph for this function:

◆ AutoloadTileEntity()

void Terraria.ModLoader.Mod.AutoloadTileEntity ( Type  type)
private

Definition at line 407 of file ModInternals.cs.

407 {
408 ModTileEntity tileEntity = (ModTileEntity)Activator.CreateInstance(type);
409 tileEntity.mod = this;
410 string name = type.Name;
411 if (tileEntity.Autoload(ref name)) {
412 AddTileEntity(name, tileEntity);
413 }
414 }
void AddTileEntity(string name, ModTileEntity entity)
Manually add a tile entity during Load.
Definition: Mod.cs:617

References Terraria.ModLoader.Mod.AddTileEntity(), Terraria.ModLoader.ModTileEntity.Autoload(), and Terraria.ModLoader.ModTileEntity.Name.

+ Here is the call graph for this function:

◆ AutoloadUgBgStyle()

void Terraria.ModLoader.Mod.AutoloadUgBgStyle ( Type  type)
private

Definition at line 538 of file ModInternals.cs.

538 {
539 ModUgBgStyle ugBgStyle = (ModUgBgStyle)Activator.CreateInstance(type);
540 ugBgStyle.mod = this;
541 string name = type.Name;
542 if (ugBgStyle.Autoload(ref name)) {
543 AddUgBgStyle(name, ugBgStyle);
544 }
545 }
void AddUgBgStyle(string name, ModUgBgStyle ugBgStyle)
Adds the given underground background style with the given name to this mod.
Definition: Mod.cs:1167

References Terraria.ModLoader.Mod.AddUgBgStyle(), Terraria.ModLoader.ModUgBgStyle.Autoload(), and Terraria.ModLoader.ModUgBgStyle.Name.

+ Here is the call graph for this function:

◆ AutoloadWall()

void Terraria.ModLoader.Mod.AutoloadWall ( Type  type)
private

Definition at line 416 of file ModInternals.cs.

416 {
417 ModWall wall = (ModWall)Activator.CreateInstance(type);
418 wall.mod = this;
419 string name = type.Name;
420 string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
421 if (wall.Autoload(ref name, ref texture)) {
422 AddWall(name, wall, texture);
423 }
424 }
void AddWall(string name, ModWall wall, string texture)
Adds a type of wall to the game with the specified name and texture.
Definition: Mod.cs:669

References Terraria.ModLoader.Mod.AddWall(), Terraria.ModLoader.ModWall.Autoload(), and Terraria.ModLoader.ModWall.Name.

+ Here is the call graph for this function:

◆ AutoloadWaterfallStyle()

void Terraria.ModLoader.Mod.AutoloadWaterfallStyle ( Type  type)
private

Definition at line 576 of file ModInternals.cs.

576 {
577 ModWaterfallStyle waterfallStyle = (ModWaterfallStyle)Activator.CreateInstance(type);
578 waterfallStyle.mod = this;
579 string name = type.Name;
580 string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
581 if (waterfallStyle.Autoload(ref name, ref texture)) {
582 AddWaterfallStyle(name, waterfallStyle, texture);
583 }
584 }
void AddWaterfallStyle(string name, ModWaterfallStyle waterfallStyle, string texture)
Adds the given waterfall style to the game with the given name and texture path.
Definition: Mod.cs:1292

References Terraria.ModLoader.Mod.AddWaterfallStyle(), Terraria.ModLoader.ModWaterfallStyle.Autoload(), and Terraria.ModLoader.ModWaterfallStyle.Name.

+ Here is the call graph for this function:

◆ AutoloadWaterStyle()

void Terraria.ModLoader.Mod.AutoloadWaterStyle ( Type  type)
private

Definition at line 565 of file ModInternals.cs.

565 {
566 ModWaterStyle waterStyle = (ModWaterStyle)Activator.CreateInstance(type);
567 waterStyle.mod = this;
568 string name = type.Name;
569 string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
570 string blockTexture = texture + "_Block";
571 if (waterStyle.Autoload(ref name, ref texture, ref blockTexture)) {
572 AddWaterStyle(name, waterStyle, texture, blockTexture);
573 }
574 }
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.
Definition: Mod.cs:1261

References Terraria.ModLoader.Mod.AddWaterStyle(), Terraria.ModLoader.ModWaterStyle.Autoload(), and Terraria.ModLoader.ModWaterStyle.Name.

+ Here is the call graph for this function:

◆ BuffType()

int Terraria.ModLoader.Mod.BuffType ( string  name)

Gets the type of the ModBuff of this mod corresponding to the given name. Returns 0 if no ModBuff with the given name is found.

Parameters
nameThe name.
Returns

◆ BuffType< T >()

Same as the other BuffType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModBuff 
T :ModContent.BuffType<T>() 

◆ Call()

virtual object Terraria.ModLoader.Mod.Call ( params object[]  args)
virtual

Used for weak inter-mod communication. This allows you to interact with other mods without having to reference their types or namespaces, provided that they have implemented this method.

Definition at line 1683 of file Mod.cs.

1683 {
1684 return null;
1685 }

◆ Close()

virtual void Terraria.ModLoader.Mod.Close ( )
virtual

Close is called before Unload, and may be called at any time when mod unloading is imminent (such as when downloading an update, or recompiling) Use this to release any additional file handles, or stop streaming music. Make sure to call base.Close() at the end May be called multiple times before Unload

Definition at line 136 of file Mod.cs.

136 {
137 fileHandle?.Dispose();
138 if (File != null && File.IsOpen)
139 throw new IOException($"TModFile has open handles: {File.path}");
140 }
IDisposable fileHandle
Definition: Mod.cs:65

References Terraria.ModLoader.Mod.fileHandle.

◆ CreateTranslation()

ModTranslation Terraria.ModLoader.Mod.CreateTranslation ( string  key)

Creates a ModTranslation object that you can use in AddTranslation.

Parameters
keyThe key for the ModTranslation. The full key will be Mods.ModName.key

Referenced by Terraria.ModLoader.Mod.AutoloadLocalization().

+ Here is the caller graph for this function:

◆ DustType()

int Terraria.ModLoader.Mod.DustType ( string  name)

Gets the type of the ModDust of this mod with the given name. Returns 0 if no ModDust with the given name is found.

Parameters
nameThe name.
Returns

◆ DustType< T >()

Same as the other DustType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModDust 
T :ModContent.DustType<T>() 

◆ EffectExists()

bool Terraria.ModLoader.Mod.EffectExists ( string  name)

Used to check if a custom Effect exists

◆ FileExists()

bool Terraria.ModLoader.Mod.FileExists ( string  name)

Shorthand for calling ModLoader.FileExists(this.FileName(name)). Note that file extensions are used here.

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.ModContent.FileExists().

+ Here is the caller graph for this function:

◆ FontExists()

bool Terraria.ModLoader.Mod.FontExists ( string  name)

Used to check if a custom SpriteFont exists

◆ GetAccessorySlot()

sbyte Terraria.ModLoader.Mod.GetAccessorySlot ( string  name,
EquipType  type 
)

Same as GetEquipSlot, except returns the number as an sbyte (signed byte) for your convenience.

Parameters
nameThe name.
type
Returns

◆ GetBackgroundSlot()

int Terraria.ModLoader.Mod.GetBackgroundSlot ( string  name)

Gets the texture slot corresponding to the specified texture name. Shorthand for calling BackgroundTextureLoader.GetBackgroundSlot(this.Name + '/' + name).

Parameters
nameThe name.
Returns

◆ GetBuff()

ModBuff Terraria.ModLoader.Mod.GetBuff ( string  name)

Gets the ModBuff of this mod corresponding to the given name. Returns null if no ModBuff with the given name is found.

Parameters
nameThe name.
Returns

◆ GetBuff< T >()

Type Constraints
T :ModBuff 
T :ModContent.GetInstance<T>() 

◆ GetConfig()

ModConfig Terraria.ModLoader.Mod.GetConfig ( string  name)

Definition at line 1707 of file Mod.cs.

1708 {
1709 List<ModConfig> configs;
1710 if (ConfigManager.Configs.TryGetValue(this, out configs))
1711 {
1712 return configs.Single(x => x.Name == name);
1713 }
1714 return null;
1715 }

◆ GetConfig< T >()

Type Constraints
T :ModConfig 
T :T 
T :GetConfig 
T :typeof 
T :T 
T :Name 

◆ GetDust()

ModDust Terraria.ModLoader.Mod.GetDust ( string  name)

Gets the ModDust of this mod corresponding to the given name. Returns null if no ModDust with the given name is found.

Parameters
nameThe name.
Returns

◆ GetDust< T >()

Same as the other GetDust, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModDust 
T :ModContent.GetInstance<T>() 

◆ GetEffect()

Effect Terraria.ModLoader.Mod.GetEffect ( string  name)

Gets an Effect loaded from the specified path.

Exceptions
MissingResourceException

Definition at line 1668 of file Mod.cs.

1668 {
1669 if (!effects.TryGetValue(name, out var effect))
1670 throw new MissingResourceException(name);
1671
1672 return effect;
1673 }

◆ GetEquipSlot()

int Terraria.ModLoader.Mod.GetEquipSlot ( string  name,
EquipType  type 
)

Gets the slot/ID of the equipment texture corresponding to the given name. Returns -1 if no EquipTexture with the given name is found.

Parameters
nameThe name.
type
Returns

◆ GetEquipTexture()

EquipTexture Terraria.ModLoader.Mod.GetEquipTexture ( string  name,
EquipType  type 
)

Gets the EquipTexture instance corresponding to the name and EquipType. Returns null if no EquipTexture with the given name and EquipType is found.

Parameters
nameThe name.
typeThe type.
Returns

◆ GetFileBytes()

byte[] Terraria.ModLoader.Mod.GetFileBytes ( string  name)

Retrieve contents of files within the tmod file

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.ModContent.GetFileBytes().

+ Here is the caller graph for this function:

◆ GetFileStream()

Stream Terraria.ModLoader.Mod.GetFileStream ( string  name,
bool  newFileStream = false 
)

Retrieve contents of files within the tmod file

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.ModContent.OpenRead().

+ Here is the caller graph for this function:

◆ GetFont()

DynamicSpriteFont Terraria.ModLoader.Mod.GetFont ( string  name)

Gets a SpriteFont loaded from the specified path.

Exceptions
MissingResourceException

Definition at line 1652 of file Mod.cs.

1652 {
1653 if (!fonts.TryGetValue(name, out var font))
1654 throw new MissingResourceException(name);
1655
1656 return font;
1657 }

◆ GetGlobalBgStyle()

GlobalBgStyle Terraria.ModLoader.Mod.GetGlobalBgStyle ( string  name)

Returns the global background style corresponding to the given name.

Parameters
nameThe name.
Returns

◆ GetGlobalBgStyle< T >()

Type Constraints
T :GlobalBgStyle 
T :ModContent.GetInstance<T>() 

◆ GetGlobalBuff()

GlobalBuff Terraria.ModLoader.Mod.GetGlobalBuff ( string  name)

Gets the GlobalBuff with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetGlobalBuff< T >()

Type Constraints
T :GlobalBuff 
T :ModContent.GetInstance<T>() 

◆ GetGlobalItem()

GlobalItem Terraria.ModLoader.Mod.GetGlobalItem ( string  name)

Gets the GlobalItem instance with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetGlobalItem< T >()

Same as the other GetGlobalItem, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :GlobalItem 
T :T 
T :GetGlobalItem 
T :typeof 
T :T 
T :Name 

◆ GetGlobalNPC()

GlobalNPC Terraria.ModLoader.Mod.GetGlobalNPC ( string  name)

Gets the GlobalNPC instance with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetGlobalNPC< T >()

Type Constraints
T :GlobalNPC 
T :ModContent.GetInstance<T>() 

◆ GetGlobalProjectile()

GlobalProjectile Terraria.ModLoader.Mod.GetGlobalProjectile ( string  name)

Gets the GlobalProjectile instance with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetGlobalProjectile< T >()

Type Constraints
T :GlobalProjectile 
T :ModContent.GetInstance<T>() 

◆ GetGlobalRecipe()

GlobalRecipe Terraria.ModLoader.Mod.GetGlobalRecipe ( string  name)

Gets the global recipe corresponding to the specified name.

Parameters
nameThe name.
Returns

◆ GetGlobalRecipe< T >()

Type Constraints
T :GlobalRecipe 
T :ModContent.GetInstance<T>() 

◆ GetGlobalTile()

GlobalTile Terraria.ModLoader.Mod.GetGlobalTile ( string  name)

Gets the GlobalTile instance with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetGlobalTile< T >()

Same as the other GetGlobalTile, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :GlobalTile 
T :ModContent.GetInstance<T>() 

◆ GetGlobalWall()

GlobalWall Terraria.ModLoader.Mod.GetGlobalWall ( string  name)

Gets the GlobalWall instance with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetGlobalWall< T >()

Type Constraints
T :GlobalWall 
T :ModContent.GetInstance<T>() 

◆ GetGoreSlot()

int Terraria.ModLoader.Mod.GetGoreSlot ( string  name)

Shorthand for calling ModGore.GetGoreSlot(this.Name + '/' + name).

Parameters
nameThe name.
Returns

◆ GetGoreSlot< T >()

Same as the other GetGoreSlot, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModGore 
T :GetGoreSlot 
T :typeof 
T :T 
T :Name 

◆ GetItem()

ModItem Terraria.ModLoader.Mod.GetItem ( string  name)

Gets the ModItem instance corresponding to the name. Because this method is in the Mod class, conflicts between mods are avoided. Returns null if no ModItem with the given name is found.

Parameters
nameThe name.
Returns

◆ GetItem< T >()

Same as the other GetItem, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModItem 
T :ModContent.GetInstance<T>() 

◆ GetLegacySoundSlot()

LegacySoundStyle Terraria.ModLoader.Mod.GetLegacySoundSlot ( SoundType  type,
string  name 
)

Shorthand for calling SoundLoader.GetLegacySoundSlot(type, this.Name + '/' + name).

Parameters
typeThe type.
nameThe name.
Returns

◆ GetModWorld()

ModWorld Terraria.ModLoader.Mod.GetModWorld ( string  name)

Gets the ModWorld instance with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetModWorld< T >()

Same as the other GetModWorld, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModWorld 
T :ModContent.GetInstance<T>() 

◆ GetMount()

ModMountData Terraria.ModLoader.Mod.GetMount ( string  name)

Gets the ModMountData instance of this mod corresponding to the given name. Returns null if no ModMountData has the given name.

Parameters
nameThe name.
Returns

◆ GetMount< T >()

Type Constraints
T :ModMountData 
T :ModContent.GetInstance<T>() 

◆ GetMusic()

Music Terraria.ModLoader.Mod.GetMusic ( string  name)

Shorthand for calling ModContent.GetMusic(this.FileName(name)).

Parameters
nameThe name.
Returns
Exceptions
MissingResourceException

Definition at line 1634 of file Mod.cs.

1634 {
1635 if (!musics.TryGetValue(name, out var music))
1636 throw new MissingResourceException(name);
1637
1638 return music;
1639 }

Referenced by Terraria.ModLoader.ModContent.GetMusic().

+ Here is the caller graph for this function:

◆ GetNPC()

ModNPC Terraria.ModLoader.Mod.GetNPC ( string  name)

Gets the ModNPC of this mod corresponding to the given name. Returns null if no ModNPC with the given name is found.

Parameters
nameThe name.
Returns

◆ GetNPC< T >()

Type Constraints
T :ModNPC 
T :ModContent.GetInstance<T>() 

◆ GetPacket()

ModPacket Terraria.ModLoader.Mod.GetPacket ( int  capacity = 256)

Creates a ModPacket object that you can write to and then send between servers and clients.

Parameters
capacityThe capacity.
Returns
Exceptions
System.ExceptionCannot get packet for " + Name + " because it does not exist on the other side

Definition at line 1693 of file Mod.cs.

1693 {
1694 if (netID < 0)
1695 throw new Exception("Cannot get packet for " + Name + " because it does not exist on the other side");
1696
1697 var p = new ModPacket(MessageID.ModPacket, capacity + 5);
1698 if (ModNet.NetModCount < 256)
1699 p.Write((byte)netID);
1700 else
1701 p.Write(netID);
1702
1703 p.netID = netID;
1704 return p;
1705 }

References Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ModNet.NetModCount.

◆ GetPlayer()

ModPlayer Terraria.ModLoader.Mod.GetPlayer ( string  name)

Gets the ModPlayer of this mod corresponding to the given name. Returns null if no ModPlayer with the given name is found.

Parameters
nameThe name.
Returns

◆ GetPlayer< T >()

Type Constraints
T :ModPlayer 
T :ModContent.GetInstance<T>() 

◆ GetPrefix()

ModPrefix Terraria.ModLoader.Mod.GetPrefix ( string  name)

Gets the ModPrefix instance corresponding to the name. Because this method is in the Mod class, conflicts between mods are avoided. Returns null if no ModPrefix with the given name is found.

Parameters
nameThe name.
Returns

◆ GetPrefix< T >()

Same as the other GetPrefix, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModPrefix 
T :ModContent.GetInstance<T>() 

◆ GetProjectile()

ModProjectile Terraria.ModLoader.Mod.GetProjectile ( string  name)

Gets the ModProjectile of this mod corresponding to the given name. Returns null if no ModProjectile with the given name is found.

Parameters
nameThe name.
Returns

◆ GetProjectile< T >()

Type Constraints
T :ModProjectile 
T :ModContent.GetInstance<T>() 

◆ GetSound()

SoundEffect Terraria.ModLoader.Mod.GetSound ( string  name)

Shorthand for calling ModContent.GetSound(this.FileName(name)).

Parameters
nameThe name.
Returns
Exceptions
MissingResourceException

Definition at line 1614 of file Mod.cs.

1614 {
1615 if (!sounds.TryGetValue(name, out var sound))
1616 throw new MissingResourceException(name);
1617
1618 return sound;
1619 }

Referenced by Terraria.ModLoader.ModContent.GetSound().

+ Here is the caller graph for this function:

◆ GetSoundSlot()

int Terraria.ModLoader.Mod.GetSoundSlot ( SoundType  type,
string  name 
)

Shorthand for calling SoundLoader.GetSoundSlot(type, this.Name + '/' + name).

Parameters
typeThe type.
nameThe name.
Returns

◆ GetSurfaceBgStyle()

ModSurfaceBgStyle Terraria.ModLoader.Mod.GetSurfaceBgStyle ( string  name)

Returns the surface background style corresponding to the given name.

Parameters
nameThe name.
Returns

◆ GetSurfaceBgStyle< T >()

Type Constraints
T :ModSurfaceBgStyle 
T :ModContent.GetInstance<T>() 

◆ GetSurfaceBgStyleSlot()

int Terraria.ModLoader.Mod.GetSurfaceBgStyleSlot ( string  name)

Returns the Slot of the surface background style corresponding to the given name.

Parameters
nameThe name.
Returns

◆ GetSurfaceBgStyleSlot< T >()

Type Constraints
T :ModSurfaceBgStyle 
T :GetSurfaceBgStyleSlot 
T :typeof 
T :T 
T :Name 

◆ GetTexture()

Texture2D Terraria.ModLoader.Mod.GetTexture ( string  name)

Shorthand for calling ModContent.GetTexture(this.FileName(name)).

Exceptions
MissingResourceException

Definition at line 1578 of file Mod.cs.

1578 {
1579 if (!textures.TryGetValue(name, out var t))
1580 throw new MissingResourceException(name, textures.Keys);
1581
1582 return t;
1583 }

◆ GetTile()

ModTile Terraria.ModLoader.Mod.GetTile ( string  name)

Gets the ModTile of this mod corresponding to the given name. Returns null if no ModTile with the given name is found.

Parameters
nameThe name.
Returns

◆ GetTile< T >()

Same as the other GetTile, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModTile 
T :ModContent.GetInstance<T>() 

◆ GetTileEntity()

ModTileEntity Terraria.ModLoader.Mod.GetTileEntity ( string  name)

Gets the ModTileEntity of this mod corresponding to the given name. Returns null if no ModTileEntity with the given name is found.

Parameters
nameThe name.
Returns

◆ GetTileEntity< T >()

Same as the other GetTileEntity, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModTileEntity 
T :ModContent.GetInstance<T>() 

◆ GetUgBgStyle()

ModUgBgStyle Terraria.ModLoader.Mod.GetUgBgStyle ( string  name)

Returns the underground background style corresponding to the given name.

Parameters
nameThe name.
Returns

◆ GetUgBgStyle< T >()

Type Constraints
T :ModUgBgStyle 
T :ModContent.GetInstance<T>() 

◆ GetWall()

ModWall Terraria.ModLoader.Mod.GetWall ( string  name)

Gets the ModWall of this mod corresponding to the given name. Returns null if no ModWall with the given name is found.

Parameters
nameThe name.
Returns

◆ GetWall< T >()

Type Constraints
T :ModWall 
T :ModContent.GetInstance<T>() 

◆ GetWaterfallStyle()

ModWaterfallStyle Terraria.ModLoader.Mod.GetWaterfallStyle ( string  name)

Returns the waterfall style with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetWaterfallStyle< T >()

Type Constraints
T :ModWaterfallStyle 
T :ModContent.GetInstance<T>() 

◆ GetWaterfallStyleSlot()

int Terraria.ModLoader.Mod.GetWaterfallStyleSlot ( string  name)

Returns the waterfall style corresponding to the given name.

Parameters
nameThe name.
Returns

◆ GetWaterfallStyleSlot< T >()

Type Constraints
T :ModWaterfallStyle 
T :GetWaterfallStyleSlot 
T :typeof 
T :T 
T :Name 

◆ GetWaterStyle()

ModWaterStyle Terraria.ModLoader.Mod.GetWaterStyle ( string  name)

Returns the water style with the given name from this mod.

Parameters
nameThe name.
Returns

◆ GetWaterStyle< T >()

Type Constraints
T :ModWaterStyle 
T :ModContent.GetInstance<T>() 

◆ HandlePacket()

virtual void Terraria.ModLoader.Mod.HandlePacket ( BinaryReader  reader,
int  whoAmI 
)
virtual

Called whenever a net message / packet is received from a client (if this is a server) or the server (if this is a client). whoAmI is the ID of whomever sent the packet (equivalent to the Main.myPlayer of the sender), and reader is used to read the binary data of the packet.

Parameters
readerThe reader.
whoAmIThe player the message is from.

Definition at line 44 of file ModHooks.cs.

44 {
45 }

◆ HijackGetData()

virtual bool Terraria.ModLoader.Mod.HijackGetData ( ref byte  messageType,
ref BinaryReader  reader,
int  playerNumber 
)
virtual

Allows you to modify net message / packet information that is received before the game can act on it.

Parameters
messageTypeType of the message.
readerThe reader.
playerNumberThe player number the message is from.
Returns

Definition at line 54 of file ModHooks.cs.

54 {
55 return false;
56 }

◆ HijackSendData()

virtual bool Terraria.ModLoader.Mod.HijackSendData ( int  whoAmI,
int  msgType,
int  remoteClient,
int  ignoreClient,
NetworkText  text,
int  number,
float  number2,
float  number3,
float  number4,
int  number5,
int  number6,
int  number7 
)
virtual

Hijacks the send data method. Only use if you absolutely know what you are doing. If any hooks return true, the message is not sent.

Definition at line 61 of file ModHooks.cs.

61 {
62 return false;
63 }

◆ HotKeyPressed()

virtual void Terraria.ModLoader.Mod.HotKeyPressed ( string  name)
virtual

Called when a hotkey is pressed. Check against the name to verify particular hotkey that was pressed. (Using the ModHotKey is more recommended.)

Parameters
nameThe display name of the hotkey.

Definition at line 36 of file ModHooks.cs.

36 {
37 }

◆ ItemType()

int Terraria.ModLoader.Mod.ItemType ( string  name)

Gets the internal ID / type of the ModItem corresponding to the name. Returns 0 if no ModItem with the given name is found.

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.ModRecipe.AddIngredient(), Terraria.ModLoader.IO.ItemIO.Load(), Terraria.ModLoader.IO.ItemIO.LoadLegacy(), and Terraria.ModLoader.ModRecipe.SetResult().

+ Here is the caller graph for this function:

◆ ItemType< T >()

Same as the other ItemType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModItem 
T :ModContent.ItemType<T>() 

◆ Load()

virtual void Terraria.ModLoader.Mod.Load ( )
virtual

Override this method to add most of your content to your mod. Here you will call other methods such as AddItem. This is guaranteed to be called after all content has been autoloaded.

Definition at line 71 of file Mod.cs.

71 {
72 }

◆ LoadMusic()

Music Terraria.ModLoader.Mod.LoadMusic ( string  path,
string  extension 
)
private

Definition at line 109 of file ModInternals.cs.

109 {
110 path = "tmod:"+Name+'/'+path+extension;
111 switch (extension) {
112 case ".wav": return new MusicStreamingWAV(path);
113 case ".mp3": return new MusicStreamingMP3(path);
114 case ".ogg": return new MusicStreamingOGG(path);
115 }
116 throw new ResourceLoadException("Unknown music extension "+extension);
117 }

References Terraria.ModLoader.Mod.Name.

Referenced by Terraria.ModLoader.Mod.LoadResource().

+ Here is the caller graph for this function:

◆ LoadResource()

virtual bool Terraria.ModLoader.Mod.LoadResource ( string  path,
int  length,
Func< Stream >  getStream 
)
virtual

Hook for pre-loading resources

Parameters
pathThe path of the resource within the tmod
lengthThe length of the uncompressed resource
getStreamA function which returns a stream containing the file content
Returns
true if the file will no-longer be needed and should not be cached

Definition at line 149 of file Mod.cs.

149 {
150 if (tModLoaderVersion < new Version(0, 11) && LoadResourceLegacy(path, length, getStream)) // TODO LoadResourceLegacy is marked obsolete
151 return false;
152
153 string extension = Path.GetExtension(path).ToLower();
154 path = Path.ChangeExtension(path, null);
155 switch (extension) {
156 case ".png":
157 case ".rawimg":
158 if (!Main.dedServ)
159 LoadTexture(path, getStream(), extension == ".rawimg");
160 return true;
161 case ".wav":
162 case ".mp3":
163 case ".ogg":
164 //Main.engine == null would be more sensible, but only the waveBank fails on Linux when there is no audio hardware
165 if (Main.dedServ || Main.waveBank == null) { }
166 else if (path.Contains("Music/"))
167 musics[path] = LoadMusic(path, extension);
168 else
169 sounds[path] = LoadSound(getStream(), length, extension);
170 return true;
171 case ".xnb":
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);
177 else
178 throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorUnknownXNBFileHint", path));
179 return true;
180 }
181
182 return false;
183 }
virtual Version Version
This version number of this mod.
Definition: Mod.cs:50
Version tModLoaderVersion
The version of tModLoader that was being used when this mod was built.
Definition: Mod.cs:46
void LoadTexture(string path, Stream stream, bool rawimg)
Definition: ModInternals.cs:60
Music LoadMusic(string path, string extension)
SoundEffect LoadSound(Stream stream, int length, string extension)
Definition: ModInternals.cs:85
bool LoadResourceLegacy(string path, int length, Func< Stream > getStream)
Definition: Mod.cs:186

References Terraria.ModLoader.Mod.LoadMusic(), Terraria.ModLoader.Mod.LoadResourceLegacy(), Terraria.ModLoader.Mod.LoadSound(), Terraria.ModLoader.Mod.LoadTexture(), Terraria.ModLoader.Mod.Name, Terraria.ModLoader.Mod.tModLoaderVersion, and Terraria.ModLoader.Mod.Version.

Referenced by Terraria.ModLoader.Mod.LoadResources().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadResourceFromStream()

virtual void Terraria.ModLoader.Mod.LoadResourceFromStream ( string  path,
int  len,
BinaryReader  reader 
)
virtual

Definition at line 194 of file Mod.cs.

194 {
195 }

Referenced by Terraria.ModLoader.Mod.LoadResourceLegacy().

+ Here is the caller graph for this function:

◆ LoadResourceLegacy()

bool Terraria.ModLoader.Mod.LoadResourceLegacy ( string  path,
int  length,
Func< Stream >  getStream 
)
private

Definition at line 186 of file Mod.cs.

186 {
187 using (var stream = getStream()) {
188 LoadResourceFromStream(path, length, new BinaryReader(stream));
189 return stream.Position > 0;
190 }
191 }
virtual void LoadResourceFromStream(string path, int len, BinaryReader reader)
Definition: Mod.cs:194

References Terraria.ModLoader.Mod.LoadResourceFromStream().

Referenced by Terraria.ModLoader.Mod.LoadResource().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadResources()

virtual void Terraria.ModLoader.Mod.LoadResources ( )
virtual

Definition at line 109 of file Mod.cs.

109 {
110 if (File == null)
111 return;
112
113 fileHandle = File.Open();
114
115 var skipCache = new HashSet<string>();
116 foreach (var entry in File) {
117 Interface.loadMods.SubProgressText = entry.Name;
118
119 Stream _stream = null;
120 Stream GetStream() => _stream = File.GetStream(entry);
121
122 if (LoadResource(entry.Name, entry.Length, GetStream))
123 skipCache.Add(entry.Name);
124
125 _stream?.Dispose();
126 }
127 File.CacheFiles(skipCache);
128 }
virtual bool LoadResource(string path, int length, Func< Stream > getStream)
Hook for pre-loading resources
Definition: Mod.cs:149

References Terraria.ModLoader.Mod.fileHandle, and Terraria.ModLoader.Mod.LoadResource().

+ Here is the call graph for this function:

◆ LoadSound()

SoundEffect Terraria.ModLoader.Mod.LoadSound ( Stream  stream,
int  length,
string  extension 
)
private

Definition at line 85 of file ModInternals.cs.

85 {
86 switch (extension) {
87 case ".wav":
88 if (!stream.CanSeek)
89 stream = new MemoryStream(stream.ReadBytes(length));
90 return SoundEffect.FromStream(stream);
91 case ".mp3":
92 using (var mp3Stream = new MP3Stream(stream))
93 using (var ms = new MemoryStream()) {
94 mp3Stream.CopyTo(ms);
95 return new SoundEffect(ms.ToArray(), mp3Stream.Frequency, (AudioChannels)mp3Stream.ChannelCount);
96 }
97 case ".ogg":
98 using (var reader = new VorbisReader(stream, true)) {
99 var buffer = new byte[reader.TotalSamples * 2 * reader.Channels];
100 var floatBuf = new float[buffer.Length / 2];
101 reader.ReadSamples(floatBuf, 0, floatBuf.Length);
102 MusicStreamingOGG.Convert(floatBuf, buffer);
103 return new SoundEffect(buffer, reader.SampleRate, (AudioChannels)reader.Channels);
104 }
105 }
106 throw new ResourceLoadException("Unknown sound extension "+extension);
107 }
static void Convert(float[] floatBuf, byte[] buffer)

References Terraria.ModLoader.Audio.MusicStreamingOGG.Convert().

Referenced by Terraria.ModLoader.Mod.LoadResource().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadTexture()

void Terraria.ModLoader.Mod.LoadTexture ( string  path,
Stream  stream,
bool  rawimg 
)
private

Definition at line 60 of file ModInternals.cs.

60 {
61 try {
62 var texTask = rawimg
63 ? ImageIO.RawToTexture2DAsync(Main.instance.GraphicsDevice, new BinaryReader(stream))
64 : ImageIO.PngToTexture2DAsync(Main.instance.GraphicsDevice, stream);
65
66 AsyncLoadQueue.Enqueue(texTask.ContinueWith(t => {
67 if (t.Exception != null)
68 throw new ResourceLoadException(
69 Language.GetTextValue("tModLoader.LoadErrorTextureFailedToLoad", path), t.Exception);
70
71 var tex = t.Result;
72 tex.Name = Name + "/" + path;
73 lock (textures)
74 textures[path] = tex;
75 }));
76 }
77 catch (Exception e) {
78 throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorTextureFailedToLoad", path), e);
79 }
80 finally {
81 stream.Close();
82 }
83 }
static Task< Texture2D > RawToTexture2DAsync(GraphicsDevice graphicsDevice, BinaryReader r)
Definition: ImageIO.cs:94
static Task< Texture2D > PngToTexture2DAsync(GraphicsDevice graphicsDevice, Stream stream)
Definition: ImageIO.cs:103
readonly Queue< Task > AsyncLoadQueue
Definition: ModInternals.cs:26

References Terraria.ModLoader.Mod.AsyncLoadQueue, Terraria.ModLoader.IO.ImageIO.PngToTexture2DAsync(), and Terraria.ModLoader.IO.ImageIO.RawToTexture2DAsync().

Referenced by Terraria.ModLoader.Mod.LoadResource().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MidUpdateDustTime()

virtual void Terraria.ModLoader.Mod.MidUpdateDustTime ( )
virtual

Called after Dust got updated, but before Time (day/night, events, etc.) gets updated.

If you are looking to hook an earlier part of the update process, see MidUpdateItemDust. If you are looking to hook a later part of the update process, see MidUpdateTimeWorld.

Definition at line 139 of file ModHooks.cs.

139 {
140 }

◆ MidUpdateGoreProjectile()

virtual void Terraria.ModLoader.Mod.MidUpdateGoreProjectile ( )
virtual

Called after Gores got updated, but before any Projectiles get updated.

If you are looking to hook an earlier part of the update process, see MidUpdateNPCGore. If you are looking to hook a later part of the update process, see MidUpdateProjectileItem.

Definition at line 112 of file ModHooks.cs.

112 {
113 }

◆ MidUpdateInvasionNet()

virtual void Terraria.ModLoader.Mod.MidUpdateInvasionNet ( )
virtual

Called after Invasions got updated. The only thing that is updated after this is the Network.

If you are looking to hook an earlier part of the update process, see MidUpdateTimeWorld. If you are looking to hook even after the Network is updated, see PostUpdateEverything.

Definition at line 157 of file ModHooks.cs.

157 {
158 }

◆ MidUpdateItemDust()

virtual void Terraria.ModLoader.Mod.MidUpdateItemDust ( )
virtual

Called after Items got updated, but before any Dust gets updated.

If you are looking to hook an earlier part of the update process, see MidUpdateProjectileItem. If you are looking to hook a later part of the update process, see MidUpdateDustTime.

Definition at line 130 of file ModHooks.cs.

130 {
131 }

◆ MidUpdateNPCGore()

virtual void Terraria.ModLoader.Mod.MidUpdateNPCGore ( )
virtual

Called after NPCs got updated, but before any Gores get updated.

If you are looking to hook an earlier part of the update process, see MidUpdatePlayerNPC. If you are looking to hook a later part of the update process, see MidUpdateGoreProjectile.

Definition at line 103 of file ModHooks.cs.

103 {
104 }

◆ MidUpdatePlayerNPC()

virtual void Terraria.ModLoader.Mod.MidUpdatePlayerNPC ( )
virtual

Called after Players got updated, but before any NPCs get updated.

If you are looking to hook an earlier part of the update process, see PreUpdateEntities. If you are looking to hook a later part of the update process, see MidUpdateNPCGore.

Definition at line 94 of file ModHooks.cs.

94 {
95 }

◆ MidUpdateProjectileItem()

virtual void Terraria.ModLoader.Mod.MidUpdateProjectileItem ( )
virtual

Gets called immediately after all Projectiles are updated, but before any Items get updated.

If you are looking to hook an earlier part of the update process, see MidUpdateGoreProjectile. If you are looking to hook a later part of the update process, see MidUpdateItemDust.

Definition at line 121 of file ModHooks.cs.

121 {
122 }

◆ MidUpdateTimeWorld()

virtual void Terraria.ModLoader.Mod.MidUpdateTimeWorld ( )
virtual

Called after Time got updated, but before the World gets updated.

If you are looking to hook an earlier part of the update process, see MidUpdateDustTime. If you are looking to hook a later part of the update process, see MidUpdateInvasionNet.

Definition at line 148 of file ModHooks.cs.

148 {
149 }

◆ ModifyInterfaceLayers()

virtual void Terraria.ModLoader.Mod.ModifyInterfaceLayers ( List< GameInterfaceLayer >  layers)
virtual

Allows you to modify the elements of the in-game interface that get drawn. GameInterfaceLayer can be found in the Terraria.UI namespace. Check https://github.com/tModLoader/tModLoader/wiki/Vanilla-Interface-layers-values for vanilla interface layer names

Parameters
layersThe layers.

Definition at line 172 of file ModHooks.cs.

172 {
173 }

◆ ModifyLightingBrightness()

virtual void Terraria.ModLoader.Mod.ModifyLightingBrightness ( ref float  scale)
virtual

Allows you to modify overall brightness of lights. Can be used to create effects similiar to what night vision and darkness (de)buffs give you. Values too high or too low might result in glitches. For night vision effect use scale 1.03

Parameters
scaleBrightness scale

Definition at line 187 of file ModHooks.cs.

187 {
188 }

◆ ModifySunLightColor()

virtual void Terraria.ModLoader.Mod.ModifySunLightColor ( ref Color  tileColor,
ref Color  backgroundColor 
)
virtual

Allows you to modify color of light the sun emits.

Parameters
tileColorTile lighting color
backgroundColorBackground lighting color

Definition at line 180 of file ModHooks.cs.

180 {
181 }

◆ ModifyTransformMatrix()

virtual void Terraria.ModLoader.Mod.ModifyTransformMatrix ( ref SpriteViewMatrix  Transform)
virtual

Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.)

Definition at line 68 of file ModHooks.cs.

68 {
69 }

◆ MountType()

int Terraria.ModLoader.Mod.MountType ( string  name)

Gets the ID of the ModMountData instance corresponding to the given name. Returns 0 if no ModMountData has the given name.

Parameters
nameThe name.
Returns

◆ MountType< T >()

Same as the other MountType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModMountData 
T :ModContent.MountType<T>() 

◆ MusicExists()

bool Terraria.ModLoader.Mod.MusicExists ( string  name)

Shorthand for calling ModLoader.MusicExists(this.FileName(name)).

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.ModContent.MusicExists().

+ Here is the caller graph for this function:

◆ NPCType()

int Terraria.ModLoader.Mod.NPCType ( string  name)

Gets the type of the ModNPC of this mod with the given name. Returns 0 if no ModNPC with the given name is found.

Parameters
nameThe name.
Returns

◆ NPCType< T >()

Same as the other NPCType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModNPC 
T :ModContent.NPCType<T>() 

◆ PostAddRecipes()

virtual void Terraria.ModLoader.Mod.PostAddRecipes ( )
virtual

This provides a hook into the mod-loading process immediately after recipes have been added. You can use this to edit recipes added by other mods.

Definition at line 106 of file Mod.cs.

106 {
107 }

◆ PostDrawFullscreenMap()

virtual void Terraria.ModLoader.Mod.PostDrawFullscreenMap ( ref string  mouseText)
virtual

Called while the fullscreen map is active. Allows custom drawing to the map.

Parameters
mouseTextThe mouse text.

Definition at line 203 of file ModHooks.cs.

203 {
204 }

◆ PostDrawInterface()

virtual void Terraria.ModLoader.Mod.PostDrawInterface ( SpriteBatch  spriteBatch)
virtual

Called after interface is drawn but right before mouse and mouse hover text is drawn. Allows for drawing interface.

Note: This hook should no longer be used. It is better to use the ModifyInterfaceLayers hook.

Parameters
spriteBatchThe sprite batch.

Definition at line 196 of file ModHooks.cs.

196 {
197 }

◆ PostSetupContent()

virtual void Terraria.ModLoader.Mod.PostSetupContent ( )
virtual

Allows you to load things in your mod after its content has been setup (arrays have been resized to fit the content, etc).

Definition at line 77 of file Mod.cs.

77 {
78 }

◆ PostUpdateEverything()

virtual void Terraria.ModLoader.Mod.PostUpdateEverything ( )
virtual

Called after the Network got updated, this is the last hook that happens in an update.

If you are looking to hook an earlier part of the update process, see MidUpdateInvasionNet.

Definition at line 165 of file ModHooks.cs.

165 {
166 }

◆ PostUpdateInput()

virtual void Terraria.ModLoader.Mod.PostUpdateInput ( )
virtual

Called after the input keys are polled. Allows for modifying things like scroll wheel if your custom drawing should capture that.

Definition at line 209 of file ModHooks.cs.

209 {
210 }

◆ PrefixType()

byte Terraria.ModLoader.Mod.PrefixType ( string  name)

Gets the internal ID / type of the ModPrefix corresponding to the name. Returns 0 if no ModPrefix with the given name is found.

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.IO.ItemIO.Load().

+ Here is the caller graph for this function:

◆ PrefixType< T >()

Same as the other PrefixType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModPrefix 
T :ModContent.PrefixType<T>() 

◆ PreSaveAndQuit()

virtual void Terraria.ModLoader.Mod.PreSaveAndQuit ( )
virtual

Called in SP or Client when the Save and Quit button is pressed. One use for this hook is clearing out custom UI slots to return items to the player.

Definition at line 215 of file ModHooks.cs.

215 {
216 }

◆ PreUpdateEntities()

virtual void Terraria.ModLoader.Mod.PreUpdateEntities ( )
virtual

Use this if you want to do something before anything in the World gets updated. Called after UI updates, but before anything in the World (Players, NPCs, Projectiles, Tiles) gets updated.

When Main.autoPause is true or Main.FrameSkipMode is 0 or 2, the game may do a partial update. This means that it only updates menus and some animations, but not the World or Entities. This hook - and every hook after it - only gets called on frames with a full update.

If you are looking to hook a later part of the update process, see MidUpdatePlayerNPC.

Definition at line 85 of file ModHooks.cs.

85 {
86 }

◆ ProjectileType()

int Terraria.ModLoader.Mod.ProjectileType ( string  name)

Gets the type of the ModProjectile of this mod with the given name. Returns 0 if no ModProjectile with the given name is found.

Parameters
nameThe name.
Returns

◆ ProjectileType< T >()

Same as the other ProjectileType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModProjectile 
T :ModContent.ProjectileType<T>() 

◆ RegisterHotKey()

ModHotKey Terraria.ModLoader.Mod.RegisterHotKey ( string  name,
string  defaultKey 
)

Registers a hotkey with a name and defaultKey. Use the returned ModHotKey to detect when buttons are pressed. Do this in a ModPlayer.ProcessTriggers.

Parameters
nameThe name.
defaultKeyThe default key.
Returns

Definition at line 1527 of file Mod.cs.

1527 {
1528 if (!loading)
1529 throw new Exception("RegisterHotKey can only be called from Mod.Load or Mod.Autoload");
1530
1531 return HotKeyLoader.RegisterHotKey(new ModHotKey(this, name, defaultKey));
1532 }

◆ SoundExists()

bool Terraria.ModLoader.Mod.SoundExists ( string  name)

Shorthand for calling ModLoader.SoundExists(this.FileName(name)).

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.ModContent.SoundExists().

+ Here is the caller graph for this function:

◆ TextureExists()

bool Terraria.ModLoader.Mod.TextureExists ( string  name)

Shorthand for calling ModLoader.TextureExists(this.FileName(name)).

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.Mod.AddTexture(), and Terraria.ModLoader.ModContent.TextureExists().

+ Here is the caller graph for this function:

◆ TileEntityType()

int Terraria.ModLoader.Mod.TileEntityType ( string  name)

Gets the type of the ModTileEntity of this mod with the given name. Returns -1 if no ModTileEntity with the given name is found.

Parameters
nameThe name.
Returns

◆ TileEntityType< T >()

Same as the other TileEntityType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModTileEntity 
T :ModContent.TileEntityType<T>() 

◆ TileType()

int Terraria.ModLoader.Mod.TileType ( string  name)

Gets the type of the ModTile of this mod with the given name. Returns 0 if no ModTile with the given name is found.

Parameters
nameThe name.
Returns

Referenced by Terraria.ModLoader.ModRecipe.AddTile().

+ Here is the caller graph for this function:

◆ TileType< T >()

Same as the other TileType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModTile 
T :ModContent.TileType<T>() 

◆ Unload()

virtual void Terraria.ModLoader.Mod.Unload ( )
virtual

This is called whenever this mod is unloaded from the game. Use it to undo changes that you've made in Load that aren't automatically handled (for example, modifying the texture of a vanilla item). Mods are guaranteed to be unloaded in the reverse order they were loaded in.

Definition at line 83 of file Mod.cs.

83 {
84 }

◆ UpdateMusic() [1/2]

virtual void Terraria.ModLoader.Mod.UpdateMusic ( ref int  music)
virtual

A legacy hook that you should no longer use. Use the version with two parameters instead.

Parameters
music

Definition at line 29 of file ModHooks.cs.

29 {
30 }

◆ UpdateMusic() [2/2]

virtual void Terraria.ModLoader.Mod.UpdateMusic ( ref int  music,
ref MusicPriority  priority 
)
virtual

Allows you to determine what music should currently play.

Parameters
musicThe music.
priorityThe music priority.

Definition at line 20 of file ModHooks.cs.

20 {
21 UpdateMusic(ref music);
22 }
virtual void UpdateMusic(ref int music, ref MusicPriority priority)
Allows you to determine what music should currently play.
Definition: ModHooks.cs:20

References Terraria.ModLoader.Mod.UpdateMusic().

Referenced by Terraria.ModLoader.Mod.UpdateMusic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateUI()

virtual void Terraria.ModLoader.Mod.UpdateUI ( GameTime  gameTime)
virtual

Ran every update and suitable for calling Update for UserInterface classes

Definition at line 74 of file ModHooks.cs.

74 {
75 }

◆ WallType()

int Terraria.ModLoader.Mod.WallType ( string  name)

Gets the type of the ModWall of this mod with the given name. Returns 0 if no ModWall with the given name is found.

Parameters
nameThe name.
Returns

◆ WallType< T >()

Same as the other WallType, but assumes that the class name and internal name are the same.

Template Parameters
T
Returns
Type Constraints
T :ModWall 
T :ModContent.WallType<T>() 

Member Data Documentation

◆ AsyncLoadQueue

readonly Queue<Task> Terraria.ModLoader.Mod.AsyncLoadQueue = new Queue<Task>()
private

Definition at line 26 of file ModInternals.cs.

Referenced by Terraria.ModLoader.Mod.LoadTexture().

◆ fileHandle

IDisposable Terraria.ModLoader.Mod.fileHandle
private

Definition at line 65 of file Mod.cs.

Referenced by Terraria.ModLoader.Mod.Close(), and Terraria.ModLoader.Mod.LoadResources().

Property Documentation

◆ Code

Assembly Terraria.ModLoader.Mod.Code
getset

The assembly code this is loaded when tModLoader loads this mod.

Definition at line 33 of file Mod.cs.

33{ get; internal set; }

◆ DisplayName

string Terraria.ModLoader.Mod.DisplayName
getset

The display name of this mod in the Mods menu.

Definition at line 60 of file Mod.cs.

60{ get; internal set; }

Referenced by Terraria.ModLoader.ModNPC.AutoStaticDefaults().

◆ ExtraPlayerBuffSlots

virtual uint Terraria.ModLoader.Mod.ExtraPlayerBuffSlots
get

The amount of extra buff slots this mod desires for Players. This value is checked after Mod.Load but before Mod.PostSetupContent. The actual number of buffs the player can use will be 22 plus the max value of all enabled mods. In-game use Player.MaxBuffs to check the maximum number of buffs.

Definition at line 89 of file Mod.cs.

89{ get; }

◆ IsNetSynced

bool Terraria.ModLoader.Mod.IsNetSynced
get

Definition at line 63 of file Mod.cs.

◆ Logger

ILog Terraria.ModLoader.Mod.Logger
getset

A logger with this mod's name for easy logging.

Definition at line 37 of file Mod.cs.

37{ get; internal set; }

◆ Name

◆ Properties

◆ Side

ModSide Terraria.ModLoader.Mod.Side
getset

The ModSide that controls how this mod is synced between client and server.

Definition at line 56 of file Mod.cs.

56{ get; internal set; }

◆ tModLoaderVersion

Version Terraria.ModLoader.Mod.tModLoaderVersion
getset

The version of tModLoader that was being used when this mod was built.

Definition at line 46 of file Mod.cs.

46{ get; internal set; }

Referenced by Terraria.ModLoader.Mod.LoadResource().

◆ Version

virtual Version Terraria.ModLoader.Mod.Version
get

This version number of this mod.

Definition at line 50 of file Mod.cs.

Referenced by Terraria.ModLoader.Mod.LoadResource().