Repository navigation
API Systems
API reference · generated by
tools/docs/ApiReference, do not edit by hand
The mod itself, content registration, systems, save data, packets and commands.
class ReLogic.Content.Asset · only in Bunny Loader
A texture, sound or effect that may still be loading. Value waits for it. ModContent.Request<T> gives one.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool Equals(object obj) |
override | ReLogic | Whether both hold the same value. |
int GetHashCode() |
override | ReLogic | The hash of this value. |
Asset<T> FromGame(IntPtr gameAsset) |
static method | ReLogic | Wraps an asset of the game. Only in Bunny Loader. |
IntPtr ToGame(Asset<T> asset) |
static method | ReLogic | The asset of the game behind this one. Only in Bunny Loader. |
string Name |
property | ReLogic | The asset's path. |
AssetState State |
property | ReLogic | How far loading has gone. |
bool IsLoaded |
property | ReLogic | Whether Value is ready. |
bool IsDisposed |
property | ReLogic | Whether it was released. |
T Value |
property | ReLogic | The loaded content. |
void Wait() |
method | ReLogic | Blocks until it has loaded. |
struct ReLogic.Content.AssetArray : IGameObject · only in Bunny Loader
A game table of assets, such as TextureAssets.Item.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
IntPtr Pointer |
field | only here | The address of the array in the game. |
new AssetArray(IntPtr pointer) |
constructor | only here | Creates an instance. |
bool IsNull |
property | only here | Whether there is no array. |
int Length |
property | only here | How many it holds. |
Asset<T> this[int index] |
indexer | only here | Reads or writes one entry. |
AssetArray<T> Resized(int length) |
method | only here | A new array of this length, with the same content. |
enum ReLogic.Content.AssetRequestMode · only in Bunny Loader
Whether a request loads in the background or now.
Values: DoNotLoad, AsyncLoad, ImmediateLoad
enum ReLogic.Content.AssetState · only in Bunny Loader
Where an asset is in its loading.
Values: NotLoaded, Loading, Loaded, Disposed
class Terraria.ModLoader.AutoloadAttribute : Attribute
Allows for customizing if the annotated Type should be automatically loaded. True to always autoload, which is the default behavior, or false to prevent autoloading this Type. It is also possible to dictate if autoloading should conditionally only happen on a client or a server by setting Side to Client or Server. One use of this is to prevent graphics related classes from loading on the server. Note that content with a non-default constructor or marked as abstract will automatically not be autoloaded, so this attribute is not needed for those.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool Value |
field | same | Whether the class is loaded at all. |
ModSide Side |
property | same | Which side loads it. |
bool NeedsAutoloading |
property | same | Whether this side should load it. |
new AutoloadAttribute(bool value) |
constructor | same | Creates an instance. |
AutoloadAttribute GetValue(Type type) |
static method | same | The attribute of a class, or the default. |
class Terraria.ModLoader.AutoloadEquip : Attribute
This attribute annotates a ModItem class to indicate that the game should autoload the specified equipment texture or textures and assign it to this item. The equipment texture is the texture that appears on the player itself when the item is worn and visible. Armor and most accessories will set at least one EquipType, but not every accessory needs on-player visuals. The equipment texture will be loaded from the path made from appending "_EquipTypeNameHere" to Texture. An error will be thrown during mod loading if the texture can't be found. For example, a helmet item named "ExampleHelmet" annotated with [AutoloadEquip(EquipType.Head)] will need both a "ExampleHelmet.png" and "ExampleHelmet_Head.png" to work. Note that equipment textures must follow specific layouts, see ExampleMod examples of similar items to use as a guide.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
EquipType[] equipTypes |
field | same | The kinds of equipment to load. |
new AutoloadEquip(params EquipType[] equipTypes) |
constructor | same | Creates an instance. |
static class Terraria.ModLoader.IO.BinaryIO
Reads and writes colors, vectors, items and compact numbers in a packet.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void ReadFlags(this BinaryReader reader, out bool b0) |
static method | same | Reads up to 8 booleans packed in one byte. |
void ReadFlags(this BinaryReader reader, out bool b0, out bool b1) |
static method | same | Reads up to 8 booleans packed in one byte. |
void ReadFlags(this BinaryReader reader, out bool b0, out bool b1, out bool b2) |
static method | same | Reads up to 8 booleans packed in one byte. |
void ReadFlags(this BinaryReader reader, out bool b0, out bool b1, out bool b2, out bool b3) |
static method | same | Reads up to 8 booleans packed in one byte. |
void ReadFlags(this BinaryReader reader, out bool b0, out bool b1, out bool b2, out bool b3, out bool b4) |
static method | same | Reads up to 8 booleans packed in one byte. |
void ReadFlags(this BinaryReader reader, out bool b0, out bool b1, out bool b2, out bool b3, out bool b4, out bool b5) |
static method | same | Reads up to 8 booleans packed in one byte. |
void ReadFlags(this BinaryReader reader, out bool b0, out bool b1, out bool b2, out bool b3, out bool b4, out bool b5, out bool b6) |
static method | same | Reads up to 8 booleans packed in one byte. |
void ReadFlags(this BinaryReader reader, out bool b0, out bool b1, out bool b2, out bool b3, out bool b4, out bool b5, out bool b6, out bool b7) |
static method | same | Reads up to 8 booleans packed in one byte. |
void WriteFlags(this BinaryWriter writer, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7, bool b8) |
static method | same | Efficiently writes up to 8 bools as a single byte. To read, use BinaryReader.ReadFlags. This is more efficient than using Write. |
void Write(this BinaryWriter writer, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7, bool b8) |
static method | same | Writes up to 8 booleans packed in one byte. |
void SafeWrite(this BinaryWriter writer, Action<BinaryWriter> write) |
static method | same | Writes through a method, with the length first, so a reader can skip it. |
void SafeRead(this BinaryReader reader, Action<BinaryReader> read) |
static method | same | Reads what SafeWrite wrote and skips what the method left. |
void ReadBytes(this Stream stream, byte[] buf) |
static method | same | Reads a fixed number of bytes from a stream. |
byte[] ReadBytes(this Stream stream, int len) |
static method | same | Reads a fixed number of bytes from a stream. |
byte[] ReadBytes(this Stream stream, long len) |
static method | same | Reads a fixed number of bytes from a stream. |
MemoryStream ToMemoryStream(this byte[] bytes, bool writeable) |
static method | same | Wraps the bytes in a stream. |
BitsByte ReadBitsByte(this BinaryReader reader) |
static method | not here | Not implemented. Use ReadFlags. |
ReadOnlySpan<byte> ReadByteSpan(this Stream stream, int len) |
static method | not here | Not implemented. Use ReadBytes. |
class Terraria.ModLoader.IO.BitReader
Reads back what a BitWriter wrote.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int MaxBits |
property | same | How many bits it holds. |
int BitsRead |
property | same | How many it has read. |
new BitReader(BinaryReader reader) |
constructor | same | Creates an instance. |
bool ReadBit() |
method | same | Reads one bit. |
class Terraria.ModLoader.IO.BitWriter
Packs many bool into a few bytes.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void WriteBit(bool b) |
method | same | Adds one bit. |
void Flush(BinaryWriter w) |
method | same | Writes the bits to a writer. |
interface Terraria.ModLoader.CommandCaller
Who ran a chat command: the player and where to reply.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
CommandType CommandType |
hook | same | Where the command came from. |
Player Player |
hook | same | The Player object corresponding to the Player that invoked this command. Use this when the Player is needed. Don't use Main.LocalPlayer because that would be incorrect for various CommandTypes. |
void Reply(string text, Color color) |
hook | same | Use this to respond to the Player that invoked this command. This method handles writing to the console, writing to chat, or sending messages over the network for you depending on the CommandType used. Avoid using Main.NewText, Console.WriteLine, or NetMessage.SendChatMessageToClient directly because the logic would change depending on CommandType. |
enum Terraria.ModLoader.CommandType
A flag enum representing context where this command operates.
Values: Chat, Server, Console, World
interface Terraria.ModLoader.ILoadable
Works with AddContent to provide Load and Unload callbacks. All non-abstract types extending this class which have a default constructor will be autoloaded and passed to AddContent For autoloading types which do not have a default constructor, see ICustomAutoload
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool IsLoadingEnabled(Mod mod) |
hook | same | Whether or not this type should be loaded when it's told to. Returning false disables AddContent from actually loading this type. |
void Load(Mod mod) |
hook | same | Called when loading the type. |
void Unload() |
hook | same | Called during unloading when needed. |
interface Terraria.ModLoader.ILocalizedModType : IModType
Content with a place in the localization files.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string LocalizationCategory |
hook | same | The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki page explains how custom ModType classes can utilize this. |
static class Terraria.ModLoader.ILocalizedModTypeExtensions
Finds the key and the text of a content's localization.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string GetLocalizationKey(this ILocalizedModType self, string suffix) |
static method | same | Gets a suitable localization key belonging to this piece of content. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}", in this case the suffix corresponds to the DataName. |
LocalizedText GetLocalization(this ILocalizedModType self, string suffix, Func<string> makeDefaultValue) |
static method | same | Returns a LocalizedText for this piece of content with the provided suffix. If no existing localization exists for the key, it will be defined so it can be exported to a matching mod localization file. |
string GetLocalizedValue(this ILocalizedModType self, string suffix) |
static method | same | Retrieves the text value for a localization key belonging to this piece of content with the given suffix. The text returned will be for the currently selected language. |
struct Terraria.Lang
What Bunny Loader adds to the game's language tables.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
LanguageSearchFilter CreateDialogFilter(string startsWith, bool checkConditions) |
static method | same | A filter for texts that start with this name and whose conditions hold. |
void RegisterModdedGlobalSubstitution(Mod mod, string key, Func<object> getValue) |
static method | same | Adds a {Key} that every game text can use. |
string LocalizedDuration(TimeSpan time, bool abbreviated, bool showAllAvailableUnits) |
static method | same | A duration as text in the current language. |
static class Terraria.Localization.Language
Contains methods to access or retrieve localization values. The Localization Guide teaches more about localization.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string GetTextValue(string key, params object[] args) |
static method | same | The text of a key, with its arguments filled in. |
LocalizedText GetOrRegister(string key, Func<string> makeDefaultValue) |
static method | same | Returns a LocalizedText for a given key. If no existing localization exists for the key, it will be defined so it can be exported to a matching mod localization file. |
LocalizedText SelectRandom(LanguageSearchFilter filter) |
static method | differs | A random text among those that match. tML: LocalizedText SelectRandom(LanguageSearchFilter filter, UnifiedRandom random)
|
struct Terraria.Localization.LocalizedText
Contains the localization value corresponding to a key for the current game language. Automatically updates as language, mods, and resource packs change. The Localization Guide teaches more about localization.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string Format(params object[] args) |
method | same | The text with its arguments filled in. |
LocalizedText WithFormatArgs(params object[] args) |
method | same | Creates a new LocalizedText with the supplied arguments formatted into the value (via Format) Will automatically update to re-format the string with cached args when language changes. The resulting LocalizedText should be stored statically. Should not be used to create 'throwaway' LocalizedText instances. Use Format instead for repeated on-demand formatting with different args. The Localization Guide teaches more about using placeholders in localization. |
LocalizedText Literal(string value) |
static method | same | Creates a LocalizedText with empty Key a given Value Only use as a last resort to call an API that requires a LocalizedText with an unlocalizable value |
string ToString() |
override | same | The text form of this value. |
object[] BoundArgs |
property | not here | Returns the args used with WithFormatArgs or WithPartialFormatArgs to create this text, if any. |
int ArgCount |
property | not here | The number of args required by Format
|
LocalizedText WithPartialFormatArgs(params object[] args) |
method | not here | Version of WithFormatArgs which supplies only the leading args, shifting the rest down. The unfilled placeholders are renumbered from 0, so Format or ToNetworkText on the result take only the args which are still missing. Eg Language.GetText("Key").WithPartialFormatArgs("red") turns "{0} and {1}" into "red and {0}" |
abstract class Terraria.ModLoader.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.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string Uid |
property | only here | The pack's unique ID. |
string Name |
property | same | 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. |
string DisplayName |
property | same | The display name of this mod in the Mods menu. |
Version Version |
property | same | This version number of this mod. |
ILog Logger |
property | same | A logger with this mod's name for easy logging. |
string Folder |
property | only here | The folder of the installed pack. |
ModAssets Assets |
property | differs | Provides access to assets (textures, sounds, shaders, etc) contained within this mod. The main usage is to call the method to retrieve an Asset instance: Asset balloonTexture = Mod.Assets.Request("Content/Items/Armor/SimpleAccessory_Balloon"); Do not include the mod name in the Request method call, the path supplied should not include the mod name. This is different from using where the mod name is required. Read the Assets guide on the wiki for more information. tML: AssetRepository Assets
|
bool ContentAutoloadingEnabled |
property | same | Whether or not this mod will autoload content by default. Autoloading content means you do not need to manually add content through methods. |
bool BackgroundAutoloadingEnabled |
property | same | Whether or not this mod will automatically add images in the "Backgrounds" folder as background textures to the game. This means you do not need to manually call AddBackgroundTexture. |
bool CloudAutoloadingEnabled |
property | same | Whether or not this mod will automatically add images in the "Clouds" folder as clouds to the game. This means you do not need to manually call AddCloudFromTexture or make a ModCloud class to add them to the game, but they will have the default spawn chance and be counted as normal clouds if autoloaded in this manner. Defaults to true. |
void Load() |
hook | same | Override this method to run code after all content has been autoloaded. Here additional content can be manually loaded and Mod-wide tasks and setup can be done. For organization, it may be more suitable to split some things into various Load methods, such as in ModSystem classes, instead of doing everything here. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. Use PostSetupContent for any logic that needs to act on all content being fully loaded. |
void PostSetupContent() |
hook | same | Allows you to load things in your mod after its content has been setup (arrays have been resized to fit the content, etc). |
void AddRecipeGroups() |
hook | same | 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. |
void AddRecipes() |
hook | same | Override this method to add recipes to the game. It is recommended that you do so through instances of Recipe, since it provides methods that simplify recipe creation. |
void PostAddRecipes() |
hook | same | 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. |
Recipe CreateRecipe(int result, int amount) |
method | same | Starts a recipe owned by this mod. |
void Unload() |
hook | same | 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. |
object Call(params object[] args) |
hook | same | 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. The Expert Cross Mod Content Guide explains how to use this hook to implement and utilize cross-mod capabilities. |
ModPacket GetPacket(int capacity) |
method | same | Creates a ModPacket object that you can write to and then send between servers and clients. |
int AddBossHeadTexture(string texture, int npcType) |
method | same | Assigns a head texture that can be used by NPCs on the map. |
int AddNPCHeadTexture(int npcType, string texture) |
method | same | Assigns a head texture to the given town NPC type. Phone: Returns the real slot at once, also from Load. |
void HandlePacket(BinaryReader reader, int whoAmI) |
hook | same | Called whenever a net message / packet pertaining to this mod 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. Note that many packets are sent from a client to the server and then relayed to the remaining clients. The whoAmI when the packet arrives at the remaining clients will be the servers myPlayer, not the original clients myPlayer. For packets only sent from a client to the server, relying on whoAmI to identify the clients player is fine, but for packets that are relayed, the clients player index will need to be part of the packet itself to correctly identify the client that sent the original packet. Use packet.Write((byte) Main.myPlayer); to write and int player = reader.ReadByte(); to read. The HijackGetData hook can be used to intercept any packet used by Terraria. |
bool AddContent(ILoadable instance) |
method | same | Call this to manually add the given content instance to the game. |
bool AddContent<T>() |
method | same | Call this to manually add a content instance of the specified type (with a parameterless constructor) to the game. |
IEnumerable<ILoadable> GetContent() |
method | same | Returns all registered content instances that are added by this mod. This only includes the 'template' instance for each piece of content, not all the clones/new instances which get added to Items/Players/NPCs etc. as the game is played |
string GetLocalizationKey(string suffix) |
method | same | Creates a localization key following the pattern of "Mods.{ModName}.{suffix}". Use this with GetOrRegister to retrieve a LocalizedText for custom localization keys. Alternatively GetLocalization can be used directly instead. Custom localization keys need to be registered during the mod loading process to appear automatically in the localization files. |
LocalizedText GetLocalization(string suffix, Func<string> makeDefaultValue) |
method | same | Returns a LocalizedText for this Mod with the provided suffix. The suffix will be used to generate a key by providing it to GetLocalizationKey. If no existing localization exists for the key, it will be defined so it can be exported to a matching mod localization file. |
T Find<T>(string name) |
method | same | Attempts to find the template instance from this mod with the specified name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended. This will throw exceptions on failure. |
bool TryFind<T>(string name, out T value) |
method | same | Safely attempts to find the template instance from this mod with the specified name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended. |
bool FileExists(string name) |
method | same | Returns whether or not a file with the specified name exists. Note that this includes file extension and the folder path: "Folders/FileNameWithExtension" |
byte[] GetFileBytes(string name) |
method | same | Retrieves the contents of a file packaged within the .tmod file as a byte array. Should be used mainly for non- files. The name should be in the format of "Folders/FileNameWithExtension" starting from your mod's source code folder. Returns null if the file does not exist within the mod. A typical usage of this might be to load a text file containing structured data included within your mod. Make sure the txt file is UTF8 encoded and use the following to retrieve file's text contents: string pointsFileContents = Encoding.UTF8.GetString(Mod.GetFileBytes("data/points.txt"));
|
Stream GetFileStream(string name, bool newFileStream) |
method | same | Retrieve contents of files within the .tmod file. |
List<string> GetFileNames() |
method | same | Retrieves the names of every file packaged into this mod. Note that this includes extensions, and for images the extension will always be .rawimg. |
Assembly Code |
property | not here | The assembly code this is loaded when tModLoader loads this mod. Do NOT call GetTypes on this as it will error out if the mod uses the ExtendsFromModAttribute attribute to inherit from weakly referenced mods. Use GetLoadableTypes instead. |
Version TModLoaderVersion |
property | not here | The version of tModLoader that was being used when this mod was built. |
Asset<Texture2D> ModIcon |
property | not here | The icon for this mod, sourced from icon.png. Must be 80x80. |
Asset<Texture2D> SmallModIcon |
property | not here | The small icon for this mod, sourced from icon_small.png. Must be 30x30. Will be null if a suitable icon doesn't exist. |
Asset<Texture2D> PlaceholderModIcon |
static property | not here | A placeholder mod icon, for use when a mod doesn't have a valid icon. |
List<string> TranslationForMods |
property | not here | Translation mods are not part of Bunny Loader. |
string SourceFolder |
property | not here | The path to the source folder the mod was built from. |
bool GoreAutoloadingEnabled |
property | not here | Whether or not this mod will automatically add images in the "Gores" folder as gores to the game, along with any ModGore classes that share names with the images. This means you do not need to manually call . |
bool MusicAutoloadingEnabled |
property | not here | Whether or not this mod will automatically add music to the game. All supported audio files in a folder or subfolder of a folder named "Music" will be autoloaded as music. |
bool MusicSkipsVolumeRemap |
property | not here | Whether or not all music loaded by this mod will automatically have SkipsVolumeRemap set to true. |
ModSide Side |
property | not here | The ModSide that controls how this mod is synced between client and server. |
string DisplayNameClean |
property | not here | Same as DisplayName, but chat tags are removed. This can be used for more readable logging and console output. It is also useful for code that searches or filters by mod name. |
IContentSource RootContentSource |
property | not here | Internal to tModLoader's asset system. |
short NetID |
property | not here | Internal here. |
bool IsNetSynced |
property | not here | If true, this mod has a NetID assigned. This is mainly useful for checking if a NoSync mod is present on the server from a client to determine if a ModPacket can be sent to the server or not. |
ModSourceBestiaryInfoElement ModSourceBestiaryInfoElement |
field | not here | Internal here. |
PreJITFilter PreJITFilter |
property | not here | tModLoader compiles mods at load time with the JIT. Not used here. |
void AddConfig(string name, ModConfig mc) |
method | not here | Configs are found by themselves. Use ModContent.GetInstance<T>(). |
bool HasAsset(string assetName) |
method | not here | Not implemented. Use ModContent.HasAsset. |
bool RequestAssetIfExists<T>(string assetName, out Asset<T> asset) |
method | not here | Not implemented. Use ModContent.RequestIfExists. |
ModConfig GetConfig(string name) |
method | not here | Not implemented. Use ModContent.GetInstance<T>() or ConfigManager.GetConfig. |
IContentSource CreateDefaultContentSource() |
hook | not here | Internal to tModLoader's asset system. |
uint ExtraPlayerBuffSlots |
hook | not here | 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 44 plus the max value of all enabled mods. In-game use Player.MaxBuffs to check the maximum number of buffs. |
void Close() |
hook | not here | 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 |
void TryAutoload(Type type) |
method | not here | Internal here. |
abstract class Terraria.ModLoader.ModCommand : ModType
This class represents a chat or console command. Use the CommandType to specify the scope of the command.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string Command |
hook | same | The desired text to trigger this command. |
CommandType Type |
hook | same | A flag enum representing context where this command operates. |
string Usage |
hook | same | A short usage explanation for this command. |
string Description |
hook | same | A short description of this command. |
bool IsCaseSensitive |
hook | same | If false (default), the arguments to Action will be provided as lowercase. |
void Action(CommandCaller caller, string input, string[] args) |
hook | same | The code that is executed when the command is triggered. |
static class Terraria.ModLoader.ModContent
Manages content added by mods. Liaisons between mod content and Terraria's arrays and oversees the Loader classes.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int GetModHeadSlot(string texture) |
static method | same | The head slot of a texture from Mod.AddNPCHeadTexture. |
T GetInstance<T>() |
static method | same | Returns the template instance of the provided content type (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). |
int TileType<T>() |
static method | same | Get the id (type) of a ModTile by class. Assumes one instance per class. |
int WallType<T>() |
static method | same | Get the id (type) of a ModWall by class. Assumes one instance per class. |
ModTile GetModTile(int type) |
static method | same | The ModTile of a number, or null. |
int ItemType<T>() |
static method | same | Get the id (type) of a ModItem by class. Assumes one instance per class. |
int RarityType<T>() |
static method | same | Get the id (type) of a ModRarity by class. Assumes one instance per class. |
int BuffType<T>() |
static method | same | Get the id (type) of a ModBuff by class. Assumes one instance per class. |
int MountType<T>() |
static method | same | Get the id (type) of a ModMount by class. Assumes one instance per class. |
int ProjectileType<T>() |
static method | same | Get the id (type) of a ModProjectile by class. Assumes one instance per class. |
int NPCType<T>() |
static method | same | Get the id (type) of a ModNPC by class. Assumes one instance per class. |
ModNPC GetModNPC(int type) |
static method | same | The ModNPC of a number, or null. |
int GetModBossHeadSlot(string texture) |
static method | same | The head slot of a texture from Mod.AddBossHeadTexture. |
int EmoteBubbleType<T>() |
static method | same | Get the id (type) of a ModEmoteBubble by class. Assumes one instance per class. |
ModEmoteBubble GetModEmoteBubble(int type) |
static method | only here | The ModEmoteBubble of a number, or null. |
ModBuff GetModBuff(int type) |
static method | same | The ModBuff of a number, or null. |
int DustType<T>() |
static method | same | Get the id (type) of a ModDust by class. Assumes one instance per class. |
int GoreType<T>() |
static method | same | Get the id (type) of a ModGore by class. Assumes one instance per class. |
ModDust GetModDust(int type) |
static method | same | The ModDust of a number, or null. |
ModItem GetModItem(int type) |
static method | same | The ModItem of a number, or null. |
T Find<T>(string fullname) |
static method | same | Attempts to find the template instance with the specified full name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended. This will throw exceptions on failure. |
T Find<T>(string modName, string name) |
static method | same | Attempts to find the template instance with the specified name and mod name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended. This will throw exceptions on failure. |
bool TryFind<T>(string fullname, out T value) |
static method | same | Safely attempts to find the template instance with the specified full name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended. |
TeleportPylonType PylonType<T>() |
static method | same | Get the id (type) of a ModPylon by class. Assumes one instance per class. If nothing is found, returns 0, or the "Forest Pylon" type. |
bool TryFind<T>(string modName, string name, out T value) |
static method | same | Safely attempts to find the template instance with the specified name and mod name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended. |
Asset<T> Request<T>(string name, AssetRequestMode mode) |
static method | same | Gets the asset with the specified name. Throws an Exception if the asset does not exist. Modders may wish to use Mod.Assets.Request where the mod name prefix may be omitted for convenience. |
bool RequestIfExists<T>(string name, out Asset<T> asset, AssetRequestMode mode) |
static method | same | Loads an asset if the file exists. |
bool HasAsset(string assetName) |
static method | same | Returns whether or not a asset with the specified name exists. Includes the mod name prefix like Request |
bool FileExists(string name) |
static method | same | Returns whether or not a file with the specified name exists. Note that this includes file extension, the folder path, and must start with the mod name at the start of the path: "ModFolder/OtherFolders/FileNameWithExtension" |
byte[] GetFileBytes(string name) |
static method | same | Retrieves the contents of a file packaged within the .tmod file as a byte array. Should be used mainly for non- files. The name should be in the format of "ModFolder/OtherFolders/FileNameWithExtension". Throws an ArgumentException if the mod does not exist. Returns null if the file does not exist. A typical usage of this might be to load a text file containing structured data included within your mod. Make sure the txt file is UTF8 encoded and use the following to retrieve file's text contents: string pointsFileContents = Encoding.UTF8.GetString(ModContent.GetFileBytes("MyMod/data/points.txt"));
|
(string modName, string subName) SplitName(string name) |
static method | differs | Splits Mod/Rest in two. tML: void SplitName(string name, out string domain, out string subName)
|
IEnumerable<T> GetContent<T>() |
static method | not here | Returns all registered content instances that derive from the provided type and that are added by all currently loaded mods. This only includes the 'template' instance for each piece of content, not all the clones/new instances which get added to Items/Players/NPCs etc. as the game is played |
ModProjectile GetModProjectile(int type) |
static method | not here | Not implemented. Use ProjectileLoader.GetProjectile. |
EquipTexture GetEquipTexture(EquipType type, int slot) |
static method | not here | Not implemented. Use EquipLoader.GetEquipTexture. |
ModMount GetModMount(int type) |
static method | not here | Not implemented. Use MountLoader.GetMount. |
ModWall GetModWall(int type) |
static method | not here | Not implemented. Use WallLoader.GetWall. |
ModWaterStyle GetModWaterStyle(int style) |
static method | not here | Returns the ModWaterStyle with the given ID. |
ModWaterfallStyle GetModWaterfallStyle(int style) |
static method | not here | Returns the ModWaterfallStyle with the given ID. |
int GetModBackgroundSlot(string texture) |
static method | not here | Not implemented. Use BackgroundTextureLoader.GetBackgroundSlot. |
ModSurfaceBackgroundStyle GetModSurfaceBackgroundStyle(int style) |
static method | not here | Returns the ModSurfaceBackgroundStyle object with the given ID. |
ModUndergroundBackgroundStyle GetModUndergroundBackgroundStyle(int style) |
static method | not here | Returns the ModUndergroundBackgroundStyle object with the given ID. |
int CloudType<T>() |
static method | not here | Get the id (type) of a ModCloud by class. Assumes one instance per class. |
int PrefixType<T>() |
static method | not here | Get the id (type) of a ModPrefix by class. Assumes one instance per class. |
int TileEntityType<T>() |
static method | not here | Get the id (type) of a ModTileEntity by class. Assumes one instance per class. |
Stream OpenRead(string assetName, bool newFileStream) |
static method | not here | Not implemented. |
static class Terraria.ModLoader.ModLoader
This serves as the central class which loads mods. It contains many static fields and methods related to mods and their contents.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Mod[] Mods |
static property | same | Every loaded mod. |
Mod GetMod(string name) |
static method | same | Gets the instance of the Mod with the specified name. This will throw an exception if the mod cannot be found so it should only be used for mods known to be enabled, such as a strong mod dependency. Use TryGetMod instead if the mod might not be enabled. |
bool TryGetMod(string name, out Mod result) |
static method | same | Safely attempts to get the instance of the Mod with the specified name. |
bool HasMod(string name) |
static method | same | Safely checks whether or not a mod with the specified internal name is currently loaded. |
Version LastLaunchedTModLoaderVersion |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
string LastLaunchedTModLoaderAlphaSha |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool ShowWhatsNew |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool PreviewFreezeNotification |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool DownloadedDependenciesOnStartup |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool ShowFirstLaunchWelcomeMessage |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool SeenFirstLaunchModderWelcomeMessage |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool WarnedFamilyShare |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool WarnedFamilyShareDontShowAgain |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
Version LastPreviewFreezeNotificationSeen |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
int LatestNewsTimestamp |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool SeenNewUpdatedModsInfo |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool ResolvedAbnormalModInstallStates |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool BetaUpgradeWelcomed144 |
static field | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
string versionedName |
static property | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
string CompressedPlatformRepresentation |
static property | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
string ModPath |
static property | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
bool IsSignedBy(TmodFile mod, string xmlPublicKey) |
static method | not here | tModLoader's own launcher and settings. Not part of Bunny Loader. |
class Terraria.ModLoader.ModPacket : BinaryWriter
Used to send data between the server and client. Syncing data is essential for keeping clients up to date with changes to the game state. ModPacket is used to sync arbitrary data, most commonly data corresponding to this mod. The Intermediate netcode wiki page explains more about this concept. Initialize a ModPacket using the GetPacket method. This class inherits from BinaryWriter. This means that you can use all of its writing functions to send information between client and server. This class also comes with a Send method that's used to actually send everything you've written between client and server. ModPacket has all the same methods as BinaryWriter, and some additional ones.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int MaxLength |
const | only here | |
void Send(int toClient, int ignoreClient) |
method | same | Sends all the information you've written to this ModPacket over the network to clients or the server. When called on a client, the data will be sent to the server and the optional parameters are ignored. When called on a server, the data will be sent to either all clients, all clients except a specific client, or just a specific client: // Sends to all connected clients packet.Send(); // Sends to a specific client only packet.Send(toClient: somePlayer.whoAmI); // Sends to all other clients except a specific client packet.Send(ignoreClient: somePlayer.whoAmI); Typically if data is sent from a client to the server, the server will then need to relay this to all other clients to keep them in sync. This is when the ignoreClient option will be used. |
abstract class Terraria.ModLoader.ModSystem : ModType
ModSystem is an abstract class that your classes can derive from. It contains general-use hooks, and, unlike Mod, can have unlimited amounts of types deriving from it.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void OnModLoad() |
hook | same | This hook is called right after Mod.Load(), which is guaranteed to be called after all content has been autoloaded. |
void OnModUnload() |
hook | same | This hook is called right before Mod.UnLoad() |
void PostSetupContent() |
hook | same | Allows you to load things in your system after the mod's content has been setup (arrays have been resized to fit the content, etc). |
void OnLocalizationsLoaded() |
hook | same | Allows mods to react to language changing. This happens whenever the language is changed, and when resource packs are reloaded. |
void ResizeArrays() |
hook | same | Called after all mods register content and before all mods start setting up content. This can be used to initialize data structures dependent on the count of various content IDs, usually through SetFactory instances directly. For example, ItemID.Sets.Factory.CreateBoolSet(false, ItemID.PoisonDart, ItemID.PoisonedKnife) will create an array with length equal to the total number of items in the game with the specified item types set to true. The CreateNamedXSet methods can be used to expose an ID set for other mods to use by name without a mod dependency. See also for another similar option. |
void AddRecipeGroups() |
hook | same | Override this method to add recipe groups to the game. You must add recipe groups by calling the RegisterGroup method here. A recipe group is a set of items that can be used interchangeably in the same recipe. |
void AddRecipes() |
hook | same | Override this method to add Recipes to the game. The Basic Recipes Guide teaches how to add new recipes to the game and how to manipulate existing recipes. |
void PostAddRecipes() |
hook | same | 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. |
void PostSetupRecipes() |
hook | same | Override this method to do treatment about recipes once they have been setup. You shouldn't edit any recipe here. |
void OnWorldLoad() |
hook | same | Called whenever a world is loaded, before LoadWorldData If you need to initialize tile or other world related data-structures, use ClearWorld instead |
void PostWorldLoad() |
hook | same | Called whenever a world is loaded, after LoadWorldData. At this point, the world is ready to be entered by players, and all modded world data is loaded. Can be used to migrate modded world data across different ModSystems, or to modify tile. For deleting temporary tiles, use ClearedOnWorldLoad instead. Only called in single player or on the server, not on multiplayer clients. |
void OnWorldUnload() |
hook | same | Called whenever a world is unloaded. |
void ClearWorld() |
hook | same | Called whenever the world is cleared. Use this to reset world-related data structures before world-gen or loading in both single and multiplayer. Also called just before mods are unloaded. |
void PreSaveAndQuit() |
hook | same | Called 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. Called on the local client only. |
void SaveWorldData(TagCompound tag) |
hook | same | Allows you to save custom data for this system in the current world. Useful for things like saving world specific flags. For example, if your mod adds a boss and you want certain NPC to only spawn once it has been defeated, this is where you would store the information that that boss has been defeated in this world. NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization. NOTE: Try to only save data that isn't default values. |
void LoadWorldData(TagCompound tag) |
hook | same | Allows you to load custom data you have saved for this system in the currently loading world. Try to write defensive loading code that won't crash if something's missing. |
void SaveWorldHeader(TagCompound tag) |
hook | same | Allows you to save custom data for this system in the current world, and have that data accessible in the world select UI and during vanilla world loading. WARNING: Saving too much data here will cause lag when opening the world select menu for users with many worlds. Can be retrieved via TryGetHeaderData and ActiveWorldFileData NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization. NOTE: Try to only save data that isn't default values. |
bool CanWorldBePlayed(PlayerFileData playerData, WorldFileData worldFileData) |
hook | same | Allows you to prevent the world and player from being loaded/selected as a valid combination, similar to Journey Mode pairing. |
string WorldCanBePlayedRejectionMessage(PlayerFileData playerData, WorldFileData worldData) |
hook | same | The text shown when CanWorldBePlayed refuses the world. |
void PreUpdateEntities() |
hook | same | 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 autoPause is true or 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. Called on all clients and the server. |
void PreUpdatePlayers() |
hook | same | Called before Players get updated. Called on all clients and the server. |
void PostUpdatePlayers() |
hook | same | Called after Players get updated. Called on all clients and the server. |
void PreUpdateNPCs() |
hook | same | Called before NPCs get updated. Called on all clients and the server. |
void PostUpdateNPCs() |
hook | same | Called after NPCs get updated. Called on all clients and the server. |
void PreUpdateGores() |
hook | same | Called before Gores get updated. Called on all clients and the server. |
void PostUpdateGores() |
hook | same | Called after Gores get updated. Called on all clients and the server. |
void PreUpdateProjectiles() |
hook | same | Called before Projectiles get updated. Called on all clients and the server. |
void PostUpdateProjectiles() |
hook | same | Called after Projectiles get updated. Called on all clients and the server. |
void PreUpdateItems() |
hook | same | Called before Items get updated. Called on all clients and the server. |
void PostUpdateItems() |
hook | same | Called after Items get updated. Called on all clients and the server. |
void PreUpdateDusts() |
hook | same | Called before Dusts get updated. Called on all clients and the server. |
void PostUpdateDusts() |
hook | same | Called after Dusts get updated. Called on all clients and the server. |
void PreUpdateTime() |
hook | same | Called before Time gets updated. Called on all clients and the server. |
void PostUpdateTime() |
hook | same | Called after Time gets updated. Called on all clients and the server. |
void PreUpdateWorld() |
hook | same | Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. Called in single player or on the server only. |
void PostUpdateWorld() |
hook | same | Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. Called in single player or on the server only. |
void PreUpdateInvasions() |
hook | same | Called before Invasions get updated. Called in single player or on the server only. |
void PostUpdateInvasions() |
hook | same | Called after Invasions get updated. Called in single player or on the server only. |
void PostUpdateEverything() |
hook | same | Called after the Network got updated, this is the last hook that happens in an update. Called on all clients and the server. |
void UpdateUI(GameTime gameTime) |
hook | same | Ran every update and suitable for calling Update for UserInterface classes Called on all clients. |
void PostUpdateInput() |
hook | same | Called after the input keys are polled. Allows for modifying things like scroll wheel if your custom drawing should capture that. Called on all clients. |
void ModifyTimeRate(ref double timeRate, ref double tileUpdateRate, ref double eventUpdateRate) |
hook | same | Called after all other time calculations. Can be used to modify the speed at which time should progress per tick in seconds, along with the rate at which the tiles in the world and the events in the world should update with it. All fields are measured in in-game minutes per real-life second (min/sec). You may want to consider IsFastForwardingTime and CreativePowerManager.Instance.GetPower<CreativePowers.FreezeTime>().Enabled here. Called on all clients and the server. |
void ResetNearbyTileEffects() |
hook | same | Use this to reset any fields you set in any of your ModTile.NearbyEffects hooks back to their default values. Called on all clients. |
void TileCountsAvailable(ReadOnlySpan<int> tileCounts) |
hook | same | Allows you to store information about how many of each tile is nearby the player. This is useful for counting how many tiles of a certain custom biome there are. The tileCounts parameter is a read-only span (treat this as an array) that stores the tile count indexed by tile type. Called on all clients. |
void ModifyScreenPosition() |
hook | same | Use this hook to modify screenPosition after weapon zoom and camera lerp have taken place. Called on all clients. Also consider using Main.instance.CameraModifiers.Add(CameraModifier); as shown in ExampleMods MinionBossBody for screen shakes. |
void ModifyTransformMatrix(ref SpriteViewMatrix Transform) |
hook | same | Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.) Called on all clients. |
void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor) |
hook | same | Allows you to modify color of light the sun emits. Called on all clients. |
void ModifyLightingBrightness(ref float scale) |
hook | same | Allows you to modify overall brightness of lights. Can be used to create effects similar 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 Called on all clients. |
void PostDrawTiles() |
hook | same | Called after drawing Tiles. Can be used for drawing a tile overlay akin to wires. Note that spritebatch should be begun and ended within this method. Called on all clients. |
void ModifyInterfaceLayers(List<GameInterfaceLayer> layers) |
hook | same | Allows you to modify the elements of the in-game interface that get drawn. GameInterfaceLayer can be found in the Terraria.UI namespace. Check the Vanilla Interface layers values wiki page for vanilla interface layer names Called on all clients. |
void PostDrawInterface(SpriteBatch spriteBatch) |
hook | same | 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. Called on all clients. |
void PreDrawMapIconOverlay(IReadOnlyList<IMapLayer> layers, MapOverlayDrawContext mapOverlayDrawContext) |
hook | same | Called right before map icon overlays are drawn. Use this hook to selectively hide existing IMapLayer or ModMapLayer Called on all clients. |
void PostDrawFullscreenMap(ref string mouseText) |
hook | same | Called while the fullscreen map is active. Allows custom drawing to the map. Using ModMapLayer is more compatible and allows drawing on the minimap and fullscreen maps. Called on all clients. |
void NetSend(BinaryWriter writer) |
hook | same | Allows you to send custom data between clients and server, which will be handled in NetReceive. This is useful for syncing information such as bosses that have been defeated. Called whenever WorldData is successfully sent, for example after a boss is defeated, a new day starts, or a player joins the server. Only called on the server. |
void NetReceive(BinaryReader reader) |
hook | same | Use this to receive information that was sent in NetSend. Called whenever WorldData is successfully received. Only called on the client. |
bool HijackGetData(ref byte messageType, ref BinaryReader reader, int playerNumber) |
hook | same | Allows you to modify net message / packet information that is received before the game can act on it. |
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) |
hook | same | 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. |
void ModifyGameTipVisibility(IReadOnlyList<GameTipData> gameTips) |
hook | same | Allows you to set the visibility of any added vanilla or modded GameTips. In order to add your OWN tips, add them in your localization file, with the key prefix of "Mods.ModName.GameTips". |
void InitTemplateInstance() |
override | only here | Prepares the template instance. |
void PreWorldGen() |
hook | same | Allows a mod to run code before a world is generated. If you use this to initialize data used during worldgen, which you save on the world, also initialize it in OnWorldLoad. |
void ModifyWorldGenTasks(List<GenPass> tasks) |
hook | same | A more advanced option to PostWorldGen, this method allows you modify the list of Generation Passes before a new world begins to be generated. For example, disabling the "Planting Trees" pass will cause a world to generate without trees. Placing a new Generation Pass before the "Dungeon" pass will prevent the mod's pass from cutting into the dungeon. To disable or hide generation passes, please use Disable and defensive coding. See the "Determining a suitable index" section of the World Generation wiki guide for more information about how to properly use this for adding new world generation passes. |
void ModifyWorldGenTasks(List<GenPass> tasks, ref double totalWeight) |
hook | differs | A more advanced option to PostWorldGen, this method allows you modify the list of Generation Passes before a new world begins to be generated. For example, disabling the "Planting Trees" pass will cause a world to generate without trees. Placing a new Generation Pass before the "Dungeon" pass will prevent the mod's pass from cutting into the dungeon. To disable or hide generation passes, please use Disable and defensive coding. See the "Determining a suitable index" section of the World Generation wiki guide for more information about how to properly use this for adding new world generation passes. tML: void ModifyWorldGenTasks(List<GenPass> tasks)
|
void PostWorldGen() |
hook | same | Use this method to place tiles in the world after world generation is complete. |
void ModifyHardmodeTasks(List<GenPass> list) |
hook | same | Similar to ModifyWorldGenTasks, but occurs in-game when Hardmode starts. Can be used to modify which tasks should be done and/or add custom tasks. By default the list will only contain 5 items, the vanilla hardmode tasks called "Hardmode Good Remix", "Hardmode Good", "Hardmode Evil", "Hardmode Walls", and "Hardmode Announcement". "Hardmode Good Remix" will only be enabled on Don't dig up worlds (remixWorld) while "Hardmode Good" and "Hardmode Evil" will be enabled otherwise. To disable or hide tasks, please use Disable and defensive coding. |
bool RequiresScreenTarget() |
hook | not here | Use this method and return true if you need the game to capture the screen (excluding UI,) ideal for use with finalScreenTarget, and edits to FilterManager.EndCapture. The game may capture the screen regardless of if this returns false explicitly, (for instance: if any vanilla filters are active.) |
abstract class Terraria.ModLoader.ModTexturedType : ModType
The base type for most modded things with textures.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string Texture |
hook | same | The file name of this type's texture file in the mod loader's file space. |
abstract class Terraria.ModLoader.ModType : IModType
The base type for most modded things.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Mod Mod |
property | same | The mod this belongs to. |
string Name |
hook | same | The internal name of this. |
string FullName |
property | same | The internal name of this, including the mod it is from. |
bool IsLoadingEnabled(Mod mod) |
hook | same | Allows you to stop AddContent from actually adding this content. Useful for items that can be disabled by a config. |
void Load() |
hook | same | Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. Use SetStaticDefaults when you need to access content. |
void SetupContent() |
hook | same | If you make a new ModType, seal this override, and call SetStaticDefaults in it. |
void SetStaticDefaults() |
hook | same | Allows you to modify the properties after initial loading has completed. |
void Unload() |
hook | same | Allows you to safely unload things you added in Load. |
string PrettyPrintName() |
method | same | The name with spaces between its words. |
void Register() |
hook | same | If you make a new ModType, seal this override. |
void InitTemplateInstance() |
hook | same | Create dummy objects for instanced mod-types |
TEntity Entity |
property | same | The object this instance works on, such as the Item of a ModItem. |
bool CloneNewInstances |
hook | same | Whether to create new instances of this mod type via Clone or via the default constructor Defaults to false (default constructor). |
TModType Clone(TEntity newEntity) |
hook | same | Create a copy of this instanced global. Called when an entity is cloned. |
TModType NewInstance(TEntity entity) |
hook | same | Create a new instance of this ModType for a specific entity |
TEntity CreateTemplateEntity() |
hook | same | Creates the object of the template instance. |
void ValidateType() |
hook | not here | Check for the correct overrides of different hook methods and fields and properties |
bool IsCloneable |
hook | not here | Whether or not this type is cloneable. Cloning is supported if all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference] |
static class Terraria.ModLoader.ModTypeLookup
Enables content instances to register with Register towards retrieval via and similar methods.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void Register(T instance) |
static method | same | Registers the instance towards lookup via and similar methods. Should only be called once per instance. Registers legacy names specified via LegacyNameAttribute on the instance's type automatically. |
void RegisterLegacyNames(T instance, params string[] legacyNames) |
static method | same | Registers the instance towards lookup via and similar methods using any number of specified legacyNames. Also see which may be more convenient. |
struct Terraria.Localization.NetworkText
Text sent over the network, translated on each client.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string ToString() |
override | same | The text form of this value. |
NetworkText FromKey(string key, params object[] substitutions) |
static method | same | A text sent as a key, so each player reads it in their language. |
NetworkText FromFormattable(string text, params object[] substitutions) |
static method | same | A text sent as is, with its arguments filled in. |
void Serialize(BinaryWriter writer) |
method | same | Writes it to a packet. |
NetworkText Deserialize(BinaryReader reader) |
static method | same | Reads it from a packet. |
static class Terraria.ModLoader.SystemLoader
This is where all ModSystem hooks are gathered and called.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void OnModUnload() |
static method | only here | This hook is called right before Mod.UnLoad() |
void OnLocalizationsLoaded() |
static method | only here | Allows mods to react to language changing. This happens whenever the language is changed, and when resource packs are reloaded. |
void ResizeArrays() |
static method | only here | Called after all mods register content and before all mods start setting up content. This can be used to initialize data structures dependent on the count of various content IDs, usually through SetFactory instances directly. For example, ItemID.Sets.Factory.CreateBoolSet(false, ItemID.PoisonDart, ItemID.PoisonedKnife) will create an array with length equal to the total number of items in the game with the specified item types set to true. The CreateNamedXSet methods can be used to expose an ID set for other mods to use by name without a mod dependency. See also for another similar option. |
void PostSetupRecipes() |
static method | only here | Override this method to do treatment about recipes once they have been setup. You shouldn't edit any recipe here. |
void PostWorldLoad() |
static method | same | Called whenever a world is loaded, after LoadWorldData. At this point, the world is ready to be entered by players, and all modded world data is loaded. Can be used to migrate modded world data across different ModSystems, or to modify tile. For deleting temporary tiles, use ClearedOnWorldLoad instead. Only called in single player or on the server, not on multiplayer clients. |
void OnWorldLoad() |
static method | same | Called whenever a world is loaded, before LoadWorldData If you need to initialize tile or other world related data-structures, use ClearWorld instead |
void OnWorldUnload() |
static method | same | Called whenever a world is unloaded. |
void ClearWorld() |
static method | same | Called whenever the world is cleared. Use this to reset world-related data structures before world-gen or loading in both single and multiplayer. Also called just before mods are unloaded. |
void PreSaveAndQuit() |
static method | same | Called 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. Called on the local client only. |
void PreUpdateEntities() |
static method | same | 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 autoPause is true or 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. Called on all clients and the server. |
void PreUpdatePlayers() |
static method | same | Called before Players get updated. Called on all clients and the server. |
void PostUpdatePlayers() |
static method | same | Called after Players get updated. Called on all clients and the server. |
void PreUpdateNPCs() |
static method | same | Called before NPCs get updated. Called on all clients and the server. |
void PostUpdateNPCs() |
static method | same | Called after NPCs get updated. Called on all clients and the server. |
void PreUpdateGores() |
static method | same | Called before Gores get updated. Called on all clients and the server. |
void PostUpdateGores() |
static method | same | Called after Gores get updated. Called on all clients and the server. |
void PreUpdateProjectiles() |
static method | same | Called before Projectiles get updated. Called on all clients and the server. |
void PostUpdateProjectiles() |
static method | same | Called after Projectiles get updated. Called on all clients and the server. |
void PreUpdateItems() |
static method | same | Called before Items get updated. Called on all clients and the server. |
void PostUpdateItems() |
static method | same | Called after Items get updated. Called on all clients and the server. |
void PreUpdateDusts() |
static method | same | Called before Dusts get updated. Called on all clients and the server. |
void PostUpdateDusts() |
static method | same | Called after Dusts get updated. Called on all clients and the server. |
void PreUpdateTime() |
static method | same | Called before Time gets updated. Called on all clients and the server. |
void PostUpdateTime() |
static method | same | Called after Time gets updated. Called on all clients and the server. |
void PreUpdateWorld() |
static method | same | Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. Called in single player or on the server only. |
void PostUpdateWorld() |
static method | same | Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. Called in single player or on the server only. |
void PreUpdateInvasions() |
static method | same | Called before Invasions get updated. Called in single player or on the server only. |
void PostUpdateInvasions() |
static method | same | Called after Invasions get updated. Called in single player or on the server only. |
void PostUpdateEverything() |
static method | same | Called after the Network got updated, this is the last hook that happens in an update. Called on all clients and the server. |
void PostUpdateInput() |
static method | same | Called after the input keys are polled. Allows for modifying things like scroll wheel if your custom drawing should capture that. Called on all clients. |
void ResetNearbyTileEffects() |
static method | same | Use this to reset any fields you set in any of your ModTile.NearbyEffects hooks back to their default values. Called on all clients. |
void UpdateUI(GameTime gameTime) |
static method | same | Ran every update and suitable for calling Update for UserInterface classes Called on all clients. |
void TileCountsAvailable(ReadOnlySpan<int> tileCounts) |
static method | same | Allows you to store information about how many of each tile is nearby the player. This is useful for counting how many tiles of a certain custom biome there are. The tileCounts parameter is a read-only span (treat this as an array) that stores the tile count indexed by tile type. Called on all clients. |
void ModifyTimeRate(ref double timeRate, ref double tileUpdateRate, ref double eventUpdateRate) |
static method | same | Called after all other time calculations. Can be used to modify the speed at which time should progress per tick in seconds, along with the rate at which the tiles in the world and the events in the world should update with it. All fields are measured in in-game minutes per real-life second (min/sec). You may want to consider IsFastForwardingTime and CreativePowerManager.Instance.GetPower<CreativePowers.FreezeTime>().Enabled here. Called on all clients and the server. |
bool CanWorldBePlayed(PlayerFileData playerData, WorldFileData worldData, out ModSystem rejector) |
static method | same | Allows you to prevent the world and player from being loaded/selected as a valid combination, similar to Journey Mode pairing. |
void ModifyScreenPosition() |
static method | same | Use this hook to modify screenPosition after weapon zoom and camera lerp have taken place. Called on all clients. Also consider using Main.instance.CameraModifiers.Add(CameraModifier); as shown in ExampleMods MinionBossBody for screen shakes. |
void ModifyTransformMatrix(ref SpriteViewMatrix Transform) |
static method | same | Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.) Called on all clients. |
void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor) |
static method | same | Allows you to modify color of light the sun emits. Called on all clients. |
void ModifyLightingBrightness(ref float scale) |
static method | differs | Allows you to modify overall brightness of lights. Can be used to create effects similar 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 Called on all clients. tML: void ModifyLightingBrightness(ref float negLight, ref float negLight2)
|
void PostDrawTiles() |
static method | same | Called after drawing Tiles. Can be used for drawing a tile overlay akin to wires. Note that spritebatch should be begun and ended within this method. Called on all clients. |
void ModifyInterfaceLayers(List<GameInterfaceLayer> layers) |
static method | same | Allows you to modify the elements of the in-game interface that get drawn. GameInterfaceLayer can be found in the Terraria.UI namespace. Check the Vanilla Interface layers values wiki page for vanilla interface layer names Called on all clients. |
void PostDrawInterface(SpriteBatch spriteBatch) |
static method | same | 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. Called on all clients. |
void PreDrawMapIconOverlay(IReadOnlyList<IMapLayer> layers, MapOverlayDrawContext mapOverlayDrawContext) |
static method | same | Called right before map icon overlays are drawn. Use this hook to selectively hide existing IMapLayer or ModMapLayer Called on all clients. |
void PostDrawFullscreenMap(ref string mouseText) |
static method | same | Called while the fullscreen map is active. Allows custom drawing to the map. Using ModMapLayer is more compatible and allows drawing on the minimap and fullscreen maps. Called on all clients. |
bool RequiresScreenTarget() |
static method | not here | Use this method and return true if you need the game to capture the screen (excluding UI,) ideal for use with finalScreenTarget, and edits to FilterManager.EndCapture. The game may capture the screen regardless of if this returns false explicitly, (for instance: if any vanilla filters are active.) |
tModLoader's SystemLoader also has 5 public methods that only run the hooks of the same name. Here those runners are internal. Override the hook in your class instead.
class Terraria.ModLoader.IO.TagCompound : IEnumerable<KeyValuePair<string, object>>
Tag compounds contained named values, serializable as per the NBT spec: NBT spec wiki page All primitive data types are supported as well as byte[], int[] and Lists of other supported data types Lists of Lists are internally stored as IList Modification of lists stored in a TagCompound will only work if there were no type conversions involved and is not advised bool is supported using TagConverter, serialized as a byte. IList will serialize as IList (quite inefficient) Additional conversions can be added using TagConverter The Saving and loading using TagCompound teaches how to properly use the TagCompound class.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Count |
property | same | How many items it holds. |
object this[string key] |
indexer | same | Use this to add values to the TagCompound, similar to working with a . An alternate to this is calling Add directly. If is also possible to use this to retrieve entries from the TagCompound directly, but since the return value is Object this is rarely the best approach. Usually one of the methods should be used for this. One situation where this is necessary is described in the Updates to data Type section of the wiki guide. |
T Get<T>(string key) |
method | same | Retrieves the value corresponding to the key of the Type T. If no entry is found, a default value will be returned. For primitives this will be the typical default value for that primitive (0, false, ""). For classes and structs the returned value will be the result of calling the appropriate deserialize method with an empty TagCompound. This will usually be a default instance of that class or struct. For , an empty list is returned. For arrays, an empty array would be returned. If the found entry is not of the Type T an exception will be thrown. |
bool TryGet<T>(string key, out T value) |
method | same | Attempts to retrieve the value corresponding to the provided key and sets it to value. If found, true is returned by this method, otherwise false is returned. Unlike , TryGet will not attempt to set value to a valid fallback default created by the deserialize method of classes and structs in the case where the key is not found. Use this instead of in situations where falling back to the default value for missing entries would be undesirable. |
void Set(string key, object value, bool replace) |
method | same | Use this to set values to the TagCompound indexed by the specified key. Phone: Accepts numbers, bool, string, byte[], int[], lists, TagCompound, TagSerializable and Item. |
void Add(string key, object value) |
method | same | Use this to add values to the TagCompound indexed by the specified key. |
void Add(KeyValuePair<string, object> entry) |
method | same | Use this to add a KeyValuePair to the TagCompound. |
bool ContainsKey(string key) |
method | same | Returns true if an entry with specified key exists. This is useful to check if a key is present prior to retrieving the value in the case that key potentially won't exist and the default behavior of would be undesirable. The Mod Version Updates section of the wiki guide shows an example of one such situation. |
bool Remove(string key) |
method | same | Removed the entry corresponding to the key. Returns true if the element is successfully found and removed; otherwise, false. |
void Clear() |
method | same | Removes every entry. |
bool GetBool(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
byte GetByte(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
short GetShort(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
int GetInt(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
long GetLong(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
float GetFloat(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
double GetDouble(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
string GetString(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
byte[] GetByteArray(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
int[] GetIntArray(string key) |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
TagCompound GetCompound(string key) |
method | same | GetCompound can be used to retrieve nested TagCompounds. This can be useful for saving complex data. An empty TagCompound is returned if not present. |
IList<T> GetList<T>(string key) |
method | same | Reads a list. Empty when the key is missing. |
object Clone() |
method | same | A copy of this object. |
IEnumerator<KeyValuePair<string, object>> GetEnumerator() |
method | same | Reads an entry of this kind, or the kind's empty value when the key is missing. |
string ToString() |
override | same | The text form of this value. |
short GetAsShort(string key) |
method | not here | Not implemented. |
int GetAsInt(string key) |
method | not here | Not implemented. |
long GetAsLong(string key) |
method | not here | Not implemented. |
double GetAsDouble(string key) |
method | not here | Not implemented. |
static class Terraria.ModLoader.IO.TagIO
Writes and reads a TagCompound in binary.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void ToFile(TagCompound root, string path, bool compress) |
static method | same | Writes a tag to a file. |
TagCompound FromFile(string path, bool compressed) |
static method | same | Reads a tag from a file. |
void ToStream(TagCompound root, Stream stream, bool compress) |
static method | same | Writes a tag to a stream. |
TagCompound FromStream(Stream stream, bool compressed) |
static method | same | Reads a tag from a stream. |
void Write(TagCompound root, BinaryWriter writer) |
static method | same | Writes the TagCompound to the writer. Please don't use this to send TagCompound over the network if you can avoid it. If you have to, consider using ToStream/FromStream with compress: true. |
TagCompound Read(BinaryReader reader) |
static method | same | Reads a tag from a reader. |
object Serialize(object value) |
static method | not here | Not implemented. |
T Deserialize<T>(object tag) |
static method | not here | Not implemented. |
T Clone<T>(T o) |
static method | not here | Not implemented. |
object ReadTag(BinaryReader r, out string name) |
static method | not here | Not implemented. |
object ReadTagImpl(int id, BinaryReader r) |
static method | not here | Not implemented. |
void WriteTag(string name, object tag, BinaryWriter w) |
static method | not here | Not implemented. |
interface Terraria.ModLoader.IO.TagSerializable
An object that saves itself to a TagCompound.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
TagCompound SerializeData() |
hook | same | Writes the value to a tag. |
class Terraria.ModLoader.UsageException : Exception
Throw it in a command to show the player how to use the command.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
new UsageException() |
constructor | same | Creates an instance. |
new UsageException(string msg) |
constructor | same | Creates an instance. |
new UsageException(string msg, Color color) |
constructor | same | Creates an instance. |
Bunny Loader wiki ·
Discord ·
Repository ·
BL Editor
Written for Bunny Loader 0.5.5-beta and Terraria Mobile 1.4.5.8.6.
Bunny Loader is not affiliated with Re-Logic or 505 Games.
