1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
5using Terraria.Localization;
38 internal string texture;
124 Array.Resize(ref array, array.Length + 1);
125 array[array.Length - 1] =
Type;
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>();
137 MapLoader.tileEntries[
Type].Add(entry);
147 if (
string.IsNullOrEmpty(key)) {
150 return mod.GetOrCreateTranslation(
string.Format(
"Mods.{0}.MapObject.{1}",
mod.
Name, key));
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>();
162 MapLoader.tileEntries[
Type].Add(entry);
169 public void AddMapEntry(Color color, LocalizedText name, Func<string, int, int, string> nameFunc) {
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>();
175 MapLoader.tileEntries[
Type].Add(entry);
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>();
188 MapLoader.tileEntries[
Type].Add(entry);
222 public virtual bool Autoload(ref
string name, ref
string texture) {
260 public virtual void NumDust(
int i,
int j,
bool fail, ref
int num) {
278 public virtual void DropCritterChance(
int i,
int j, ref
int wormChance, ref
int grassHopperChance, ref
int jungleGrubChance) {
286 public virtual bool Drop(
int i,
int j) {
295 public virtual bool CanKillTile(
int i,
int j, ref
bool blockDamaged) {
304 public virtual void KillTile(
int i,
int j, ref
bool fail, ref
bool effectOnly, ref
bool noItem) {
337 public virtual void ModifyLight(
int i,
int j, ref
float r, ref
float g, ref
float b) {
362 public virtual void SetDrawPositions(
int i,
int j, ref
int width, ref
int offsetY, ref
int height) {
378 public virtual void AnimateTile(ref
int frame, ref
int frameCounter) {
398 public virtual bool PreDraw(
int i,
int j, SpriteBatch spriteBatch) {
408 public virtual void DrawEffects(
int i,
int j, SpriteBatch spriteBatch, ref Color drawColor, ref
int nextSpecialDrawIndex) {
416 public virtual void PostDraw(
int i,
int j, SpriteBatch spriteBatch) {
424 public virtual void SpecialDraw(
int i,
int j, SpriteBatch spriteBatch) {
449 public virtual bool TileFrame(
int i,
int j, ref
bool resetFrame, ref
bool noBreak) {
467 [Obsolete(
"ModTile.RightClick will return a bool value later. This version is deprecated since v0.11.5, please use ModTile.NewRightClick instead and return true if a tile interaction has occurred.")]
519 public virtual bool Slope(
int i,
int j) {
591 public virtual bool UnlockChest(
int i,
int j, ref
short frameXAdjustment, ref
int dustType, ref
bool manual) =>
false;
This class represents a type of modded cactus. The cactus will share a tile ID with the vanilla cacti...
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
virtual string Name
Stores the name of the mod. This name serves as the mod's identification, and also helps with saving ...
This class represents a type of modded palm tree. The palm tree will share a tile ID with the vanilla...
This class represents a type of tile that can be added by a mod. Only one instance of this class will...
virtual void RandomUpdate(int i, int j)
Called whenever the world randomly decides to update this tile in a given tick. Useful for things suc...
virtual void MouseOver(int i, int j)
Allows you to make something happen when the mouse hovers over this tile. Useful for showing item ico...
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...
virtual void SetDefaults()
Allows you to set the properties of this tile. Many properties are stored as arrays throughout Terrar...
bool disableSmartCursor
Whether or not the smart cursor function is disabled when the cursor hovers above this tile....
int soundType
The default type of sound made when this tile is hit. Defaults to 0.
Mod mod
The mod which has added this type of ModTile.
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 s...
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,...
string dresser
Same as chest, except use this if your block is a dresser (has a size of 3x2 instead of 2x2).
ushort Type
The internal ID of this type of tile.
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 t...
bool bed
Whether or not this tile is a valid spawn point. Defaults to false. If you set this to true,...
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 ...
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.
bool sapling
Whether or not this tile is a sapling, which can grow into a modded tree or palm tree.
void SetModTree(ModTree tree)
Allows this tile to grow the given modded tree.
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 w...
int drop
The default type of item dropped when this tile is killed. Defaults to 0, which means no item.
int[] adjTiles
An array of the IDs of tiles that this tile can be considered as when looking for crafting stations.
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,...
int chestDrop
The ID of the item that drops when this chest is destroyed. Defaults to 0. Honestly,...
ModTranslation CreateMapEntryName(string key=null)
Creates a ModTranslation object that you can use in AddMapEntry.
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 fr...
virtual void HitWire(int i, int j)
Allows you to make something happen when a wire current passes through this tile.
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....
virtual bool Drop(int i, int j)
Allows you to customize which items the tile at the given coordinates drops. Remember that the x,...
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 hi...
int openDoorID
The ID of the tile that this door transforms into when it is opened. Defaults to -1,...
virtual ushort GetMapOption(int i, int j)
Allows you to choose which minimap entry the tile at the given coordinates will use....
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 fro...
int closeDoorID
The ID of the tile that this door transforms into when it is closed. Defaults to -1,...
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 bee...
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....
int dresserDrop
The ID of the item that drops when this dresser is destroyed. Defaults to 0. Honestly,...
virtual bool IsLockedChest(int i, int j)
Return true if this Tile corresponds to a chest that is locked. Prevents Quick Stacking items into th...
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.
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 fr...
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....
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....
void SetModPalmTree(ModPalmTree palmTree)
Allows this tile to grow the given modded palm tree.
int soundStyle
The default style of sound made when this tile is hit. Defaults to 1.
virtual bool HasSmartInteract()
Whether or not the smart interact function can select this tile. Useful for things like chests....
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 p...
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 call...
string Name
The name of this type of tile.
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 w...
virtual void RightClick(int i, int j)
Allows you to make something happen when this tile is right-clicked by the player.
int animationFrameHeight
The height of a group of animation frames for this tile. Defaults to 0, which disables animations.
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....
virtual void PostSetDefaults()
Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main....
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 call...
virtual bool HasWalkDust()
Whether or not this tile creates dust when the player walks on it. Returns false by default.
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 ti...
virtual void SpecialDraw(int i, int j, SpriteBatch spriteBatch)
Special Draw. Only called if coordinates are placed in Main.specX/Y during DrawEffects....
virtual void FloorVisuals(Player player)
Allows you to make something happen when a player stands on this type of tile. For example,...
virtual string HighlightTexture
The highlight texture used when this tile is selected by smart interact. Defaults to adding "_Highlig...
virtual bool NewRightClick(int i, int j)
Allows you to make something happen when this tile is right-clicked by the player....
float mineResist
A multiplier describing how much this block resists harvesting. Higher values will make it take longe...
void SetModCactus(ModCactus cactus)
Allows this tile to grow the given modded cactus.
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 ...
int dustType
The default type of dust made when this tile is hit. Defaults to 0.
virtual bool CanExplode(int i, int j)
Whether or not the tile at the given coordinates can be killed by an explosion (ie....
bool disableSmartInteract
Whether or not the smart tile interaction function is disabled when the cursor hovers above this tile...
int minPick
The minimum pickaxe power required for pickaxes to mine this block. Defaults to 0.
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 ...
string chest
The default name of this chest that is displayed when this 2x2 chest is open. Defaults to the empty s...
virtual void PlaceInWorld(int i, int j, Item item)
Allows you to do something when this tile is placed. Called on the local Client and Single Player.
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....
virtual bool Slope(int i, int j)
Allows you to control how hammers slope this tile. Return true to allow it to slope normally....
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 s...
virtual void ChangeWaterfallStyle(ref int style)
Allows you to change the style of waterfall that passes through or over this type of tile.
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....
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,...
bool torch
Whether or not this tile behaves like a torch. If you are making a torch tile, then setting this to t...
This class represents a type of modded tree. The tree will share a tile ID with the vanilla trees (5)...
This serves as the central class from which tile-related functions are supported and carried out.
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...