tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.ModLoader.GlobalTile Class Reference

This class allows you to modify the behavior of any tile in the game. Create an instance of an overriding class then call Mod.AddGlobalTile to use this. More...

Inherits Terraria.ModLoader.GlobalBlockType.

Public Member Functions

void AddModCactus (int soilType, ModCactus cactus)
 Allows the given type of tile to grow the given modded cactus. More...
 
void AddModPalmTree (int soilType, ModPalmTree palmTree)
 Allows the given type of tile to grow the given modded palm tree. More...
 
void AddModTree (int soilType, ModTree tree)
 Allows the given type of tile to grow the given modded tree. More...
 
void AddToArray (ref int[] array, int type)
 A convenient method for adding an integer to the end of an array. This can be used with the arrays in TileID.Sets.RoomNeeds. More...
 
virtual int[] AdjTiles (int type)
 Allows you to determine which tiles the given tile type can be considered as when looking for crafting stations. More...
 
virtual void AnimateTile ()
 Allows animating tiles that were previously static. Loading a new texture for the tile is required first. Use Main.tileFrameCounter to count game frames and Main.tileFrame to change animation frames. More...
 
virtual bool AutoSelect (int i, int j, int type, Item item)
 Allows you to determine whether the given item can become selected when the cursor is hovering over a tile and the auto selection keybind is pressed. More...
 
virtual bool CanKillTile (int i, int j, int type, 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 (int type, ref int style)
 Allows you to change the style of waterfall that passes through or over any tile. More...
 
virtual bool Dangersense (int i, int j, int type, Player player)
 Allows you to determine whether the block glows red when the given player has the Dangersense buff. More...
 
virtual void DrawEffects (int i, int j, int type, 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, int type)
 Allows you to customize which items the tile at the given coordinates drops. Return false to stop the game from dropping the tile's default item. Returns true by default. More...
 
virtual void DropCritterChance (int i, int j, int type, 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 (int type, Player player)
 Allows you to make something happen when a player stands on the given type of tile. For example, you can make the player slide as if on ice. More...
 
virtual void HitWire (int i, int j, int type)
 Allows you to make something happen when a wire current passes through any tile. More...
 
virtual void KillTile (int i, int j, int type, 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. If fail is true, the tile will not be mined; effectOnly makes it so that only dust is created; noItem stops items from dropping. More...
 
virtual void MouseOver (int i, int j, int type)
 Allows you to make something happen when the mouse hovers over any tile. Useful for showing item icons or text on the mouse. More...
 
virtual void MouseOverFar (int i, int j, int type)
 Allows you to make something happen when the mouse hovers over any 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, int type, bool closer)
 Allows you to make things happen when the 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 bool PreHitWire (int i, int j, int type)
 Whether or not the vanilla HitWire code and the HitWire hook is allowed to run. Useful for overriding vanilla behavior by returning false. Returns true by default. More...
 
virtual void RightClick (int i, int j, int type)
 Allows you to make something happen when any tile is right-clicked by the player. More...
 
virtual int SaplingGrowthType (int type, ref int style)
 Allows a 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 SetSpriteEffects (int i, int j, int type, ref SpriteEffects spriteEffects)
 Allows you to determine whether or not a 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, int type)
 Allows you to control how hammers slope any tile. Return true to allow the tile to slope normally. Returns true by default. Called on the local Client and Single Player. More...
 
virtual void SpecialDraw (int i, int j, int type, 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, int type, ref bool resetFrame, ref bool noBreak)
 Called for every tile that 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...
 
- Public Member Functions inherited from Terraria.ModLoader.GlobalBlockType
virtual bool CanExplode (int i, int j, int type)
 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, int type)
 Allows you to stop a tile/wall from being placed at the given coordinates. Return false to block the tile/wall from being placed. Returns true by default. More...
 
virtual bool CreateDust (int i, int j, int type, ref int dustType)
 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 dustType parameter) from being created. Returns true by default. More...
 
virtual bool KillSound (int i, int j, int type)
 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, int type, ref float r, ref float g, ref float b)
 Allows you to determine how much light the block 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, int type, 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, int type, 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, int type, 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. Called on active tiles. See also ModSystem.PostDrawTiles. More...
 
virtual bool PreDraw (int i, int j, int type, 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/wall normally. Returns true by default. More...
 
virtual void RandomUpdate (int i, int j, int type)
 Called for every tile/wall the world randomly decides to update in a given tick. Useful for things such as growing or spreading. More...
 
virtual void SetDefaults ()
 Allows you to modify the properties of any tile/wall in the game. Most properties are stored as arrays throughout the Terraria code. 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 SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. 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...
 

Additional Inherited Members

- 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 allows you to modify the behavior of any tile in the game. Create an instance of an overriding class then call Mod.AddGlobalTile to use this.

Member Function Documentation

◆ AddModCactus()

void Terraria.ModLoader.GlobalTile.AddModCactus ( int  soilType,
ModCactus  cactus 
)

Allows the given type of tile to grow the given modded cactus.

Parameters
soilType
cactus

◆ AddModPalmTree()

void Terraria.ModLoader.GlobalTile.AddModPalmTree ( int  soilType,
ModPalmTree  palmTree 
)

Allows the given type of tile to grow the given modded palm tree.

Parameters
soilType
palmTree

◆ AddModTree()

void Terraria.ModLoader.GlobalTile.AddModTree ( int  soilType,
ModTree  tree 
)

Allows the given type of tile to grow the given modded tree.

Parameters
soilType
tree

◆ AddToArray()

void Terraria.ModLoader.GlobalTile.AddToArray ( ref int[]  array,
int  type 
)

A convenient method for adding an integer to the end of an array. This can be used with the arrays in TileID.Sets.RoomNeeds.

Parameters
array
type

◆ AdjTiles()

virtual int [] Terraria.ModLoader.GlobalTile.AdjTiles ( int  type)
virtual

Allows you to determine which tiles the given tile type can be considered as when looking for crafting stations.

Parameters
type
Returns

◆ AnimateTile()

virtual void Terraria.ModLoader.GlobalTile.AnimateTile ( )
virtual

Allows animating tiles that were previously static. Loading a new texture for the tile is required first. Use Main.tileFrameCounter to count game frames and Main.tileFrame to change animation frames.

◆ AutoSelect()

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

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

Parameters
i
j
type
item
Returns

◆ CanKillTile()

virtual bool Terraria.ModLoader.GlobalTile.CanKillTile ( int  i,
int  j,
int  type,
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
i
j
type
blockDamaged
Returns

◆ ChangeWaterfallStyle()

virtual void Terraria.ModLoader.GlobalTile.ChangeWaterfallStyle ( int  type,
ref int  style 
)
virtual

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

Parameters
type
style

◆ Dangersense()

virtual bool Terraria.ModLoader.GlobalTile.Dangersense ( int  i,
int  j,
int  type,
Player  player 
)
virtual

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

Parameters
i
j
type
player
Returns

◆ DrawEffects()

virtual void Terraria.ModLoader.GlobalTile.DrawEffects ( int  i,
int  j,
int  type,
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.GlobalTile.Drop ( int  i,
int  j,
int  type 
)
virtual

Allows you to customize which items the tile at the given coordinates drops. Return false to stop the game from dropping the tile's default item. Returns true by default.

◆ DropCritterChance()

virtual void Terraria.ModLoader.GlobalTile.DropCritterChance ( int  i,
int  j,
int  type,
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
i
j
type
wormChance
grassHopperChance
jungleGrubChance

◆ FloorVisuals()

virtual void Terraria.ModLoader.GlobalTile.FloorVisuals ( int  type,
Player  player 
)
virtual

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

Parameters
type
player

◆ HitWire()

virtual void Terraria.ModLoader.GlobalTile.HitWire ( int  i,
int  j,
int  type 
)
virtual

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

Parameters
i
j
type

◆ KillTile()

virtual void Terraria.ModLoader.GlobalTile.KillTile ( int  i,
int  j,
int  type,
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. If fail is true, the tile will not be mined; effectOnly makes it so that only dust is created; noItem stops items from dropping.

Parameters
i
j
type
fail
effectOnly
noItem

◆ MouseOver()

virtual void Terraria.ModLoader.GlobalTile.MouseOver ( int  i,
int  j,
int  type 
)
virtual

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

Parameters
i
j
type

◆ MouseOverFar()

virtual void Terraria.ModLoader.GlobalTile.MouseOverFar ( int  i,
int  j,
int  type 
)
virtual

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

Parameters
i
j
type

◆ NearbyEffects()

virtual void Terraria.ModLoader.GlobalTile.NearbyEffects ( int  i,
int  j,
int  type,
bool  closer 
)
virtual

Allows you to make things happen when the 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
i
j
type
closer

◆ PreHitWire()

virtual bool Terraria.ModLoader.GlobalTile.PreHitWire ( int  i,
int  j,
int  type 
)
virtual

Whether or not the vanilla HitWire code and the HitWire hook is allowed to run. Useful for overriding vanilla behavior by returning false. Returns true by default.

Parameters
i
j
type
Returns

◆ Register()

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

If you make a new ModType, seal this override.

Implements Terraria.ModLoader.ModType.

◆ RightClick()

virtual void Terraria.ModLoader.GlobalTile.RightClick ( int  i,
int  j,
int  type 
)
virtual

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

Parameters
i
j
type

◆ SaplingGrowthType()

virtual int Terraria.ModLoader.GlobalTile.SaplingGrowthType ( int  type,
ref int  style 
)
virtual

Allows a 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
type
style
Returns

◆ SetSpriteEffects()

virtual void Terraria.ModLoader.GlobalTile.SetSpriteEffects ( int  i,
int  j,
int  type,
ref SpriteEffects  spriteEffects 
)
virtual

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

Parameters
i
j
type
spriteEffects

◆ SetupContent()

sealed override void Terraria.ModLoader.GlobalTile.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.GlobalTile.Slope ( int  i,
int  j,
int  type 
)
virtual

Allows you to control how hammers slope any tile. Return true to allow the tile to slope normally. Returns true by default. Called on the local Client and Single Player.

Parameters
i
j
type
Returns

◆ SpecialDraw()

virtual void Terraria.ModLoader.GlobalTile.SpecialDraw ( int  i,
int  j,
int  type,
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.GlobalTile.TileFrame ( int  i,
int  j,
int  type,
ref bool  resetFrame,
ref bool  noBreak 
)
virtual

Called for every tile that 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
i
j
type
resetFrame
noBreak
Returns