Mod
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.
Methods
- 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.
- PostSetupContent()
- Allows you to load things in your mod after its content has been setup (arrays have been resized to fit the content, etc).
- 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.
- 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.
- 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.
- 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.
- LoadResource(System.String,System.Int32,System.Func{System.IO.Stream})()
- Hook for pre-loading resources
- AddItem(System.String,Terraria.ModLoader.ModItem)()
- 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.
- GetItem(System.String)()
- 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.
- GetItem``1()
- Same as the other GetItem, but assumes that the class name and internal name are the same.
- ItemType(System.String)()
- Gets the internal ID / type of the ModItem corresponding to the name. Returns 0 if no ModItem with the given name is found.
- ItemType``1()
- Same as the other ItemType, but assumes that the class name and internal name are the same.
- AddGlobalItem(System.String,Terraria.ModLoader.GlobalItem)()
- Adds the given GlobalItem instance to this mod with the provided name.
- GetGlobalItem(System.String)()
- Gets the GlobalItem instance with the given name from this mod.
- GetGlobalItem``1()
- Same as the other GetGlobalItem, but assumes that the class name and internal name are the same.
- AddEquipTexture(Terraria.ModLoader.ModItem,Terraria.ModLoader.EquipType,System.String,System.String,System.String,System.String)()
- 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.
- AddEquipTexture(Terraria.ModLoader.EquipTexture,Terraria.ModLoader.ModItem,Terraria.ModLoader.EquipType,System.String,System.String,System.String,System.String)()
- 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.
- GetEquipTexture(System.String,Terraria.ModLoader.EquipType)()
- Gets the EquipTexture instance corresponding to the name and EquipType. Returns null if no EquipTexture with the given name and EquipType is found.
- GetEquipSlot(System.String,Terraria.ModLoader.EquipType)()
- Gets the slot/ID of the equipment texture corresponding to the given name. Returns -1 if no EquipTexture with the given name is found.
- GetAccessorySlot(System.String,Terraria.ModLoader.EquipType)()
- Same as GetEquipSlot, except returns the number as an sbyte (signed byte) for your convenience.
- AddPrefix(System.String,Terraria.ModLoader.ModPrefix)()
- 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.
- GetPrefix(System.String)()
- 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.
- GetPrefix``1()
- Same as the other GetPrefix, but assumes that the class name and internal name are the same.
- PrefixType(System.String)()
- Gets the internal ID / type of the ModPrefix corresponding to the name. Returns 0 if no ModPrefix with the given name is found.
- PrefixType``1()
- Same as the other PrefixType, but assumes that the class name and internal name are the same.
- AddDust(System.String,Terraria.ModLoader.ModDust,System.String)()
- 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.
- GetDust(System.String)()
- Gets the ModDust of this mod corresponding to the given name. Returns null if no ModDust with the given name is found.
- GetDust``1()
- Same as the other GetDust, but assumes that the class name and internal name are the same.
- DustType(System.String)()
- Gets the type of the ModDust of this mod with the given name. Returns 0 if no ModDust with the given name is found.
- DustType``1()
- Same as the other DustType, but assumes that the class name and internal name are the same.
- AddTile(System.String,Terraria.ModLoader.ModTile,System.String)()
- Adds a type of tile to the game with the specified name and texture.
- GetTile(System.String)()
- Gets the ModTile of this mod corresponding to the given name. Returns null if no ModTile with the given name is found.
- GetTile``1()
- Same as the other GetTile, but assumes that the class name and internal name are the same.
- TileType(System.String)()
- Gets the type of the ModTile of this mod with the given name. Returns 0 if no ModTile with the given name is found.
- TileType``1()
- Same as the other TileType, but assumes that the class name and internal name are the same.
- AddGlobalTile(System.String,Terraria.ModLoader.GlobalTile)()
- Adds the given GlobalTile instance to this mod with the provided name.
- GetGlobalTile(System.String)()
- Gets the GlobalTile instance with the given name from this mod.
- GetGlobalTile``1()
- Same as the other GetGlobalTile, but assumes that the class name and internal name are the same.
- AddTileEntity(System.String,Terraria.ModLoader.ModTileEntity)()
- Manually add a tile entity during Load.
- GetTileEntity(System.String)()
- Gets the ModTileEntity of this mod corresponding to the given name. Returns null if no ModTileEntity with the given name is found.
- GetTileEntity``1()
- Same as the other GetTileEntity, but assumes that the class name and internal name are the same.
- TileEntityType(System.String)()
- Gets the type of the ModTileEntity of this mod with the given name. Returns -1 if no ModTileEntity with the given name is found.
- TileEntityType``1()
- Same as the other TileEntityType, but assumes that the class name and internal name are the same.
- AddWall(System.String,Terraria.ModLoader.ModWall,System.String)()
- Adds a type of wall to the game with the specified name and texture.
- GetWall(System.String)()
- Gets the ModWall of this mod corresponding to the given name. Returns null if no ModWall with the given name is found.
- WallType(System.String)()
- Gets the type of the ModWall of this mod with the given name. Returns 0 if no ModWall with the given name is found.
- WallType``1()
- Same as the other WallType, but assumes that the class name and internal name are the same.
- AddGlobalWall(System.String,Terraria.ModLoader.GlobalWall)()
- Adds the given GlobalWall instance to this mod with the provided name.
- GetGlobalWall(System.String)()
- Gets the GlobalWall instance with the given name from this mod.
- AddProjectile(System.String,Terraria.ModLoader.ModProjectile)()
- Adds a type of projectile to the game with the specified name.
- GetProjectile(System.String)()
- Gets the ModProjectile of this mod corresponding to the given name. Returns null if no ModProjectile with the given name is found.
- ProjectileType(System.String)()
- Gets the type of the ModProjectile of this mod with the given name. Returns 0 if no ModProjectile with the given name is found.
- ProjectileType``1()
- Same as the other ProjectileType, but assumes that the class name and internal name are the same.
- AddGlobalProjectile(System.String,Terraria.ModLoader.GlobalProjectile)()
- Adds the given GlobalProjectile instance to this mod with the provided name.
- GetGlobalProjectile(System.String)()
- Gets the GlobalProjectile instance with the given name from this mod.
- AddNPC(System.String,Terraria.ModLoader.ModNPC)()
- Adds a type of NPC to the game with the specified name and texture. Also allows you to give the NPC alternate textures.
- GetNPC(System.String)()
- Gets the ModNPC of this mod corresponding to the given name. Returns null if no ModNPC with the given name is found.
- NPCType(System.String)()
- Gets the type of the ModNPC of this mod with the given name. Returns 0 if no ModNPC with the given name is found.
- NPCType``1()
- Same as the other NPCType, but assumes that the class name and internal name are the same.
- AddGlobalNPC(System.String,Terraria.ModLoader.GlobalNPC)()
- Adds the given GlobalNPC instance to this mod with the provided name.
- GetGlobalNPC(System.String)()
- Gets the GlobalNPC instance with the given name from this mod.
- AddNPCHeadTexture(System.Int32,System.String)()
- Assigns a head texture to the given town NPC type.
- AddBossHeadTexture(System.String,System.Int32)()
- Assigns a head texture that can be used by NPCs on the map.
- AddPlayer(System.String,Terraria.ModLoader.ModPlayer)()
- Adds a type of ModPlayer to this mod. All ModPlayer types will be newly created and attached to each player that is loaded.
- GetPlayer(System.String)()
- Gets the ModPlayer of this mod corresponding to the given name. Returns null if no ModPlayer with the given name is found.
- AddBuff(System.String,Terraria.ModLoader.ModBuff,System.String)()
- Adds a type of buff to the game with the specified internal name and texture.
- GetBuff(System.String)()
- Gets the ModBuff of this mod corresponding to the given name. Returns null if no ModBuff with the given name is found.
- BuffType(System.String)()
- 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.
- BuffType``1()
- Same as the other BuffType, but assumes that the class name and internal name are the same.
- AddGlobalBuff(System.String,Terraria.ModLoader.GlobalBuff)()
- Adds the given GlobalBuff instance to this mod using the provided name.
- GetGlobalBuff(System.String)()
- Gets the GlobalBuff with the given name from this mod.
- AddMount(System.String,Terraria.ModLoader.ModMountData,System.String,System.Collections.Generic.IDictionary{Terraria.ModLoader.MountTextureType,System.String})()
- 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.
- GetMount(System.String)()
- Gets the ModMountData instance of this mod corresponding to the given name. Returns null if no ModMountData has the given name.
- MountType(System.String)()
- Gets the ID of the ModMountData instance corresponding to the given name. Returns 0 if no ModMountData has the given name.
- MountType``1()
- Same as the other MountType, but assumes that the class name and internal name are the same.
- AddModWorld(System.String,Terraria.ModLoader.ModWorld)()
- Adds a ModWorld to this mod with the given name.
- GetModWorld(System.String)()
- Gets the ModWorld instance with the given name from this mod.
- GetModWorld``1()
- Same as the other GetModWorld, but assumes that the class name and internal name are the same.
- AddUgBgStyle(System.String,Terraria.ModLoader.ModUgBgStyle)()
- Adds the given underground background style with the given name to this mod.
- GetUgBgStyle(System.String)()
- Returns the underground background style corresponding to the given name.
- AddSurfaceBgStyle(System.String,Terraria.ModLoader.ModSurfaceBgStyle)()
- Adds the given surface background style with the given name to this mod.
- GetSurfaceBgStyle(System.String)()
- Returns the surface background style corresponding to the given name.
- GetSurfaceBgStyleSlot(System.String)()
- Returns the Slot of the surface background style corresponding to the given name.
- AddGlobalBgStyle(System.String,Terraria.ModLoader.GlobalBgStyle)()
- Adds the given global background style with the given name to this mod.
- GetGlobalBgStyle(System.String)()
- Returns the global background style corresponding to the given name.
- AddWaterStyle(System.String,Terraria.ModLoader.ModWaterStyle,System.String,System.String)()
- Adds the given water style to the game with the given name, texture path, and block texture path.
- GetWaterStyle(System.String)()
- Returns the water style with the given name from this mod.
- AddWaterfallStyle(System.String,Terraria.ModLoader.ModWaterfallStyle,System.String)()
- Adds the given waterfall style to the game with the given name and texture path.
- GetWaterfallStyle(System.String)()
- Returns the waterfall style with the given name from this mod.
- GetWaterfallStyleSlot(System.String)()
- Returns the waterfall style corresponding to the given name.
- AddGore(System.String,Terraria.ModLoader.ModGore)()
- 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.
- GetGoreSlot(System.String)()
- Shorthand for calling ModGore.GetGoreSlot(this.Name + '/' + name).
- GetGoreSlot``1()
- Same as the other GetGoreSlot, but assumes that the class name and internal name are the same.
- AddSound(Terraria.ModLoader.SoundType,System.String,Terraria.ModLoader.ModSound)()
- 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.
- GetSoundSlot(Terraria.ModLoader.SoundType,System.String)()
- Shorthand for calling SoundLoader.GetSoundSlot(type, this.Name + '/' + name).
- GetLegacySoundSlot(Terraria.ModLoader.SoundType,System.String)()
- Shorthand for calling SoundLoader.GetLegacySoundSlot(type, this.Name + '/' + name).
- AddBackgroundTexture(System.String)()
- Adds a texture to the list of background textures and assigns it a background texture slot.
- GetBackgroundSlot(System.String)()
- Gets the texture slot corresponding to the specified texture name. Shorthand for calling BackgroundTextureLoader.GetBackgroundSlot(this.Name + '/' + name).
- AddGlobalRecipe(System.String,Terraria.ModLoader.GlobalRecipe)()
- Manually add a Global Recipe during Load
- GetGlobalRecipe(System.String)()
- Gets the global recipe corresponding to the specified name.
- AddCommand(System.String,Terraria.ModLoader.ModCommand)()
- Manually add a Command during Load
- AddMusicBox(System.Int32,System.Int32,System.Int32,System.Int32)()
- 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.
- RegisterHotKey(System.String,System.String)()
- Registers a hotkey with a name and defaultKey. Use the returned ModHotKey to detect when buttons are pressed. Do this in a ModPlayer.ProcessTriggers.
- CreateTranslation(System.String)()
- Creates a ModTranslation object that you can use in AddTranslation.
- AddTranslation(Terraria.ModLoader.ModTranslation)()
- Adds a ModTranslation to the game so that you can use Language.GetText to get a LocalizedText.
- GetFileBytes(System.String)()
- Retrieve contents of files within the tmod file
- GetFileSteam(System.String)()
- Retrieve contents of files within the tmod file
- FileExists(System.String)()
- Shorthand for calling ModLoader.FileExists(this.FileName(name)). Note that file extensions are used here.
- GetTexture(System.String)()
- Shorthand for calling ModContent.GetTexture(this.FileName(name)).
- TextureExists(System.String)()
- Shorthand for calling ModLoader.TextureExists(this.FileName(name)).
- AddTexture(System.String,Microsoft.Xna.Framework.Graphics.Texture2D)()
- Shorthand for calling ModLoader.AddTexture(this.FileName(name), texture).
- GetSound(System.String)()
- Shorthand for calling ModContent.GetSound(this.FileName(name)).
- SoundExists(System.String)()
- Shorthand for calling ModLoader.SoundExists(this.FileName(name)).
- GetMusic(System.String)()
- Shorthand for calling ModContent.GetMusic(this.FileName(name)).
- MusicExists(System.String)()
- Shorthand for calling ModLoader.MusicExists(this.FileName(name)).
- GetFont(System.String)()
- Gets a SpriteFont loaded from the specified path.
- FontExists(System.String)()
- Used to check if a custom SpriteFont exists
- GetEffect(System.String)()
- Gets an Effect loaded from the specified path.
- EffectExists(System.String)()
- Used to check if a custom Effect exists
- Call(System.Object[])()
- 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.
- GetPacket(System.Int32)()
- Creates a ModPacket object that you can write to and then send between servers and clients.
- AutoloadLocalization()
- Loads .lang files
- UpdateMusic(System.Int32@,Terraria.ModLoader.MusicPriority@)()
- Allows you to determine what music should currently play.
- UpdateMusic(System.Int32@)()
- A legacy hook that you should no longer use. Use the version with two parameters instead.
- HotKeyPressed(System.String)()
- Called when a hotkey is pressed. Check against the name to verify particular hotkey that was pressed. (Using the ModHotKey is more recommended.)
- HandlePacket(System.IO.BinaryReader,System.Int32)()
- 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.
- HijackGetData(System.Byte@,System.IO.BinaryReader@,System.Int32)()
- Allows you to modify net message / packet information that is received before the game can act on it.
- HijackSendData(System.Int32,System.Int32,System.Int32,System.Int32,Terraria.Localization.NetworkText,System.Int32,System.Single,System.Single,System.Single,System.Int32,System.Int32,System.Int32)()
- 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.
- ModifyTransformMatrix(Terraria.Graphics.SpriteViewMatrix@)()
- Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.)
- UpdateUI(Microsoft.Xna.Framework.GameTime)()
- Ran every update and suitable for calling Update for UserInterface classes
- 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.
- MidUpdatePlayerNPC()
- Called after Players got updated, but before any NPCs get updated.
- MidUpdateNPCGore()
- Called after NPCs got updated, but before any Gores get updated.
- MidUpdateGoreProjectile()
- Called after Gores got updated, but before any Projectiles get updated.
- MidUpdateProjectileItem()
- Gets called immediately after all Projectiles are updated, but before any Items get updated.
- MidUpdateItemDust()
- Called after Items got updated, but before any Dust gets updated.
- MidUpdateDustTime()
- Called after Dust got updated, but before Time (day/night, events, etc.) gets updated.
- MidUpdateTimeWorld()
- Called after Time got updated, but before the World gets updated.
- MidUpdateInvasionNet()
- Called after Invasions got updated. The only thing that is updated after this is the Network.
- PostUpdateEverything()
- Called after the Network got updated, this is the last hook that happens in an update.
- ModifyInterfaceLayers(System.Collections.Generic.List{Terraria.UI.GameInterfaceLayer})()
- 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/blushiemagic/tModLoader/wiki/Vanilla-Interface-layers-values for vanilla interface layer names
- ModifySunLightColor(Microsoft.Xna.Framework.Color@,Microsoft.Xna.Framework.Color@)()
- Allows you to modify color of light the sun emits.
- ModifyLightingBrightness(System.Single@)()
- 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
- PostDrawInterface(Microsoft.Xna.Framework.Graphics.SpriteBatch)()
- 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.
- PostDrawFullscreenMap(System.String@)()
- Called while the fullscreen map is active. Allows custom drawing to the map.
- PostUpdateInput()
- Called after the input keys are polled. Allows for modifying things like scroll wheel if your custom drawing should capture that.
- 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.