Terraria ModLoader  0.10.1.5
A framework for 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...

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 Autoload (ref string name)
 Allows you to automatically load a GlobalTile instead of using Mod.AddGlobalTile. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name. 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 hotkey is pressed. More...
 
virtual bool CanExplode (int i, int j, int type)
 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, 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 bool CanPlace (int i, int j, int type)
 Allows you to stop a 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 (int type, ref int style)
 Allows you to change the style of waterfall that passes through or over any tile. 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 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 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 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, 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 bool KillSound (int i, int j, int type)
 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, 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. 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, int type, ref float r, ref float g, ref float b)
 Allows you to determine how much light the 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, 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 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 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, int type, 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 bool PreDraw (int i, int j, int type, 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 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 RandomUpdate (int i, int j, int type)
 Called for every tile the world randomly decides to update in a given tick. Useful for things such as growing or spreading. 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 SetDefaults ()
 Allows you to modify the properties of any tile in the game. Most properties are stored as arrays throughout the Terraria code. 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...
 
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. More...
 
virtual void SpecialDraw (int i, int j, int type, 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, 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...
 

Properties

Mod mod [get, set]
 The mod to which this GlobalTile belongs to. More...
 
string Name [get, set]
 The name of this GlobalTile 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.

Definition at line 10 of file GlobalTile.cs.

Member Function Documentation

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

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

Parameters
soilType
cactus

Definition at line 61 of file GlobalTile.cs.

61  {
62  TileLoader.cacti[soilType] = cactus;
63  }
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

Definition at line 52 of file GlobalTile.cs.

52  {
53  TileLoader.palmTrees[soilType] = palmTree;
54  }
void Terraria.ModLoader.GlobalTile.AddModTree ( int  soilType,
ModTree  tree 
)

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

Parameters
soilType
tree

Definition at line 43 of file GlobalTile.cs.

43  {
44  TileLoader.trees[soilType] = tree;
45  }
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

Definition at line 33 of file GlobalTile.cs.

33  {
34  Array.Resize(ref array, array.Length + 1);
35  array[array.Length - 1] = type;
36  }
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

Definition at line 298 of file GlobalTile.cs.

298  {
299  return new int[0];
300  }
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.

Definition at line 215 of file GlobalTile.cs.

215  {
216  }
virtual bool Terraria.ModLoader.GlobalTile.Autoload ( ref string  name)
virtual

Allows you to automatically load a GlobalTile instead of using Mod.AddGlobalTile. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name.

Parameters
name
Returns

Definition at line 70 of file GlobalTile.cs.

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

70  {
71  return mod.Properties.Autoload;
72  }
Mod mod
The mod to which this GlobalTile belongs to.
Definition: GlobalTile.cs:15
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.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 hotkey is pressed.

Parameters
i
j
type
item
Returns

Definition at line 337 of file GlobalTile.cs.

337  {
338  return false;
339  }
virtual bool Terraria.ModLoader.GlobalTile.CanExplode ( int  i,
int  j,
int  type 
)
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
i
j
type
Returns

Definition at line 164 of file GlobalTile.cs.

164  {
165  return true;
166  }
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

Definition at line 141 of file GlobalTile.cs.

141  {
142  return true;
143  }
virtual bool Terraria.ModLoader.GlobalTile.CanPlace ( int  i,
int  j,
int  type 
)
virtual

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

Parameters
i
j
type
Returns

Definition at line 289 of file GlobalTile.cs.

289  {
290  return true;
291  }
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

Definition at line 385 of file GlobalTile.cs.

385  {
386  }
virtual bool Terraria.ModLoader.GlobalTile.CreateDust ( int  i,
int  j,
int  type,
ref int  dustType 
)
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 dustType parameter) from being created. Returns true by default.

Parameters
i
j
type
dustType
Returns

Definition at line 110 of file GlobalTile.cs.

110  {
111  return true;
112  }
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

Definition at line 198 of file GlobalTile.cs.

198  {
199  return false;
200  }
virtual void Terraria.ModLoader.GlobalTile.DrawEffects ( int  i,
int  j,
int  type,
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
i
j
type
spriteBatch
drawColor
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 239 of file GlobalTile.cs.

239  {
240  }
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.

Definition at line 129 of file GlobalTile.cs.

129  {
130  return true;
131  }
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

Definition at line 123 of file GlobalTile.cs.

123  {
124  }
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

Definition at line 377 of file GlobalTile.cs.

377  {
378  }
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

Definition at line 358 of file GlobalTile.cs.

358  {
359  }
virtual bool Terraria.ModLoader.GlobalTile.KillSound ( int  i,
int  j,
int  type 
)
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
i
j
type
Returns

Definition at line 87 of file GlobalTile.cs.

87  {
88  return true;
89  }
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. Fail determines whether the tile is mined, effectOnly makes it so that only dust is created, and noItem stops items from dropping.

Parameters
i
j
type
fail
effectOnly
noItem

Definition at line 154 of file GlobalTile.cs.

154  {
155  }
virtual void Terraria.ModLoader.GlobalTile.ModifyLight ( int  i,
int  j,
int  type,
ref float  r,
ref float  g,
ref float  b 
)
virtual

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

Parameters
i
j
type
r
g
b

Definition at line 187 of file GlobalTile.cs.

187  {
188  }
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

Definition at line 317 of file GlobalTile.cs.

317  {
318  }
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

Definition at line 326 of file GlobalTile.cs.

326  {
327  }
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

Definition at line 175 of file GlobalTile.cs.

175  {
176  }
virtual void Terraria.ModLoader.GlobalTile.NumDust ( int  i,
int  j,
int  type,
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
i
j
type
fail
num

Definition at line 99 of file GlobalTile.cs.

99  {
100  }
virtual void Terraria.ModLoader.GlobalTile.PlaceInWorld ( int  i,
int  j,
Item  item 
)
virtual

Allows you to do something when this tile is placed.

Parameters
i
j
item

Definition at line 404 of file GlobalTile.cs.

404  {
405  }
virtual void Terraria.ModLoader.GlobalTile.PostDraw ( int  i,
int  j,
int  type,
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
i
j
type
spriteBatch

Definition at line 249 of file GlobalTile.cs.

249  {
250  }
virtual bool Terraria.ModLoader.GlobalTile.PreDraw ( int  i,
int  j,
int  type,
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
i
j
type
spriteBatch
Returns

Definition at line 226 of file GlobalTile.cs.

226  {
227  return true;
228  }
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

Definition at line 348 of file GlobalTile.cs.

348  {
349  return true;
350  }
virtual void Terraria.ModLoader.GlobalTile.RandomUpdate ( int  i,
int  j,
int  type 
)
virtual

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

Parameters
i
j
type

Definition at line 266 of file GlobalTile.cs.

266  {
267  }
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

Definition at line 308 of file GlobalTile.cs.

308  {
309  }
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

Definition at line 394 of file GlobalTile.cs.

394  {
395  return -1;
396  }
virtual void Terraria.ModLoader.GlobalTile.SetDefaults ( )
virtual

Allows you to modify the properties of any tile in the game. Most properties are stored as arrays throughout the Terraria code.

Definition at line 77 of file GlobalTile.cs.

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

77  {
78  }

+ Here is the caller graph for this function:

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

Definition at line 209 of file GlobalTile.cs.

209  {
210  }
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.

Parameters
i
j
type
Returns

Definition at line 368 of file GlobalTile.cs.

368  {
369  return true;
370  }
virtual void Terraria.ModLoader.GlobalTile.SpecialDraw ( int  i,
int  j,
int  type,
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 257 of file GlobalTile.cs.

257  {
258  }
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

Definition at line 278 of file GlobalTile.cs.

278  {
279  return true;
280  }

Property Documentation

Mod Terraria.ModLoader.GlobalTile.mod
getset

The mod to which this GlobalTile belongs to.

Definition at line 15 of file GlobalTile.cs.

Referenced by Terraria.ModLoader.Mod.AddGlobalTile(), and Terraria.ModLoader.Mod.AutoloadGlobalTile().

string Terraria.ModLoader.GlobalTile.Name
getset

The name of this GlobalTile instance.

Definition at line 23 of file GlobalTile.cs.

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