tModLoader v2024.08
A mod to make and play Terraria mods
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.
The Basic Tile Guideteaches the basics of making a modded tile. More...

Inherits ModBlockType.

Inherited by ModPylon, and UnloadedTile.

Public Member Functions

void AddMapEntry (Color color, LocalizedText name, Func< string, int, int, string > nameFunc)
 

Overload specific: This overload has an additional nameFunc parameter. This function will be used to dynamically adjust the hover text. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This function is most typically used for chests and dressers to show the current chest name, if assigned, instead of the default chest name. ExampleMod's ExampleChestis one example of this functionality.
 
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.
For a typical tile that has a map display name, use ModBlockType.CreateMapEntryName as the name parameter for a default key using the pattern "Mods.{ModName}.Tiles.{ContentName}.MapEntry".
If a tile will be using multiple map entries, it is suggested to use this.GetLocalization("CustomMapEntryName"). Modders can also re-use the display name localization of items, such as ModContent.GetInstance<ItemThatPlacesThisStyle>().DisplayName.

Multiple map entries are suitable for tiles that need a different color or hover text for different tile styles. Vanilla code uses this mostly only for chest and dresser tiles. Map entries will be given a corresponding map option value, counting from 0, according to the order in which they are added. Map option values don't necessarily correspond to tile styles.
ModBlockType.GetMapOption will be used to choose which map entry is used for a given coordinate.

Vanilla map entries for most furniture tiles tend to be fairly generic, opting to use a single map entry to show "Table" for all styles of tables instead of the style-specific text such as "Wooden Table", "Honey Table", etc. To use these existing localizations, use the Language.GetText(string) method with the appropriate key, such as "MapObject.Chair", "MapObject.Door", "ItemName.WorkBench", etc. Consult the source code or ExampleMod to find the existing localization keys for common furniture types.
 
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.
 
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 Tile.TileFrameX and Tile.TileFrameY. 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(ref int, ref int). Use this hook for off-sync animations (lightning bug in a bottle), state specific animations (campfires), temporary animations (trap chests), or TileEntities to achieve unique animation behaviors without having to manually draw the tile via ModBlockType.PreDraw(int, int, SpriteBatch). 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. AnimationFrameHeight must be set for the animation timing set in this method to actually apply to the tile drawing. Use AnimateIndividualTile(int, int, int, ref int, ref int) 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 CanDrop (int i, int j)
 Allows prevention of item drops from the tile dropping at the given coordinates. Return false to stop the game from dropping the tile's item(s). Returns true by default. See GetItemDrops to customize the item drop. More...
 
virtual bool CanKillTile (int i, int j, ref bool blockDamaged)
 Allows you to determine whether or not the tile at the given coordinates can be hit by anything. Returns true by default. blockDamaged currently has no use. More...
 
virtual bool CanReplace (int i, int j, int tileTypeBeingPlaced)
 Allows you to stop this tile at the given coordinates from being replaced via the block swap feature. The tileTypeBeingPlaced parameter is the tile type that will replace the current tile.
This method is called on the local client. This method is only called if the local player has sufficient pickaxe power to mine the existing tile.
Return false to block the tile from being replaced. Returns true by default.
Use this for dynamic logic. ID.TileID.Sets.DoesntGetReplacedWithTileReplacement, ID.TileID.Sets.DoesntPlaceWithTileReplacement, and ID.TileID.Sets.PreventsTileReplaceIfOnTopOfIt cover the most common use cases and should be used instead if possible. 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 LocalizedText DefaultContainerName (int frameX, int frameY)
 Returns the default name for a chest or dresser with the provided FrameX and FrameY values.
A typical implementation of a tile with only a single name might return CreateMapEntryName()
A container with multiple styles might return this.GetLocalization("MapEntry" + option) where option is determined using similar logic to ModBlockType.GetMapOption to match the AddMapEntry(Color, LocalizedText) entries. Another option is using return Lang._mapLegendCache[MapHelper.TileToLookup(Type, option)];, this will reuse the localizations used for the map entries. 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 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 IEnumerable< ItemGetItemDrops (int i, int j)
 Allows customization of the items the tile at the given coordinates drops.

The default item drop is determined by finding an item with Item.createTile and Item.placeStyle matching the type and style of this tile. ModTile.RegisterItemDrop(int, int[]) can be used to manually register item drops for tile styles with no corresponding item. It can also be used to register a fallback item, which will be dropped if no suitable item is found.

The default behavior should cover 99% of use cases, meaning that overriding this method should only be necessary in extremely unique tiles, such as tiles dropping multiple items, tiles dropping items with custom data, or tiles with custom tile style code.

When overriding, use yield return new Item(ItemTypeHere); for each spawned item. Note that a random prefix will be applied to these items, if applicable, so if specific prefixes or no prefix is needed for an item drop, it will have to be spawned in manually using KillMultiTile(int, int, int, int) or KillTile(int, int, ref bool, ref bool, ref bool).

The style based drop logic is based on TileObjectData. If a tile has custom 'styles' but still wants to make use of ModTile.RegisterItemDrop(int, int[]), TileLoader.GetItemDropFromTypeAndStyle(Type, style) can be used to retrieve the associated item drop.

Use CanDrop to conditionally prevent any item drops. Use KillMultiTile(int, int, int, int) or KillTile(int, int, ref bool, ref bool, ref bool) for other logic such as cleaning up TileEntities or killing chests or signs.
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 (int i, int j, SmartInteractScanSettings settings)
 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. Customize the dust spawned using WalkDust(ref int, ref bool, ref Color). The default dust is DustID.Snow otherwise.
 
virtual void HitWire (int i, int j)
 Allows you to make something happen when a wire current passes through this tile. Both Wiring.SkipWire(int, int) and NetMessage.SendTileSquare(int, int, int, int, TileChangeType) are usually required in the logic used in this method to correctly work.
Only called on the server and single player. All wiring happens on the world, not multiplayer clients. 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 bool IsTileBiomeSightable (int i, int j, ref Color sightColor)
 Allows you to determine whether this tile glows sightColor while the local player has the Biome Sight buff.
Return true and assign to sightColor to allow this tile to glow.
This is only called on the local client. More...
 
virtual bool IsTileDangerous (int i, int j, Player player)
 Allows you to determine whether this tile glows red when the given player has the Dangersense buff.
This is only called on the local client. More...
 
virtual bool IsTileSpelunkable (int i, int j)
 Allows you to customize whether this tile can glow yellow while having the Spelunker buff, and is also detected by various pets.
This is only called if Main.tileSpelunker[type] is false. 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. Use this to clean up extra data such as Chests, Signs, or TileEntities. For tiles that are 1x1, use KillTile(int, int, ref bool, ref bool, ref bool). The i and j coordinates will be the top left tile of a multi-tile. 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. Use this to clean up extra data such as Chests, Signs, or TileEntities. For tiles larger than 1x1, use KillMultiTile(int, int, int, int). More...
 
virtual bool LockChest (int i, int j, ref short frameXAdjustment, ref bool manual)
 Allows customization of how locking a chest is accomplished. By default, frameXAdjustment will be 36, shifting the frameX over to the right 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 ModifyFrameMerge (int i, int j, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
 Allows you to change the merge type of the adjacent tiles before Tile.TileFrameX and Tile.TileFrameY is picked by vanilla framing code. Useful to make tiles that only selectively connect with others, or for tiles
Tiles can be easily made to use custom merge frames with non-dirt tiles by using TileID.Sets.ChecksForMerge in combination with WorldGen.TileMergeAttempt(int, bool[], ref int, ref int, ref int, ref int, ref int, ref int, ref int, ref int) to set the adjacent tile's merge type to -2
Only called if TileFrame(int, int, ref bool, ref bool) returns true More...
 
virtual void ModifySittingTargetInfo (int i, int j, ref TileRestingInfo info)
 Modify the parameters for the entity sitting on this furniture tile with its type registered to TileID.Sets.CanBeSatOnForPlayers.
This is also called on NPCs sitting on this tile! To access the entity (player or NPC), use info.restingEntity.
This gets called when calling PlayerSittingHelper.SitDown, when the town NPC decides to sit, and each tick while the player is sitting on a suitable furniture. i and j derived from "(entity.Bottom + new Vector2(0f, -2f)).ToTileCoordinates()" or from the tile coordinates the player clicked on.
Formula: anchorTilePosition.ToWorldCoordinates(8f, 16f) + finalOffset + new Vector2(0, targetDirection * directionOffset). More...
 
virtual void ModifySleepingTargetInfo (int i, int j, ref TileRestingInfo info)
 Modify the visual player offset when sleeping on this tile with its type registered to TileID.Sets.CanBeSleptIn.
This gets called when calling PlayerSleepingHelper.SetIsSleepingAndAdjustPlayerRotation, and each tick while the player is resting in the bed, i and j derived from "(player.Bottom + new Vector2(0f, -2f)).ToTileCoordinates()" or from the tile coordinates the player clicked on.
Formula: new Point(anchorTilePosition.X, anchorTilePosition.Y + 1).ToWorldCoordinates(8f, 16f) + finalOffset + new Vector2(0, targetDirection * directionOffset). More...
 
virtual void ModifySmartInteractCoords (ref int width, ref int height, ref int frameWidth, ref int frameHeight, ref int extraY)
 Allows you to modify the smart interact parameters for the tile. Parameters already preset by deriving from TileObjectData defined for the tile.
Example usage: Beds/Dressers which have separate interactions based on where to click. 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.
 
virtual void PostSetupTileMerge ()
 Can be used to adjust tile merge related things that are not possible to do in ModBlockType.SetStaticDefaults due to timing.
 
virtual void PostTileFrame (int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
 Allows you to modify the frame of a tile after the vanilla framing code has set Tile.TileFrameX and Tile.TileFrameY. Useful for offsetting the final frame position without entirely overriding the vanilla framing logic
Only called if TileFrame(int, int, ref bool, ref bool) returns true More...
 
void RegisterItemDrop (int itemType, params int[] tileStyles)
 Manually registers an item to drop for the provided tile styles. Use this for tile styles that don't have an item that places them. For example, open door tiles don't have any item that places them, but they should drop an item when destroyed. A tile style with no registered drop and no fallback drop will not drop anything when destroyed.

This method can also be used to register the fallback item drop. The fallback item will drop for any tile with a style that does not have a manual or automatic item drop.
To register the fallback item, omit the tileStyles parameter.

If a mod removes content, manually specifying a replacement/fallback item allows users to recover something from the tile.
If more control over tile item drops is required, such as conditional drops, custom data on dropped items, or multiple item drops, use GetItemDrops(int, int).
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 targeting from happening. Returns false by default. 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...
 
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. If flipping, consider setting TileObjectData.DrawFlipHorizontal or TileObjectData.DrawFlipVertical as well to ensure that the tile placement preview is also flipped. 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. The default dust (dustType ) is DustID.Snow More...
 
- Public Member Functions inherited from 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. This method is called on the local client. For tiles this is also checked during block replacement, but ModTile.CanReplace(int, int, int) should be used for replace-specific logic. 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. The type parameter defaults to DustType. More...
 
LocalizedText CreateMapEntryName ()
 Legacy helper method for creating a localization sub-key MapEntry 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, bool fail)
 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.
See Terraria.Graphics.Light.TileLightScanner.ApplyTileLight(Tile, int, int, ref Terraria.Utilities.FastRandom, ref Microsoft.Xna.Framework.Vector3) for vanilla tile light values to use as a reference.
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. Use CreateDust(int, int, ref int) to customize the dust spawned. 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. Note that the coordinates in this method account for the placement origin and are not necessarily the coordinates of the top left tile of a multi-tile. 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.Note that this method will be called for tiles even when the tile is Tile.IsTileInvisible due to Echo Coating. Use the GameContent.Drawing.TileDrawing.IsVisible(Tile) method to skip effects that shouldn't show when the tile is invisible. This method won't be called for invisible walls. 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:

More...
 
- Public Member Functions inherited from ModType< TEntity, TModType >
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
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 TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
string PrettyPrintName ()
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More...
 
abstract void Load (Mod mod)
 Called when loading the type. More...
 
abstract void Unload ()
 Called during unloading when needed. More...
 
- Public Member Functions inherited from ModType< TEntity >
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
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 TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
string PrettyPrintName ()
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. 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...
 
- Protected Member Functions inherited from ModType< TEntity, TModType >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 
- Protected Member Functions inherited from ModType< TEntity >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties 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.
 
int AnimationFrameHeight [get, set]
 The height of a group of animation frames for this tile. Defaults to 0, which disables animations. Used in conjunction with AnimateTile(ref int, ref int) to automatically animate tiles. Use AnimateIndividualTile(int, int, int, ref int, ref int) as well if needed. An easy way to set this correctly without doing any math is to set this to the value of TileObjectData.CoordinateFullHeight. Note that this assumes animation frames are laid out vertically in the tile spritesheet, if that is not the case then AnimateIndividualTile will need to be used to apply AnimationFrameHeight to X coordinates instead.
 
virtual string HighlightTexture [get]
 The highlight texture used when this tile is selected by smart interact. Defaults to adding "_Highlight" onto the main texture.
 
bool IsDoor [get]
 
override string LocalizationCategory [get]
 The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this. More...
 
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. For example a MineResist value of 2f, such as used by TileID.Pearlstone, would require roughly twice as many hits to mine. Conversely, a MineResist value of 0.5f, such as used by TileID.Sand, would require roughtly half as many hits to mine To find an appropriate value, see the wiki. Use MinPick to adjust the minimum pickaxe power required to mine this tile.
 
int MinPick [get, set]
 The minimum pickaxe power required for pickaxes to mine this block.
Defaults to 0. For example a MinPick value of 50, such as what TileID.Meteorite uses, would require a pickaxe with at least 50% pickaxe power (Item.pick) to break. To find an appropriate value, see the wiki. Use MineResist to adjust how long a tile takes to be mined.
 
- Properties inherited from ModBlockType
int DustType [get, set]
 The default type of dust made when this tile/wall is hit. Defaults to 0.
 
SoundStyleHitSound = SoundID.Dig [get, set]
 The default style of sound made when this tile/wall is hit.
Defaults to SoundID.Dig, which is the sound used for tiles such as dirt and sand.
 
abstract string LocalizationCategory [get]
 The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this. More...
 
ushort Type [get, set]
 The internal ID of this type of tile/wall.
 
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.
 
- Properties inherited from ModTexturedType
virtual string Texture [get]
 The file name of this type's texture file in the mod loader's file space.
 
- Properties inherited from ModType< TEntity, TModType >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from 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...
 
- Properties inherited from ModType< TEntity >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from ILocalizedModType
abstract string LocalizationCategory [get]
 The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this. 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.
The Basic Tile Guide

teaches the basics of making a modded tile.

Member Function Documentation

◆ AnimateIndividualTile()

virtual void 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 Tile.TileFrameX and Tile.TileFrameY. 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(ref int, ref int). Use this hook for off-sync animations (lightning bug in a bottle), state specific animations (campfires), temporary animations (trap chests), or TileEntities to achieve unique animation behaviors without having to manually draw the tile via ModBlockType.PreDraw(int, int, SpriteBatch).

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 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. AnimationFrameHeight must be set for the animation timing set in this method to actually apply to the tile drawing. Use AnimateIndividualTile(int, int, int, ref int, ref int) to animate specific tile instances directly.

// Cycle 5 frames of animation spending 8 ticks on each if (++frameCounter >= 8) { frameCounter = 0; if (++frame >= 5) { frame = 0; } } or, more compactly: if (++frameCounter >= 8) { frameCounter = 0; frame = ++frame % 5; } or, to mimic another tile, simply: frame = Main.tileFrame[TileID.FireflyinaBottle];

◆ AutoSelect()

virtual bool 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.
itemThe inventory item

◆ CanDrop()

virtual bool ModTile.CanDrop ( int  i,
int  j 
)
virtual

Allows prevention of item drops from the tile dropping at the given coordinates. Return false to stop the game from dropping the tile's item(s). Returns true by default. See GetItemDrops to customize the item drop.

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

◆ CanKillTile()

virtual bool 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.
blockDamaged

◆ CanReplace()

virtual bool ModTile.CanReplace ( int  i,
int  j,
int  tileTypeBeingPlaced 
)
virtual

Allows you to stop this tile at the given coordinates from being replaced via the block swap feature. The tileTypeBeingPlaced parameter is the tile type that will replace the current tile.
This method is called on the local client. This method is only called if the local player has sufficient pickaxe power to mine the existing tile.
Return false to block the tile from being replaced. Returns true by default.
Use this for dynamic logic. ID.TileID.Sets.DoesntGetReplacedWithTileReplacement, ID.TileID.Sets.DoesntPlaceWithTileReplacement, and ID.TileID.Sets.PreventsTileReplaceIfOnTopOfIt cover the most common use cases and should be used instead if possible.

Parameters
i
j
tileTypeBeingPlaced
Returns

◆ ChangeWaterfallStyle()

virtual void 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

◆ DefaultContainerName()

virtual LocalizedText ModTile.DefaultContainerName ( int  frameX,
int  frameY 
)
virtual

Returns the default name for a chest or dresser with the provided FrameX and FrameY values.
A typical implementation of a tile with only a single name might return CreateMapEntryName()
A container with multiple styles might return this.GetLocalization("MapEntry" + option) where option is determined using similar logic to ModBlockType.GetMapOption to match the AddMapEntry(Color, LocalizedText) entries. Another option is using return Lang._mapLegendCache[MapHelper.TileToLookup(Type, option)];, this will reuse the localizations used for the map entries.

Reimplemented in UnloadedChest.

◆ DrawEffects()

virtual void 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.
spriteBatch
drawDataVarious information about the tile that is being drawn, such as color, framing, glow textures, etc.

Reimplemented in ModPylon.

◆ DropCritterChance()

virtual void 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.
wormChanceChance for a worm to spawn. Value corresponds to a chance of 1 in X. Vanilla values include: Grass-400, Plants-200, Various Piles-6
grassHopperChanceChance for a grass hopper to spawn. Value corresponds to a chance of 1 in X. Vanilla values include: Grass-100, Plants-50
jungleGrubChanceChance for a jungle grub to spawn. Value corresponds to a chance of 1 in X. Vanilla values include: JungleVines-250, JunglePlants2-40, PlantDetritus-10

◆ FloorVisuals()

virtual void 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

◆ GetItemDrops()

virtual IEnumerable< Item > ModTile.GetItemDrops ( int  i,
int  j 
)
virtual

Allows customization of the items the tile at the given coordinates drops.

The default item drop is determined by finding an item with Item.createTile and Item.placeStyle matching the type and style of this tile. ModTile.RegisterItemDrop(int, int[]) can be used to manually register item drops for tile styles with no corresponding item. It can also be used to register a fallback item, which will be dropped if no suitable item is found.

The default behavior should cover 99% of use cases, meaning that overriding this method should only be necessary in extremely unique tiles, such as tiles dropping multiple items, tiles dropping items with custom data, or tiles with custom tile style code.

When overriding, use yield return new Item(ItemTypeHere); for each spawned item. Note that a random prefix will be applied to these items, if applicable, so if specific prefixes or no prefix is needed for an item drop, it will have to be spawned in manually using KillMultiTile(int, int, int, int) or KillTile(int, int, ref bool, ref bool, ref bool).

The style based drop logic is based on TileObjectData. If a tile has custom 'styles' but still wants to make use of ModTile.RegisterItemDrop(int, int[]), TileLoader.GetItemDropFromTypeAndStyle(Type, style) can be used to retrieve the associated item drop.

Use CanDrop to conditionally prevent any item drops. Use KillMultiTile(int, int, int, int) or KillTile(int, int, ref bool, ref bool, ref bool) for other logic such as cleaning up TileEntities or killing chests or signs.

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

◆ GetTorchLuck()

virtual float 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 ModTile.HasSmartInteract ( int  i,
int  j,
SmartInteractScanSettings  settings 
)
virtual

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

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
settingsUse if you need special conditions, like settings.player.HasItem(ItemID.LihzahrdPowerCell)
Returns

Reimplemented in ModPylon.

◆ HitWire()

virtual void ModTile.HitWire ( int  i,
int  j 
)
virtual

Allows you to make something happen when a wire current passes through this tile. Both Wiring.SkipWire(int, int) and NetMessage.SendTileSquare(int, int, int, int, TileChangeType) are usually required in the logic used in this method to correctly work.
Only called on the server and single player. All wiring happens on the world, not multiplayer clients.

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

◆ IsLockedChest()

virtual bool 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

◆ IsTileBiomeSightable()

virtual bool ModTile.IsTileBiomeSightable ( int  i,
int  j,
ref Color  sightColor 
)
virtual

Allows you to determine whether this tile glows sightColor while the local player has the Biome Sight buff.
Return true and assign to sightColor to allow this tile to glow.
This is only called on the local client.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
sightColorThe color this tile should glow with, which defaults to Color.White.

◆ IsTileDangerous()

virtual bool ModTile.IsTileDangerous ( int  i,
int  j,
Player  player 
)
virtual

Allows you to determine whether this tile glows red when the given player has the Dangersense buff.
This is only called on the local client.

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

◆ IsTileSpelunkable()

virtual bool ModTile.IsTileSpelunkable ( int  i,
int  j 
)
virtual

Allows you to customize whether this tile can glow yellow while having the Spelunker buff, and is also detected by various pets.
This is only called if Main.tileSpelunker[type] is false.

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

◆ KillMultiTile()

virtual void 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. Use this to clean up extra data such as Chests, Signs, or TileEntities. For tiles that are 1x1, use KillTile(int, int, ref bool, ref bool, ref bool). The i and j coordinates will be the top left tile of a multi-tile.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
frameXThe TileFrameX of the Tile at the coordinates
frameYThe TileFrameY of the Tile at the coordinates

◆ KillTile()

virtual void 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. Use this to clean up extra data such as Chests, Signs, or TileEntities. For tiles larger than 1x1, use KillMultiTile(int, int, int, int).

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
failIf true, the tile won't be mined
effectOnlyIf true, only the dust visuals will happen
noItemIf true, the corresponding item won't drop

◆ LockChest()

virtual bool ModTile.LockChest ( int  i,
int  j,
ref short  frameXAdjustment,
ref bool  manual 
)
virtual

Allows customization of how locking a chest is accomplished. By default, frameXAdjustment will be 36, shifting the frameX over to the right 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
manualSet this to true to bypass the code playing the lock sound and adjusting the tile frame. Network syncing will still happen.
Returns
Return true if this tile truly is an unlocked chest and the chest can be locked

◆ ModifyFrameMerge()

virtual void ModTile.ModifyFrameMerge ( int  i,
int  j,
ref int  up,
ref int  down,
ref int  left,
ref int  right,
ref int  upLeft,
ref int  upRight,
ref int  downLeft,
ref int  downRight 
)
virtual

Allows you to change the merge type of the adjacent tiles before Tile.TileFrameX and Tile.TileFrameY is picked by vanilla framing code. Useful to make tiles that only selectively connect with others, or for tiles
Tiles can be easily made to use custom merge frames with non-dirt tiles by using TileID.Sets.ChecksForMerge in combination with WorldGen.TileMergeAttempt(int, bool[], ref int, ref int, ref int, ref int, ref int, ref int, ref int, ref int) to set the adjacent tile's merge type to -2
Only called if TileFrame(int, int, ref bool, ref bool) returns true

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
upThe merge type of the tile above. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile
downThe merge type of the tile below. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile
leftThe merge type of the tile to the keft. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile
rightThe merge type of the tile to the right. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile
upLeftThe merge type of the tile on the top left. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile
upRightThe merge type of the tile on the top right. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile
downLeftThe merge type of the tile on the bottom left. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile
downRightThe merge type of the tile on the bottom right. The tile will merge with it if the value is the same as its tile type
-1 Means it'll consider the tile empty, and -2 means tiles that use Main.tileMergeDirt or TileID.Sets.ChecksForMerge will attempt to use their custom merge frames with that tile

◆ ModifySittingTargetInfo()

virtual void ModTile.ModifySittingTargetInfo ( int  i,
int  j,
ref TileRestingInfo  info 
)
virtual

Modify the parameters for the entity sitting on this furniture tile with its type registered to TileID.Sets.CanBeSatOnForPlayers.
This is also called on NPCs sitting on this tile! To access the entity (player or NPC), use info.restingEntity.
This gets called when calling PlayerSittingHelper.SitDown, when the town NPC decides to sit, and each tick while the player is sitting on a suitable furniture. i and j derived from "(entity.Bottom + new Vector2(0f, -2f)).ToTileCoordinates()" or from the tile coordinates the player clicked on.
Formula: anchorTilePosition.ToWorldCoordinates(8f, 16f) + finalOffset + new Vector2(0, targetDirection * directionOffset).

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
infoThe parameters for setting the anchor and offsets. You need to edit this

◆ ModifySleepingTargetInfo()

virtual void ModTile.ModifySleepingTargetInfo ( int  i,
int  j,
ref TileRestingInfo  info 
)
virtual

Modify the visual player offset when sleeping on this tile with its type registered to TileID.Sets.CanBeSleptIn.
This gets called when calling PlayerSleepingHelper.SetIsSleepingAndAdjustPlayerRotation, and each tick while the player is resting in the bed, i and j derived from "(player.Bottom + new Vector2(0f, -2f)).ToTileCoordinates()" or from the tile coordinates the player clicked on.
Formula: new Point(anchorTilePosition.X, anchorTilePosition.Y + 1).ToWorldCoordinates(8f, 16f) + finalOffset + new Vector2(0, targetDirection * directionOffset).

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
infoThe parameters for setting the anchor and offsets. Default values match the regular vanilla bed.

◆ ModifySmartInteractCoords()

virtual void ModTile.ModifySmartInteractCoords ( ref int  width,
ref int  height,
ref int  frameWidth,
ref int  frameHeight,
ref int  extraY 
)
virtual

Allows you to modify the smart interact parameters for the tile. Parameters already preset by deriving from TileObjectData defined for the tile.
Example usage: Beds/Dressers which have separate interactions based on where to click.

Parameters
widthAmount of tiles in x direction for which the smart interact should select for
heightAmount of tiles in y direction for which the smart interact should select for
frameWidthWidth of each tile, in pixels
frameHeightHeight of each tile, in pixels
extraYAdditional offset applied after calculations with frameHeight, in pixels

◆ MouseOver()

virtual void 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 UnloadedTile.

◆ MouseOverFar()

virtual void 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 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.
closer

◆ PostTileFrame()

virtual void ModTile.PostTileFrame ( int  i,
int  j,
int  up,
int  down,
int  left,
int  right,
int  upLeft,
int  upRight,
int  downLeft,
int  downRight 
)
virtual

Allows you to modify the frame of a tile after the vanilla framing code has set Tile.TileFrameX and Tile.TileFrameY. Useful for offsetting the final frame position without entirely overriding the vanilla framing logic
Only called if TileFrame(int, int, ref bool, ref bool) returns true

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
upThe merge type of the tile above. Unitializaed if the tile is Main.tileFrameImportant.
downThe merge type of the tile below. Unitializaed if the tile is Main.tileFrameImportant.
leftThe merge type of the tile to the left. Unitializaed if the tile is Main.tileFrameImportant.
rightThe merge type of the tile to the right. Unitializaed if the tile is Main.tileFrameImportant.
upLeftThe merge type of the tile on the top left. Unitializaed if the tile is Main.tileFrameImportant.
upRightThe merge type of the tile on the top right. Unitializaed if the tile is Main.tileFrameImportant.
downLeftThe merge type of the tile on the bottom left. Unitializaed if the tile is Main.tileFrameImportant.
downRightThe merge type of the tile on the bottom right. Unitializaed if the tile is Main.tileFrameImportant.

◆ Register()

sealed override void ModTile.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements ModType< TEntity >.

◆ RegisterItemDrop()

void ModTile.RegisterItemDrop ( int  itemType,
params int[]  tileStyles 
)

Manually registers an item to drop for the provided tile styles. Use this for tile styles that don't have an item that places them. For example, open door tiles don't have any item that places them, but they should drop an item when destroyed. A tile style with no registered drop and no fallback drop will not drop anything when destroyed.

This method can also be used to register the fallback item drop. The fallback item will drop for any tile with a style that does not have a manual or automatic item drop.
To register the fallback item, omit the tileStyles parameter.

If a mod removes content, manually specifying a replacement/fallback item allows users to recover something from the tile.
If more control over tile item drops is required, such as conditional drops, custom data on dropped items, or multiple item drops, use GetItemDrops(int, int).

Parameters
itemType
tileStyles

◆ RightClick()

virtual bool 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 targeting 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 targeting from happening. Returns false by default.

Reimplemented in ModPylon.

◆ SetDrawPositions()

virtual void 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.TileFrameX/Y intact for other purposes.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
width
offsetY
height
tileFrameX
tileFrameY

◆ SetSpriteEffects()

virtual void 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. If flipping, consider setting TileObjectData.DrawFlipHorizontal or TileObjectData.DrawFlipVertical as well to ensure that the tile placement preview is also flipped.

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

◆ SetupContent()

sealed override void ModTile.SetupContent ( )
virtual

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

Reimplemented from ModType< TEntity >.

◆ Slope()

virtual bool 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 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.
spriteBatch

◆ TileFrame()

virtual bool 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.
resetFrame
noBreak

Reimplemented in ModPylon.

◆ UnlockChest()

virtual bool 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 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. The default dust (dustType ) is DustID.Snow

Parameters
dustType
makeDust
color

Property Documentation

◆ LocalizationCategory

override string ModTile.LocalizationCategory
get

The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this.

Implements ILocalizedModType.