tModLoader v2025.03
A mod to make and play Terraria mods
All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
EntityDefinition Class Reference

Classes implementing EntityDefinition serve to function as a way to save and load the identities of various Terraria objects. Only the identity is preserved, no other data such as stack size, damage, etc. These classes are well suited for ModConfig, but can be saved and loaded in a TagCompound as well. An EntityDefinition can potentially refer to content removed from a mod or content from a mod not currently enabled. Use IsUnloaded to check if this is the case, especially before using Type as an index into an array. It is usually desirable to preserve all unloaded EntityDefinition entries so user data is not lost, so structure your code accordingly. More...

Inherits TagSerializable.

Inherited by BuffDefinition, ItemDefinition, NPCDefinition, PrefixDefinition, ProjectileDefinition, and TileDefinition.

Public Member Functions

 EntityDefinition (string key)
 
 EntityDefinition (string mod, string name)
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
TagCompound SerializeData ()
 
override string ToString ()
 
TagCompound SerializeData ()
 

Public Attributes

string Mod
 
string Name
 

Properties

virtual string DisplayName [get]
 
virtual bool IsUnloaded [get]
 
abstract int Type [get]
 The content ID of the content this EntityDefinition represents. Will be -1 for IsUnloaded EntityDefinition.
 

Detailed Description

Classes implementing EntityDefinition serve to function as a way to save and load the identities of various Terraria objects. Only the identity is preserved, no other data such as stack size, damage, etc. These classes are well suited for ModConfig, but can be saved and loaded in a TagCompound as well.

An EntityDefinition can potentially refer to content removed from a mod or content from a mod not currently enabled. Use IsUnloaded to check if this is the case, especially before using Type as an index into an array. It is usually desirable to preserve all unloaded EntityDefinition entries so user data is not lost, so structure your code accordingly.

Member Function Documentation

◆ SerializeData()

TagCompound EntityDefinition.SerializeData ( )

Implements TagSerializable.