Skip to content

API Interface

JonataOliveiraa edited this page Nov 14, 2026 · 1 revision
Reference

API reference · generated by tools/docs/ApiReference, do not edit by hand

UI states, layers, touch buttons, keybinds, config menus, menus, sounds and music.

AchievementLoader

static class Terraria.ModLoader.AchievementLoader · only in Bunny Loader

Registers mod achievements.

Member Kind tModLoader What it does
int AchievementCount static property only here How many exist, with the game's and every mod's.

AchievementsHelper

struct Terraria.GameContent.Achievements.AchievementsHelper

Reports achievement progress.

Member Kind tModLoader What it does
Action<Player, short, int> OnItemPickup static event differs Fires when a player picks up an item. tML: ItemPickupEvent OnItemPickup
Action<short, int> OnItemCraft static event differs Fires when an item is crafted. tML: ItemCraftEvent OnItemCraft
Action<Player, ushort> OnTileDestroyed static event differs Fires when a player breaks a tile. tML: TileDestroyedEvent OnTileDestroyed
Action<Player, short> OnNPCKilled static event differs Fires when a player kills an NPC. tML: NPCKilledEvent OnNPCKilled
Action<int> OnProgressionEvent static event differs Fires on a progression event of the game. tML: ProgressionEventEvent OnProgressionEvent

ArmorShaderData

struct Terraria.Graphics.Shaders.ArmorShaderData

A shader for a dye.

Member Kind tModLoader What it does
new ArmorShaderData(Asset<Effect> shader, string passName) constructor only here Creates an instance.

ArmorShaderDataSet

struct Terraria.Graphics.Shaders.ArmorShaderDataSet

GameShaders.Armor: binds a dye item to its shader.

Member Kind tModLoader What it does
T BindShader<T>(int itemId, T shaderData) method same Ties a shader to a dye item.

Color

struct Microsoft.Xna.Framework.Graphics.Color · only in Bunny Loader

What Bunny Loader adds to the color.

Member Kind tModLoader What it does
new Color(int r, int g, int b) constructor XNA Creates an instance.
new Color(int r, int g, int b, int a) constructor XNA Creates an instance.
new Color(float r, float g, float b) constructor XNA Creates an instance.
bool Equals(object obj) override XNA Whether both hold the same value.
int GetHashCode() override XNA The hash of this value.
new Color(float r, float g, float b, float a) constructor XNA Creates an instance.
string ToString() override XNA The text form of this value.

ColorHSLSliderAttribute

class Terraria.ModLoader.Config.ColorHSLSliderAttribute : Attribute

Add this attribute to a Color item and the UI will present a Hue, Saturation, and Lightness sliders rather than Red, Green, and Blue sliders. Pass in false to skip Saturation and Lightness.

Member Kind tModLoader What it does
bool ShowSaturationAndLightness property same Whether those two sliders show.
new ColorHSLSliderAttribute(bool showSaturationAndLightness) constructor same Creates an instance.

ColorNoAlphaAttribute

class Terraria.ModLoader.Config.ColorNoAlphaAttribute : Attribute

Add this attribute to a Color item and Alpha will not be presented in the UI and will remain as 255 unless manually edited.

Member Kind tModLoader What it does

Colors

static class Terraria.ID.Colors

The game's named colors.

Member Kind tModLoader What it does
Color PrefixBad static field only here The color of a bad prefix.
Color PrefixGood static field only here The color of a good prefix.

ConfigArgsAttribute

abstract class Terraria.ModLoader.Config.ConfigArgsAttribute : Attribute

Base of config attributes with arguments.

Member Kind tModLoader What it does
new ConfigArgsAttribute(params object[] args) constructor same Creates an instance.

ConfigKeyAttribute

abstract class Terraria.ModLoader.Config.ConfigKeyAttribute : Attribute

Base of config attributes that take a localization key.

Member Kind tModLoader What it does
new ConfigKeyAttribute(string key) constructor same Creates an instance.

ConfigManager

static class Terraria.ModLoader.Config.ConfigManager

Finds configs by type. ConfigManager.Save writes one.

Member Kind tModLoader What it does
string ModConfigPath static property same The folder of the config files.
ModConfig GetConfig(Mod mod, string config) static method only here A config of a mod, by name.
JsonSerializerSettings serializerSettings static field not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
string ServerModConfigPath static field not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
IEnumerable<PropertyFieldWrapper> GetFieldsAndProperties(object item) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
ModConfig GeneratePopulatedClone(ModConfig original) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
object AlternateCreateInstance(Type type) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
T GetCustomAttributeFromMemberThenMemberType<T>(PropertyFieldWrapper memberInfo, object item, object array) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
T GetCustomAttributeFromCollectionMemberThenElementType<T>(MemberInfo memberInfo, Type elementType) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
Tuple<UIElement, UIElement> WrapIt(UIElement parent, ref int top, PropertyFieldWrapper memberInfo, object item, int order, object list, Type arrayType, int index) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
void SetPendingChanges(bool changes) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
bool ObjectEquals(object a, object b) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.
bool EnumerableEquals(IEnumerable a, IEnumerable b) static method not here Part of tModLoader's config screen. The screen here is Bunny Loader's own.

ConfigSaveResult

enum Terraria.ModLoader.Config.ConfigSaveResult

Contains potential results for SaveChanges.

Values: Success, NeedsReload, RequestSentToServer

ConfigScope

enum Terraria.ModLoader.Config.ConfigScope

Each ModConfig class has a different scope. Failure to use the correct mode will lead to bugs.

Values: ServerSide, ClientSide

DefaultDamageClass

class Terraria.ModLoader.DefaultDamageClass : VanillaDamageClass

One of the game's damage classes. Reach it with DamageClass.X.

Member Kind tModLoader What it does
int LangKey override differs Which Lang.tip text names this class. tML: string LangKey
StatInheritanceData GetModifierInheritance(DamageClass damageClass) override same This lets you define the classes that this DamageClass will benefit from (other than itself) for the purposes of stat bonuses, such as damage and crit chance. This is used to allow extensive specifications for what your damage class can and can't benefit from in terms of other classes' stat bonuses.

DefaultDictionaryKeyValueAttribute

class Terraria.ModLoader.Config.DefaultDictionaryKeyValueAttribute : Attribute

Defines the default key value to be added when using the ModConfig UI to add elements to a Dictionary. Works the same as System.ComponentModel.DefaultValueAttribute, but can't inherit from it because it would break when deserializing any data structure annotated with it. This attribute compliments DefaultListValueAttribute when used annotating a Dictionary.

Member Kind tModLoader What it does
object Value hook same The value given to the attribute.
new DefaultDictionaryKeyValueAttribute(Type type, string value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(char value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(byte value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(short value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(int value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(long value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(float value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(double value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(bool value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(string value) constructor same Creates an instance.
new DefaultDictionaryKeyValueAttribute(object value) constructor same Creates an instance.
void SetValue(object value) method not here Internal to the attribute.

DefaultListValueAttribute

class Terraria.ModLoader.Config.DefaultListValueAttribute : Attribute

Defines the default value to be added when using the ModConfig UI to add elements to a Collection (List, Set, or Dictionary value). Works the same as System.ComponentModel.DefaultValueAttribute, but can't inherit from it because it would break when deserializing any data structure annotated with it.

Member Kind tModLoader What it does
object Value property same The value given to the attribute.
new DefaultListValueAttribute(Type type, string value) constructor same Creates an instance.
new DefaultListValueAttribute(char value) constructor same Creates an instance.
new DefaultListValueAttribute(byte value) constructor same Creates an instance.
new DefaultListValueAttribute(short value) constructor same Creates an instance.
new DefaultListValueAttribute(int value) constructor same Creates an instance.
new DefaultListValueAttribute(long value) constructor same Creates an instance.
new DefaultListValueAttribute(float value) constructor same Creates an instance.
new DefaultListValueAttribute(double value) constructor same Creates an instance.
new DefaultListValueAttribute(bool value) constructor same Creates an instance.
new DefaultListValueAttribute(string value) constructor same Creates an instance.
void SetValue(object value) method not here Internal to the attribute.

DrawTicksAttribute

class Terraria.ModLoader.Config.DrawTicksAttribute : Attribute

Add this attribute and the sliders will show white tick marks at each increment.

Member Kind tModLoader What it does

GameInterfaceDrawMethod

delegate Terraria.UI.GameInterfaceDrawMethod

The body of a LegacyGameInterfaceLayer.

Member Kind tModLoader What it does

GameInterfaceLayer

class Terraria.UI.GameInterfaceLayer

One layer of the game's interface, from ModSystem.ModifyInterfaceLayers.

Member Kind tModLoader What it does
string Name field same The layer's name, used to find it in the list.
InterfaceScaleType ScaleType field same Which scale the layer draws in.
bool Active field same Whether it draws.
new GameInterfaceLayer(string name, InterfaceScaleType scaleType) constructor same Creates an instance.
bool Draw() method same Sets the scale and draws. Returns false to stop the layers after it.
bool DrawSelf() hook same Draws the layer's content.

HairColorMethod

delegate Terraria.GameContent.Dyes.HairColorMethod · only in Bunny Loader

The color a hair dye gives.

HairID

class Terraria.ID.HairID

Hair types.

Member Kind tModLoader What it does
int Count const same How many items it holds.
IdDictionary Search static field not here Not implemented.

HairID.Sets

static class Terraria.ID.HairID.Sets

Tables indexed by hair type.

Member Kind tModLoader What it does
bool[] DrawBackHair static field same If true for a given hair value, then that hair will additionally draw behind the player's back using hairBackFrame. Set this to prevent long hair from drawing in front of capes. Defaults to false.
SetFactory Factory static field not here Not implemented.

HairShaderDataSet

struct Terraria.Graphics.Shaders.HairShaderDataSet

GameShaders.Hair: binds a hair dye to its shader.

Member Kind tModLoader What it does
T BindShader<T>(int itemId, T shaderData) method same Ties a shader to a dye item.

HeaderAttribute

class Terraria.ModLoader.Config.HeaderAttribute : Attribute

This attribute adds a label above this property or field in the ModConfig UI that acts as a header. Use this to delineate sections within your config. Note that fields will be in order, and properties will be in order, but fields and properties will not be interleaved together in the source code order. Header accept either a translation key or an identifier. To use a translation key, the value passed in must start with "$". A value passed in that does not start with "$" is interpreted as an identifier. The identifier is used to construct the localization key "Mods.{ModName}.Configs.{ConfigName}.Headers.{Identifier}" No spaces are allowed in translation keys, so avoid spaces Annotations on members of non-ModConfig classes need to supply a localization key using this attribute to be localized, no localization key can be correctly assumed using just an identifier.

Member Kind tModLoader What it does
bool IsIdentifier property same Whether Header is a key in the mod's config texts.
string Header property same The text or key of the header.
new HeaderAttribute(string identifierOrKey) constructor same Creates an instance.

IncrementAttribute

class Terraria.ModLoader.Config.IncrementAttribute : Attribute

Use this to set an increment for sliders (if using SliderAttribute) or the +/- buttons. The slider will move by the amount assigned. The +/- buttons will adjust the value by the amount as well. Remember that this is just a UI suggestion and manual editing of config files can specify other values, so validate your values. Defaults are as follows: float: 0.01f byte/int/uint/long/ulong: 1 When using this, you might need to cast the arguments to the desired numeric type to call the correct overload.

Member Kind tModLoader What it does
object Increment property same The step of the slider.
new IncrementAttribute(int increment) constructor same Creates an instance.
new IncrementAttribute(float increment) constructor same Creates an instance.
new IncrementAttribute(uint increment) constructor same Creates an instance.
new IncrementAttribute(long increment) constructor same Creates an instance.
new IncrementAttribute(ulong increment) constructor same Creates an instance.
new IncrementAttribute(byte increment) constructor same Creates an instance.

JsonDefaultDictionaryKeyValueAttribute

class Terraria.ModLoader.Config.JsonDefaultDictionaryKeyValueAttribute : Attribute

Similar to JsonDefaultListValueAttribute, but for assigning to the Dictionary Key rather than the Value.

Member Kind tModLoader What it does
string Json property same The default value, written as JSON.
new JsonDefaultDictionaryKeyValueAttribute(string json) constructor same Creates an instance.

JsonDefaultListValueAttribute

class Terraria.ModLoader.Config.JsonDefaultListValueAttribute : Attribute

Similar to DefaultListValueAttribute but for reference types. It uses a json string that will be used populate new instances list elements. Defines the default value, expressed as json, to be added when using the ModConfig UI to add elements to a Collection (List, Set, or Dictionary value).

Member Kind tModLoader What it does
string Json property same The default value, written as JSON.
new JsonDefaultListValueAttribute(string json) constructor same Creates an instance.

JsonDefaultValueAttribute

class Terraria.ModLoader.Config.JsonDefaultValueAttribute : Attribute

Similar to DefaultValueAttribute but for reference types. It uses a json string that will be used populate this element when initialized. Defines the default value, expressed as json, to be used to populate an object with the NullAllowed attribute. Modders should only use this in conjunction with NullAllowed, as simply initializing the field with a default value is preferred.

Member Kind tModLoader What it does
string Json property same The default value, written as JSON.
new JsonDefaultValueAttribute(string json) constructor same Creates an instance.

KeybindLoader

static class Terraria.ModLoader.KeybindLoader

Registers a ModKeybind. On the phone it gives a ModTouchButton.

Member Kind tModLoader What it does
ModKeybind RegisterKeybind(Mod mod, string name, Keys defaultBinding) static method same Registers a keybind with a name and defaultBinding. Use the returned ModKeybind to detect when buttons are pressed.
ModKeybind RegisterKeybind(Mod mod, string name, string defaultBinding) static method same Registers a keybind with a name and defaultBinding. Use the returned ModKeybind to detect when buttons are pressed.

LabelArgsAttribute

class Terraria.ModLoader.Config.LabelArgsAttribute : ConfigArgsAttribute

Use to provide values to be interpolated into the label of the annotated property or field. string arguments starting with "$" are interpreted as localization keys. Interpolating values can be useful for reusing common labels to keep localization files clean and organized. For example, if a mod provides toggles for several features, a common label could be used for each with only the provided value being different. The string formatting section of the Localization wiki page explains this concept further. Scope simplification can be used to shorten localization keys passed in.

Member Kind tModLoader What it does
new LabelArgsAttribute(params object[] args) constructor same Creates an instance.

LabelKeyAttribute

class Terraria.ModLoader.Config.LabelKeyAttribute : ConfigKeyAttribute

A label is the text shown to the user in the ModConfig UI. This attribute sets a custom localization key for the label of the annotated property, field, or class. The provided localization key must start with "$". Without this attribute, the localization key "Mods.{ModName}.Configs.{ConfigName}.{MemberName}.Label" will be assumed for members of ModConfig classes. Annotations on members of non-ModConfig classes need to supply a custom localization key using this attribute to be localized, otherwise they will appear as the member name directly. If the translation value of a property or field that is an object is an empty string, the label of the class will be used instead. Values can be interpolated into the resulting label text using LabelArgsAttribute.

Member Kind tModLoader What it does
new LabelKeyAttribute(string key) constructor same Creates an instance.

LegacyGameInterfaceLayer

class Terraria.UI.LegacyGameInterfaceLayer : GameInterfaceLayer

A layer that draws with a method of yours. The usual way to add one.

Member Kind tModLoader What it does
new LegacyGameInterfaceLayer(string name, GameInterfaceDrawMethod drawMethod, InterfaceScaleType scaleType) constructor same Creates an instance.
bool DrawSelf() override same Calls the method given to the layer.

MenuLoader

static class Terraria.ModLoader.MenuLoader

Runs the mod title menus.

Member Kind tModLoader What it does
ModMenu CurrentMenu static property same The menu theme in use.
void ActivateOldVanillaMenu() static method not here Internal to tModLoader's menu.
void ActivateBiggerAndBoulderMenu() static method not here Internal to tModLoader's menu.

ModAchievement

abstract class Terraria.ModLoader.ModAchievement : ModType<Achievement, ModAchievement>

Defines a custom achievement and implements how it should act upon completion. An achievement consists of several parts: The ModAchievement represents a single achievement, it provides the image (Texture), display name (FriendlyName), description (Description), and category (SetCategory). Each achievement also has one or more conditions (AchievementCondition). Conditions can be existing conditions, like crafting specific items or killing specific NPCs, or they can be completely custom. If an achievement has multiple conditions, each must use a unique identifier. Once every condition is completed, the achievement itself is completed and OnCompleted is called. And finally, each achievement can have an optional tracker. The tracker is responsible for consolidating all of the conditions and reporting a completion progress value shown in the achievements menu. A tracker will be assigned automatically if not assigned in SetStaticDefaults and if there are multiple conditions or if the sole condition has an associated tracker. Achievements are not loaded on the server.

Member Kind tModLoader What it does
Achievement Achievement property same The Achievement object that this ModAchievement controls.
string TextureName hook same The texture's path.
Asset<Texture2D> Texture property same The texture loaded from TextureName.
int Index hook same The index of this achievement within the texture. Additional achievements are placed below on new rows. Can be used to share a achievement texture among multiple achievements. Defaults to 0.
string LocalizationCategory property same The folder of this content in the localization files.
bool Hidden hook same Should the achievement be hidden, meaning its name and description will both appear as "???" in the achievements menu. Defaults to false.
LocalizedText FriendlyName hook same Gets the localized friendly name of the achievement.
LocalizedText Description hook same Gets the localized description of the achievement.
CustomFlagCondition AddCondition(string key) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
CustomIntCondition AddIntCondition(int maxValue) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
CustomIntCondition AddIntCondition(string key, int maxValue) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
CustomFloatCondition AddFloatCondition(float maxValue) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
CustomFloatCondition AddFloatCondition(string key, float maxValue) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemCraftCondition AddItemCraftCondition(int itemId) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemCraftCondition AddItemCraftCondition(string key, int itemId) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemCraftCondition AddItemCraftCondition(int[] itemIds) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemCraftCondition AddItemCraftCondition(string key, int[] itemIds) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemCraftCondition[] AddManyItemCraftCondition(int[] itemIds) method same Adds a ItemCraftCondition for each itemIds entry. Unlike with passing in several Item IDs to AddItemCraftCondition, this method will require that each Item be crafted rather than just any one of them.
ItemPickupCondition AddItemPickupCondition(int itemId) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemPickupCondition AddItemPickupCondition(string key, int itemId) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemPickupCondition AddItemPickupCondition(int[] itemIds) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemPickupCondition AddItemPickupCondition(string key, int[] itemIds) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
ItemPickupCondition[] AddManyItemPickupCondition(int[] itemIds) method same Adds a ItemPickupCondition for each itemIds entry. Unlike with passing in several Item IDs to AddItemPickupCondition, this method will require that each Item be picked up rather than just any one of them.
NPCKilledCondition AddNPCKilledCondition(int npcID) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
NPCKilledCondition AddNPCKilledCondition(string key, int npcID) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
NPCKilledCondition AddNPCKilledCondition(int[] npcIDs) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
NPCKilledCondition AddNPCKilledCondition(string key, int[] npcIDs) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
NPCKilledCondition[] AddManyNPCKilledCondition(int[] npcIDs) method same Adds a NPCKilledCondition for each npcIDs entry. Unlike with passing in several NPC IDs to AddNPCKilledCondition, this method will require that each NPC be killed rather than just any one of them.
TileDestroyedCondition AddTileDestroyedCondition(int[] tileIds) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
TileDestroyedCondition AddTileDestroyedCondition(string key, int[] tileIds) method same Adds a condition that completes the achievement. Each overload takes a custom key or the default one.
T AddCondition<T>(T condition) method same Used to add any custom AchievementCondition.
void OnCompleted(Achievement achievement) hook same Called when the achievement is completed. Use this to add custom behavior when the achievement is achieved. Note that achievements will only be completed once per user, not per world or per player, so rewarding players with tangible rewards, like an Item, isn't recommended.
void AutoStaticDefaults() hook same Automatically assigns an IAchievementTracker if not yet assigned. Override this if you need to skip this logic.
Position GetDefaultPosition() hook same Returns the achievement's default position in regard to vanilla's achievement ordering. Make use of e.g. Before/After, and provide an achievement (for example new After("EYE_ON_YOU")). Consult the Achievement Identifiers section of the Vanilla Content IDs wiki page to look up the string to use with GetAchievement. You can also use BeforeFirstVanillaAchievement or AfterLastVanillaAchievement to put your achievement at the start/end of the vanilla achievement order. NOTE: The position must specify a vanilla Achievement otherwise an exception will be thrown. Use GetModdedConstraints to order modded achievements. By default, this hook positions this achievement after all vanilla achievements.
Position GetAdvisorPosition() hook same Some of the vanilla achievements are showed next to the inventory to advise the player on what to do next. This hook allows you to place this achievement in the advisor before/after other vanilla advisor achievements. Make use of e.g. Before/After, and provide an achievement (for example new After("EYE_ON_YOU")). Consult the Achievement Identifiers section of the Vanilla Content IDs wiki page to look up the string to use with GetAchievement. You can also use BeforeFirstAdvisorAchievement or AfterLastAdvisorAchievement to put your achievement at the start/end of the vanilla advisor achievement order. NOTE: The position must specify a vanilla Achievement that is in the advisor otherwise an exception will be thrown. The wiki page lists which vanilla achievements are used in the advisor and their order, which differs from the normal order. Use to order modded achievements. By default, this hook returns null, which indicates that this achievement will not be placed inside the advisor.
IEnumerable<Position> GetModdedConstraints() hook same Modded achievements are placed between vanilla achievements via GetDefaultPosition and, by default, are sorted in load order. This hook allows you to sort this achievement before/after other modded achievements that were placed between the same two vanilla achievements. Example: yield return new After(ModContent.GetInstance<MinionBossKilled>()); By default, this hook returns null, which indicates that this achievement has no modded ordering constraints.
Position BeforeFirstVanillaAchievement static property same Before every achievement of the game.
Position AfterLastVanillaAchievement static property same After every achievement of the game.
Position BeforeFirstAdvisorAchievement static property same Before the first advisor achievement.
Position AfterLastAdvisorAchievement static property same After the last advisor achievement.

ModAchievement.After

class Terraria.ModLoader.ModAchievement.After : Position

Places an achievement after another one.

Member Kind tModLoader What it does
Achievement Achievement property same The achievement it follows.
new After(Achievement achievement) constructor same Creates an instance.
new After(ModAchievement modAchievement) constructor same Creates an instance.
new After(string achievementIdentifier) constructor same Consult the Achievement Identifiers section of the Vanilla Content IDs wiki page to look up vanilla achievement identifiers. Modded achievements will be in the form of "ModName/Name".

ModAchievement.Before

class Terraria.ModLoader.ModAchievement.Before : Position

Places an achievement before another one.

Member Kind tModLoader What it does
Achievement Achievement property same The achievement it comes before.
new Before(Achievement achievement) constructor same Creates an instance.
new Before(ModAchievement modAchievement) constructor same Creates an instance.
new Before(string achievementIdentifier) constructor same Creates an instance.

ModAchievement.Default

class Terraria.ModLoader.ModAchievement.Default : Position

Places an achievement in its default spot, at the end.

Member Kind tModLoader What it does

ModAchievement.Position

abstract class Terraria.ModLoader.ModAchievement.Position

Where an achievement goes in the list.

Member Kind tModLoader What it does

ModConfig

abstract class Terraria.ModLoader.Config.ModConfig : ILocalizedModType

ModConfig provides a way for mods to be configurable. ModConfigs can either be Client specific or Server specific. When joining a MP server, Client configs are kept but Server configs are synced from the server. Using serialization attributes such as [DefaultValue(5)] or [JsonIgnore] are critical for proper usage of ModConfig. tModLoader also provides its own attributes such as ReloadRequiredAttribute and LabelAttribute.

Member Kind tModLoader What it does
Mod Mod property same The mod.
string Name property same The config's name.
string FullName property same Mod/Name.
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.
LocalizedText DisplayName hook same The name shown to the player, as localized text.
ConfigScope Mode hook same Whether it belongs to the client or the server.
bool Autoload(ref string name) hook same Whether this class is loaded.
void OnLoaded() hook same This method is called when the ModConfig has been loaded for the first time. This happens before regular Autoloading and Mod.Load. You can use this hook to assign a static reference to this instance for easy access. tModLoader will automatically assign (and later unload) this instance to a static field named Instance in the class prior to calling this method, if it exists.
void OnChanged() hook same This hook is called anytime new config values have been set and are ready to take effect. This will always be called right after OnLoaded and anytime new configuration values are ready to be used. The hook won't be called with values that violate NeedsReload. Use this hook to integrate with other code in your Mod to apply the effects of the configuration values. If your NeedsReload is correctly implemented, you should be able to apply the settings without error in this hook. Be aware that this hook can be called in-game and in the main menu, as well as in single player and multiplayer situations.
bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref NetworkText message) hook same Called on the Server for ServerSide configs to determine if the changes asked for by the Client will be accepted. Useful for enforcing permissions. Called after a check for NeedsReload. In advanced situations pendingConfig can be modified here and the changes will be applied and be synced.
void HandleAcceptClientChangesReply(bool success, int player, NetworkText message) hook same Called on multiplayer clients after the server accepts or rejects ServerSide config changes made by a client. Can be used to update UI attempting to manually save changes to a ServerSide config (using SaveChanges. For rejections this is only called on the client who requested the changes. player indicates which player requested the changes (see myPlayer). success indicates if the changes were accepted and message is the corresponding message from AcceptClientChanges.
ModConfig Clone() hook same tModLoader will call Clone on ModConfig to facilitate proper implementation of the ModConfig user interface and detecting when a reload is required. Modders need to override this method if their config contains reference types. Failure to do so will lead to bugs. See ModConfigShowcaseDataTypes.Clone for examples and explanations.
bool NeedsReload(ModConfig pendingConfig) hook same Whether or not a reload is required. The default implementation compares properties and fields annotated with the ReloadRequiredAttribute. Unlike the other ModConfig hooks, this method is called on a clone of the ModConfig that was saved during mod loading. The pendingConfig has values that are about to take effect. Neither of these instances necessarily match the instance used in OnLoaded.
ConfigSaveResult SaveChanges(ModConfig pendingConfig, Action<string, Color> status, bool silent, bool broadcast) method same Attempts to save changes made to this ModConfig. This must be called on the active ModConfig instance. If pendingConfig is provided, it will be used as the source for the changes to apply to the active config instance. If status is provided, it will be called with text and a color to indicate the status of the operation. If silent is false, sounds will play indicating success or failure. If broadcast is false, the chat message informing all players when a ServerSide config is changed saying "Shared config changed: Message: {0}, Mod: {1}, Config: {2}" will not appear on clients. Mod code can run this method in-game, but there are some considerations to keep in mind: Calling this method on a ServerSide config from a multiplayer client will result in RequestSentToServer being returned and the actual save logic being performed on the server. HandleAcceptClientChangesReply will be called on all clients after the server accepts or denies the changes. Calling this method on the server for a ServerSide config is also supported. Attempting to save changes that would violate NeedsReload will fail and NeedsReload will be returned. If there is a chance that the changes won't be accepted, or if you want to provide a UI for the user to make changes without them taking effect immediately, you should use a clone of the ModConfig and pass it in as pendingConfig instead of modifying the active ModConfig directly. To make a clone, call the GeneratePopulatedClone method. See ExampleFullscreenUI.cs for a complete example of using this method.
void Open(Action onClose, string scrollToOption, bool centerScrolledOption, bool playSound) method same Opens this config in the config UI. Can be used to allow your own UI to access the config. onClose can be used to run code after the config is closed, such as opening a modded UI or showing a message to the user. scrollToOption can be used to scroll to a specific member of the config and highlight it. It can also be used to scroll to the header above a member using the format "Header:{MemberNameHere}". If the member has [SeparatePage] then the subpage will open automatically as well. Set centerScrolledOption to false if you'd like the config option to be at the top of the list when focused instead of at the center.

ModKeybind

class Terraria.ModLoader.ModKeybind

Represents a loaded input binding. It is suggested to access the keybind status only in ModPlayer.ProcessTriggers.

Member Kind tModLoader What it does
LocalizedText DisplayName property same The name shown to the player, as localized text.
List<string> GetAssignedKeys(InputMode mode) method same Gets the currently assigned keybindings. Useful for prompts, tooltips, informing users.
bool RetroCurrent property same Current, but false during chat, an NPC chat or a sign.
bool Current property same Returns true if this keybind is pressed currently. Useful for creating a behavior that relies on the keybind being held down.
bool JustPressed property same Returns true if this keybind has just been pressed this update. This is a fire-once-per-press behavior.
bool JustReleased property same Returns true if this keybind has just been released this update.
bool Old property same Returns true if this keybind has been pressed during the previous update.
string ToString() override only here The text form of this value.

ModMenu

abstract class Terraria.ModLoader.ModMenu : ModType

A class that is used to customize aesthetic features of the main menu, such as the logo, background and music.

Member Kind tModLoader What it does
Asset<Texture2D> Logo hook same The logo texture shown when this ModMenu is active. If not overridden, it will use the tModLoader logo.
Asset<Texture2D> SunTexture hook same The sun texture shown when this ModMenu is active. If not overridden, it will use the vanilla sun.
Asset<Texture2D> MoonTexture hook same The moon texture shown when this ModMenu is active. If not overridden, it will use the vanilla moon.
int Music hook same The music that will be played while this ModMenu is active. If not overridden, it will use the vanilla music.
ModSurfaceBackgroundStyle MenuBackgroundStyle hook same The background style that will be used when this ModMenu is active. If not overridden, it will use the vanilla background.
bool IsAvailable hook same Controls whether this ModMenu will be available to switch to. Useful if you want this menu to only be available at specific times.
string DisplayName hook same Controls the name that shows up at the base of the screen when this ModMenu is active. If not overridden, it will use this mod's display name.
bool IsSelected property same Whether this theme is in use.
void OnSelected() hook same Called when this ModMenu is selected. Set the state of the UserInterface to a given UIState to make that UIState appear on the main menu.
void OnDeselected() hook same Called when this ModMenu is deselected.
void Update(bool isOnTitleScreen) hook same Called when this ModMenu's logic is updated.
bool PreDrawLogo(SpriteBatch spriteBatch, ref Vector2 logoDrawCenter, ref float logoRotation, ref float logoScale, ref Color drawColor) hook same Called just before the logo is drawn, and allows you to modify some of the parameters of the logo draw code.
void PostDrawLogo(SpriteBatch spriteBatch, Vector2 logoDrawCenter, float logoRotation, float logoScale, Color drawColor) hook same Called just after the logo is drawn, and gives the values of some of the parameters of the logo draw code.
UserInterface UserInterface property not here Not implemented. The menu theme draws through PreDrawLogo and PostDrawLogo.
bool IsNew property not here Marks a new theme in tModLoader's selector. The selector here is different.

ModTouchButton

class Terraria.ModLoader.ModTouchButton : ModKeybind · only in Bunny Loader

A button on the screen, placed by the player in the game's controls editor. A ModKeybind on the phone. See Touch buttons.

Member Kind tModLoader What it does
Mod Mod property only here The mod that registered it.
string Name property only here The button's name.
string FullName property only here Mod/Name.
string Icon property only here The icon's path, or null for the default.
Func<string> Label property only here The button's name in the editor list.
Func<bool> Visible property only here Whether it shows now. Null always shows.
Func<bool> Enabled property only here Whether it reacts now. Null always reacts.
Action<Player> OnPress property only here Runs when it is tapped.
bool IsBound property only here Whether the player placed it on the screen.

ModTouchJoystick

class Terraria.ModLoader.ModTouchJoystick : ModTouchButton · only in Bunny Loader

A button the player drags to aim. See Touch buttons.

Member Kind tModLoader What it does
Vector2 Direction property only here Where the stick points now.
bool Aiming property only here Whether a finger is on it.
Action<Player, Vector2> OnRelease property only here Runs when the finger lifts, with the last direction.

MusicLoader

static class Terraria.ModLoader.MusicLoader

Registers mod music and music boxes. GetMusicSlot gives a track's number.

Member Kind tModLoader What it does
int MusicCount static property same How many exist, with the game's and every mod's.
int GetMusicSlot(Mod mod, string musicPath) static method same Gets the music id of the track with the specified mod path. The path must not have a file extension.
int GetMusicSlot(string musicPath) static method same Gets the music id of the track with the specified full path. The path must be prefixed with a mod name and must not have a file extension.
bool MusicExists(Mod mod, string musicPath) static method same Returns whether or not a music track with the specified mod path exists. The path must not have a file extension.
bool MusicExists(string musicPath) static method same Returns whether or not a music track with the specified path exists. The path must be prefixed with a mod name and must not have a file extension.
void AddMusic(Mod mod, string musicPath) static method same Registers a new music track with the provided mod and its local path to the sound file. Use this for any music not autoloaded by the MusicAutoloadingEnabled logic.
void AddMusicBox(Mod mod, int musicSlot, int itemType, int tileType, int tileFrameY) static method same 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.
bool IsMusicPlaying(int slot) static method only here Whether a music slot of a mod is playing.
IAudioTrack GetMusic(Mod mod, string musicPath) static method not here Gets the music track with the specified mod path. The path must not have a file extension.

OptionStringsAttribute

class Terraria.ModLoader.Config.OptionStringsAttribute : Attribute

By default, string fields will provide the user with a text input field. Use this attribute to restrict strings to a selection of options. This approach is not recommended due to feature deficiencies. It is recommended to use an enum instead of a string for this type of option selection. By using an enum instead of a string paired with OptionStringsAttribute, localization is possible and automatic. It is also easier to work with enum values and less prone to errors caused by typos. If you want to migrate from a string option entry to an enum in an update to a released mod, you should use the EnumMemberAttribute on the enum fields corresponding to existing string options that had spaces in them previously to support correctly loading the existing config choices of your users when they update the mod: [EnumMember(Value = "Left Aligned")] LeftAligned,

Member Kind tModLoader What it does
string[] OptionLabels property same The choices.
new OptionStringsAttribute(string[] optionLabels) constructor same Creates an instance.

RangeAttribute

class Terraria.ModLoader.Config.RangeAttribute : Attribute

Specifies a range for primitive data values. Without this, default min and max are as follows: float: 0, 1 int/uint: 0, 100 byte: 0, 255 long/ulong: Unchanged from the full range of the type When using this, you might need to cast the arguments to the desired numeric type to call the correct overload.

Member Kind tModLoader What it does
object Min property same The smallest value.
object Max property same The largest value.
new RangeAttribute(int min, int max) constructor same Creates an instance.
new RangeAttribute(float min, float max) constructor same Creates an instance.
new RangeAttribute(uint min, uint max) constructor same Creates an instance.
new RangeAttribute(long min, long max) constructor same Creates an instance.
new RangeAttribute(ulong min, ulong max) constructor same Creates an instance.
new RangeAttribute(byte min, byte max) constructor same Creates an instance.

RangedDamageClass

class Terraria.ModLoader.RangedDamageClass : VanillaDamageClass

One of the game's damage classes. Reach it with DamageClass.X.

Member Kind tModLoader What it does
int LangKey override differs Which Lang.tip text names this class. tML: string LangKey

ReloadRequiredAttribute

class Terraria.ModLoader.Config.ReloadRequiredAttribute : Attribute

This attribute hints that changing the value of the annotated property or field will put the config in a state that requires a reload. An overridden ModConfig.NeedsReload can further validate if more complex logic is needed.

Member Kind tModLoader What it does

SeparatePageAttribute

class Terraria.ModLoader.Config.SeparatePageAttribute : Attribute

This specifies that the annotated item will appear as a button that leads to a separate page in the UI. Use this to organize hierarchies.

Member Kind tModLoader What it does

ShowDespiteJsonIgnoreAttribute

class Terraria.ModLoader.Config.ShowDespiteJsonIgnoreAttribute : Attribute

This attribute indicates that the field or property should be shown in the ModConfig UI despite having a JsonIgnoreAttribute annotation.

Member Kind tModLoader What it does

ShowItemDropInUI

enum Terraria.GameContent.ItemDropRules.ShowItemDropInUI

Whether a drop shows in the bestiary.

Values: Always, Never, WhenConditionSatisfied

SliderAttribute

class Terraria.ModLoader.Config.SliderAttribute : Attribute

Affects whether this data will be presented as a slider or an input field. Add this attribute to use a slider. Currently only affects data of type int and enum.

Member Kind tModLoader What it does

SliderColorAttribute

class Terraria.ModLoader.Config.SliderColorAttribute : Attribute

Specifies a slider color for ModConfig elements that use a slider. The default color is white.

Member Kind tModLoader What it does
Color Color property same The slider's color.
new SliderColorAttribute(int r, int g, int b, int a) constructor same Creates an instance.

SoundEngine

static class Terraria.Audio.SoundEngine

Plays sounds. PlaySound takes a SoundStyle.

Member Kind tModLoader What it does
bool TryGetActiveSound(SlotId slot, out ActiveSound sound) static method only here Finds a playing sound by its slot.
SlotId PlaySound(in SoundStyle style, Vector2 position, SoundUpdateCallback updateCallback) static method differs Plays a sound. A position makes it fade with distance. tML: void PlaySound(int type, Vector2 position, int style, float pitchOffset)
SlotId PlaySound(in SoundStyle style, Vector2 position) static method differs Plays a sound. A position makes it fade with distance. tML: void PlaySound(int type, Vector2 position, int style, float pitchOffset)

SoundID

struct Terraria.ID.SoundID

Member Kind tModLoader What it does
SoundStyle ScaryScream static property only here
SoundStyle Zombie1 static property only here
SoundStyle Zombie2 static property only here
SoundStyle Zombie3 static property only here
SoundStyle Zombie4 static property only here
SoundStyle Zombie5 static property only here
SoundStyle Zombie6 static property only here
SoundStyle Zombie7 static property only here
SoundStyle Zombie8 static property only here
SoundStyle Zombie9 static property only here
SoundStyle Zombie10 static property only here
SoundStyle Zombie11 static property only here
SoundStyle Zombie12 static property only here
SoundStyle Zombie13 static property only here
SoundStyle Zombie14 static property only here
SoundStyle Zombie15 static property only here
SoundStyle Zombie16 static property only here
SoundStyle Zombie17 static property only here
SoundStyle Zombie18 static property only here
SoundStyle Zombie19 static property only here
SoundStyle Zombie20 static property only here
SoundStyle Zombie21 static property only here
SoundStyle Zombie22 static property only here
SoundStyle Zombie23 static property only here
SoundStyle Zombie24 static property only here
SoundStyle Zombie25 static property only here
SoundStyle Zombie26 static property only here
SoundStyle Zombie27 static property only here
SoundStyle Zombie28 static property only here
SoundStyle Zombie29 static property only here
SoundStyle Zombie30 static property only here
SoundStyle Zombie31 static property only here
SoundStyle Zombie32 static property only here
SoundStyle Zombie33 static property only here
SoundStyle Zombie34 static property only here
SoundStyle Zombie35 static property only here
SoundStyle Zombie36 static property only here
SoundStyle Zombie37 static property only here
SoundStyle Zombie38 static property only here
SoundStyle Zombie39 static property only here
SoundStyle Zombie40 static property only here
SoundStyle Zombie41 static property only here
SoundStyle Zombie42 static property only here
SoundStyle Zombie43 static property only here
SoundStyle Zombie44 static property only here
SoundStyle Zombie45 static property only here
SoundStyle Zombie46 static property only here
SoundStyle Zombie47 static property only here
SoundStyle Zombie48 static property only here
SoundStyle Zombie49 static property only here
SoundStyle Zombie50 static property only here
SoundStyle Zombie51 static property only here
SoundStyle Zombie52 static property only here
SoundStyle Zombie53 static property only here
SoundStyle Zombie54 static property only here
SoundStyle Zombie55 static property only here
SoundStyle Zombie56 static property only here
SoundStyle Zombie57 static property only here
SoundStyle Zombie58 static property only here
SoundStyle Zombie59 static property only here
SoundStyle Zombie60 static property only here
SoundStyle Zombie61 static property only here
SoundStyle Zombie62 static property only here
SoundStyle Zombie63 static property only here
SoundStyle Zombie64 static property only here
SoundStyle Zombie65 static property only here
SoundStyle Zombie66 static property only here
SoundStyle Zombie67 static property only here
SoundStyle Zombie68 static property only here
SoundStyle Zombie69 static property only here
SoundStyle Zombie70 static property only here
SoundStyle Zombie71 static property only here
SoundStyle Zombie72 static property only here
SoundStyle Zombie73 static property only here
SoundStyle Zombie74 static property only here
SoundStyle Zombie75 static property only here
SoundStyle Zombie76 static property only here
SoundStyle Zombie77 static property only here
SoundStyle Zombie78 static property only here
SoundStyle Zombie79 static property only here
SoundStyle Zombie80 static property only here
SoundStyle Zombie81 static property only here
SoundStyle Zombie82 static property only here
SoundStyle Zombie83 static property only here
SoundStyle Zombie84 static property only here
SoundStyle Zombie85 static property only here
SoundStyle Zombie86 static property only here
SoundStyle Zombie87 static property only here
SoundStyle Zombie88 static property only here
SoundStyle Zombie89 static property only here
SoundStyle Zombie90 static property only here
SoundStyle Zombie91 static property only here
SoundStyle Zombie92 static property only here
SoundStyle Zombie93 static property only here
SoundStyle Zombie94 static property only here
SoundStyle Zombie95 static property only here
SoundStyle Zombie96 static property only here
SoundStyle Zombie97 static property only here
SoundStyle Zombie98 static property only here
SoundStyle Zombie99 static property only here
SoundStyle Zombie100 static property only here
SoundStyle Zombie101 static property only here
SoundStyle Zombie102 static property only here
SoundStyle Zombie103 static property only here
SoundStyle Zombie104 static property only here
SoundStyle Zombie105 static property only here
SoundStyle Zombie106 static property only here
SoundStyle Zombie107 static property only here
SoundStyle Zombie108 static property only here
SoundStyle Zombie109 static property only here
SoundStyle Zombie110 static property only here
SoundStyle Zombie111 static property only here
SoundStyle Zombie112 static property only here
SoundStyle Zombie113 static property only here
SoundStyle Zombie114 static property only here
SoundStyle Zombie115 static property only here
SoundStyle Zombie116 static property only here
SoundStyle Zombie117 static property only here
SoundStyle Zombie118 static property only here
SoundStyle Zombie119 static property only here
SoundStyle Zombie120 static property only here
SoundStyle Zombie121 static property only here
SoundStyle Zombie122 static property only here
SoundStyle Zombie123 static property only here
SoundStyle Zombie124 static property only here
SoundStyle Zombie125 static property only here
SoundStyle Zombie126 static property only here
SoundStyle Zombie127 static property only here
SoundStyle Zombie128 static property only here
SoundStyle Zombie129 static property only here
SoundStyle Zombie130 static property only here

SoundLimitBehavior

enum Terraria.Audio.SoundLimitBehavior

What happens when too many of a sound play together.

Values: IgnoreNew, ReplaceOldest

SoundStyle

struct Terraria.Audio.SoundStyle

This data type describes in detail how a sound should be played. Passable to the PlaySound method.

Member Kind tModLoader What it does
string SoundPath property same The sound effect to play.
SoundType Type property same Controls which volume setting will this be affected by. Ambience sounds also don't play when the game is out of focus.
string Identifier property same If defined, this string will be the only thing used to determine which styles should instances be shared with.
float Volume property same The volume multiplier to play sounds with.
float Pitch property same The pitch offset to play sounds with. In XNA and FNA, Pitch ranges from -1.0f (down one octave) to 1.0f (up one octave). 0.0f is unity (normal) pitch.
float PitchVariance property same The pitch offset randomness value. Cannot be negative. With Pitch at 0.0, and PitchVariance at 1.0, used pitch will range from -0.5 to 0.5. In XNA and FNA, Pitch ranges from -1.0f (down one octave) to 1.0f (up one octave). 0.0f is unity (normal) pitch.
(float minPitch, float maxPitch) PitchRange property same A helper property for controlling both Pitch and PitchVariance at once. In XNA and FNA, Pitch ranges from -1.0f (down one octave) to 1.0f (up one octave). 0.0f is unity (normal) pitch.
int MaxInstances property same The max amount of sound instances that this style will allow creating, before stopping a playing sound or refusing to play a new one. If using variants, use LimitsArePerVariant to allow MaxInstances to apply to each variant individually rather than to all variants as a group. Set to 0 for no limits.
SoundLimitBehavior SoundLimitBehavior property same Determines what the action taken when the max amount of sound instances is reached. Defaults to ReplaceOldest, which means a currently playing sound will be stopped and a new sound instance will be started.
bool IsLooped property same Whether or not to loop played sounds.
bool PlayOnlyIfFocused property same If true, this sound won't play if the game's window isn't selected.
ReadOnlySpan<int> Variants property same An array of possible suffixes to randomly append to after SoundPath. Setting this property resets VariantsWeights.
new SoundStyle(string soundPath, SoundType type) constructor same Creates an instance.
new SoundStyle(string soundPath, int numberOfVariants, SoundType type) constructor same Creates an instance.
new SoundStyle(string soundPath, int variantSuffixesStart, int numberOfVariants, SoundType type) constructor same Creates an instance.
new SoundStyle(string soundPath, ReadOnlySpan<int> variants, SoundType type) constructor same Creates an instance.
SoundStyle WithVolumeScale(float scale) method same A copy with this volume.
SoundStyle WithPitchOffset(float offset) method same A copy with this pitch.
int RerollAttempts property not here How many additional times to attempt to find a variant that is not currently playing before applying the SoundLimitBehavior. Only has effect if LimitsArePerVariant is true. Defaults to 0.
bool LimitsArePerVariant property not here If true, then variants are treated as different sounds for the purposes of SoundLimitBehavior and MaxInstances. Defaults to false, meaning that all variants share the same sound instance limitations.
PauseBehavior PauseBehavior property not here Determines how the sound will be affected when the game is paused (or unfocused) and subsequently resumed. Long-running sounds might benefit from changing this value. Defaults to KeepPlaying, which means the sound will continue playing while the game is paused.
ReadOnlySpan<float> VariantsWeights property not here An array of randomization weights to optionally go with Variants. Set this last, if at all, as the Variants's setter resets all weights data.
bool IsTheSameAs(SoundStyle style) method not here Checks if this SoundStyle is the same as another SoundStyle. This method takes into account differences in chosen variants if LimitsArePerVariant is true.
bool IsVariantOf(SoundStyle style) method not here Same as IsTheSameAs except it doesn't take into account differences in chosen variants.
SoundEffect GetSoundEffect() method not here Internal to the game's sound code.
float GetRandomPitch() method not here Internal to the game's sound code.
SoundStyle WithVolumePerceived(float volume) method not here Not implemented. Use WithVolumeScale.

SoundUpdateCallback

delegate Terraria.Audio.SoundUpdateCallback · only in Bunny Loader

Runs each frame for a playing sound, to change it or stop it.

TooltipArgsAttribute

class Terraria.ModLoader.Config.TooltipArgsAttribute : ConfigArgsAttribute

Use to provide values to be interpolated into the tooltip of the annotated property or field. string arguments starting with "$" are interpreted as localization keys. Interpolating values can be useful for reusing common tooltips to keep localization files clean and organized. For example, if a mod provides toggles for several features, a common tooltip could be used for each with only the provided value being different. The string formatting section of the Localization wiki page explains this concept further. Scope simplification can be used to shorten localization keys passed in.

Member Kind tModLoader What it does
new TooltipArgsAttribute(params object[] args) constructor same Creates an instance.

TooltipKeyAttribute

class Terraria.ModLoader.Config.TooltipKeyAttribute : ConfigKeyAttribute

A tooltip is the text shown to the user in the ModConfig UI next to the cursor when they hover over the annotated member (property, field, or class). This can be longer and more descriptive than the Label. This attribute sets a custom localization key for the tooltip of the annotated property, field, or class. The provided localization key must start with "$". Without this attribute, the localization key "Mods.{ModName}.Configs.{ConfigName}.{MemberName}.Tooltip" will be assumed for members of ModConfig classes. Annotations on members of non-ModConfig classes need to supply a custom localization key using this attribute to be localized, no localization key is assumed. If the translation value of a property or field that is an object is an empty string, the tooltip of the class will be used instead. Passing in just "$" will result in no tooltip entry being added to the localization files. Values can be interpolated into the resulting label text using TooltipArgsAttribute.

Member Kind tModLoader What it does
new TooltipKeyAttribute(string key) constructor same Creates an instance.

TouchButtonLoader

static class Terraria.ModLoader.TouchButtonLoader · only in Bunny Loader

Registers touch buttons and joysticks: RegisterButton, RegisterJoystick.

Member Kind tModLoader What it does
int Count static property only here How many buttons the mods have registered.
IReadOnlyList<ModTouchButton> Buttons static property only here Every button of every mod.
ModTouchButton RegisterButton(Mod mod, string name) static method only here Creates a button in Load.
ModTouchJoystick RegisterJoystick(Mod mod, string name) static method only here Creates a joystick in Load.
int ActionOf(ModKeybind button) static method only here The action number of the button in the game's touch system.

UICommon

static class Terraria.ModLoader.UI.UICommon

Common colors and text of the mod menus.

Member Kind tModLoader What it does
void TooltipMouseText(string text) static method same Draws a tooltip on the mouse cursor. Functions like MouseText and hoverItemName, but adds the same background seen in item tooltips behind the text. Only works during rendering, calling this during Update will not do anything.

UIElement

class Terraria.UI.UIElement : IComparable

The base of every UI piece: position and size in StyleDimension, children, events, drawing. See User interface.

Member Kind tModLoader What it does
List<UIElement> Elements field same The children, in the order they draw.
StyleDimension Top field same Distance from the top of the parent.
StyleDimension Left field same Distance from the left of the parent.
StyleDimension Width field same The width.
StyleDimension Height field same The height.
StyleDimension MaxWidth field same The largest width.
StyleDimension MaxHeight field same The largest height.
StyleDimension MinWidth field same The smallest width.
StyleDimension MinHeight field same The smallest height.
bool IgnoresMouseInteraction field same Touches and clicks go through it to what lies behind.
bool PassThroughMouseInteraction field same It gets the hover, and what lies behind gets the touch too.
bool OverflowHidden field same Cuts children to its area.
float PaddingTop field same Inner space at the top.
float PaddingLeft field same Inner space at the left.
float PaddingRight field same Inner space at the right.
float PaddingBottom field same Inner space at the bottom.
float MarginTop field same Outer space at the top.
float MarginLeft field same Outer space at the left.
float MarginRight field same Outer space at the right.
float MarginBottom field same Outer space at the bottom.
float HAlign field same Horizontal place in the parent, from 0 to 1.
float VAlign field same Vertical place in the parent, from 0 to 1.
bool UseImmediateMode field same Draws it with an immediate sprite batch, for shaders.
new UIElement() constructor same Creates an instance.
UIElement Parent property same The parent, or null.
int UniqueId property same A number unique to this element.
IEnumerable<UIElement> Children property same The children.
bool IsMouseHovering property same Whether the pointer is over it.
MouseEvent OnLeftMouseDown event same Event that fires on this input or moment.
MouseEvent OnLeftMouseUp event same Event that fires on this input or moment.
MouseEvent OnLeftClick event same Event that fires on this input or moment.
MouseEvent OnLeftDoubleClick event same Event that fires on this input or moment.
MouseEvent OnRightMouseDown event same Event that fires on this input or moment.
MouseEvent OnRightMouseUp event same Event that fires on this input or moment.
MouseEvent OnRightClick event same Event that fires on this input or moment.
MouseEvent OnRightDoubleClick event same Event that fires on this input or moment.
MouseEvent OnMouseOver event same Event that fires on this input or moment.
MouseEvent OnMouseOut event same Event that fires on this input or moment.
ScrollWheelEvent OnScrollWheel event same Event that fires on this input or moment.
ElementEvent OnUpdate event same Event that fires on this input or moment.
DrawEvent OnDraw event same Event that fires on this input or moment.
void ExecuteRecursively(UIElementAction action) hook same Runs a method on it and on everything under it.
void DrawSelf(SpriteBatch spriteBatch) hook same Draws this element only. Override this for custom drawing.
void DrawChildren(SpriteBatch spriteBatch) hook same Draws the children.
void Append(UIElement element) method same Adds a child.
void Remove() method same Removes an entry.
void RemoveChild(UIElement child) method same Removes a child.
void RemoveAllChildren() method same Removes every child.
bool HasChild(UIElement child) method only here Whether this is one of its children.
void AddOrRemoveChild(UIElement child, bool add) method only here Adds or removes a child according to the second argument.
void Draw(SpriteBatch spriteBatch) hook same Draws it and its children.
void Update(GameTime gameTime) hook same Runs each tick, and on the children.
Rectangle GetClippingRectangle(SpriteBatch spriteBatch) method same The area on screen children are cut to.
void Recalculate() hook same Works out its size and position, then those of its children. Call it after changing them.
UIElement GetElementAt(Vector2 point) method same The deepest element at a point.
bool ContainsPoint(Vector2 point) hook same Whether a point is inside it.
Rectangle GetViewCullingArea() hook same The area used to skip children out of view.
void SetPadding(float pixels) method same Sets the four paddings.
void RecalculateChildren() hook same Works out the children only.
CalculatedStyle GetInnerDimensions() method same Its area without the padding.
CalculatedStyle GetDimensions() method same Its area.
CalculatedStyle GetOuterDimensions() method same Its area with the margin.
void CopyStyle(UIElement element) method same Copies the position, size, padding and alignment of another element.
void LeftMouseDown(UIMouseEvent evt) hook same Runs when the left button goes down on it.
void LeftMouseUp(UIMouseEvent evt) hook same Runs when the left button goes up on it.
void LeftClick(UIMouseEvent evt) hook same Runs on a left click.
void LeftDoubleClick(UIMouseEvent evt) hook same Runs on a left double click.
void RightMouseDown(UIMouseEvent evt) hook same Runs when the right button goes down on it.
void RightMouseUp(UIMouseEvent evt) hook same Runs when the right button goes up on it.
void RightClick(UIMouseEvent evt) hook same Runs on a right click.
void RightDoubleClick(UIMouseEvent evt) hook same Runs on a right double click.
void MouseOver(UIMouseEvent evt) hook same Runs when the pointer enters it.
void MouseOut(UIMouseEvent evt) hook same Runs when the pointer leaves it.
void ScrollWheel(UIScrollWheelEvent evt) hook same Runs when the wheel turns over it.
void Activate() method same Runs when its state becomes the current one.
void OnActivate() hook same Event that fires on this input or moment.
void Deactivate() method same Runs when its state stops being the current one.
void OnDeactivate() hook same Event that fires on this input or moment.
void Initialize() method same Runs once, before the first activation. Build the children here.
void OnInitialize() hook same Event that fires on this input or moment.
int CompareTo(object obj) hook same The order used to sort children.

UIEvent

class Terraria.UI.UIEvent

An event of an element.

Member Kind tModLoader What it does
UIElement Target field same The element that received the event.
new UIEvent(UIElement target) constructor same Creates an instance.

UIImage

class Terraria.GameContent.UI.Elements.UIImage : UIElement

Shows a texture.

Member Kind tModLoader What it does
float ImageScale field same The image's scale.
float Rotation field same The image's rotation.
bool ScaleToFit field same Stretches the image to the element's size.
bool AllowResizingDimensions field same SetImage also resizes the element.
Color Color field same The tint of the image or text.
Vector2 NormalizedOrigin field same The image's origin, from 0 to 1.
Rectangle Frame field same The part of the image that shows.
bool RemoveFloatingPointsFromDrawPosition field same Draws at whole pixels.
bool UseTextureSizeForOrigin field same Measures the origin on the image, not on the element.
new UIImage() constructor same Creates an instance.
new UIImage(Asset<Texture2D> texture) constructor same Creates an instance.
new UIImage(Texture2D nonReloadingTexture) constructor same Creates an instance.
Asset<Texture2D> Texture property same The image.
void SetImage(Asset<Texture2D> value) method same Changes the image.
void SetImage(Texture2D value) method same Changes the image.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.

UIImageButton

class Terraria.GameContent.UI.Elements.UIImageButton : UIElement

A texture that responds to a touch.

Member Kind tModLoader What it does
float _visibilityActive field same Opacity under the pointer.
float _visibilityInactive field same Opacity away from the pointer.
Color Color field same The tint of the image or text.
Color BorderColor field same The border's color.
new UIImageButton(Asset<Texture2D> texture, Rectangle frame) constructor same Creates an instance.
void SetHoverImage(Asset<Texture2D> texture, Rectangle frame) method same An image drawn on top under the pointer.
void SetImage(Asset<Texture2D> texture, Rectangle frame) method same Changes the image.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.
void MouseOver(UIMouseEvent evt) override same Plays the hover effect.
void SetVisibility(float whenActive, float whenInactive) method same Sets both opacities.

UIImageFramed

class Terraria.GameContent.UI.Elements.UIImageFramed : UIElement

Shows one frame of a texture.

Member Kind tModLoader What it does
new UIImageFramed(Asset<Texture2D> texture, Rectangle frame) constructor same Creates an instance.
Color Color property same The tint of the image or text.
void SetImage(Asset<Texture2D> texture, Rectangle frame) method same Changes the image.
void SetFrame(Rectangle frame) method same Picks the part of the image that shows.
void SetFrame(int frameCountHorizontal, int frameCountVertical, int frameX, int frameY, int sizeOffsetX, int sizeOffsetY) method same Picks the part of the image that shows.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.

UIList

class Terraria.GameContent.UI.Elements.UIList : UIElement

A scrollable list element. Typically paired with a UIScrollbar. To add elements to the list, use Add (or AddRange) rather than Append. If the ordering of list elements is inconsistent, either override CompareTo on the elements of the list or assign a custom sort delegate to ManualSortMethod. If elements are added in order, you can use an empty sort method to not do any sorting to preserve the original order: myList.ManualSortMethod = (e) => { };

Member Kind tModLoader What it does
List<UIElement> _items field same The rows.
UIScrollbar _scrollbar field same The bar tied to it.
float ListPadding field same The space between rows.
Action<List<UIElement>> ManualSortMethod field same Replaces the sort.
new UIList() constructor same Creates an instance.
int Count property same How many items it holds.
bool IsDragging property only here Whether a finger is scrolling it.
float ViewPosition property same How far it has scrolled.
float GetTotalHeight() method same The height of all rows.
void Goto(ElementSearchMethod searchMethod) method same Scrolls to the row a method finds.
void Add(UIElement item) hook same Adds a row.
void AddRange(IEnumerable<UIElement> items) hook same Similar to Add, but adds many elements at once, which is more efficient.
bool Remove(UIElement item) hook same Removes an entry.
void Clear() hook same Removes every row.
void Recalculate() override same Works out its size and position again.
void ScrollWheel(UIScrollWheelEvent evt) override same Scrolls by this amount.
void RecalculateChildren() override same Places its children again.
void SetScrollbar(UIScrollbar scrollbar) method same Ties a bar to it.
void UpdateOrder() method same Sorts the rows again.
int SortMethod(UIElement item1, UIElement item2) method same The order of two rows.
void Update(GameTime gameTime) override same Runs each tick.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.
IEnumerator<UIElement> GetEnumerator() method same Walks the items in foreach.

UIMouseEvent

class Terraria.UI.UIMouseEvent : UIEvent

A touch on an element.

Member Kind tModLoader What it does
Vector2 MousePosition field same Where the pointer was.
new UIMouseEvent(UIElement target, Vector2 mousePosition) constructor same Creates an instance.

UIPanel

class Terraria.GameContent.UI.Elements.UIPanel : UIElement

The game's blue panel.

Member Kind tModLoader What it does
Color BorderColor field same The border's color.
Color BackgroundColor field same The fill color.
new UIPanel() constructor same Creates an instance.
new UIPanel(Asset<Texture2D> customBackground, Asset<Texture2D> customBorder, int customCornerSize, int customBarSize) constructor same Creates an instance.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.

UIScrollWheelEvent

class Terraria.UI.UIScrollWheelEvent : UIMouseEvent

A scroll on an element.

Member Kind tModLoader What it does
int ScrollWheelValue field same How far the wheel turned.
new UIScrollWheelEvent(UIElement target, Vector2 mousePosition, int scrollWheelValue) constructor same Creates an instance.

UIScrollbar

class Terraria.GameContent.UI.Elements.UIScrollbar : UIElement

The game's scrollbar.

Member Kind tModLoader What it does
bool AutoHide field same Hides when everything fits.
new UIScrollbar() constructor same Creates an instance.
float ViewPosition property same How far it has scrolled.
bool CanScroll property same Whether there is anything to scroll.
void GoToBottom() method same Scrolls to the end.
void SetView(float viewSize, float maxViewSize) method same Sets what fits on screen and the whole size.
float GetValue() method same How far it has scrolled.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.
void LeftMouseDown(UIMouseEvent evt) override same Runs when the left button goes down.
void LeftMouseUp(UIMouseEvent evt) override same Runs when the left button goes up.
float ViewSize property not here Not implemented. Use SetView.
float MaxViewSize property not here Not implemented. Use SetView.

UIState

class Terraria.UI.UIState : UIElement

A full screen of UI: the root element you give a UserInterface.

Member Kind tModLoader What it does
bool NoGamepadSupport field same Whether a gamepad cannot navigate it.
new UIState() constructor same Creates an instance.

UIText

class Terraria.GameContent.UI.Elements.UIText : UIElement

Text.

Member Kind tModLoader What it does
new UIText(string text, float textScale, bool large) constructor same Creates an instance.
new UIText(LocalizedText text, float textScale, bool large) constructor same Creates an instance.
string Text property same The current text.
float TextOriginX property same Where the text sits inside the element, across.
float TextOriginY property same Where the text sits inside the element, down.
float WrappedTextBottomPadding property same Extra room under wrapped text.
bool IsWrapped property same Breaks lines at the element's width.
bool DynamicallyScaleDownToWidth property same Shrinks the text to fit the width.
Color TextColor property same The text's color.
Color ShadowColor property same The outline's color.
Action OnInternalTextChange event same Fires when the text changes.
void Recalculate() override same Works out its size and position again.
void SetText(string text) method same Changes the text and the element's size to fit it.
void SetText(LocalizedText text) method same Changes the text and the element's size to fit it.
void SetText(string text, float textScale, bool large) method same Changes the text and the element's size to fit it.
void SetText(LocalizedText text, float textScale, bool large) method same Changes the text and the element's size to fit it.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.

UITextPanel

class Terraria.GameContent.UI.Elements.UITextPanel : UIPanel

A panel with text in it.

Member Kind tModLoader What it does
T _text field same The text.
float _textScale field same The text's scale.
bool _isLarge field same Whether it uses the large font.
bool _drawPanel field same Whether the panel draws.
float TextHAlign field same Horizontal place of the text, from 0 to 1.
bool HideContents field same Shows * for each character.
new UITextPanel(T text, float textScale, bool large) constructor same Creates an instance.
bool IsLarge property same Whether it uses the large font.
bool DrawPanel property same Whether the panel draws.
float TextScale property same The text's scale.
string Text property same The current text.
Color TextColor property same The text's color.
void Recalculate() override same Works out its size and position again.
void SetText(T text) method same Changes the text and the element's size to fit it.
void SetText(T text, float textScale, bool large) hook same Changes the text and the element's size to fit it.
void DrawSelf(SpriteBatch spriteBatch) override same Draws this element.

UserInterface

class Terraria.UI.UserInterface

Runs one UIState: update, draw and touch.

Member Kind tModLoader What it does
UserInterface ActiveInstance static field same The interface that is handling input or drawing now.
Vector2 MousePosition field same The pointer's position in UI units.
bool IsVisible field same Whether it was drawn.
new UserInterface() constructor same Creates an instance.
UIState CurrentState property same The state on show, or null.
void ClearPointers() method same Forgets which elements the pointer touched.
bool MouseCaptured() method same Whether a button is held on an element.
void ResetLasts() method same Forgets what was hovered and pressed.
void EscapeElements() method same The same as ResetLasts.
void Use() method same Makes it the active one and recalculates when needed.
void Update(GameTime time) method same Handles input and updates the state. Call it from ModSystem.UpdateUI.
void Draw(SpriteBatch spriteBatch, GameTime time) method same Draws the state. Call it from a layer in ModifyInterfaceLayers.
void SetState(UIState state) method same Changes the state. Null closes it.
void GoBack() method same Returns to the state before this one.
void Recalculate() method same Lays out the state again.
CalculatedStyle GetDimensions() method same The area it uses on screen.
bool IsElementUnderMouse() method same Whether the pointer is over one of its elements.

← Mods, systems and network  ·  Talking to the game →

Clone this wiki locally