ModTile
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.
Methods
- AddToArray(System.Int32[]@)()
- A convenient method for adding this tile's Type to the given array. This can be used with the arrays in TileID.Sets.RoomNeeds.
- AddMapEntry(Microsoft.Xna.Framework.Color,Terraria.Localization.LocalizedText)()
- Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults.
- CreateMapEntryName(System.String)()
- Creates a ModTranslation object that you can use in AddMapEntry.
- AddMapEntry(Microsoft.Xna.Framework.Color,Terraria.ModLoader.ModTranslation)()
- Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults.
- AddMapEntry(Microsoft.Xna.Framework.Color,Terraria.Localization.LocalizedText,System.Func{System.String,System.Int32,System.Int32,System.String})()
- Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.
- AddMapEntry(Microsoft.Xna.Framework.Color,Terraria.ModLoader.ModTranslation,System.Func{System.String,System.Int32,System.Int32,System.String})()
- Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.
- SetModTree(Terraria.ModLoader.ModTree)()
- Allows this tile to grow the given modded tree.
- SetModPalmTree(Terraria.ModLoader.ModPalmTree)()
- Allows this tile to grow the given modded palm tree.
- SetModCactus(Terraria.ModLoader.ModCactus)()
- Allows this tile to grow the given modded cactus.
- Autoload(System.String@,System.String@)()
- Allows you to modify the name and texture path of this tile when it is autoloaded. Return true to autoload this tile. When a tile is autoloaded, that means you do not need to manually call Mod.AddTile. By default returns the mod's autoload property.
- SetDefaults()
- Allows you to set the properties of this tile. Many properties are stored as arrays throughout Terraria's code.
- PostSetDefaults()
- Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main.tileObsidianKill.
- HasSmartInteract()
- Whether or not the smart interact function can select this tile. Useful for things like chests. Defaults to false.
- KillSound(System.Int32,System.Int32)()
- 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.
- NumDust(System.Int32,System.Int32,System.Boolean,System.Int32@)()
- Allows you to change how many dust particles are created when the tile at the given coordinates is hit.
- CreateDust(System.Int32,System.Int32,System.Int32@)()
- 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 type parameter) from being created. Returns true by default.
- DropCritterChance(System.Int32,System.Int32,System.Int32@,System.Int32@,System.Int32@)()
- Allows you to modify the chance the tile at the given coordinates has of spawning a certain critter when the tile is killed.
- Drop(System.Int32,System.Int32)()
- Allows you to customize which items the tile at the given coordinates drops. Remember that the x, y (i, j) coordinates are in tile coordinates, you will need to multiply them by 16 if you want to drop an item using them. Return false to stop the game from dropping the tile's default item. Returns true by default. Please note that this hook currently only works for 1x1 tiles.
- CanKillTile(System.Int32,System.Int32,System.Boolean@)()
- 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.
- KillTile(System.Int32,System.Int32,System.Boolean@,System.Boolean@,System.Boolean@)()
- 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.
- KillMultiTile(System.Int32,System.Int32,System.Int32,System.Int32)()
- This hook is called exactly once whenever a block encompassing multiple tiles is destroyed. You can use it to make your multi-tile block drop a single item, for example.
- CanExplode(System.Int32,System.Int32)()
- 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.
- NearbyEffects(System.Int32,System.Int32,System.Boolean)()
- 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 things like campfires and banners work.
- ModifyLight(System.Int32,System.Int32,System.Single@,System.Single@,System.Single@)()
- Allows you to determine how much light this block emits. Make sure you set Main.tileLighted[Type] to true in SetDefaults for this to work.
- Dangersense(System.Int32,System.Int32,Terraria.Player)()
- Allows you to determine whether this block glows red when the given player has the Dangersense buff.
- SetSpriteEffects(System.Int32,System.Int32,Microsoft.Xna.Framework.Graphics.SpriteEffects@)()
- Allows you to determine whether or not the tile will draw itself flipped in the world.
- SetDrawPositions(System.Int32,System.Int32,System.Int32@,System.Int32@,System.Int32@)()
- 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, and 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.
- AnimateTile(System.Int32@,System.Int32@)()
- Allows you to animate your tile. Use frameCounter to keep track of how long the current frame has been active, and use frame to change the current frame. This is called once an update. Use AnimateIndividualTile to animate specific tile instances directly.
- AnimateIndividualTile(System.Int32,System.Int32,System.Int32,System.Int32@,System.Int32@)()
- Animates an individual tile. i and j are the coordinates of the Tile in question. frameXOffset and frameYOffset should be used to specify an offset from the tiles frameX and frameY. "frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type];" will already be set before this hook is called, taking into account the TileID-wide animation set via AnimateTile. Use this hook for off-sync animations (lightning bug in a bottle), temporary animations (trap chests), or TileEntities to achieve unique animation behaviors without having to manually draw the tile via PreDraw.
- PreDraw(System.Int32,System.Int32,Microsoft.Xna.Framework.Graphics.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.
- DrawEffects(System.Int32,System.Int32,Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Color@,System.Int32@)()
- 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.
- PostDraw(System.Int32,System.Int32,Microsoft.Xna.Framework.Graphics.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.
- SpecialDraw(System.Int32,System.Int32,Microsoft.Xna.Framework.Graphics.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.
- GetMapOption(System.Int32,System.Int32)()
- Allows you to choose which minimap entry the tile at the given coordinates will use. 0 is the first entry added by AddMapEntry, 1 is the second entry, etc. Returns 0 by default.
- RandomUpdate(System.Int32,System.Int32)()
- Called whenever the world randomly decides to update this tile in a given tick. Useful for things such as growing or spreading.
- TileFrame(System.Int32,System.Int32,System.Boolean@,System.Boolean@)()
- 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.
- CanPlace(System.Int32,System.Int32)()
- Allows you to stop this tile from being placed at the given coordinates. Return false to block the tile from being placed. Returns true by default.
- RightClick(System.Int32,System.Int32)()
- Allows you to make something happen when this tile is right-clicked by the player.
- MouseOver(System.Int32,System.Int32)()
- Allows you to make something happen when the mouse hovers over this tile. Useful for showing item icons or text on the mouse.
- MouseOverFar(System.Int32,System.Int32)()
- 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.
- AutoSelect(System.Int32,System.Int32,Terraria.Item)()
- Allows you to determine whether the given item can become selected when the cursor is hovering over this tile and the auto selection hotkey is pressed.
- HitWire(System.Int32,System.Int32)()
- Allows you to make something happen when a wire current passes through this tile.
- Slope(System.Int32,System.Int32)()
- Allows you to control how hammers slope this tile. Return true to allow it to slope normally. Returns true by default.
- FloorVisuals(Terraria.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.
- HasWalkDust()
- Whether or not this tile creates dust when the player walks on it. Returns false by default.
- WalkDust(System.Int32@,System.Boolean@,Microsoft.Xna.Framework.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.
- ChangeWaterfallStyle(System.Int32@)()
- Allows you to change the style of waterfall that passes through or over this type of tile.
- SaplingGrowthType(System.Int32@)()
- Allows this tile to support a sapling that can eventually grow into a tree. The type of the sapling should be returned here. Returns -1 by default. The style parameter will determine which sapling is chosen if multiple sapling types share the same ID; even if you only have a single sapling in an ID, you must still set this to 0.
- PlaceInWorld(System.Int32,System.Int32,Terraria.Item)()
- Allows you to do something when this tile is placed.