tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.ModLoader.ModTileEntity Class Referenceabstract

Tile Entities are Entities tightly coupled with tiles, allowing the possibility of tiles to exhibit cool behavior. TileEntity.Update is called in SP and on Server, not on Clients. More...

Inherits Terraria.DataStructures.TileEntity, and Terraria.ModLoader.IModType.

Inherited by Terraria.ModLoader.Default.UnloadedTileEntity.

Public Member Functions

int Find (int i, int j)
 Returns the entity ID of this kind of tile entity at the given coordinates for you. More...
 
sealed override TileEntity GenerateInstance ()
 
virtual int Hook_AfterPlacement (int i, int j, int type, int style, int direction, int alternate)
 This method does not get called by tModLoader, and is only included for you convenience so you do not have to cast the result of Mod.GetTileEntity. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More...
 
void Kill (int i, int j)
 A helper method that removes this kind of tile entity from the given coordinates for you. More...
 
virtual void Load (Mod mod)
 Called when loading the type. More...
 
override void NetPlaceEntityAttempt (int i, int j)
 You should never use this. It is only included here for completion's sake. More...
 
override void NetReceive (BinaryReader reader)
 Receives the data sent in the NetSend hook. Called on MP Client when receiving tile data (!lightReceive) and when a MessageID.TileEntitySharing message is sent (lightReceive) More...
 
override void NetSend (BinaryWriter writer)
 Allows you to send custom data for this tile entity between client and server. This is called on the server while sending tile data (!lightSend) and when a MessageID.TileEntitySharing message is sent (lightSend) More...
 
virtual void OnKill ()
 This method only gets called in the Kill method. If you plan to use that, you can put code here to make things happen when it is called. More...
 
virtual void OnNetPlace ()
 Code that should be run when this tile entity is placed by means of server-syncing. Called on Server only. More...
 
int Place (int i, int j)
 A helper method that places this kind of tile entity in the given coordinates for you. More...
 
virtual void PostGlobalUpdate ()
 Code that should be run after all tile entities in the world update. More...
 
virtual void PreGlobalUpdate ()
 Code that should be run before all tile entities in the world update. More...
 
sealed override void ReadExtraData (BinaryReader reader, bool networkSend)
 Should never be called on ModTileEntity. Replaced by NetReceive and Load Would make the base method internal if not for patch size More...
 
sealed override void RegisterTileEntityID (int assignedID)
 
virtual void Unload ()
 Called during unloading when needed. More...
 
abstract bool ValidTile (int i, int j)
 Whether or not this tile entity is allowed to survive at the given coordinates. You should check whether the tile is active, as well as the tile's type and frame. More...
 
sealed override void WriteExtraData (BinaryWriter writer, bool networkSend)
 Should never be called on ModTileEntity. Replaced by NetSend and Save. Would make the base method internal if not for patch size More...
 
- Public Member Functions inherited from Terraria.DataStructures.TileEntity
virtual string GetItemGamepadInstructions (int slot=0)
 
virtual bool IsTileValidForEntity (int x, int y)
 
virtual void Load (TagCompound tag)
 Allows you to load the custom data you have saved for this tile entity. More...
 
virtual void OnInventoryDraw (Player player, SpriteBatch spriteBatch)
 
virtual void OnPlayerUpdate (Player player)
 
virtual bool OverrideItemSlotHover (Item[] inv, int context=0, int slot=0)
 
virtual bool OverrideItemSlotLeftClick (Item[] inv, int context=0, int slot=0)
 
virtual TagCompound Save ()
 Allows you to save custom data for this tile entity. More...
 
virtual bool TryGetItemGamepadOverrideInstructions (Item[] inv, int context, int slot, out string instruction)
 
virtual void Update ()
 

Static Public Member Functions

static ModTileEntity ConstructFromBase (ModTileEntity tileEntity)
 Returns a new ModTileEntity with the same class, mod, name, and type as the parameter. It is very rare that you should have to use this. More...
 
static ModTileEntity ConstructFromType (int type)
 Returns a new ModTileEntity with the same class, mod, name, and type as the ModTileEntity with the given type. It is very rare that you should have to use this. More...
 
static int CountInWorld ()
 Returns the number of modded tile entities that exist in the world currently being played. More...
 
- Static Public Member Functions inherited from Terraria.DataStructures.TileEntity
static int AssignNewID ()
 
static void BasicOpenCloseInteraction (Player player, int x, int y, int id)
 
static void Clear ()
 
static void InitializeAll ()
 
static bool IsOccupied (int id, out int interactingPlayer)
 
static void PlaceEntityNet (int x, int y, int type)
 
static TileEntity Read (BinaryReader reader, bool networkSend=false, bool lightSend=false)
 
static void SetInteractionAnchor (Player player, int x, int y, int id)
 
static void UpdateEnd ()
 
static void UpdateStart ()
 
static void Write (BinaryWriter writer, TileEntity ent, bool networkSend=false, bool lightSend=false)
 

Static Public Attributes

static readonly int NumVanilla
 
- Static Public Attributes inherited from Terraria.DataStructures.TileEntity
static Dictionary< int, TileEntityByID = new Dictionary<int, TileEntity>()
 
static Dictionary< Point16, TileEntityByPosition = new Dictionary<Point16, TileEntity>()
 
static object EntityCreationLock = new object()
 
static TileEntitiesManager manager
 
const int MaxEntitiesPerChunk = 1000
 
static int TileEntitiesNextID
 

Properties

string FullName [get]
 
Mod Mod [get, set]
 The mod that added this ModTileEntity. More...
 
string Name [get]
 The internal name of this ModTileEntity. More...
 
int Type [get, set]
 The numeric type used to identify this kind of tile entity. More...
 
- Properties inherited from Terraria.ModLoader.IModType
string FullName [get]
 => $"{Mod.Name}/{Name}" More...
 
Mod Mod [get]
 The mod this belongs to. More...
 
string Name [get]
 The internal name of this instance. More...
 

Additional Inherited Members

- Public Attributes inherited from Terraria.DataStructures.TileEntity
int ID
 
Point16 Position
 
byte type
 
- Events inherited from Terraria.DataStructures.TileEntity
static Action _UpdateEnd
 
static Action _UpdateStart
 

Detailed Description

Tile Entities are Entities tightly coupled with tiles, allowing the possibility of tiles to exhibit cool behavior. TileEntity.Update is called in SP and on Server, not on Clients.

See also
Terraria.DataStructures.TileEntity

Member Function Documentation

◆ ConstructFromBase()

static ModTileEntity Terraria.ModLoader.ModTileEntity.ConstructFromBase ( ModTileEntity  tileEntity)
static

Returns a new ModTileEntity with the same class, mod, name, and type as the parameter. It is very rare that you should have to use this.

◆ ConstructFromType()

static ModTileEntity Terraria.ModLoader.ModTileEntity.ConstructFromType ( int  type)
static

Returns a new ModTileEntity with the same class, mod, name, and type as the ModTileEntity with the given type. It is very rare that you should have to use this.

◆ CountInWorld()

static int Terraria.ModLoader.ModTileEntity.CountInWorld ( )
static

Returns the number of modded tile entities that exist in the world currently being played.

◆ Find()

int Terraria.ModLoader.ModTileEntity.Find ( int  i,
int  j 
)

Returns the entity ID of this kind of tile entity at the given coordinates for you.

◆ Hook_AfterPlacement()

virtual int Terraria.ModLoader.ModTileEntity.Hook_AfterPlacement ( int  i,
int  j,
int  type,
int  style,
int  direction,
int  alternate 
)
virtual

This method does not get called by tModLoader, and is only included for you convenience so you do not have to cast the result of Mod.GetTileEntity.

◆ IsLoadingEnabled()

virtual bool Terraria.ModLoader.ModTileEntity.IsLoadingEnabled ( Mod  mod)
virtual

Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type.

Parameters
modThe mod instance trying to add this content

Implements Terraria.ModLoader.ILoadable.

◆ Kill()

void Terraria.ModLoader.ModTileEntity.Kill ( int  i,
int  j 
)

A helper method that removes this kind of tile entity from the given coordinates for you.

◆ Load()

virtual void Terraria.ModLoader.ModTileEntity.Load ( Mod  mod)
virtual

Called when loading the type.

Parameters
modThe mod instance associated with this type.

Implements Terraria.ModLoader.ILoadable.

◆ NetPlaceEntityAttempt()

override void Terraria.ModLoader.ModTileEntity.NetPlaceEntityAttempt ( int  i,
int  j 
)
virtual

You should never use this. It is only included here for completion's sake.

Reimplemented from Terraria.DataStructures.TileEntity.

◆ NetReceive()

override void Terraria.ModLoader.ModTileEntity.NetReceive ( BinaryReader  reader)
virtual

Receives the data sent in the NetSend hook. Called on MP Client when receiving tile data (!lightReceive) and when a MessageID.TileEntitySharing message is sent (lightReceive)

Parameters
readerThe reader.

Reimplemented from Terraria.DataStructures.TileEntity.

◆ NetSend()

override void Terraria.ModLoader.ModTileEntity.NetSend ( BinaryWriter  writer)
virtual

Allows you to send custom data for this tile entity between client and server. This is called on the server while sending tile data (!lightSend) and when a MessageID.TileEntitySharing message is sent (lightSend)

Parameters
writerThe writer.

Reimplemented from Terraria.DataStructures.TileEntity.

◆ OnKill()

virtual void Terraria.ModLoader.ModTileEntity.OnKill ( )
virtual

This method only gets called in the Kill method. If you plan to use that, you can put code here to make things happen when it is called.

◆ OnNetPlace()

virtual void Terraria.ModLoader.ModTileEntity.OnNetPlace ( )
virtual

Code that should be run when this tile entity is placed by means of server-syncing. Called on Server only.

◆ Place()

int Terraria.ModLoader.ModTileEntity.Place ( int  i,
int  j 
)

A helper method that places this kind of tile entity in the given coordinates for you.

◆ PostGlobalUpdate()

virtual void Terraria.ModLoader.ModTileEntity.PostGlobalUpdate ( )
virtual

Code that should be run after all tile entities in the world update.

◆ PreGlobalUpdate()

virtual void Terraria.ModLoader.ModTileEntity.PreGlobalUpdate ( )
virtual

Code that should be run before all tile entities in the world update.

◆ ReadExtraData()

sealed override void Terraria.ModLoader.ModTileEntity.ReadExtraData ( BinaryReader  reader,
bool  networkSend 
)
virtual

Should never be called on ModTileEntity. Replaced by NetReceive and Load Would make the base method internal if not for patch size

Reimplemented from Terraria.DataStructures.TileEntity.

◆ Unload()

virtual void Terraria.ModLoader.ModTileEntity.Unload ( )
virtual

Called during unloading when needed.

Implements Terraria.ModLoader.ILoadable.

◆ ValidTile()

abstract bool Terraria.ModLoader.ModTileEntity.ValidTile ( int  i,
int  j 
)
pure virtual

Whether or not this tile entity is allowed to survive at the given coordinates. You should check whether the tile is active, as well as the tile's type and frame.

Implemented in Terraria.ModLoader.Default.UnloadedTileEntity.

◆ WriteExtraData()

sealed override void Terraria.ModLoader.ModTileEntity.WriteExtraData ( BinaryWriter  writer,
bool  networkSend 
)
virtual

Should never be called on ModTileEntity. Replaced by NetSend and Save. Would make the base method internal if not for patch size

Reimplemented from Terraria.DataStructures.TileEntity.

Member Data Documentation

◆ NumVanilla

readonly int Terraria.ModLoader.ModTileEntity.NumVanilla
static
Initial value:
= Assembly.GetExecutingAssembly()
.GetTypes()
.Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(TileEntity)) && !typeof(ModTileEntity).IsAssignableFrom(t))
.Count()

Property Documentation

◆ Mod

Mod Terraria.ModLoader.ModTileEntity.Mod
getset

The mod that added this ModTileEntity.

◆ Name

string Terraria.ModLoader.ModTileEntity.Name
get

The internal name of this ModTileEntity.

◆ Type

int Terraria.ModLoader.ModTileEntity.Type
getset

The numeric type used to identify this kind of tile entity.