TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
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...

+ Inheritance diagram for Terraria.ModLoader.ModTileEntity:
+ Collaboration diagram for Terraria.ModLoader.ModTileEntity:

Public Member Functions

 ModTileEntity ()
 
override void NetPlaceEntityAttempt (int i, int j)
 You should never use this. It is only included here for completion's sake.
 
int Place (int i, int j)
 A helper method that places this kind of tile entity in the given coordinates for you.
 
void Kill (int i, int j)
 A helper method that removes this kind of tile entity from the given coordinates for you.
 
int Find (int i, int j)
 Returns the entity ID of this kind of tile entity at the given coordinates for you.
 
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.
 
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.
 
override void NetSend (BinaryWriter writer)
 Allows you to send custom data for this tile entity between client and server, which will be handled in M:Terraria.DataStructures.TileEntity.NetReceive(System.IO.BinaryReader).
Called while sending tile data (!lightSend) and when F:Terraria.ID.MessageID.TileEntitySharing is sent (lightSend).
Only called on the server.
 
override void NetReceive (BinaryReader reader)
 Receives custom data sent in the M:Terraria.DataStructures.TileEntity.NetSend(System.IO.BinaryWriter) hook.
Called while receiving tile data (!lightReceive) and when F:Terraria.ID.MessageID.TileEntitySharing is received (lightReceive).
Only called on the client.
 
override TileEntity GenerateInstance ()
 
override void RegisterTileEntityID (int assignedID)
 
virtual void Load (Mod mod)
 Called when loading the type.
 
virtual void Load ()
 
virtual bool IsLoadingEnabled (Mod mod)
 Whether or not this type should be loaded when it's told to. Returning false disables M:Terraria.ModLoader.Mod.AddContent(Terraria.ModLoader.ILoadable) from actually loading this type.
 
virtual void Unload ()
 Called during unloading when needed.
 
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.
 
virtual void OnNetPlace ()
 Code that should be run when this tile entity is placed by means of server-syncing. Called on Server only.
 
virtual void PreGlobalUpdate ()
 Code that should be run before all tile entities in the world update.
 
virtual void PostGlobalUpdate ()
 Code that should be run after all tile entities in the world update.
 
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.
 
override bool IsTileValidForEntity (int x, int y)
 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.
 
virtual void Update ()
 
virtual void OnPlayerUpdate (Player player)
 
virtual void OnInventoryDraw (Player player, SpriteBatch spriteBatch)
 
virtual string GetItemGamepadInstructions (int slot=0)
 
virtual bool TryGetItemGamepadOverrideInstructions (Item[] inv, int context, int slot, out string instruction)
 
virtual bool OverrideItemSlotHover (Item[] inv, int context=0, int slot=0)
 
virtual bool OverrideItemSlotLeftClick (Item[] inv, int context=0, int slot=0)
 
virtual void SaveData (TagCompound tag)
 Allows you to save custom data for this tile entity.

NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization.
NOTE: Try to only save data that isn't default values.
 
virtual void LoadData (TagCompound tag)
 Allows you to load custom data that you have saved for this tile entity.
Try to write defensive loading code that won't crash if something's missing.
 

Static Public Member Functions

static int CountInWorld ()
 Returns the number of modded tile entities that exist in the world currently being played.
 
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.
 
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.
 
static int AssignNewID ()
 
static void Clear ()
 
static void UpdateStart ()
 
static void UpdateEnd ()
 
static void InitializeAll ()
 
static void PlaceEntityNet (int x, int y, int type)
 
static void Write (BinaryWriter writer, TileEntity ent, bool networkSend=false, bool lightSend=false)
 
static TileEntity Read (BinaryReader reader, bool networkSend=false, bool lightSend=false)
 
static bool IsOccupied (int id, out int interactingPlayer)
 
static void BasicOpenCloseInteraction (Player player, int x, int y, int id)
 
static void SetInteractionAnchor (Player player, int x, int y, int id)
 

Public Attributes

int ID
 
Point16 Position
 
byte type
 

Static Public Attributes

static readonly int NumVanilla = Assembly.GetExecutingAssembly().GetTypes().Count((Type t) => !t.IsAbstract && t.IsSubclassOf(typeof(TileEntity)) && !typeof(ModTileEntity).IsAssignableFrom(t))
 
static TileEntitiesManager manager
 
const int MaxEntitiesPerChunk = 1000
 
static object EntityCreationLock = new object()
 
static Dictionary< int, TileEntityByID = new Dictionary<int, TileEntity>()
 
static Dictionary< Point16, TileEntityByPosition = new Dictionary<Point16, TileEntity>()
 
static int TileEntitiesNextID
 

Static Package Functions

static void Initialize ()
 

Properties

Mod Mod [get, set]
 The mod that added this ModTileEntity.
 
virtual string Name [get]
 The internal name of this ModTileEntity.
 
string FullName [get]
 => $"{Mod.Name}/{Name}"
 
int Type [get, set]
 The numeric type used to identify this kind of tile entity.
 

Events

static Action _UpdateStart
 
static Action _UpdateEnd
 

Private Member Functions

void ILoadable. Load (Mod mod)
 Called when loading the type.
 
void Load_Obsolete (Mod mod)
 
void WriteInner (BinaryWriter writer, bool networkSend, bool lightSend)
 
void ReadInner (BinaryReader reader, bool networkSend, bool lightSend)
 

Static Private Member Functions

static void UpdateStartInternal ()
 
static void UpdateEndInternal ()
 

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
T:Terraria.DataStructures.TileEntity

Definition at line 14 of file ModTileEntity.cs.


The documentation for this class was generated from the following file: