Terraria ModLoader  0.10.1.5
A framework for Terraria mods
Terraria.ModLoader.ModTile Class Reference

This class represents a type of tile that can be added by a mod. Only one instance of this class will ever exist for each type of tile that is added. Any hooks that are called will be called by the instance corresponding to the tile type. This is to prevent the game from using a massive amount of memory storing tile instances. More...

+ Collaboration diagram for Terraria.ModLoader.ModTile:

Public Member Functions

void AddMapEntry (Color color, LocalizedText name=null)
 Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults. More...
 
void AddMapEntry (Color color, ModTranslation name)
 Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults. More...
 
void AddMapEntry (Color color, LocalizedText name, Func< string, int, int, string > nameFunc)
 Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults. More...
 
void AddMapEntry (Color color, ModTranslation name, Func< string, int, int, string > nameFunc)
 Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults. More...
 
void AddToArray (ref int[] array)
 A convenient method for adding this tile's Type to the given array. This can be used with the arrays in TileID.Sets.RoomNeeds. More...
 
virtual void AnimateIndividualTile (int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
 Animates an individual tile. i and j are the coordinates of the Tile in question. frameXOffset and frameYOffset should be used to specify an offset from the tiles frameX and frameY. "frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type];" will already be set before this hook is called, taking into account the TileID-wide animation set via AnimateTile. Use this hook for off-sync animations (lightning bug in a bottle), temporary animations (trap chests), or TileEntities to achieve unique animation behaviors without having to manually draw the tile via PreDraw. More...
 
virtual void AnimateTile (ref int frame, ref int frameCounter)
 Allows you to animate your tile. Use frameCounter to keep track of how long the current frame has been active, and use frame to change the current frame. This is called once an update. Use AnimateIndividualTile to animate specific tile instances directly. More...
 
virtual bool Autoload (ref string name, ref string texture)
 Allows you to modify the name and texture path of this tile when it is autoloaded. Return true to autoload this tile. When a tile is autoloaded, that means you do not need to manually call Mod.AddTile. By default returns the mod's autoload property. More...
 
virtual bool AutoSelect (int i, int j, Item item)
 Allows you to determine whether the given item can become selected when the cursor is hovering over this tile and the auto selection hotkey is pressed. More...
 
virtual bool CanExplode (int i, int j)
 Whether or not the tile at the given coordinates can be killed by an explosion (ie. bombs). Returns true by default; return false to stop an explosion from destroying it. More...
 
virtual bool CanKillTile (int i, int j, ref bool blockDamaged)
 Allows you to determine whether or not the tile at the given coordinates can be hit by anything. Returns true by default. blockDamaged currently has no use. More...
 
virtual bool CanPlace (int i, int j)
 Allows you to stop this tile from being placed at the given coordinates. Return false to block the tile from being placed. Returns true by default. More...
 
virtual void ChangeWaterfallStyle (ref int style)
 Allows you to change the style of waterfall that passes through or over this type of tile. More...
 
virtual bool CreateDust (int i, int j, ref int type)
 Allows you to modify the default type of dust created when the tile at the given coordinates is hit. Return false to stop the default dust (the type parameter) from being created. Returns true by default. More...
 
ModTranslation CreateMapEntryName (string key=null)
 Creates a ModTranslation object that you can use in AddMapEntry. More...
 
virtual bool Dangersense (int i, int j, Player player)
 Allows you to determine whether this block glows red when the given player has the Dangersense buff. More...
 
virtual void DrawEffects (int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
 Allows you to make stuff happen whenever the tile at the given coordinates is drawn. For example, creating dust or changing the color the tile is drawn in. More...
 
virtual bool Drop (int i, int j)
 Allows you to customize which items the tile at the given coordinates drops. Remember that the x, y (i, j) coordinates are in tile coordinates, you will need to multiply them by 16 if you want to drop an item using them. Return false to stop the game from dropping the tile's default item. Returns true by default. Please note that this hook currently only works for 1x1 tiles. More...
 
virtual void DropCritterChance (int i, int j, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance)
 Allows you to modify the chance the tile at the given coordinates has of spawning a certain critter when the tile is killed. More...
 
virtual void FloorVisuals (Player player)
 Allows you to make something happen when a player stands on this type of tile. For example, you can make the player slide as if on ice. More...
 
virtual ushort GetMapOption (int i, int j)
 Allows you to choose which minimap entry the tile at the given coordinates will use. 0 is the first entry added by AddMapEntry, 1 is the second entry, etc. Returns 0 by default. More...
 
virtual bool HasSmartInteract ()
 Whether or not the smart interact function can select this tile. Useful for things like chests. Defaults to false. More...
 
virtual bool HasWalkDust ()
 Whether or not this tile creates dust when the player walks on it. Returns false by default. More...
 
virtual void HitWire (int i, int j)
 Allows you to make something happen when a wire current passes through this tile. More...
 
virtual void KillMultiTile (int i, int j, int frameX, int frameY)
 This hook is called exactly once whenever a block encompassing multiple tiles is destroyed. You can use it to make your multi-tile block drop a single item, for example. More...
 
virtual bool KillSound (int i, int j)
 Allows you to customize which sound you want to play when the tile at the given coordinates is hit. Return false to stop the game from playing its default sound for the tile. Returns true by default. More...
 
virtual void KillTile (int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
 Allows you to determine what happens when the tile at the given coordinates is killed or hit with a pickaxe. Fail determines whether the tile is mined, effectOnly makes it so that only dust is created, and noItem stops items from dropping. More...
 
virtual void ModifyLight (int i, int j, ref float r, ref float g, ref float b)
 Allows you to determine how much light this block emits. Make sure you set Main.tileLighted[Type] to true in SetDefaults for this to work. More...
 
virtual void MouseOver (int i, int j)
 Allows you to make something happen when the mouse hovers over this tile. Useful for showing item icons or text on the mouse. More...
 
virtual void MouseOverFar (int i, int j)
 Allows you to make something happen when the mouse hovers over this tile, even when the player is far away. Useful for showing what's written on signs, etc. More...
 
virtual void NearbyEffects (int i, int j, bool closer)
 Allows you to make things happen when this tile is within a certain range of the player (around the same range water fountains and music boxes work). The closer parameter is whether or not the tile is within the range at which things like campfires and banners work. More...
 
virtual void NumDust (int i, int j, bool fail, ref int num)
 Allows you to change how many dust particles are created when the tile at the given coordinates is hit. More...
 
virtual void PlaceInWorld (int i, int j, Item item)
 Allows you to do something when this tile is placed. More...
 
virtual void PostDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things in front of the tile at the given coordinates. This can also be used to do things such as creating dust. More...
 
virtual void PostSetDefaults ()
 Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main.tileObsidianKill. More...
 
virtual bool PreDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things behind the tile at the given coordinates. Return false to stop the game from drawing the tile normally. Returns true by default. More...
 
virtual void RandomUpdate (int i, int j)
 Called whenever the world randomly decides to update this tile in a given tick. Useful for things such as growing or spreading. More...
 
virtual void RightClick (int i, int j)
 Allows you to make something happen when this tile is right-clicked by the player. More...
 
virtual int SaplingGrowthType (ref int style)
 Allows this tile to support a sapling that can eventually grow into a tree. The type of the sapling should be returned here. Returns -1 by default. The style parameter will determine which sapling is chosen if multiple sapling types share the same ID; even if you only have a single sapling in an ID, you must still set this to 0. More...
 
virtual void SetDefaults ()
 Allows you to set the properties of this tile. Many properties are stored as arrays throughout Terraria's code. More...
 
virtual void SetDrawPositions (int i, int j, ref int width, ref int offsetY, ref int height)
 Allows you to customize the position in which this tile is drawn. Width refers to the width of one frame of the tile, offsetY refers to how many pixels below its actual position the tile should be drawn, and height refers to the height of one frame of the tile. By default the values will be set to the values you give this tile's TileObjectData. If this tile has no TileObjectData then they will default to 16, 0, and 16, respectively. More...
 
void SetModCactus (ModCactus cactus)
 Allows this tile to grow the given modded cactus. More...
 
void SetModPalmTree (ModPalmTree palmTree)
 Allows this tile to grow the given modded palm tree. More...
 
void SetModTree (ModTree tree)
 Allows this tile to grow the given modded tree. More...
 
virtual void SetSpriteEffects (int i, int j, ref SpriteEffects spriteEffects)
 Allows you to determine whether or not the tile will draw itself flipped in the world. More...
 
virtual bool Slope (int i, int j)
 Allows you to control how hammers slope this tile. Return true to allow it to slope normally. Returns true by default. More...
 
virtual void SpecialDraw (int i, int j, SpriteBatch spriteBatch)
 Special Draw. Only called if coordinates are placed in Main.specX/Y during DrawEffects. Useful for drawing things that would otherwise be impossible to draw due to draw order, such as items in item frames. More...
 
virtual bool TileFrame (int i, int j, ref bool resetFrame, ref bool noBreak)
 Called whenever this tile updates due to being placed or being next to a tile that is changed. Return false to stop the game from carrying out its default TileFrame operations. Returns true by default. More...
 
virtual void WalkDust (ref int dustType, ref bool makeDust, ref Color color)
 Allows you to modify the dust created when the player walks on this tile. The makeDust parameter is whether or not to make dust; you can randomly set this to false to reduce the amount of dust produced. More...
 

Public Attributes

int[] adjTiles = new int[0]
 An array of the IDs of tiles that this tile can be considered as when looking for crafting stations. More...
 
int animationFrameHeight = 0
 The height of a group of animation frames for this tile. Defaults to 0, which disables animations. More...
 
bool bed = false
 Whether or not this tile is a valid spawn point. Defaults to false. If you set this to true, you will still have to manually set the spawn yourself in the RightClick hook. More...
 
string chest = ""
 The default name of this chest that is displayed when this 2x2 chest is open. Defaults to the empty string, which means that this tile isn't a chest. Setting this field will make the tile behave like a chest (meteors will avoid it, tiles underneath cannot be mined, etc.), but you will have to manually give it storage capabilities yourself. (See the ExampleMod for something you can copy/paste.) More...
 
int chestDrop = 0
 The ID of the item that drops when this chest is destroyed. Defaults to 0. Honestly, this is only really used when the chest limit is reached on a server. More...
 
int closeDoorID = -1
 The ID of the tile that this door transforms into when it is closed. Defaults to -1, which means this tile isn't a door. More...
 
bool disableSmartCursor = false
 Whether or not the smart cursor function is disabled when the cursor hovers above this tile. Defaults to false. More...
 
bool disableSmartInteract = false
 Whether or not the smart tile interaction function is disabled when the cursor hovers above this tile. Defaults to false. More...
 
string dresser = ""
 Same as chest, except use this if your block is a dresser (has a size of 3x2 instead of 2x2). More...
 
int dresserDrop = 0
 The ID of the item that drops when this dresser is destroyed. Defaults to 0. Honestly, this is only really used when the chest limit is reached on a server. More...
 
int drop = 0
 The default type of item dropped when this tile is killed. Defaults to 0, which means no item. More...
 
int dustType = 0
 The default type of dust made when this tile is hit. Defaults to 0. More...
 
virtual string HighlightTexture => texture + "_Highlight"
 The highlight texture used when this tile is selected by smart interact. Defaults to adding "_Highlight" onto the main texture. More...
 
float mineResist = 1f
 A multiplier describing how much this block resists harvesting. Higher values will make it take longer to harvest. Defaults to 1f. More...
 
int minPick = 0
 The minimum pickaxe power required for pickaxes to mine this block. Defaults to 0. More...
 
int openDoorID = -1
 The ID of the tile that this door transforms into when it is opened. Defaults to -1, which means this tile isn't a door. More...
 
bool sapling = false
 Whether or not this tile is a sapling, which can grow into a modded tree or palm tree. More...
 
int soundStyle = 1
 The default style of sound made when this tile is hit. Defaults to 1. More...
 
int soundType = 0
 The default type of sound made when this tile is hit. Defaults to 0. More...
 
bool torch = false
 Whether or not this tile behaves like a torch. If you are making a torch tile, then setting this to true is necessary in order for tile placement, tile framing, and the item's smart selection to work properly. More...
 

Properties

Mod mod [get, set]
 The mod which has added this type of ModTile. More...
 
string Name [get, set]
 The name of this type of tile. More...
 
ushort Type [get, set]
 The internal ID of this type of tile. More...
 

Detailed Description

This class represents a type of tile that can be added by a mod. Only one instance of this class will ever exist for each type of tile that is added. Any hooks that are called will be called by the instance corresponding to the tile type. This is to prevent the game from using a massive amount of memory storing tile instances.

Definition at line 12 of file ModTile.cs.

Member Function Documentation

void Terraria.ModLoader.ModTile.AddMapEntry ( Color  color,
LocalizedText  name = null 
)

Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults.

Definition at line 131 of file ModTile.cs.

131  {
132  if (!MapLoader.initialized) {
133  MapEntry entry = new MapEntry(color, name);
134  if (!MapLoader.tileEntries.Keys.Contains(Type)) {
135  MapLoader.tileEntries[Type] = new List<MapEntry>();
136  }
137  MapLoader.tileEntries[Type].Add(entry);
138  }
139  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
void Terraria.ModLoader.ModTile.AddMapEntry ( Color  color,
ModTranslation  name 
)

Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults.

Definition at line 156 of file ModTile.cs.

156  {
157  if (!MapLoader.initialized) {
158  MapEntry entry = new MapEntry(color, name);
159  if (!MapLoader.tileEntries.Keys.Contains(Type)) {
160  MapLoader.tileEntries[Type] = new List<MapEntry>();
161  }
162  MapLoader.tileEntries[Type].Add(entry);
163  }
164  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
void Terraria.ModLoader.ModTile.AddMapEntry ( Color  color,
LocalizedText  name,
Func< string, int, int, string >  nameFunc 
)

Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.

Definition at line 169 of file ModTile.cs.

169  {
170  if (!MapLoader.initialized) {
171  MapEntry entry = new MapEntry(color, name, nameFunc);
172  if (!MapLoader.tileEntries.Keys.Contains(Type)) {
173  MapLoader.tileEntries[Type] = new List<MapEntry>();
174  }
175  MapLoader.tileEntries[Type].Add(entry);
176  }
177  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
void Terraria.ModLoader.ModTile.AddMapEntry ( Color  color,
ModTranslation  name,
Func< string, int, int, string >  nameFunc 
)

Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.

Definition at line 182 of file ModTile.cs.

182  {
183  if (!MapLoader.initialized) {
184  MapEntry entry = new MapEntry(color, name, nameFunc);
185  if (!MapLoader.tileEntries.Keys.Contains(Type)) {
186  MapLoader.tileEntries[Type] = new List<MapEntry>();
187  }
188  MapLoader.tileEntries[Type].Add(entry);
189  }
190  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
void Terraria.ModLoader.ModTile.AddToArray ( ref int[]  array)

A convenient method for adding this tile's Type to the given array. This can be used with the arrays in TileID.Sets.RoomNeeds.

Definition at line 123 of file ModTile.cs.

123  {
124  Array.Resize(ref array, array.Length + 1);
125  array[array.Length - 1] = Type;
126  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
virtual void Terraria.ModLoader.ModTile.AnimateIndividualTile ( int  type,
int  i,
int  j,
ref int  frameXOffset,
ref int  frameYOffset 
)
virtual

Animates an individual tile. i and j are the coordinates of the Tile in question. frameXOffset and frameYOffset should be used to specify an offset from the tiles frameX and frameY. "frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type];" will already be set before this hook is called, taking into account the TileID-wide animation set via AnimateTile. Use this hook for off-sync animations (lightning bug in a bottle), temporary animations (trap chests), or TileEntities to achieve unique animation behaviors without having to manually draw the tile via PreDraw.

Parameters
typeThe tile type.
iThe x position in tile coordinates.
jThe y position in tile coordinates.
frameXOffsetThe offset to frameX.
frameYOffsetThe offset to frameY.

Definition at line 390 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.SetAnimationFrame().

390  {
391  }

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModTile.AnimateTile ( ref int  frame,
ref int  frameCounter 
)
virtual

Allows you to animate your tile. Use frameCounter to keep track of how long the current frame has been active, and use frame to change the current frame. This is called once an update. Use AnimateIndividualTile to animate specific tile instances directly.

if (++frameCounter > 8)
{
frameCounter = 0;
if (++frame > 5)
{
frame = 0;
}
}

or, to mimic another tile, simply:

frame = Main.tileFrame[TileID.FireflyinaBottle];

Definition at line 378 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.AnimateTiles().

378  {
379  }

+ Here is the caller graph for this function:

virtual bool Terraria.ModLoader.ModTile.Autoload ( ref string  name,
ref string  texture 
)
virtual

Allows you to modify the name and texture path of this tile when it is autoloaded. Return true to autoload this tile. When a tile is autoloaded, that means you do not need to manually call Mod.AddTile. By default returns the mod's autoload property.

Parameters
nameThe internal name.
textureThe texture path.
Returns
Whether or not to autoload this tile.

Definition at line 222 of file ModTile.cs.

Referenced by Terraria.ModLoader.Mod.AutoloadTile().

222  {
223  return mod.Properties.Autoload;
224  }
Mod mod
The mod which has added this type of ModTile.
Definition: ModTile.cs:17
ModProperties Properties
Definition: Mod.cs:49
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

+ Here is the caller graph for this function:

virtual bool Terraria.ModLoader.ModTile.AutoSelect ( int  i,
int  j,
Item  item 
)
virtual

Allows you to determine whether the given item can become selected when the cursor is hovering over this tile and the auto selection hotkey is pressed.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 491 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.AutoSelect().

491  {
492  return false;
493  }

+ Here is the caller graph for this function:

virtual bool Terraria.ModLoader.ModTile.CanExplode ( int  i,
int  j 
)
virtual

Whether or not the tile at the given coordinates can be killed by an explosion (ie. bombs). Returns true by default; return false to stop an explosion from destroying it.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 320 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.CanExplode().

320  {
321  return true;
322  }

+ Here is the caller graph for this function:

virtual bool Terraria.ModLoader.ModTile.CanKillTile ( int  i,
int  j,
ref bool  blockDamaged 
)
virtual

Allows you to determine whether or not the tile at the given coordinates can be hit by anything. Returns true by default. blockDamaged currently has no use.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 295 of file ModTile.cs.

295  {
296  return true;
297  }
virtual bool Terraria.ModLoader.ModTile.CanPlace ( int  i,
int  j 
)
virtual

Allows you to stop this tile from being placed at the given coordinates. Return false to block the tile from being placed. Returns true by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 458 of file ModTile.cs.

458  {
459  return true;
460  }
virtual void Terraria.ModLoader.ModTile.ChangeWaterfallStyle ( ref int  style)
virtual

Allows you to change the style of waterfall that passes through or over this type of tile.

Parameters
style

Definition at line 539 of file ModTile.cs.

539  {
540  }
virtual bool Terraria.ModLoader.ModTile.CreateDust ( int  i,
int  j,
ref int  type 
)
virtual

Allows you to modify the default type of dust created when the tile at the given coordinates is hit. Return false to stop the default dust (the type parameter) from being created. Returns true by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 268 of file ModTile.cs.

268  {
269  type = dustType;
270  return true;
271  }
int dustType
The default type of dust made when this tile is hit. Defaults to 0.
Definition: ModTile.cs:54
ModTranslation Terraria.ModLoader.ModTile.CreateMapEntryName ( string  key = null)

Creates a ModTranslation object that you can use in AddMapEntry.

Parameters
keyThe key for the ModTranslation. The full key will be MapObject.ModName.key
Returns

Definition at line 146 of file ModTile.cs.

146  {
147  if (string.IsNullOrEmpty(key)) {
148  key = Name;
149  }
150  return mod.GetOrCreateTranslation(string.Format("Mods.{0}.MapObject.{1}", mod.Name, key));
151  }
Mod mod
The mod which has added this type of ModTile.
Definition: ModTile.cs:17
virtual string Name
Stores the name of the mod. This name serves as the mod&#39;s identification, and also helps with saving ...
Definition: Mod.cs:39
string Name
The name of this type of tile.
Definition: ModTile.cs:25
virtual bool Terraria.ModLoader.ModTile.Dangersense ( int  i,
int  j,
Player  player 
)
virtual

Allows you to determine whether this block glows red when the given player has the Dangersense buff.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 345 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.Dangersense().

345  {
346  return false;
347  }

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModTile.DrawEffects ( int  i,
int  j,
SpriteBatch  spriteBatch,
ref Color  drawColor,
ref int  nextSpecialDrawIndex 
)
virtual

Allows you to make stuff happen whenever the tile at the given coordinates is drawn. For example, creating dust or changing the color the tile is drawn in.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
nextSpecialDrawIndexThe special draw count. Use with Main.specX and Main.specY and then increment to draw special things after the main tile drawing loop is complete via DrawSpecial.

Definition at line 408 of file ModTile.cs.

408  {
409  }
virtual bool Terraria.ModLoader.ModTile.Drop ( int  i,
int  j 
)
virtual

Allows you to customize which items the tile at the given coordinates drops. Remember that the x, y (i, j) coordinates are in tile coordinates, you will need to multiply them by 16 if you want to drop an item using them. Return false to stop the game from dropping the tile's default item. Returns true by default. Please note that this hook currently only works for 1x1 tiles.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 286 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.Drop().

286  {
287  return true;
288  }

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModTile.DropCritterChance ( int  i,
int  j,
ref int  wormChance,
ref int  grassHopperChance,
ref int  jungleGrubChance 
)
virtual

Allows you to modify the chance the tile at the given coordinates has of spawning a certain critter when the tile is killed.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 278 of file ModTile.cs.

278  {
279  }
virtual void Terraria.ModLoader.ModTile.FloorVisuals ( Player  player)
virtual

Allows you to make something happen when a player stands on this type of tile. For example, you can make the player slide as if on ice.

Parameters
player

Definition at line 516 of file ModTile.cs.

516  {
517  }
virtual ushort Terraria.ModLoader.ModTile.GetMapOption ( int  i,
int  j 
)
virtual

Allows you to choose which minimap entry the tile at the given coordinates will use. 0 is the first entry added by AddMapEntry, 1 is the second entry, etc. Returns 0 by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 432 of file ModTile.cs.

432  {
433  return 0;
434  }
virtual bool Terraria.ModLoader.ModTile.HasSmartInteract ( )
virtual

Whether or not the smart interact function can select this tile. Useful for things like chests. Defaults to false.

Returns

Definition at line 242 of file ModTile.cs.

242  {
243  return false;
244  }
virtual bool Terraria.ModLoader.ModTile.HasWalkDust ( )
virtual

Whether or not this tile creates dust when the player walks on it. Returns false by default.

Definition at line 522 of file ModTile.cs.

522  {
523  return false;
524  }
virtual void Terraria.ModLoader.ModTile.HitWire ( int  i,
int  j 
)
virtual

Allows you to make something happen when a wire current passes through this tile.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 500 of file ModTile.cs.

500  {
501  }
virtual void Terraria.ModLoader.ModTile.KillMultiTile ( int  i,
int  j,
int  frameX,
int  frameY 
)
virtual

This hook is called exactly once whenever a block encompassing multiple tiles is destroyed. You can use it to make your multi-tile block drop a single item, for example.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 312 of file ModTile.cs.

312  {
313  }
virtual bool Terraria.ModLoader.ModTile.KillSound ( int  i,
int  j 
)
virtual

Allows you to customize which sound you want to play when the tile at the given coordinates is hit. Return false to stop the game from playing its default sound for the tile. Returns true by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 251 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.KillSound().

251  {
252  return true;
253  }

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModTile.KillTile ( int  i,
int  j,
ref bool  fail,
ref bool  effectOnly,
ref bool  noItem 
)
virtual

Allows you to determine what happens when the tile at the given coordinates is killed or hit with a pickaxe. Fail determines whether the tile is mined, effectOnly makes it so that only dust is created, and noItem stops items from dropping.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 304 of file ModTile.cs.

304  {
305  }
virtual void Terraria.ModLoader.ModTile.ModifyLight ( int  i,
int  j,
ref float  r,
ref float  g,
ref float  b 
)
virtual

Allows you to determine how much light this block emits. Make sure you set Main.tileLighted[Type] to true in SetDefaults for this to work.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 337 of file ModTile.cs.

337  {
338  }
virtual void Terraria.ModLoader.ModTile.MouseOver ( int  i,
int  j 
)
virtual

Allows you to make something happen when the mouse hovers over this tile. Useful for showing item icons or text on the mouse.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 475 of file ModTile.cs.

475  {
476  }
virtual void Terraria.ModLoader.ModTile.MouseOverFar ( int  i,
int  j 
)
virtual

Allows you to make something happen when the mouse hovers over this tile, even when the player is far away. Useful for showing what's written on signs, etc.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 483 of file ModTile.cs.

483  {
484  }
virtual void Terraria.ModLoader.ModTile.NearbyEffects ( int  i,
int  j,
bool  closer 
)
virtual

Allows you to make things happen when this tile is within a certain range of the player (around the same range water fountains and music boxes work). The closer parameter is whether or not the tile is within the range at which things like campfires and banners work.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 329 of file ModTile.cs.

329  {
330  }
virtual void Terraria.ModLoader.ModTile.NumDust ( int  i,
int  j,
bool  fail,
ref int  num 
)
virtual

Allows you to change how many dust particles are created when the tile at the given coordinates is hit.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 260 of file ModTile.cs.

260  {
261  }
virtual void Terraria.ModLoader.ModTile.PlaceInWorld ( int  i,
int  j,
Item  item 
)
virtual

Allows you to do something when this tile is placed.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
itemThe item used to place this tile.

Definition at line 557 of file ModTile.cs.

557  {
558  }
virtual void Terraria.ModLoader.ModTile.PostDraw ( int  i,
int  j,
SpriteBatch  spriteBatch 
)
virtual

Allows you to draw things in front of the tile at the given coordinates. This can also be used to do things such as creating dust.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 416 of file ModTile.cs.

416  {
417  }
virtual void Terraria.ModLoader.ModTile.PostSetDefaults ( )
virtual

Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main.tileObsidianKill.

Definition at line 235 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.IsModMusicBox().

235  {
236  }

+ Here is the caller graph for this function:

virtual bool Terraria.ModLoader.ModTile.PreDraw ( int  i,
int  j,
SpriteBatch  spriteBatch 
)
virtual

Allows you to draw things behind the tile at the given coordinates. Return false to stop the game from drawing the tile normally. Returns true by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 398 of file ModTile.cs.

398  {
399  return true;
400  }
virtual void Terraria.ModLoader.ModTile.RandomUpdate ( int  i,
int  j 
)
virtual

Called whenever the world randomly decides to update this tile in a given tick. Useful for things such as growing or spreading.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 441 of file ModTile.cs.

441  {
442  }
virtual void Terraria.ModLoader.ModTile.RightClick ( int  i,
int  j 
)
virtual

Allows you to make something happen when this tile is right-clicked by the player.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 467 of file ModTile.cs.

467  {
468  }
virtual int Terraria.ModLoader.ModTile.SaplingGrowthType ( ref int  style)
virtual

Allows this tile to support a sapling that can eventually grow into a tree. The type of the sapling should be returned here. Returns -1 by default. The style parameter will determine which sapling is chosen if multiple sapling types share the same ID; even if you only have a single sapling in an ID, you must still set this to 0.

Parameters
style
Returns

Definition at line 547 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.SaplingGrowthType().

547  {
548  return -1;
549  }

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModTile.SetDefaults ( )
virtual

Allows you to set the properties of this tile. Many properties are stored as arrays throughout Terraria's code.

Definition at line 229 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.IsModMusicBox().

229  {
230  }

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModTile.SetDrawPositions ( int  i,
int  j,
ref int  width,
ref int  offsetY,
ref int  height 
)
virtual

Allows you to customize the position in which this tile is drawn. Width refers to the width of one frame of the tile, offsetY refers to how many pixels below its actual position the tile should be drawn, and height refers to the height of one frame of the tile. By default the values will be set to the values you give this tile's TileObjectData. If this tile has no TileObjectData then they will default to 16, 0, and 16, respectively.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 362 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.SetDrawPositions().

362  {
363  }

+ Here is the caller graph for this function:

void Terraria.ModLoader.ModTile.SetModCactus ( ModCactus  cactus)

Allows this tile to grow the given modded cactus.

Parameters
cactusThe ModCactus

Definition at line 212 of file ModTile.cs.

212  {
213  TileLoader.cacti[Type] = cactus;
214  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
void Terraria.ModLoader.ModTile.SetModPalmTree ( ModPalmTree  palmTree)

Allows this tile to grow the given modded palm tree.

Parameters
palmTreeThe ModPalmTree

Definition at line 204 of file ModTile.cs.

204  {
205  TileLoader.palmTrees[Type] = palmTree;
206  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
void Terraria.ModLoader.ModTile.SetModTree ( ModTree  tree)

Allows this tile to grow the given modded tree.

Parameters
treeThe ModTree.

Definition at line 196 of file ModTile.cs.

196  {
197  TileLoader.trees[Type] = tree;
198  }
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
virtual void Terraria.ModLoader.ModTile.SetSpriteEffects ( int  i,
int  j,
ref SpriteEffects  spriteEffects 
)
virtual

Allows you to determine whether or not the tile will draw itself flipped in the world.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 354 of file ModTile.cs.

354  {
355  }
virtual bool Terraria.ModLoader.ModTile.Slope ( int  i,
int  j 
)
virtual

Allows you to control how hammers slope this tile. Return true to allow it to slope normally. Returns true by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 508 of file ModTile.cs.

508  {
509  return true;
510  }
virtual void Terraria.ModLoader.ModTile.SpecialDraw ( int  i,
int  j,
SpriteBatch  spriteBatch 
)
virtual

Special Draw. Only called if coordinates are placed in Main.specX/Y during DrawEffects. Useful for drawing things that would otherwise be impossible to draw due to draw order, such as items in item frames.

Parameters
iThe i.
jThe j.

Definition at line 424 of file ModTile.cs.

424  {
425  }
virtual bool Terraria.ModLoader.ModTile.TileFrame ( int  i,
int  j,
ref bool  resetFrame,
ref bool  noBreak 
)
virtual

Called whenever this tile updates due to being placed or being next to a tile that is changed. Return false to stop the game from carrying out its default TileFrame operations. Returns true by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.

Definition at line 449 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.TileFrame().

449  {
450  return true;
451  }

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModTile.WalkDust ( ref int  dustType,
ref bool  makeDust,
ref Color  color 
)
virtual

Allows you to modify the dust created when the player walks on this tile. The makeDust parameter is whether or not to make dust; you can randomly set this to false to reduce the amount of dust produced.

Parameters
dustType
makeDust
color

Definition at line 532 of file ModTile.cs.

532  {
533  }

Member Data Documentation

int [] Terraria.ModLoader.ModTile.adjTiles = new int[0]

An array of the IDs of tiles that this tile can be considered as when looking for crafting stations.

Definition at line 82 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.AdjTiles().

int Terraria.ModLoader.ModTile.animationFrameHeight = 0

The height of a group of animation frames for this tile. Defaults to 0, which disables animations.

Definition at line 62 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.SetAnimationFrame().

bool Terraria.ModLoader.ModTile.bed = false

Whether or not this tile is a valid spawn point. Defaults to false. If you set this to true, you will still have to manually set the spawn yourself in the RightClick hook.

Definition at line 110 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.IsModBed().

string Terraria.ModLoader.ModTile.chest = ""

The default name of this chest that is displayed when this 2x2 chest is open. Defaults to the empty string, which means that this tile isn't a chest. Setting this field will make the tile behave like a chest (meteors will avoid it, tiles underneath cannot be mined, etc.), but you will have to manually give it storage capabilities yourself. (See the ExampleMod for something you can copy/paste.)

Definition at line 94 of file ModTile.cs.

Referenced by Terraria.ModLoader.Mod.LoadEffect(), and Terraria.ModLoader.TileLoader.ModChestName().

int Terraria.ModLoader.ModTile.chestDrop = 0

The ID of the item that drops when this chest is destroyed. Defaults to 0. Honestly, this is only really used when the chest limit is reached on a server.

Definition at line 98 of file ModTile.cs.

int Terraria.ModLoader.ModTile.closeDoorID = -1

The ID of the tile that this door transforms into when it is closed. Defaults to -1, which means this tile isn't a door.

Definition at line 86 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.CloseDoorID().

bool Terraria.ModLoader.ModTile.disableSmartCursor = false

Whether or not the smart cursor function is disabled when the cursor hovers above this tile. Defaults to false.

Definition at line 74 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.DisableSmartCursor().

bool Terraria.ModLoader.ModTile.disableSmartInteract = false

Whether or not the smart tile interaction function is disabled when the cursor hovers above this tile. Defaults to false.

Definition at line 78 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.DisableSmartInteract().

string Terraria.ModLoader.ModTile.dresser = ""

Same as chest, except use this if your block is a dresser (has a size of 3x2 instead of 2x2).

Definition at line 102 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.ModDresserName().

int Terraria.ModLoader.ModTile.dresserDrop = 0

The ID of the item that drops when this dresser is destroyed. Defaults to 0. Honestly, this is only really used when the chest limit is reached on a server.

Definition at line 106 of file ModTile.cs.

int Terraria.ModLoader.ModTile.drop = 0

The default type of item dropped when this tile is killed. Defaults to 0, which means no item.

Definition at line 58 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.Drop().

int Terraria.ModLoader.ModTile.dustType = 0

The default type of dust made when this tile is hit. Defaults to 0.

Definition at line 54 of file ModTile.cs.

virtual string Terraria.ModLoader.ModTile.HighlightTexture => texture + "_Highlight"

The highlight texture used when this tile is selected by smart interact. Defaults to adding "_Highlight" onto the main texture.

Definition at line 42 of file ModTile.cs.

Referenced by Terraria.ModLoader.Mod.LoadEffect().

float Terraria.ModLoader.ModTile.mineResist = 1f

A multiplier describing how much this block resists harvesting. Higher values will make it take longer to harvest. Defaults to 1f.

Definition at line 66 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.MineDamage().

int Terraria.ModLoader.ModTile.minPick = 0

The minimum pickaxe power required for pickaxes to mine this block. Defaults to 0.

Definition at line 70 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.PickPowerCheck().

int Terraria.ModLoader.ModTile.openDoorID = -1

The ID of the tile that this door transforms into when it is opened. Defaults to -1, which means this tile isn't a door.

Definition at line 90 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.IsClosedDoor(), and Terraria.ModLoader.TileLoader.OpenDoorID().

bool Terraria.ModLoader.ModTile.sapling = false

Whether or not this tile is a sapling, which can grow into a modded tree or palm tree.

Definition at line 118 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.IsSapling().

int Terraria.ModLoader.ModTile.soundStyle = 1

The default style of sound made when this tile is hit. Defaults to 1.

Definition at line 50 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.KillSound().

int Terraria.ModLoader.ModTile.soundType = 0

The default type of sound made when this tile is hit. Defaults to 0.

Definition at line 46 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.KillSound().

bool Terraria.ModLoader.ModTile.torch = false

Whether or not this tile behaves like a torch. If you are making a torch tile, then setting this to true is necessary in order for tile placement, tile framing, and the item's smart selection to work properly.

Definition at line 114 of file ModTile.cs.

Referenced by Terraria.ModLoader.TileLoader.IsTorch().

Property Documentation

Mod Terraria.ModLoader.ModTile.mod
getset

The mod which has added this type of ModTile.

Definition at line 17 of file ModTile.cs.

Referenced by Terraria.ModLoader.Mod.AddTile(), and Terraria.ModLoader.Mod.AutoloadTile().

string Terraria.ModLoader.ModTile.Name
getset

The name of this type of tile.

Definition at line 25 of file ModTile.cs.

Referenced by Terraria.ModLoader.Mod.AddTile().

ushort Terraria.ModLoader.ModTile.Type
getset