tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.ModLoader.ModContent Class Reference

Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loader classes. More...

Static Public Member Functions

static int BuffType< T > ()
 Get the id (type) of a ModBuff by class. Assumes one instance per class. More...
 
static int DustType< T > ()
 Get the id (type) of a ModDust by class. Assumes one instance per class. More...
 
static bool FileExists (string name)
 Returns whether or not a file with the specified name exists. More...
 
static T Find< T > (string fullname)
 Attempts to find the content instance with the specified full name. Caching the result is recommended.This will throw exceptions on failure. More...
 
static T Find< T > (string modName, string name)
 Attempts to find the content instance with the specified name and mod name. Caching the result is recommended.This will throw exceptions on failure. More...
 
static IEnumerable< T > GetContent< T > ()
 Returns all base content instances that derive from the provided content type across all currently loaded mods. More...
 
static EquipTexture GetEquipTexture (EquipType type, int slot)
 Gets the equipment texture for the specified equipment type and ID. More...
 
static byte[] GetFileBytes (string name)
 Gets the byte representation of the file with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNameWithExtension". Throws an ArgumentException if the file does not exist. More...
 
static T GetInstance< T > ()
 Returns the base instance of the provided content type. More...
 
static int GetModBackgroundSlot (string texture)
 Returns the slot/ID of the background texture with the given name. More...
 
static int GetModBossHeadSlot (string texture)
 Gets the index of the boss head texture corresponding to the given texture path. More...
 
static ModBuff GetModBuff (int type)
 Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null. More...
 
static ModDust GetModDust (int type)
 Gets the ModDust instance with the given type. Returns null if no ModDust with the given type exists. More...
 
static int GetModHeadSlot (string texture)
 Gets the index of the head texture corresponding to the given texture path. More...
 
static ModItem GetModItem (int type)
 Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the given type. More...
 
static ModMount GetModMount (int type)
 Gets the ModMount instance corresponding to the given type. Returns null if no ModMount has the given type. More...
 
static ModNPC GetModNPC (int type)
 Gets the ModNPC instance corresponding to the specified type. More...
 
static ModProjectile GetModProjectile (int type)
 Gets the ModProjectile instance corresponding to the specified type. More...
 
static ModSurfaceBackgroundStyle GetModSurfaceBackgroundStyle (int style)
 Returns the ModSurfaceBackgroundStyle object with the given ID. More...
 
static ModTile GetModTile (int type)
 Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null. More...
 
static ModUndergroundBackgroundStyle GetModUndergroundBackgroundStyle (int style)
 Returns the ModUndergroundBackgroundStyle object with the given ID. More...
 
static ModWall GetModWall (int type)
 Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null. More...
 
static ModWaterfallStyle GetModWaterfallStyle (int style)
 Returns the ModWaterfallStyle with the given ID. More...
 
static ModWaterStyle GetModWaterStyle (int style)
 Returns the ModWaterStyle with the given ID. More...
 
static int GoreType< T > ()
 Get the id (type) of a ModGore by class. Assumes one instance per class. More...
 
static bool HasAsset (string name)
 Returns whether or not a asset with the specified name exists. Includes the mod name prefix like GetAsset More...
 
static int ItemType< T > ()
 Get the id (type) of a ModItem by class. Assumes one instance per class. More...
 
static int MountType< T > ()
 Get the id (type) of a ModMount by class. Assumes one instance per class. More...
 
static int NPCType< T > ()
 Get the id (type) of a ModNPC by class. Assumes one instance per class. More...
 
static Stream OpenRead (string assetName, bool newFileStream=false)
 
static int PrefixType< T > ()
 Get the id (type) of a ModPrefix by class. Assumes one instance per class. More...
 
static int ProjectileType< T > ()
 Get the id (type) of a ModProjectile by class. Assumes one instance per class. More...
 
static int RarityType< T > ()
 Get the id (type) of a ModRarity by class. Assumes one instance per class. More...
 
static Asset< T > Request< T > (string name, AssetRequestMode mode=AssetRequestMode.AsyncLoad)
 Gets the asset with the specified name. Throws an Exception if the asset does not exist. More...
 
static bool RequestIfExists< T > (string name, out Asset< T > asset, AssetRequestMode mode=AssetRequestMode.AsyncLoad)
 
static void SplitName (string name, out string domain, out string subName)
 
static int TileEntityType< T > ()
 Get the id (type) of a ModTileEntity by class. Assumes one instance per class. More...
 
static int TileType< T > ()
 Get the id (type) of a ModTile by class. Assumes one instance per class. More...
 
static bool TryFind< T > (string fullname, out T value)
 Safely attempts to find the content instance with the specified full name. Caching the result is recommended. More...
 
static bool TryFind< T > (string modName, string name, out T value)
 Safely attempts to find the content instance with the specified name and mod name. Caching the result is recommended. More...
 
static int WallType< T > ()
 Get the id (type) of a ModWall by class. Assumes one instance per class. More...
 

Detailed Description

Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loader classes.

Member Function Documentation

◆ BuffType< T >()

static int Terraria.ModLoader.ModContent.BuffType< T > ( )
static

Get the id (type) of a ModBuff by class. Assumes one instance per class.

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

◆ DustType< T >()

static int Terraria.ModLoader.ModContent.DustType< T > ( )
static

Get the id (type) of a ModDust by class. Assumes one instance per class.

Type Constraints
T :ModDust 
T :GetInstance<T>() 
T :Type 

◆ FileExists()

static bool Terraria.ModLoader.ModContent.FileExists ( string  name)
static

Returns whether or not a file with the specified name exists.

◆ Find< T >() [1/2]

static T Terraria.ModLoader.ModContent.Find< T > ( string  fullname)
static

Attempts to find the content instance with the specified full name. Caching the result is recommended.This will throw exceptions on failure.

Exceptions
KeyNotFoundException
Type Constraints
T :IModType 
T :ModTypeLookup<T> 
T :Get 
T :fullname 

◆ Find< T >() [2/2]

static T Terraria.ModLoader.ModContent.Find< T > ( string  modName,
string  name 
)
static

Attempts to find the content instance with the specified name and mod name. Caching the result is recommended.This will throw exceptions on failure.

Exceptions
KeyNotFoundException
Type Constraints
T :IModType 
T :ModTypeLookup<T> 
T :Get 
T :modName 
T :name 

◆ GetContent< T >()

static IEnumerable<T> Terraria.ModLoader.ModContent.GetContent< T > ( )
static

Returns all base content instances that derive from the provided content type across all currently loaded mods.

Type Constraints
T :ILoadable 
T :ModLoader.Mods.SelectMany 
T :m 
T :m.GetContent<T>() 

◆ GetEquipTexture()

static EquipTexture Terraria.ModLoader.ModContent.GetEquipTexture ( EquipType  type,
int  slot 
)
static

Gets the equipment texture for the specified equipment type and ID.

Parameters
type
slot
Returns

◆ GetFileBytes()

static byte [] Terraria.ModLoader.ModContent.GetFileBytes ( string  name)
static

Gets the byte representation of the file with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNameWithExtension". Throws an ArgumentException if the file does not exist.

Exceptions
MissingResourceExceptionMissing mod: " + name

◆ GetInstance< T >()

static T Terraria.ModLoader.ModContent.GetInstance< T > ( )
static

Returns the base instance of the provided content type.

Type Constraints
T :class 
T :ContentInstance<T> 
T :Instance 

◆ GetModBackgroundSlot()

static int Terraria.ModLoader.ModContent.GetModBackgroundSlot ( string  texture)
static

Returns the slot/ID of the background texture with the given name.

◆ GetModBossHeadSlot()

static int Terraria.ModLoader.ModContent.GetModBossHeadSlot ( string  texture)
static

Gets the index of the boss head texture corresponding to the given texture path.

Parameters
texture
Returns

◆ GetModBuff()

static ModBuff Terraria.ModLoader.ModContent.GetModBuff ( int  type)
static

Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.

◆ GetModDust()

static ModDust Terraria.ModLoader.ModContent.GetModDust ( int  type)
static

Gets the ModDust instance with the given type. Returns null if no ModDust with the given type exists.

◆ GetModHeadSlot()

static int Terraria.ModLoader.ModContent.GetModHeadSlot ( string  texture)
static

Gets the index of the head texture corresponding to the given texture path.

Parameters
textureRelative texture path
Returns
The index of the texture in the heads array, -1 if not found.

◆ GetModItem()

static ModItem Terraria.ModLoader.ModContent.GetModItem ( int  type)
static

Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the given type.

◆ GetModMount()

static ModMount Terraria.ModLoader.ModContent.GetModMount ( int  type)
static

Gets the ModMount instance corresponding to the given type. Returns null if no ModMount has the given type.

Parameters
typeThe type of the mount.
Returns
Null if not found, otherwise the ModMount associated with the mount.

◆ GetModNPC()

static ModNPC Terraria.ModLoader.ModContent.GetModNPC ( int  type)
static

Gets the ModNPC instance corresponding to the specified type.

Parameters
typeThe type of the npc
Returns
The ModNPC instance in the npcs array, null if not found.

◆ GetModProjectile()

static ModProjectile Terraria.ModLoader.ModContent.GetModProjectile ( int  type)
static

Gets the ModProjectile instance corresponding to the specified type.

Parameters
typeThe type of the projectile
Returns
The ModProjectile instance in the projectiles array, null if not found.

◆ GetModSurfaceBackgroundStyle()

static ModSurfaceBackgroundStyle Terraria.ModLoader.ModContent.GetModSurfaceBackgroundStyle ( int  style)
static

Returns the ModSurfaceBackgroundStyle object with the given ID.

◆ GetModTile()

static ModTile Terraria.ModLoader.ModContent.GetModTile ( int  type)
static

Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null.

Parameters
typeThe type of the ModTile
Returns
The ModTile instance in the tiles array, null if not found.

◆ GetModUndergroundBackgroundStyle()

static ModUndergroundBackgroundStyle Terraria.ModLoader.ModContent.GetModUndergroundBackgroundStyle ( int  style)
static

Returns the ModUndergroundBackgroundStyle object with the given ID.

◆ GetModWall()

static ModWall Terraria.ModLoader.ModContent.GetModWall ( int  type)
static

Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.

◆ GetModWaterfallStyle()

static ModWaterfallStyle Terraria.ModLoader.ModContent.GetModWaterfallStyle ( int  style)
static

Returns the ModWaterfallStyle with the given ID.

◆ GetModWaterStyle()

static ModWaterStyle Terraria.ModLoader.ModContent.GetModWaterStyle ( int  style)
static

Returns the ModWaterStyle with the given ID.

◆ GoreType< T >()

static int Terraria.ModLoader.ModContent.GoreType< T > ( )
static

Get the id (type) of a ModGore by class. Assumes one instance per class.

Type Constraints
T :ModGore 
T :GetInstance<T>() 
T :Type 

◆ HasAsset()

static bool Terraria.ModLoader.ModContent.HasAsset ( string  name)
static

Returns whether or not a asset with the specified name exists. Includes the mod name prefix like GetAsset

◆ ItemType< T >()

static int Terraria.ModLoader.ModContent.ItemType< T > ( )
static

Get the id (type) of a ModItem by class. Assumes one instance per class.

Type Constraints
T :ModItem 
T :GetInstance<T>() 
T :Type 

◆ MountType< T >()

static int Terraria.ModLoader.ModContent.MountType< T > ( )
static

Get the id (type) of a ModMount by class. Assumes one instance per class.

Type Constraints
T :ModMount 
T :GetInstance<T>() 
T :Type 

◆ NPCType< T >()

static int Terraria.ModLoader.ModContent.NPCType< T > ( )
static

Get the id (type) of a ModNPC by class. Assumes one instance per class.

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

◆ PrefixType< T >()

static int Terraria.ModLoader.ModContent.PrefixType< T > ( )
static

Get the id (type) of a ModPrefix by class. Assumes one instance per class.

Type Constraints
T :ModPrefix 
T :GetInstance<T>() 
T :Type 

◆ ProjectileType< T >()

static int Terraria.ModLoader.ModContent.ProjectileType< T > ( )
static

Get the id (type) of a ModProjectile by class. Assumes one instance per class.

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

◆ RarityType< T >()

static int Terraria.ModLoader.ModContent.RarityType< T > ( )
static

Get the id (type) of a ModRarity by class. Assumes one instance per class.

Type Constraints
T :ModRarity 
T :GetInstance<T>() 
T :Type 

◆ Request< T >()

static Asset<T> Terraria.ModLoader.ModContent.Request< T > ( string  name,
AssetRequestMode  mode = AssetRequestMode.AsyncLoad 
)
static

Gets the asset with the specified name. Throws an Exception if the asset does not exist.

Parameters
nameThe path to the asset without extension, including the mod name (or Terraria) for vanilla assets. Eg "ModName/Folder/FileNameWithoutExtension"
Type Constraints
T :class 

◆ TileEntityType< T >()

static int Terraria.ModLoader.ModContent.TileEntityType< T > ( )
static

Get the id (type) of a ModTileEntity by class. Assumes one instance per class.

Type Constraints
T :ModTileEntity 
T :GetInstance<T>() 
T :Type 

◆ TileType< T >()

static int Terraria.ModLoader.ModContent.TileType< T > ( )
static

Get the id (type) of a ModTile by class. Assumes one instance per class.

Type Constraints
T :ModTile 
T :GetInstance<T>() 
T :Type 

◆ TryFind< T >() [1/2]

static bool Terraria.ModLoader.ModContent.TryFind< T > ( string  fullname,
out T  value 
)
static

Safely attempts to find the content instance with the specified full name. Caching the result is recommended.

Returns
Whether or not the requested instance has been found.
Type Constraints
T :IModType 
T :ModTypeLookup<T> 
T :TryGetValue 
T :fullname 
T :out 
T :value 

◆ TryFind< T >() [2/2]

static bool Terraria.ModLoader.ModContent.TryFind< T > ( string  modName,
string  name,
out T  value 
)
static

Safely attempts to find the content instance with the specified name and mod name. Caching the result is recommended.

Returns
Whether or not the requested instance has been found.
Type Constraints
T :IModType 
T :ModTypeLookup<T> 
T :TryGetValue 
T :modName 
T :name 
T :out 
T :value 

◆ WallType< T >()

static int Terraria.ModLoader.ModContent.WallType< T > ( )
static

Get the id (type) of a ModWall by class. Assumes one instance per class.

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