tModLoader  0.12 Alpha
A mod to make and play 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...

Inherits Terraria.ModLoader.ModBlockType.

Inherited by Terraria.ModLoader.Default.UnloadedTile.

Public Member Functions

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, 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, 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 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 keybind is pressed. 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 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 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 TileDrawInfo drawData)
 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. SpecialDraw will only be called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint here. 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 float GetTorchLuck (Player player)
 Only called for torches, when there is one nearby. Use this to contribute to vanilla torch luck calculations. Typical return values are 1f for a torch in its biome, 0.5f for a weak positive torch, -1f for a torch in an opposing biome, and -0.5f for a weak negative torch. 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 bool IsLockedChest (int i, int j)
 Return true if this Tile corresponds to a chest that is locked. Prevents Quick Stacking items into the chest. 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 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 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 aesthetics like monoliths and music boxes and clocks work. It is false for campfires and heart lanterns. More...
 
virtual void PostSetDefaults ()
 Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main.tileObsidianKill. More...
 
virtual bool RightClick (int i, int j)
 Allows you to make something happen when this tile is right-clicked by the player. Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default. 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 SetDrawPositions (int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY)
 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, height refers to the height of one frame of the tile. 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...
 
sealed override void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. 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. Called on the local Client and Single Player. More...
 
virtual void SpecialDraw (int i, int j, SpriteBatch spriteBatch)
 Special Draw. Only called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint 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 bool UnlockChest (int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual)
 Allows customization of how a chest unlock is accomplished. By default, frameXAdjustment will be -36, shifting the frameX over to the left by 1 chest style. If your chests are in a different order, adjust frameXAdjustment accordingly. This hook is called on the client, and if successful will be called on the server and other clients as the action is synced. Make sure that the logic is consistent and not dependent on local player data. 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 Member Functions inherited from Terraria.ModLoader.ModBlockType
virtual bool CanExplode (int i, int j)
 Whether or not the tile/wall 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 CanPlace (int i, int j)
 Allows you to stop this tile/wall from being placed at the given coordinates. Return false to stop the tile/wall from being placed. Returns true by default. More...
 
virtual bool CreateDust (int i, int j, ref int type)
 Allows you to modify the default type of dust created when the tile/wall 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 ushort GetMapOption (int i, int j)
 Allows you to choose which minimap entry the tile/wall 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 KillSound (int i, int j)
 Allows you to customize which sound you want to play when the tile/wall at the given coordinates is hit. Return false to stop the game from playing its default sound for the tile/wall. Returns true by default. 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 tile/wall emits. If it is a tile, make sure you set Main.tileLighted[Type] to true in SetDefaults for this to work. If it is a wall, it can also let you light up the block in front of this wall. 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/wall at the given coordinates is hit. More...
 
virtual void PlaceInWorld (int i, int j, Item item)
 Allows you to do something when this tile/wall is placed. Called on the local Client and Single Player. More...
 
virtual void PostDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things in front of the tile/wall at the given coordinates. This can also be used to do things such as creating dust. More...
 
virtual bool PreDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things behind the tile/wall 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/wall in a given tick. Useful for things such as growing or spreading. More...
 
override void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed.
This is where you would set the properties of this tile/wall. Many properties are stored as arrays throughout Terraria's code.
For example:

  • Main.tileSolid[Type] = true;
  • Main.tileSolidTop[Type] = true;
  • Main.tileBrick[Type] = true;
  • Main.tileBlockLight[Type] = true;
More...
 
- Public Member Functions inherited from Terraria.ModLoader.ModType
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 

Protected Member Functions

sealed override void Register ()
 If you make a new ModType, seal this override. More...
 

Properties

int[] AdjTiles = new int[0] [get, set]
 An array of the IDs of tiles that this tile can be considered as when looking for crafting stations. More...
 
int AnimationFrameHeight [get, set]
 The height of a group of animation frames for this tile. Defaults to 0, which disables animations. More...
 
int ChestDrop [get, set]
 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 [get, set]
 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...
 
ModTranslation ContainerName [get, set]
 The translations for the name that is displayed when this tile is opened as a chest or dresser. This won't be used if you don't add your tile to TileID.Sets.BasicChest or TileID.Sets.BasicDresser. More...
 
int DresserDrop [get, set]
 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...
 
virtual string HighlightTexture [get]
 The highlight texture used when this tile is selected by smart interact. Defaults to adding "_Highlight" onto the main texture. More...
 
bool IsDoor [get]
 
float MineResist = 1f [get, set]
 A multiplier describing how much this block resists harvesting. Higher values will make it take longer to harvest. Defaults to 1f. More...
 
int MinPick [get, set]
 The minimum pickaxe power required for pickaxes to mine this block. Defaults to 0. More...
 
int OpenDoorID = -1 [get, set]
 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...
 
- Properties inherited from Terraria.ModLoader.ModBlockType
int DustType [get, set]
 The default type of dust made when this tile/wall is hit. Defaults to 0. More...
 
int ItemDrop [get, set]
 The default type of item dropped when this tile/wall is killed. Defaults to 0, which means no item. More...
 
int SoundStyle = 1 [get, set]
 The default style of sound made when this tile/wall is hit. Defaults to 1. More...
 
int SoundType [get, set]
 The default type of sound made when this tile/wall is hit. Defaults to 0. More...
 
ushort Type [get, set]
 The internal ID of this type of tile/wall. More...
 
ushort VanillaFallbackOnModDeletion = 0 [get, set]
 The vanilla ID of what should replace the instance when a user unloads and subsequently deletes data from your mod in their save file. Defaults to 0. More...
 
- Properties inherited from Terraria.ModLoader.ModTexturedType
virtual string Texture [get]
 The file name of this type's texture file in the mod loader's file space. More...
 
- Properties inherited from Terraria.ModLoader.ModType
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. 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...
 

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.

Member Function Documentation

◆ AddMapEntry() [1/4]

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.

◆ AddMapEntry() [2/4]

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.

◆ AddMapEntry() [3/4]

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.

◆ AddMapEntry() [4/4]

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.

◆ AddToArray()

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.

◆ AnimateIndividualTile()

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.

◆ AnimateTile()

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];

◆ AutoSelect()

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 keybind is pressed.

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

◆ CanKillTile()

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.

◆ ChangeWaterfallStyle()

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

◆ Dangersense()

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.

◆ DrawEffects()

virtual void Terraria.ModLoader.ModTile.DrawEffects ( int  i,
int  j,
SpriteBatch  spriteBatch,
ref TileDrawInfo  drawData 
)
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. SpecialDraw will only be called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint here.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
drawDataVarious information about the tile that is being drawn, such as color, framing, glow textures, etc.

◆ Drop()

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.

◆ DropCritterChance()

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.

◆ FloorVisuals()

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

◆ GetTorchLuck()

virtual float Terraria.ModLoader.ModTile.GetTorchLuck ( Player  player)
virtual

Only called for torches, when there is one nearby. Use this to contribute to vanilla torch luck calculations. Typical return values are 1f for a torch in its biome, 0.5f for a weak positive torch, -1f for a torch in an opposing biome, and -0.5f for a weak negative torch.

Parameters
playerMain.LocalPlayer
Returns

◆ HasSmartInteract()

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

◆ HasWalkDust()

virtual bool Terraria.ModLoader.ModTile.HasWalkDust ( )
virtual

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

◆ HitWire()

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.

◆ IsLockedChest()

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

Return true if this Tile corresponds to a chest that is locked. Prevents Quick Stacking items into the chest.

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

◆ KillMultiTile()

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.

◆ KillTile()

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.

◆ MouseOver()

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.

Reimplemented in Terraria.ModLoader.Default.UnloadedTile.

◆ MouseOverFar()

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.

◆ NearbyEffects()

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 aesthetics like monoliths and music boxes and clocks work. It is false for campfires and heart lanterns.

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

◆ PostSetDefaults()

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

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

◆ Register()

sealed override void Terraria.ModLoader.ModTile.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements Terraria.ModLoader.ModType.

◆ RightClick()

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

Allows you to make something happen when this tile is right-clicked by the player. Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
Returns
Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default.

◆ SaplingGrowthType()

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

◆ SetDrawPositions()

virtual void Terraria.ModLoader.ModTile.SetDrawPositions ( int  i,
int  j,
ref int  width,
ref int  offsetY,
ref int  height,
ref short  tileFrameX,
ref short  tileFrameY 
)
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, 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.

tileFrameX and tileFrameY allow you to change which frames are drawn, keeping tile.frameX/Y intact for other purposes.

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

◆ SetModCactus()

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

Allows this tile to grow the given modded cactus.

Parameters
cactusThe ModCactus

◆ SetModPalmTree()

void Terraria.ModLoader.ModTile.SetModPalmTree ( ModPalmTree  palmTree)

Allows this tile to grow the given modded palm tree.

Parameters
palmTreeThe ModPalmTree

◆ SetModTree()

void Terraria.ModLoader.ModTile.SetModTree ( ModTree  tree)

Allows this tile to grow the given modded tree.

Parameters
treeThe ModTree.

◆ SetSpriteEffects()

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.

◆ SetupContent()

sealed override void Terraria.ModLoader.ModTile.SetupContent ( )
virtual

If you make a new ModType, seal this override, and call SetStaticDefaults in it.

Reimplemented from Terraria.ModLoader.ModType.

◆ Slope()

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. Called on the local Client and Single Player.

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

◆ SpecialDraw()

virtual void Terraria.ModLoader.ModTile.SpecialDraw ( int  i,
int  j,
SpriteBatch  spriteBatch 
)
virtual

Special Draw. Only called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint 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 x position in tile coordinates.
jThe y position in tile coordinates.

◆ TileFrame()

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.

◆ UnlockChest()

virtual bool Terraria.ModLoader.ModTile.UnlockChest ( int  i,
int  j,
ref short  frameXAdjustment,
ref int  dustType,
ref bool  manual 
)
virtual

Allows customization of how a chest unlock is accomplished. By default, frameXAdjustment will be -36, shifting the frameX over to the left by 1 chest style. If your chests are in a different order, adjust frameXAdjustment accordingly. This hook is called on the client, and if successful will be called on the server and other clients as the action is synced. Make sure that the logic is consistent and not dependent on local player data.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
frameXAdjustmentThe adjustment made to each Tile.frameX, defaults to -36
dustTypeThe dust spawned, defaults to 11
manualSet this to true to bypass the code playing the unlock sound, adjusting the tile frame, and spawning dust. Network syncing will still happen.
Returns
Return true if this tile truly is a locked chest and the chest can be unlocked

◆ WalkDust()

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

Property Documentation

◆ AdjTiles

int [] Terraria.ModLoader.ModTile.AdjTiles = new int[0]
getset

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

◆ AnimationFrameHeight

int Terraria.ModLoader.ModTile.AnimationFrameHeight
getset

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

◆ ChestDrop

int Terraria.ModLoader.ModTile.ChestDrop
getset

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.

◆ CloseDoorID

int Terraria.ModLoader.ModTile.CloseDoorID = -1
getset

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.

◆ ContainerName

ModTranslation Terraria.ModLoader.ModTile.ContainerName
getset

The translations for the name that is displayed when this tile is opened as a chest or dresser. This won't be used if you don't add your tile to TileID.Sets.BasicChest or TileID.Sets.BasicDresser.

◆ DresserDrop

int Terraria.ModLoader.ModTile.DresserDrop
getset

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.

◆ HighlightTexture

virtual string Terraria.ModLoader.ModTile.HighlightTexture
get

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

◆ MineResist

float Terraria.ModLoader.ModTile.MineResist = 1f
getset

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

◆ MinPick

int Terraria.ModLoader.ModTile.MinPick
getset

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

◆ OpenDoorID

int Terraria.ModLoader.ModTile.OpenDoorID = -1
getset

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.