Repository navigation
API Tiles
API reference · generated by
tools/docs/ApiReference, do not edit by hand
Tiles, tile entities, walls, trees, cactus, pylons, waterfalls, biomes, world generation and dimensions.
class Terraria.ModLoader.Config.BackgroundColorAttribute : Attribute
Specifies a background color to be used for the property, field, or class in the ModConfig UI.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Color Color |
property | same | The color. |
new BackgroundColorAttribute(int r, int g, int b, int a) |
constructor | same | Creates an instance. |
static class Terraria.ModLoader.BackgroundTextureLoader
This is the class that keeps track of all modded background textures and their slots/IDs. Remember that unless you manually register backgrounds via AddBackgroundTexture, only files found in a folder or subfolder of a folder named "Backgrounds" will be autoloaded as background textures.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int VanillaCount |
static property | only here | How many exist, with the game's and every mod's. |
int TotalCount |
static property | only here | How many exist, with the game's and every mod's. |
int GetBackgroundSlot(string texture) |
static method | same | Returns the slot/ID of the background texture with the given full path. The path must be prefixed with a mod name. Throws exceptions on failure. |
int GetBackgroundSlot(Mod mod, string texture) |
static method | same | Returns the slot/ID of the background texture with the given mod and path. Throws exceptions on failure. |
bool TryGetBackgroundSlot(string texture, out int slot) |
static method | same | Safely attempts to output the slot/ID of the background texture with the given full path. The path must be prefixed with a mod name. |
bool TryGetBackgroundSlot(Mod mod, string texture, out int slot) |
static method | same | Safely attempts to output the slot/ID of the background texture with the given mod and path. |
void AddBackgroundTexture(Mod mod, string texture) |
static method | same | Adds a texture to the list of background textures and assigns it a background texture slot. Use this for any background textures not autoloaded by the BackgroundAutoloadingEnabled logic. |
static class Terraria.ModLoader.BiomeConversionLoader
Registers conversion types and runs the conversions of tiles and walls.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ModBiomeConversion GetBiomeConversion(int type) |
static method | same | Gets the ModBiomeConversion instance with the given type. Returns null if no ModBiomeConversion with the given type exists. |
int Register(ModBiomeConversion conversion) |
static method | same | If you make a new ModType, seal this override. |
static class Terraria.ModLoader.BiomeLoader
Runs the hooks of mod biomes.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Count |
static property | only here | How many exist, with the game's and every mod's. |
ModBiome Get(int type) |
static method | only here | The ModBiome of a number, or null. |
void UpdateBiomes(Player player) |
static method | same | Works out the player's mod biomes. |
bool CustomBiomesMatch(Player player, Player other) |
static method | not here | Internal here. |
void CopyCustomBiomesTo(Player player, Player other) |
static method | not here | Internal here. |
void SendCustomBiomes(Player player, BinaryWriter writer) |
static method | not here | Internal here. |
void ReceiveCustomBiomes(Player player, BinaryReader reader) |
static method | not here | Internal here. |
struct Terraria.Chest
What Bunny Loader adds to the game's chest.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Item GetItem(int slot) |
method | only here | The item in a slot. |
void SetItem(int slot, Item value) |
method | only here | Puts an item in a slot. |
class Terraria.ModLoader.CloudInABottleJump : VanillaExtraJump
One of the game's extra jumps, as an ExtraJump you can position against or read from Player.GetJumpState.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
float GetDurationMultiplier(Player player) |
override | same | Vanilla's jumps use the following values: Basilisk mount: 0.75 Blizzard in a Bottle: 1.5 Cloud in a Bottle: 0.75 Fart in a Jar: 2 Goat mount: 2 Sandstorm in a Bottle: 3 Santank mount: 2 Tsunami in a Bottle: 1.25 Unicorn mount: 2 |
static class Terraria.ModLoader.CloudLoader
Registers mod clouds.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int CloudCount |
static property | same | How many exist, with the game's and every mod's. |
bool cloudLoaded |
static field | same | Whether mod clouds are in. |
bool AddCloudFromTexture<TCloud>(Mod mod, string texture, float spawnChance, bool rareCloud) |
static method | same | Registers a new cloud with the provided texture, spawn chance, and indication if the cloud belongs to the "rare cloud" category. Typically used with SimpleModCloud as TCloud for cloud with no additional logic. Use this to manually load a modded cloud rather than making a ModCloud class or autoloading the cloud through CloudAutoloadingEnabled logic. |
int ChooseCloud(float vanillaPool, bool rare) |
static method | same | Picks a cloud. |
class Terraria.ID.ContentBoolTable : IEnumerable<int> · only in Bunny Loader
A yes-or-no table by content type. Works for any type, without resizing, and starts false.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool this[int type] |
indexer | only here | Reads or writes one entry. |
void Add(int type) |
method | only here | Sets this ID to true. |
IEnumerator<int> GetEnumerator() |
method | only here | Walks the items in foreach. |
class Terraria.ID.ContentIntTable · only in Bunny Loader
A number table by content type.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int this[int type] |
indexer | only here | Reads or writes one entry. |
class Terraria.ID.ContentTable · only in Bunny Loader
A table by content type that holds objects.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
T this[int type] |
indexer | only here | Reads or writes one entry. |
static class Terraria.ID.DustID
The game's dust types.
Members: WoodFurniture, HeartCrystal, Demonite, MagicMirror, Sunflower, PurificationPowder, VilePowder, Pot, PiggyBank, Meteorite, CorruptionThorns, MeteorHead, GoblinSorcerer, Clay, Water, BreatheBubble, Obsidian, Mud, JungleGrass, GlowingMushroom, Harpy, JungleSpore, ManaRegeneration, Poisoned, Cobalt, Mythril, Adamantite, SnowBlock, Pearlsand, UnholyWater, Silt, Wraith, Pixie, BlueFairy, Enchanted_Gold, HallowedWeapons, Enchanted_Pink, RainbowRod, IceRod, UndergroundHallowedEnemies, Gastropod, PinkFairy, GreenFairy, Snow, Ebonwood, RichMahogany, Pearlwood, UnusedBrown, Frost, FrostStaff, Water_Corruption, Water_Jungle, Water_Hallowed, Water_Snow, Water_Desert, Water_Space, Water_GlowingMushroom, Water_Cavern, Water_BloodMoon, RuneWizard, TerraBlade, RainCloud, Asphalt, Clentaminator_Green, Clentaminator_Cyan, Clentaminator_Purple, Clentaminator_Blue, Clentaminator_Red, CrimtaneWeapons, Skyware, Crimstone, Ice_Purple, Ice_Pink, Ice_Red, Shadewood_Tree, BorealWood, Water_Crimson, SandstormInABottle, Shadewood, Rope, Firework_Red, Firework_Green, Firework_Blue, Firework_Yellow, Firework_Pink, Crimslime, IcyMerman, Confetti_Blue, Confetti_Green, Confetti_Pink, Confetti_Yellow, Paint, Palladium, Orichalcum, Titanium, Hive, Lihzahrd, Slush, Bee, SeaSnail, Squid, Honey2, Rain, Ambient_DarkBrown, ChlorophyteWeapon, Teleporter, MagnetSphere, IceGolem, PoisonStaff, DryadsWard, TeleportationPotion, FungiHit, Plantera_Pink, Plantera_Green, Ichor, Venom, DungeonWater, ShadowbeamStaff, InfernoFork, SpectreStaff, BubbleBurst_Blue, BubbleBurst_Pink, BubbleBurst_Green, BubbleBurst_Purple, DungeonSpirit, GiantCursedSkullBolt, TheDestroyer, VampireHeal, ScourgeOfTheCorruptor, RedsWingsRun, Flare_Blue, FartInAJar, Pumpkin, Hay, SpookyWood, Ghost, BunnySlime, SlimeBunny, Scarecrow, BatScepter, Everscream, NorthPole, FireflyHit, Butterfly, Worm, Snail, GlowingSnail, Scorpion, TreasureSparkle, SpelunkerGlowstickSparkle, VenomStaff, UnusedWhiteBluePurple, DynastyWood, DynastyShingle_Red, DynastyShingle_Blue, DynastyWall, Wet, BubbleBurst_White, MinecartSpark, BorealWood_Small, PalmWood, PirateStaff, FishronWings, RazorbladeTyphoon, Rain_BloodMoon, FireworkFountain_Red, FireworkFountain_Green, FireworkFountain_Blue, FireworkFountain_Yellow, FireworkFountain_Pink, Shiverthorn, Coralstone, MartianHit, MartianSaucerSpark, InfluxWaver, Phantasmal, DrillContainmentUnit, CosmicCarKeys, ViciousPowder, GoldCritter, GoldCritter_LessOutline, LifeDrain, FrostDaggerfish, TsunamiInABottle, SailfishBoots, CrystalSerpent, CrystalSerpent_Pink, Toxikarp, MechanicalCart, BloodWater, LastPrism
static class Terraria.ModLoader.DustLoader
Registers mod dusts.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int DustCount |
static property | only here | How many exist, with the game's and every mod's. |
ModDust GetDust(int type) |
static method | same | Gets the ModDust instance with the given type. Returns null if no ModDust with the given type exists. |
struct Terraria.GameContent.FlexibleTileWand
Lets an item place several tile styles, as the Rubble Maker does.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
FlexibleTileWand AddVariations(int itemType, int tileIdToPlace, params int[] stylesToPlace) |
method | same | Adds an item the wand can place, with its styles. |
abstract class Terraria.ModLoader.GlobalPylon : ModType
Global Type that exists for pylons that allows for modification of teleportation steps, map drawing, and other functionality for any pylon that exists, whether it be vanilla or modded.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool PreDrawMapIcon(ref MapOverlayDrawContext context, ref string mouseOverText, ref TeleportPylonInfo pylonInfo, ref bool isNearPylon, ref Color drawColor, ref float deselectedScale, ref float selectedScale) |
hook | same | Called right before both modded and vanilla pylons draw their icons on the map. Returning false will prevent the passed in icon from being drawn on the map. Returns true by default. |
bool PreCanPlacePylon(int x, int y, int tileType, TeleportPylonType pylonType) |
hook | same | Called right before both modded and vanilla pylons determine whether or not they can be placed. Returning false will prevent vanilla checks from taking place, forcefully preventing the pylon from being placed. Returning null will enact vanilla behavior, and returning true will make the check forcefully succeed, regardless of vanilla behavior. Returns null by default. |
bool ValidTeleportCheck_PreNPCCount(TeleportPylonInfo pylonInfo, ref int defaultNecessaryNPCCount) |
hook | same | Called before Step 1 of the ValidTeleportCheck process. This is the first vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their NPC requirements, and returning false will prevent those checks from taking place, forcefully failing the NPCCount step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default. |
bool ValidTeleportCheck_PreBiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) |
hook | same | Called before Step 2 of the ValidTeleportCheck process. This is the third vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their Biome requirements, and returning false will prevent those checks from taking place, forcefully failing the BiomeRequirements step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default. |
void PostValidTeleportCheck(TeleportPylonInfo destinationPylonInfo, TeleportPylonInfo nearbyPylonInfo, ref bool destinationPylonValid, ref bool validNearbyPylonFound, ref string errorKey) |
hook | same | Called after all checks have taken place for all vanilla and modded pylons when a teleportation request is sent (AKA when the player clicks on a pylon on the map). You can (for example) use this to allow teleportation to go through even if one the normal requirements haven't been met, or vice versa; to do this, change destinationPylonValid to true or false respectively (for the given example). |
abstract class Terraria.ModLoader.GlobalTile : ModType
This class allows you to modify the behavior of any tile in the game, both vanilla and modded. To use it, simply create a new class deriving from this one. Implementations will be registered automatically.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool KillSound(int i, int j, int type, bool fail) |
hook | only here | 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. |
void NumDust(int i, int j, int type, bool fail, ref int num) |
hook | only here | Allows you to change how many dust particles are created when the tile/wall at the given coordinates is hit. Use CreateDust to customize the dust spawned. |
bool CreateDust(int i, int j, int type, ref int dustType) |
hook | only here | 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. |
bool CanPlace(int i, int j, int type) |
hook | only here | 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 CanReplace should be used for replace-specific logic. Return false to stop the tile/wall from being placed. Returns true by default. |
bool CanExplode(int i, int j, int type) |
hook | only here | 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. |
bool CanDrop(int i, int j, int type) |
hook | same | 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. Use Drop to spawn additional items. |
void Drop(int i, int j, int type) |
hook | same | Allows you to spawn additional items when the tile at the given coordinates drops. This hook is called once for multi-tiles. Trees or Cactus call this method for every individual tile. For multi-tiles, the coordinates correspond to the tile that triggered this multi-tile to drop, so if checking TileFrameX and TileFrameY, be aware that the coordinates won't necessarily be the top left corner or origin of the multi-tile. Also be aware that some parts of the multi-tile might already be mined out when this method is called, so any math to determine tile style should be done on the tile at the coordinates passed in. |
bool CanKillTile(int i, int j, int type, ref bool blockDamaged) |
hook | same | 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. |
void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem) |
hook | same | Allows you to determine what happens when the tile at the given coordinates is killed or hit with a pickaxe. If fail is true, the tile will not be mined; effectOnly makes it so that only dust is created; noItem stops items from dropping. |
void PlaceInWorld(int i, int j, int type, Item item) |
hook | only here | 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. |
void NearbyEffects(int i, int j, int type, bool closer) |
hook | same | Allows you to make things happen when this tile is within a certain range of the player, such as how banners, campfire, and monoliths work. This method will be called on tiles within 2 specific ranges, once for calculating visual effects and another time for calculating gameplay effects: When calculating visual effects, the closer parameter will be true. The visual effect range depend on the game window resolution, zoom level, and lighting mode, so it will not be reliable for gameplay effects but rather it adjusts to the players view of the game world. This is suitable for monoliths, water fountains, and music boxes. When calculating gameplay effects, the closer parameter will be false. The gameplay effect range will always be a 169x124 tile rectangle centered on the player. This is suitable for tiles that give buffs like the sunflower, banners, heart lantern, and campfire. Make sure to check closer when using this method to ensure the effects of this tile are applying to the intended range. |
void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) |
hook | only here | 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 ApplyTileLight for vanilla tile light values to use as a reference. |
void RandomUpdate(int i, int j, int type, bool underground) |
hook | only here | Called whenever the world randomly decides to update this tile/wall in a given tick. Useful for things such as growing or spreading. |
void AnimateTile() |
hook | same | 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. |
void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects) |
hook | same | Allows you to determine whether or not a tile will draw itself flipped in the world. |
bool IsTileDangerous(int i, int j, int type, Player player) |
hook | same | Allows you to determine whether this tile glows red when the given player has the Dangersense buff. Return true to force this behavior, or false to prevent it, overriding vanilla conditions. Returns null by default. This is only called on the local client. |
bool IsTileSpelunkable(int i, int j, int type) |
hook | same | Allows you to customize whether this tile can glow yellow while the player has the Spelunker buff, and is also detected by various pets. The player isn't necessarily the local player, but the player being used to view the area (such as when spectating), Main.SceneMetrics.PerspectivePlayer. Return true to force this behavior, or false to prevent it, overriding vanilla conditions. Returns null by default. |
bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) |
hook | only here | 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. Note that tiles are drawn one at a time in sequence (top to bottom, left to right), so this runs immediately before a single tile's sprite is drawn, not before all tiles on screen are rendered. |
void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) |
hook | only here | 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 IsTileInvisible due to Echo Coating. Use the IsVisible method to skip effects that shouldn't show when the tile is invisible. This method won't be called for invisible walls. Note that tiles are drawn one at a time in sequence (top to bottom, left to right), so this runs immediately after a single tile's sprite is drawn. Any effects drawn here will be overdrawn by sprites of tiles drawn after it. Use SpecialDraw via DrawEffects to draw after all tiles on screen have been rendered. |
void PreShakeTree(int x, int y, TreeTypes treeType) |
hook | same | This hook runs before ShakeTree and is intended to be used to spawn bonus tree shaking drops and prevent existing drops using blockLoot. The tile coordinates provided indicates the leafy top of the tree where entities should be spawned. Runs on the server or singleplayer. |
bool ShakeTree(int x, int y, TreeTypes treeType) |
hook | same | This hook runs when any tree is shaken (See the Tree Shaking wiki page). It is intended to be used to drop the primary item (or NPC). Use PreShakeTree to implement bonus drops instead, since this method isn't guaranteed to be called if another mod rolls an item drop. If a drop happens, return true to signify that a primary drop has been spawned and to prevent other mods and vanilla code from also attempting to drop the primary item. When spawning the drop be sure to use EntitySource_ShakeTree as the source. The tile coordinates provided indicates the leafy top of the tree where entities should be spawned. Returns false by default. Runs on the server or singleplayer. |
void OnTileConverted(int i, int j, int fromType, int toType, int conversionType) |
hook | same | Called when this tile has been converted to another tile type via biome conversion. Check fromType and toType to see the tile types the tile changed between. For ModTile, this will be called when converting both to and from the tile. conversionType is a BiomeConversionID (or Type). |
void EmitParticles(int i, int j, Tile tileCache, ushort typeCache, short tileFrameX, short tileFrameY, Color tileLight, bool visible) |
hook | same | Used to spawn Dust or Gore particle effects. Note that this is called even if the tile is invisible due to echo coating, so check visible if dust should only be spawned if the tile is visible. Tiles that still spawn particle effects while invisible can be useful to builders. Some tiles that spawn dust even when invisible include BubbleMachine, FogMachine, BrazierSuspended, Campfire, Chimney, SillyBalloonMachine, LeafBlock, and PoopBlock. The tileFrameX and tileFrameY values differ from the Tile frame values in that they incorporate the changes from SetDrawPositions and should normally be used instead of TileFrameX and Y directly. This method is only called under the conditions where particle effects are intended to spawn, that being the game is active, not paused, and at the intended frequency determined by the lighting mode. There is no need to check for these conditions in this method. |
void DrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref TileDrawInfo drawData) |
hook | same | Allows you to adjust how the tile at the given coordinates is drawn. For example, changing the color the tile is drawn in. Can also be used to register this tile location for additional rendering after all tiles are drawn normally. SpecialDraw will be called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint or Main.instance.TilesRenderer.AddSpecialPoint(i, j, TileCounterType.CustomNonSolid or CustomSolid) here or in PreDraw. Note: Previously ExampleMod examples showed spawning particles (dust or gore) in this method, but they should be spawned in EmitParticles instead now. This is because particles are only spawned under specific conditions and those conditions are baked into the logic calling EmitParticles. |
void SpecialDraw(int i, int j, int type, SpriteBatch spriteBatch) |
hook | same | 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. |
void RightClick(int i, int j, int type) |
hook | same | Allows you to make something happen when any tile is right-clicked by the player. |
void MouseOver(int i, int j, int type) |
hook | same | Allows you to make something happen when the mouse hovers over any tile. Useful for showing item icons or text on the mouse. |
void MouseOverFar(int i, int j, int type) |
hook | same | 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. |
bool PreHitWire(int i, int j, int type) |
hook | same | 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. |
void HitWire(int i, int j, int type) |
hook | same | Allows you to make something happen when a wire current passes through any tile. Both SkipWire and SendTileSquare 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. |
bool Slope(int i, int j, int type) |
hook | same | Allows you to control how hammers slope any tile. Return true to allow the tile to slope normally. Returns true by default. Called on the local Client and Single Player. |
bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) |
hook | same | 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. |
bool CanReplace(int i, int j, int type, int tileTypeBeingPlaced) |
hook | same | Allows you to stop a 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. The type parameter is the tile type currently at the coordinates. 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. DoesntGetReplacedWithTileReplacement, DoesntPlaceWithTileReplacement, and PreventsTileReplaceIfOnTopOfIt cover the most common use cases and should be used instead if possible. |
int[] AdjTiles(int type) |
hook | same | Allows you to determine which tiles the given tile type can be considered as when looking for crafting stations. |
void ReplaceTile(int i, int j, int type, int targetType, int targetStyle) |
hook | same | Called when this tile at the given coordinates is being replaced via the block swap feature. For supported multi-tiles, the coordinates will be the top left corner. targetType and targetStyle are the tile type and style that will replace the current tile. An implementation of this method might end up duplicating some custom KillMultiTile or KillTile code, but not all. For example, for a chest or dresser tile you wouldn't want to call Chest.DestroyChest. Called on local, server, and remote clients. |
void AddToArray(ref int[] array, int type) |
method | not here | A convenient method for adding an integer to the end of an array. This can be used with the arrays in TileID.Sets.RoomNeeds. |
void DropCritterChance(int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance) |
hook | not here | Allows you to modify the chance the tile at the given coordinates has of spawning a certain critter when the tile is killed. |
bool IsTileBiomeSightable(int i, int j, int type, ref Color sightColor) |
hook | not here | Allows you to customize whether this tile glows sightColor while the player has the Biome Sight buff. The player isn't necessarily the local player, but the player being used to view the area (such as when spectating), Main.SceneMetrics.PerspectivePlayer. Return true to force this behavior, or false to prevent it, overriding vanilla conditions and colors. Returns null by default. This is only called on the local client. |
bool PreDrawPlacementPreview(int i, int j, int type, SpriteBatch spriteBatch, ref Rectangle frame, ref Vector2 position, ref Color color, bool validPlacement, ref SpriteEffects spriteEffects) |
hook | not here | Allows you to draw behind this multi-tile's regular placement preview rendering, or change relevant drawing parameters. This is ran for each rendered section of the multi-tile. Make sure to use frame for logic rather than the TileFrameX/Y values of the tile at the provided coordinates, this tile isn't placed yet. Return false to stop this section from drawing normally. Returns true by default. |
void PostDrawPlacementPreview(int i, int j, int type, SpriteBatch spriteBatch, Rectangle frame, Vector2 position, Color color, bool validPlacement, SpriteEffects spriteEffects) |
hook | not here | Allows you to draw in front of this multi-tile's placement preview rendering. This is ran for each rendered section of the multi-tile. Make sure to use frame for logic rather than the TileFrameX/Y values of the tile at the provided coordinates, this tile isn't placed yet. |
bool AutoSelect(int i, int j, int type, Item item) |
hook | not here | Allows you to determine whether the given item can become selected when the cursor is hovering over a tile and the auto selection keybind is pressed. |
bool HitSwitch(int i, int j, int type) |
hook | not here | Called when HitSwitch is called on the tile. Can be used to skip or override the vanilla behavior by returning false. Returns true by default. |
bool SwitchTiles(int i, int j, int type, Entity entity, Vector2 position, int width, int height, Vector2 oldPosition, int objType) |
hook | not here | Called in SwitchTiles. This hook allows acting on entities colliding with tiles. The position, width, and height parameters indicate the hitbox of the entity, while oldPosition is the position of the entity on the previous update. You'll need to use these to determine if a collision is occurring and if the entity is entering or leaving the collision bounds this tile is interested in. This is called on every Called on the local client for owned projectile and the player, and on the server for boulder projectiles and NPC. Returns false by default. Return true to indicate that the tile had some sort of interaction occur. This return value is only used to force specific friendly NPC to keep walking, preventing them from resting on pressure plates, for example. |
void FloorVisuals(int type, Player player) |
hook | not here | 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. |
void ChangeWaterfallStyle(int type, ref int style) |
hook | not here | Allows you to change the style of waterfall that passes through or over any tile. |
void PostSetupTileMerge() |
hook | not here | Can be used to adjust tile merge related things that are not possible to do in SetStaticDefaults due to timing. |
abstract class Terraria.ModLoader.GlobalWall : ModType
This class allows you to modify the behavior of any wall in the game (although admittedly walls don't have much behavior). To use it, simply create a new class deriving from this one. Implementations will be registered automatically.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool KillSound(int i, int j, int type, bool fail) |
hook | only here | 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. |
void NumDust(int i, int j, int type, bool fail, ref int num) |
hook | only here | Allows you to change how many dust particles are created when the tile/wall at the given coordinates is hit. Use CreateDust to customize the dust spawned. |
bool CreateDust(int i, int j, int type, ref int dustType) |
hook | only here | 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. |
bool CanPlace(int i, int j, int type) |
hook | only here | 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 CanReplace should be used for replace-specific logic. Return false to stop the tile/wall from being placed. Returns true by default. |
bool CanExplode(int i, int j, int type) |
hook | only here | 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. |
bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) |
hook | only here | 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. Note that tiles are drawn one at a time in sequence (top to bottom, left to right), so this runs immediately before a single tile's sprite is drawn, not before all tiles on screen are rendered. Phone: Runs before all the walls are drawn, not cell by cell. Returning false hides that wall for this pass. |
void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) |
hook | only here | 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 IsTileInvisible due to Echo Coating. Use the IsVisible method to skip effects that shouldn't show when the tile is invisible. This method won't be called for invisible walls. Note that tiles are drawn one at a time in sequence (top to bottom, left to right), so this runs immediately after a single tile's sprite is drawn. Any effects drawn here will be overdrawn by sprites of tiles drawn after it. Use SpecialDraw via DrawEffects to draw after all tiles on screen have been rendered. Phone: Runs after all the walls are drawn, not cell by cell. |
void RandomUpdate(int i, int j, int type, bool underground) |
hook | only here | Called whenever the world randomly decides to update this tile/wall in a given tick. Useful for things such as growing or spreading. |
void PlaceInWorld(int i, int j, int type, Item item) |
hook | only here | 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. |
void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) |
hook | only here | 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 ApplyTileLight for vanilla tile light values to use as a reference. |
bool Drop(int i, int j, int type, ref int dropType) |
hook | same | Allows you to customize which items the wall at the given coordinates drops. Return false to stop the game from dropping the wall's default item (the dropType parameter). Returns true by default. |
void KillWall(int i, int j, int type, ref bool fail) |
hook | same | Allows you to determine what happens when the wall at the given coordinates is killed or hit with a hammer. Fail determines whether the wall is mined (whether it is killed). |
bool WallFrame(int i, int j, int type, bool randomizeFrame, ref int style, ref int frameNumber) |
hook | same | Called for every wall that updates due to being placed or being next to a wall that is changed. Return false to stop the game from carrying out its default WallFrame operations. If you return false, make sure to set WallFrameNumber, WallFrameX, and WallFrameY according to the your desired custom framing design. Returns true by default. |
bool CanBeTeleportedTo(int i, int j, int type, Player player, string context) |
hook | same | Whether teleports may land on this wall. |
void OnWallConverted(int i, int j, int fromType, int toType, int conversionType) |
hook | same | Called when this wall has been converted to another wall type via biome conversion. Check fromType and toType to see the wall types the wall changed between. For ModWall, this will be called when converting both to and from the wall. conversionType is a BiomeConversionID (or Type). |
struct Terraria.Gore
What Bunny Loader adds to the game's gore.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ModGore ModGore |
property | same | Its ModGore, or null. |
int NewGore(IEntitySource source, Vector2 Position, Vector2 Velocity, int Type, float Scale) |
static method | differs | Creates a gore. Returns its index. tML: int NewGore(Vector2 Position, Vector2 Velocity, int Type, float Scale)
|
Gore NewGoreDirect(IEntitySource source, Vector2 Position, Vector2 Velocity, int Type, float Scale) |
static method | differs | Creates a gore. Returns the gore. tML: Gore NewGoreDirect(Vector2 Position, Vector2 Velocity, int Type, float Scale)
|
Gore NewGorePerfect(IEntitySource source, Vector2 Position, Vector2 Velocity, int Type, float Scale) |
static method | differs | Creates a gore with an exact velocity. tML: Gore NewGorePerfect(Vector2 Position, Vector2 Velocity, int Type, float Scale)
|
Vector2 drawOffset |
field | not here | Not implemented. |
static class Terraria.ModLoader.GoreLoader
Registers mod gores.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int GoreCount |
static property | same | How many exist, with the game's and every mod's. |
bool AddGoreFromTexture<TGore>(Mod mod, string texture) |
static method | same | Registers a new gore with the provided texture. Typically used with SimpleModGore as TGore for gore with no additional logic. Use this for any gore textures not autoloaded by the GoreAutoloadingEnabled logic. |
static class Terraria.ModLoader.MapLayerLoader
Runs the mod map layers.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int MapLayerCount |
static property | same | How many exist, with the game's and every mod's. |
abstract class Terraria.ModLoader.ModBannerTile : ModTile
Extension to that streamlines the process of creating an enemy banner tile. Behaves the same as Banners except it does not set StyleWrapLimit to 111. Handles applying banner buffs for ModNPC automatically provided Banner and BannerItem are properly assigned and a ModItem to place each banner placement style exists.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void SetStaticDefaults() |
override | same | Sets up the banner tile. |
void NearbyEffects(int i, int j, bool closer) |
override | same | Applies the banner's bonus when the player is near. |
void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) |
override | same | Moves the banner to hang from the block above. |
bool PreDraw(int i, int j, SpriteBatch spriteBatch) |
override | same | Draws the banner's sway. |
abstract class Terraria.ModLoader.ModBiome : ModSceneEffect
This class represents a biome added by a mod. It exists to centralize various biome related hooks, handling a lot of biome boilerplate, such as netcode. To check if a player is in the biome, use . Unlike ModSceneEffect, this defaults Music to 0 and Priority to BiomeLow.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
SceneEffectPriority Priority |
override | same | Defaults to BiomeLow. |
int Music |
override | same | Defaults to 0. If custom music is not implemented for this biome, set this to -1. |
int BiomeTorchItemType |
hook | same | The torch item type that will be placed when under the effect of biome torches |
int BiomeCampfireItemType |
hook | same | The campfire item type that will be placed when under the effect of biome torches |
string LocalizationCategory |
hook | same | The folder of this content in the localization files. |
LocalizedText DisplayName |
hook | same | The display name for this biome in the bestiary. |
string BestiaryIcon |
hook | same | The path to the 30x30 texture that will appear for this biome in the bestiary. Defaults to adding "_Icon" onto the usual namespace+classname derived texture path. Vanilla icons use a drop shadow at 40 percent opacity and the texture will be offset 1 pixel left and up from centered in the bestiary filter grid. |
string BackgroundPath |
hook | same | The path to the background texture that will appear for this biome behind NPC's in the bestiary. Defaults to adding "_Background" onto the usual namespace+classname derived texture path. |
Color BackgroundColor |
hook | same | The color of the bestiary background. |
ModBiomeBestiaryInfoElement ModBiomeBestiaryInfoElement |
property | same | The biome's element in a bestiary page. |
void SetStaticDefaults() |
override | same | This is where you can set values for DisplayName. |
bool IsBiomeActive(Player player) |
hook | same | Return true if the player is in the biome. |
void OnEnter(Player player) |
hook | same | Override this hook to make things happen when the player enters the biome. |
void OnInBiome(Player player) |
hook | same | Override this hook to make things happen when the player is in the biome. |
void OnLeave(Player player) |
hook | same | Override this hook to make things happen when the player leaves the biome. |
struct Terraria.GameContent.Bestiary.ModBiomeBestiaryInfoElement
The icon and name of a mod biome in a bestiary page.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
SpawnConditionBestiaryInfoElement Element |
field | only here | The game's element behind this. |
bool IsNull |
property | only here | Whether it is empty. |
string GetDisplayNameKey() |
method | only here | The key of the biome's name. |
Asset<Texture2D> GetBackgroundImage() |
method | not here | Internal here. |
Color GetBackgroundColor() |
method | not here | Internal here. |
abstract class Terraria.ModLoader.ModBiomeConversion : ModType
This class allows you to define a modded conversion to work with Convert and RegisterConversion / RegisterConversion For the moment, this class does not provide any functional hooks, but it can still be used by mods in combination with the aforementioned hooks to create custom conversion behavior
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | The ID of the biome conversion, equivalent to BiomeConversionID. |
void PostSetupContent() |
hook | same | Allows you to run code after the mod's content has been setup (ID sets have been filled, etc). Use RegisterConversion and RegisterConversion in this hook if you want to implement conversions that rely on Conversion and Conversion sets being fully populated. |
abstract class Terraria.ModLoader.ModBlockType : ModTexturedType
This is the superclass for ModTile and ModWall, combining common code
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ushort Type |
property | same | The internal ID of this type of tile/wall. |
SoundStyle HitSound |
field | same | 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. |
int DustType |
field | same | The default type of dust made when this tile/wall is hit. Defaults to 0, which is Dirt. To prevent spawning any hit dust, set this to -1 instead. |
ushort VanillaFallbackOnModDeletion |
field | same | The vanilla ID of what should replace the instance when a user unloads and subsequently deletes data from your mod in their save file. tileFrameImportant tiles attempting to fallback to a vanilla tileFrameImportant tile need to match the layout (FrameX and FrameY values) of the fallback tile so that the resulting tiles aren't broken. Also note that tiles with ModTileEntity won't be able to fallback to a working vanilla Tile+TileEntity. The user will have to mine and replace the tile to spawn the correct TileEntity. Defaults to Dirt (0). |
string LocalizationCategory |
hook | same | The folder of this content in the localization files. |
LocalizedText CreateMapEntryName() |
method | same | Legacy helper method for creating a localization sub-key MapEntry |
ushort GetMapOption(int i, int j) |
hook | same | 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. |
bool KillSound(int i, int j, bool fail) |
hook | same | 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. |
void NumDust(int i, int j, bool fail, ref int num) |
hook | same | Allows you to change how many dust particles are created when the tile/wall at the given coordinates is hit. Use CreateDust to customize the dust spawned. |
bool CreateDust(int i, int j, ref int type) |
hook | same | 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. |
bool CanPlace(int i, int j) |
hook | same | 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 CanReplace should be used for replace-specific logic. Return false to stop the tile/wall from being placed. Returns true by default. |
bool CanExplode(int i, int j) |
hook | same | 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. |
bool PreDraw(int i, int j, SpriteBatch spriteBatch) |
hook | same | 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. Note that tiles are drawn one at a time in sequence (top to bottom, left to right), so this runs immediately before a single tile's sprite is drawn, not before all tiles on screen are rendered. Phone: On walls it runs before all the walls are drawn, not cell by cell, because the phone draws walls on threads. On tiles it replaces the tile's own drawing. |
void PostDraw(int i, int j, SpriteBatch spriteBatch) |
hook | same | 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 IsTileInvisible due to Echo Coating. Use the IsVisible method to skip effects that shouldn't show when the tile is invisible. This method won't be called for invisible walls. Note that tiles are drawn one at a time in sequence (top to bottom, left to right), so this runs immediately after a single tile's sprite is drawn. Any effects drawn here will be overdrawn by sprites of tiles drawn after it. Use SpecialDraw via DrawEffects to draw after all tiles on screen have been rendered. |
void RandomUpdate(int i, int j, bool underground) |
hook | same | Called whenever the world randomly decides to update this tile/wall in a given tick. Useful for things such as growing or spreading. |
void PlaceInWorld(int i, int j, Item item) |
hook | same | 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. |
void ModifyLight(int i, int j, ref float r, ref float g, ref float b) |
hook | same | 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 ApplyTileLight for vanilla tile light values to use as a reference. |
void Convert(int i, int j, int conversionType) |
hook | same | Allows you to change what happens when this tile/wall is converted into another biome. If you need to override or add a new conversion to a vanilla tile, use RegisterConversion and RegisterConversion. Purification powder uses a separate conversionType, as it doesn't convert hallowed tiles back to purity tiles. Be sure to check for PurificationPowder as well as Purity when handling corruption/crimson tiles. You can use ConvertTile or ConvertWall to automatically handle tile framing and multiplayer syncing. |
abstract class Terraria.ModLoader.ModCactus : IPlant
This class represents a type of modded cactus. This class encapsulates a function for retrieving the cactus's texture and an array for type of soil it grows on.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int PlantTileId |
property | same | The cactus will share a tile ID with the vanilla cacti (80), so that the cacti can freely convert between each other if the sand below is converted. |
int VanillaCount |
property | same | How many cactus the game has. |
int[] GrowsOnTileId |
property | same | The tiles it grows on. |
void SetStaticDefaults() |
hook | same | Sets GrowsOnTileId. |
Asset<Texture2D> GetTexture() |
hook | same | The cactus texture. |
Asset<Texture2D> GetFruitTexture() |
hook | same | The fruit texture has a special layout that needs to be followed, see ExampleCactus_Fruit.png in ExampleMod for a template. |
abstract class Terraria.ModLoader.ModCloud : ModTexturedType
This class allows you to customize the behavior of a custom cloud. Modded clouds can be autoloaded automatically (see CloudAutoloadingEnabled) or manually registered (AddCloudFromTexture), but autoloaded clouds default to being normal clouds with the default spawn chance. Make a ModCloud class if custom behavior is needed or use AddCloudFromTexture if customizing cloud category and spawn chance is all that is needed. This class is not instanced, all clouds of the same type will share the same instance.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | The cloud's number. |
bool RareCloud |
hook | same | If true, this cloud will belong to the "Rare clouds" pool instead of the "Normal clouds" (see the Terraria wiki for more information). Rare clouds typically can only spawn after certain world conditions have been met. For example Rare_Skeletron can only spawn if downedBoss3 is true. Rare clouds can be used by mods to highlight achievements such as defeating a boss. Defaults to false. |
string Name |
override | same | The cloud's name. |
string Texture |
override | same | The texture's path. |
void Register() |
override | same | If you make a new ModType, seal this override. |
float SpawnChance() |
hook | same | The chance that this cloud can spawn. Return 1f to spawn just as often compared as vanilla clouds. A cloud can be either a "Normal cloud" or a "Rare cloud" if RareCloud is true. The spawn chance is the chance to spawn within each cloud category, so there is no need to return a very small chance value for rare clouds, the logic already takes that into account. If RareCloud is true, the spawn chance already takes into account secret seed adjustments so there is no need to implement that logic in this method either. See the Terraria wiki for more information. If checking for modded biomes using Main.LocalPlayer, be sure to check Main.gameMenu as well to prevent exceptions. Defaults to 1f. |
void OnSpawn(Cloud cloud) |
hook | same | Gets called when the Cloud spawns. |
bool Draw(List<DrawData> drawDataCache, Cloud cloud, int cloudIndex, ref DrawData drawData) |
hook | same | Allows customization of the DrawData responsible for drawing the this cloud. Return true to draw using vanilla drawing logic, which will render drawData by adding it to drawDataCache. Return false to prevent drawData from being added to drawDataCache. |
abstract class Terraria.ModLoader.ModDust : ModTexturedType
This class represents a type of dust that is added by a mod. Only one instance of this class will ever exist for each type of dust you add. The Basic Dust Guide teaches the basics of making modded dust.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int UpdateType |
property | same | Allows you to choose a type of dust for this type of dust to copy the behavior of. Defaults to -1, which means that no behavior is copied. |
Asset<Texture2D> Texture2D |
property | same | The sprite sheet that this type of dust uses. Normally a sprite sheet will consist of a vertical alignment of three 10 x 10 pixel squares, each one containing a possible look for the dust. |
int Type |
property | same | The ID of this type of dust. |
void SetStaticDefaults() |
override | same | Allows you to modify the properties after initial loading has completed. This is where you would update ModDust's UpdateType property and modify the Terraria.GameContent.ChildSafety.SafeDust array. |
bool PreDraw(Dust dust) |
hook | same | Allows drawing behind this dust, such as a trail, or modifying the way it is drawn. Return false to stop the normal dust drawing code (useful if you're manually drawing the dust itself). Returns true by default. |
void OnSpawn(Dust dust) |
hook | same | Allows you to modify a dust's fields when it is created. |
bool Update(Dust dust) |
hook | same | Allows you to customize how you want this type of dust to behave. Return true to allow for vanilla dust updating to also take place; will return true by default. Normally you will want this to return false. |
bool MidUpdate(Dust dust) |
hook | same | Allows you to add behavior to this dust on top of the default dust behavior. Return true if you're applying your own behavior; return false to make the dust slow down by itself. Normally you will want this to return true. |
Color GetAlpha(Dust dust, Color lightColor) |
hook | same | Allows you to override the color this dust will draw in. Return null to draw it in the normal light color; returns null by default. Note that the dust.noLight field makes the dust ignore lighting and draw in full brightness, and can be set in OnSpawn instead of having to return Color.White here. fullBright will also force this dust to use a value of Color.White and will skip this method. |
abstract class Terraria.ModLoader.ModGore : ModTexturedType
This class allows you to customize the behavior of a custom gore.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int UpdateType |
property | same | Allows you to copy the Update behavior of a different type of gore. This defaults to 0, which means no behavior is copied. |
int Type |
property | same | The gore's number. |
string Name |
override | same | The gore's name. |
string Texture |
override | same | The texture's path. |
void Register() |
override | same | If you make a new ModType, seal this override. |
void OnSpawn(Gore gore, IEntitySource source) |
hook | same | Allows you to modify a gore's fields when it is created. |
bool Update(Gore gore) |
hook | same | Allows you to customize how you want this type of gore to behave. Return true to allow for vanilla gore updating to also take place; returns true by default. |
Color GetAlpha(Gore gore, Color lightColor) |
hook | same | Allows you to override the color this gore will draw in. Return null to draw it in the normal light color; returns null by default. |
abstract class Terraria.ModLoader.ModMapLayer : ModType
This class is used to facilitate easily drawing icons and other things over the map. Pylons and spawn/bed icons are examples of vanilla map layers. Use PreDrawMapIconOverlay to selectively hide vanilla layers if needed.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool Visible |
property | same | Whether it draws now. |
Position GetDefaultPosition() |
hook | same | Returns the map layer's default position in regard to vanilla's map layer ordering. Make use of e.g. Before/After, and provide a map layer. You can also use BeforeFirstVanillaLayer or AfterLastVanillaLayer to put your layer at the start/end of the vanilla layer order. NOTE: The position must specify a vanilla IMapLayer otherwise an exception will be thrown. Use GetModdedConstraints to order modded layers. By default, this hook positions this map layer after all vanilla layers. |
IEnumerable<Position> GetModdedConstraints() |
hook | same | Modded layers are placed between vanilla layers via GetDefaultPosition and, by default, are sorted in load order. This hook allows you to sort this map layer before/after other modded layers that were placed between the same two vanilla layers. Example: yield return new After(ModContent.GetInstance<ExampleMapLayer>()); By default, this hook returns null, which indicates that this map layer has no modded ordering constraints. |
void Draw(ref MapOverlayDrawContext context, ref string text) |
hook | same | This method is called when this MapLayer is to be drawn. Map layers are drawn after the map itself is drawn. Use Draw as described in ExampleMod and in vanilla examples for full compatibility and simplicity of code. context: Contains the scaling and positional data of the map being drawn. You should use the MapOverlayDrawContext.Draw method for all drawing. text: The mouse hover text. Assign a value typically if the user is hovering over something you draw. Note that MapLayers are drawn on the fullscreen map, overlay map, and minimap. Use mapFullscreen and mapStyle to limit drawing to specific map modes if appropriate. |
Position BeforeFirstVanillaLayer |
static property | same | Under every layer of the game. |
Position AfterLastVanillaLayer |
static property | same | Over every layer of the game. |
class Terraria.ModLoader.ModMapLayer.After : Position
Draws a map layer after another one.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
new After(IMapLayer layer) |
constructor | same | Creates an instance. |
new After(ModMapLayer layer) |
constructor | differs | Creates an instance. tML: new After(IMapLayer layer)
|
IMapLayer Layer |
property | not here | Not implemented. |
class Terraria.ModLoader.ModMapLayer.Before : Position
Draws a map layer before another one.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
new Before(IMapLayer layer) |
constructor | same | Creates an instance. |
new Before(ModMapLayer layer) |
constructor | differs | Creates an instance. tML: new Before(IMapLayer layer)
|
IMapLayer Layer |
property | not here | Not implemented. |
abstract class Terraria.ModLoader.ModMapLayer.Position
Where a map layer goes in the draw order.
| Member | Kind | tModLoader | What it does |
|---|
abstract class Terraria.ModLoader.ModPylon : ModTile
Extension to that streamlines the process of creating a modded Pylon. Has all of ModTile's hooks for customization, but additional hooks for Pylon functionality.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
TeleportPylonType PylonType |
property | same | What type of Pylon this ModPylon represents. |
bool CanPlacePylon() |
hook | same | Whether or not this Pylon can even be placed. By default, it returns false if a Pylon of this type already exists in the world, otherwise true. If you want to allow an infinite amount of these pylons to be placed, simply always return true. |
Entry GetNPCShopEntry() |
hook | same | Creates the npc shop entry which will be registered to the shops of all NPCs which can sell pylons. Override this to change the sold item type, or alter the conditions of sale. Return null to prevent automatically registering this pylon in shops. By default, the pylon will be sold in all shops when the provided conditions are met, if the pylon has a non-zero item drop. The standard pylon conditions are AnotherTownNPCNearby, NotInEvilBiome
|
bool ValidTeleportCheck_NPCCount(TeleportPylonInfo pylonInfo, int defaultNecessaryNPCCount) |
hook | same | Step 1 of the ValidTeleportCheck process. This is the first vanilla check that is called when checking both the destination pylon and any possible nearby pylons. This check should be where you check how many NPCs are nearby, returning false if the Pylon does not satisfy the conditions. By default, returns true if there are 2 or more NPCs nearby. |
bool ValidTeleportCheck_BiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) |
hook | same | Step 2 of the ValidTeleportCheck process. This is the third vanilla check that is called when checking both the destination pylon and any possible nearby pylons. This check should be where you check biome related things, such as the simple check of whether or not the Pylon is in the proper biome. By default, returns true. |
void ValidTeleportCheck_DestinationPostCheck(TeleportPylonInfo destinationPylonInfo, ref bool destinationPylonValid, ref string errorKey) |
hook | same | The 3rd check of the ValidTeleportCheck process. This check is for modded Pylons only, called after ALL other checks have completed pertaining the pylon clicked on the map (the destination pylon), but before any nearby pylon information is calculated. This is where you an do custom checks that don't pertain to the past destination checks, as well as customize the localization key to give custom messages to the player on teleportation failure. By default, does nothing. If you're confused about the order of which the ValidTeleportCheck methods are called, check out the XML summary on the ModPylon class. |
void ValidTeleportCheck_NearbyPostCheck(TeleportPylonInfo nearbyPylonInfo, ref bool destinationPylonValid, ref bool anyNearbyValidPylon, ref string errorKey) |
hook | same | The 4th and final check of the ValidTeleportCheck process. This check is for modded Pylons only, called after ALL other checks have completed for the destination pylon and all normal checks have taken place for the nearby pylon, if applicable. This is where you can do custom checks that don't pertain to the past nearby pylon checks, as well as customize the localization key to give custom messages to the player on teleportation failure. By default, does nothing. If you're confused about the order of which the ValidTeleportCheck methods are called, check out the XML summary on the ModPylon class. |
void ModifyTeleportationPosition(TeleportPylonInfo destinationPylonInfo, ref Vector2 teleportationPosition) |
hook | same | Called right BEFORE the teleportation of the player occurs, when all checks succeed during the ValidTeleportCheck process. Allows the modification of where the player ends up when the teleportation takes place. Remember that the teleport location is in WORLD coordinates, not tile coordinates. |
void DrawMapIcon(ref MapOverlayDrawContext context, ref string mouseOverText, TeleportPylonInfo pylonInfo, bool isNearPylon, Color drawColor, float deselectedScale, float selectedScale) |
hook | same | Called when the map is visible, in order to draw the passed in Pylon on the map. In order to draw on the map, you must use 's Draw Method. By default, doesn't draw anything. |
bool RightClick(int i, int j) |
override | same | Opens the map to choose a pylon. |
bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) |
override | same | Pylons can be reached by smart interact. |
void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) |
override | same | Registers the crystal that draws over the tile. |
void DefaultDrawPylonCrystal(SpriteBatch spriteBatch, int i, int j, Asset<Texture2D> crystalTexture, Asset<Texture2D> crystalHighlightTexture, Vector2 crystalOffset, Color pylonShadowColor, Color dustColor, int dustChanceDenominator, int crystalVerticalFrameCount) |
method | same | Draws the passed in pylon crystal texture the exact way that vanilla draws it. This MUST be called in SpecialDraw in order to function properly. |
bool DefaultDrawMapIcon(ref MapOverlayDrawContext context, Asset<Texture2D> mapIcon, Vector2 drawCenter, Color drawColor, float deselectedScale, float selectedScale) |
method | same | Draws the passed in map icon texture for pylons the exact way that vanilla would draw it. Note that this method assumes that the texture is NOT framed, i.e there is only a single sprite that is not animated. Returns whether or not the player is currently hovering over the icon. |
void DefaultMapClickHandle(bool mouseIsHovering, TeleportPylonInfo pylonInfo, string hoveringTextKey, ref string mouseOverText) |
method | same | Handles mouse clicking on the map icon the exact way that vanilla handles it. In normal circumstances, this should be called directly after DefaultDrawMapIcon. |
abstract class Terraria.ModLoader.ModSceneEffect : ModType
ModSceneEffect is an abstract class that your classes can derive from. It serves as a container for handling exclusive SceneEffect content such as backgrounds, music, and water styling.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | The scene's number. |
ModWaterStyle WaterStyle |
hook | same | The ModWaterStyle that will apply to water. |
ModSurfaceBackgroundStyle SurfaceBackgroundStyle |
hook | same | The ModSurfaceBackgroundStyle that will draw its background when the player is on the surface. |
ModUndergroundBackgroundStyle UndergroundBackgroundStyle |
hook | same | The ModUndergroundBackgroundStyle that will draw its background when the player is underground. |
int Music |
hook | same | Defaults to -1. |
string MapBackground |
hook | same | The path to the texture that will display behind the map. Should be 115x65. |
bool MapBackgroundFullbright |
hook | same | If true, the map background (MapBackground) will be forced to be drawn at full brightness (White). For example, the background map of the Mushroom biome draws at full brightness even when above ground. By default, this returns false, indicating that the sky color should be used if above surface level and full brightness otherwise. Use MapBackgroundColor instead to fully customize the map background draw color. |
SceneEffectPriority Priority |
hook | same | Defaults to None. |
TileColorStyle TileColorStyle |
hook | same | Used to apply secondary color shading for the capture camera. For example, darkening the background with the GlowingMushroom style. |
void Register() |
override | same | If you make a new ModType, seal this override. |
void SetupContent() |
override | only here | If you make a new ModType, seal this override, and call SetStaticDefaults in it. |
float GetWeight(Player player) |
hook | same | Is invoked when two or more modded SceneEffect layers are active within the same Priority group to attempt to determine which one should take precedence, if it matters. It's uncommon to have the need to assign a weight - you'd have to specifically believe that you don't need higher SceneEffectPriority, but do need to be the active SceneEffect within the priority you designated. Analogously, if SceneEffect were competing in a wrestling match, this would be how likely the SceneEffect should win within its weight class. Is intentionally bounded at a max of 100% (1) to reduce complexity. Defaults to 50% (0.5). Typical calculations may include: 1) how many tiles are present as a percentage of target amount; 2) how far away you are from the cause of the SceneEffect |
bool IsSceneEffectActive(Player player) |
hook | same | Return true to make the SceneEffect apply its effects (as long as its priority and weight allow that). |
void SpecialVisuals(Player player, bool isActive) |
hook | same | Allows you to create special visual effects in the area around the player. For example, the Blood Moon's red filter on the screen or the Slime Rain's falling slime in the background. You must create classes that override ScreenShaderData or CustomSky, add them in a Load hook, then call ManageSpecialBiomeVisuals. See the ExampleMod if you do not have access to the source code. This runs even if IsSceneEffectActive returns false. Check isActive for the active status. |
void MapBackgroundColor(ref Color color) |
hook | same | Uses to customize the draw color of the map background (MapBackground) drawn on the fullscreen map. MapBackgroundFullbright can be used for typical effects, but this method can be used if further customization is needed. |
abstract class Terraria.ModLoader.ModSubworld : ModType · only in Bunny Loader
A dimension: a separate world the player travels to, with its own size, generation and save file. See Dimensions.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string LocalizationCategory |
hook | only here |
Subworlds. |
LocalizedText DisplayName |
hook | only here | The world's name, from the Subworlds translations. |
int Width |
hook | only here | Width in tiles, from 200 to 8400. Not used with WorldFile. |
int Height |
hook | only here | Height in tiles, from 160 to 2400. Not used with WorldFile. |
List<GenPass> GenerationTasks |
hook | only here | The passes that build the world, as in world generation. Not used with WorldFile. |
string WorldFile |
hook | only here | A .wld inside the mod to load instead of generating, with the mod's .bl files beside it. |
bool Persistent |
hook | only here |
true keeps the world between trips; false builds it again on every trip. |
bool SavePlayerChanges |
hook | only here |
false gives the player back as they entered. |
bool RandomTileUpdates |
hook | only here | Grass spreading and plants growing. Liquids, wiring and tile entities update either way. |
bool HideUnderworld |
hook | only here | The bottom 200 rows are not the underworld: no background, light, music, enemies or evaporating water. |
bool HideOcean |
hook | only here | The columns next to the edges are not a beach: no ocean zone, music or background. |
string LoadingText |
hook | only here | The text of the loading screen. |
bool ShowLoadingScreen |
hook | only here |
false keeps the screen black while the world changes, with DrawTransition on top. |
float TransitionOutSeconds |
hook | only here | How long the transition plays in the world being left. |
float TransitionInSeconds |
hook | only here | How long the transition plays in the world being entered. |
string FileName |
property | only here |
<Mod>_<Name>, the name of the save file. |
void OnEnter() |
hook | only here | Before the dimension loads or generates. |
void OnExit() |
hook | only here | Before the player leaves the dimension. |
void PostWorldReady() |
hook | only here | Once the player is in the dimension. |
void Update() |
hook | only here | Once per world update while the dimension is active. |
void SaveCarriedData(TagCompound tag) |
hook | only here | Writes what travels to the next world, on every dimension, whenever a world is left. |
void LoadCarriedData(TagCompound tag) |
hook | only here | Reads back the tag SaveCarriedData wrote, once the next world is loaded. |
void DrawTransition(SpriteBatch spriteBatch, float progress) |
hook | only here | Draws the transition over the whole screen, interface included (Main.screenWidth × Main.screenHeight); progress goes 0 to 1 while leaving and back to 0 while arriving. Draws black by default. |
abstract class Terraria.ModLoader.ModSurfaceBackgroundStyle : ModBackgroundStyle
Each background style determines in its own way how exactly the background is drawn. This class serves as a collection of functions for above-ground backgrounds.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void ModifyFarFades(float[] fades, float transitionSpeed) |
hook | same | Allows you to modify the transparency of all background styles that exist. In general, you should move the index equal to this style's slot closer to 1, and all other indexes closer to 0. The transitionSpeed parameter is what you should add/subtract to each element of the fades parameter. See the ExampleMod for an example. |
int ChooseFarTexture() |
hook | same | Allows you to determine which texture is drawn in the very back of the background. BackgroundTextureLoader.GetBackgroundSlot may be useful here, as well as for the other texture-choosing hooks. |
int ChooseMiddleTexture() |
hook | same | Allows you to determine which texture is drawn in the middle of the background. |
bool PreDrawCloseBackground(SpriteBatch spriteBatch) |
hook | same | Gives you complete freedom over how the closest part of the background is drawn. Return true for ChooseCloseTexture to have an effect; return false to disable tModLoader's own code for drawing the close background. |
int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) |
hook | same | Allows you to determine which texture is drawn in the closest part of the background. This also lets you modify the scale and parallax (as well as two unfortunately-unknown parameters). |
abstract class Terraria.ModLoader.ModTile : ModBlockType
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 | Kind | tModLoader | What it does |
|---|---|---|---|
float MineResist |
field | same | 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 Pearlstone, would require roughly twice as many hits to mine. Conversely, a MineResist value of 0.5f, such as used by 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 |
field | same | The minimum pickaxe power required for pickaxes to mine this block. Defaults to 0. For example a MinPick value of 50, such as what Meteorite uses, would require a pickaxe with at least 50% pickaxe power (pick) to break. To find an appropriate value, see the wiki. Use MineResist to adjust how long a tile takes to be mined. |
int[] AdjTiles |
field | same | An array of the IDs of tiles that this tile can be considered as when looking for crafting stations. |
int AnimationFrameHeight |
field | same | The height of a group of animation frames for this tile. Defaults to 0, which disables animations. Used in conjunction with AnimateTile to automatically animate tiles. Use AnimateIndividualTile as well if needed. An easy way to set this correctly without doing any math is to set this to the value of 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. |
string HighlightTexture |
hook | same | The highlight texture used when this tile is selected by smart interact. Defaults to adding "_Highlight" onto the main texture. HasOutlines must be set to true for this to texture to be used. |
bool IsDoor |
property | same | Whether it is a door. |
string LocalizationCategory |
override | same | The folder of this content in the localization files. |
void AddMapEntry(Color color, LocalizedText name, Func<string, int, int, string> nameFunc) |
method | same | 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 ExampleChest is one example of this functionality. |
void AddToArray(ref int[] array) |
method | same | A convenient method for adding this tile's Type to the given array. This can be used with the arrays in TileID.Sets.RoomNeeds. |
void RegisterItemDrop(int itemType, params int[] tileStyles) |
method | same | 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. Manually registered item drops take precedence over the automatic item drop system. 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. |
bool CanDrop(int i, int j) |
hook | same | 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. |
IEnumerable<Item> GetItemDrops(int i, int j) |
hook | same | Allows customization of the items the tile at the given coordinates drops. The default item drop is determined by finding an item with createTile and placeStyle matching the type and style of this tile. RegisterItemDrop 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 or KillTile. The style based drop logic is based on TileObjectData. If a tile has custom 'styles' but still wants to make use of RegisterItemDrop, TileLoader.GetItemDropFromTypeAndStyle(Type, style) can be used to retrieve the associated item drop. Use CanDrop to conditionally prevent any item drops. Use KillMultiTile or KillTile for other logic such as cleaning up TileEntities or killing chests or signs. |
bool CanKillTile(int i, int j, ref bool blockDamaged) |
hook | same | 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. |
void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) |
hook | same | 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. |
void KillMultiTile(int i, int j, int frameX, int frameY) |
hook | same | 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. The i and j coordinates will be the top left tile of a multi-tile. |
void ReplaceTile(int i, int j, int targetType, int targetStyle) |
hook | same | Called when this tile at the given coordinates is being replaced via the block swap feature. For supported multi-tiles, the coordinates will be the top left corner. targetType and targetStyle are the tile type and style that will replace the current tile. An implementation of this method might end up duplicating some custom KillMultiTile or KillTile code, but not all. For example, for a chest or dresser tile you wouldn't want to call Chest.DestroyChest. Called on local, server, and remote clients. |
void NearbyEffects(int i, int j, bool closer) |
hook | same | Allows you to make things happen when this tile is within a certain range of the player, such as how banners, campfire, and monoliths work. This method will be called on tiles within 2 specific ranges, once for calculating visual effects and another time for calculating gameplay effects: When calculating visual effects, the closer parameter will be true. The visual effect range depend on the game window resolution, zoom level, and lighting mode, so it will not be reliable for gameplay effects but rather it adjusts to the players view of the game world. This is suitable for monoliths, water fountains, and music boxes. When calculating gameplay effects, the closer parameter will be false. The gameplay effect range will always be a 169x124 tile rectangle centered on the player. This is suitable for tiles that give buffs like the sunflower, banners, heart lantern, and campfire. Make sure to check closer when using this method to ensure the effects of this tile are applying to the intended range. |
bool IsTileDangerous(int i, int j, Player player) |
hook | same | 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. |
bool IsTileSpelunkable(int i, int j) |
hook | same | Allows you to customize whether this tile can glow yellow while the player has the Spelunker buff, and is also detected by various pets. The player isn't necessarily the local player, but the player being used to view the area (such as when spectating), Main.SceneMetrics.PerspectivePlayer. This is only called if Main.tileSpelunker[type] is false. |
void SetSpriteEffects(int i, int j, ref SpriteEffects spriteEffects) |
hook | same | Allows you to determine whether or not the tile will draw itself flipped in the world. If flipping, consider setting DrawFlipHorizontal or DrawFlipVertical as well to ensure that the tile placement preview is also flipped. |
void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) |
hook | same | 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. |
void AnimateTile(ref int frame, ref int frameCounter) |
hook | same | 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 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]; Note: For the smoothest animation, frameCounter should count up to a multiple of 4 before advancing the frame value. This is because tiles are rendered every 4 game draws but this method is called every game update. Values that aren't multiples of 4 would result in some frames drawing for twice as long as the next animation frame, resulting in jerky animation. Similarly, attempting to change frames at intervals shorter than 4 will result in skipped animation frames. |
void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) |
hook | same | 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 TileFrameX and 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. 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 PreDraw. |
void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) |
hook | same | Allows you to adjust how the tile at the given coordinates is drawn. For example, changing the color the tile is drawn in. Can also be used to register this tile location for additional rendering after all tiles are drawn normally. SpecialDraw will be called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint or Main.instance.TilesRenderer.AddSpecialPoint(i, j, TileCounterType.CustomNonSolid or CustomSolid) here or in PreDraw. Note: Previously ExampleMod examples showed spawning particles (dust or gore) in this method, but they should be spawned in EmitParticles instead now. This is because particles are only spawned under specific conditions and those conditions are baked into the logic calling EmitParticles. |
void SpecialDraw(int i, int j, SpriteBatch spriteBatch) |
hook | same | Special Draw. Allows for additional rendering after all tiles are drawn normally. Only called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint or Main.instance.TilesRenderer.AddSpecialPoint(i, j, TileCounterType.CustomNonSolid or CustomSolid) during DrawEffects or PreDraw. Useful for drawing things that would otherwise be impossible to draw due to draw order, such as items in item frames. |
bool RightClick(int i, int j) |
hook | same | 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. |
bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) |
hook | same | Whether or not the smart interact function can select this tile. Useful for things like chests. Defaults to false. Any tile used in as a crafting station in a recipe will automatically behave this way as well. Phone: The phone's smart cursor reaches mod tiles through a port of the game's loop. |
void ModifySmartInteractCoords(ref int width, ref int height, ref int frameWidth, ref int frameHeight, ref int extraY) |
hook | same | 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. |
bool IsLockedChest(int i, int j) |
hook | same | Return true if this Tile corresponds to a chest that is locked. Prevents Quick Stacking items into the chest. |
bool UnlockChest(int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual) |
hook | same | 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. |
bool LockChest(int i, int j, ref short frameXAdjustment, ref bool manual) |
hook | same | 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. |
LocalizedText DefaultContainerName(int frameX, int frameY) |
hook | same | 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 GetMapOption to match the AddMapEntry entries. Another option is using return Lang._mapLegendCache[MapHelper.TileToLookup(Type, option)];, this will reuse the localizations used for the map entries. |
void MouseOver(int i, int j) |
hook | same | Allows you to make something happen when the mouse hovers over this tile. Useful for showing item icons or text on the mouse. |
void MouseOverFar(int i, int j) |
hook | same | 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. |
void HitWire(int i, int j) |
hook | same | Allows you to make something happen when a wire current passes through this tile. Both SkipWire and SendTileSquare 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. |
bool Slope(int i, int j) |
hook | same | 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. |
bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) |
hook | same | 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. |
bool CanReplace(int i, int j, int tileTypeBeingPlaced) |
hook | same | 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. DoesntGetReplacedWithTileReplacement, DoesntPlaceWithTileReplacement, and PreventsTileReplaceIfOnTopOfIt cover the most common use cases and should be used instead if possible. |
void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) |
hook | same | Modify the parameters for the entity sitting on this furniture tile with its type registered to 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 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). |
void ModifySleepingTargetInfo(int i, int j, ref TileRestingInfo info) |
hook | same | Modify the visual player offset when sleeping on this tile with its type registered to CanBeSleptIn. This gets called when calling 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). |
bool GrowSapling(int i, int j, bool underground, int treeHeightAddon, bool ignoreWalls) |
hook | same | Called when a tree is attempting to grow from a sapling tile (Assuming CommonSapling is set for this tile type) at this location. This can be either a natural growth from code calling AttemptToGrowTreeFromSapling in RandomUpdate or unnaturally, such as when fertilizer (Fertilizer or SuperFertilizer) is used on this tile. treeHeightAddon and ignoreWalls are set based on how the tree is being grown. For example, SuperFertilizer will set treeHeightAddon to 15 and ignoreWalls to true, while natural growth will set treeHeightAddon to 0 and ignoreWalls to false. By default, attempts to grow a standard tree via GrowTree and then potentially spawns leaves if a player is nearby, matching vanilla behavior. Override to use a different growth method (e.g. GrowPalmTree) or to add custom logic. Return true if a tree was grown, false otherwise. |
void PostSetDefaults() |
hook | same | Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main.tileObsidianKill. |
void DropCritterChance(int i, int j, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance) |
hook | same | Allows you to modify the chance the tile at the given coordinates has of spawning a certain critter when the tile is killed. |
void HitSwitch(int i, int j) |
hook | same | Called when HitSwitch is called on the tile. Ordinarily this only happens for modded tiles if they opt in to specific functionality, such as PressurePlate, but mods can call it directly as well. Can be used for running code on the server and all clients for tile interactions, unlike HitWire which runs on the server or RightClick which runs on the local client. Code in HitWire, RightClick, or SwitchTiles could call HitSwitch followed by NetMessage.SendData(MessageID.HitSwitch...) (Or just HitSwitchAndSync by itself), which would result in HitSwitch and consequently this method running on the server and all clients. Essentially, this can be used to sync a tile interaction effect without making a custom ModPacket, and it is up to the modder to decide how that interaction is triggered. The most common usage of this is to sync playing a sound. |
bool SwitchTiles(int i, int j, Entity entity, Vector2 position, int width, int height, Vector2 oldPosition, int objType) |
hook | same | Called in SwitchTiles. This hook allows acting on entities colliding with tiles. The position, width, and height parameters indicate the hitbox of the entity, while oldPosition is the position of the entity on the previous update. You'll need to use these to determine if a collision is occurring and if the entity is entering or leaving the collision bounds this tile is interested in. This is called on every Called on the local client for owned projectile and the player, and on the server for boulder projectiles and NPC. Returns false by default. Return true to indicate that the tile had some sort of interaction occur. This return value is only used to force specific friendly NPC to keep walking, preventing them from resting on pressure plates, for example. |
void FloorVisuals(Player player) |
hook | same | 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. |
bool HasWalkDust() |
hook | same | Whether or not this tile creates dust when the player walks on it. Returns false by default. Customize the dust spawned using WalkDust. The default dust is Snow otherwise. |
void WalkDust(ref int dustType, ref bool makeDust, ref Color color) |
hook | same | 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 Snow
|
float GetTorchLuck(Player player) |
hook | same | 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. |
void EmitParticles(int i, int j, Tile tile, short tileFrameX, short tileFrameY, Color tileLight, bool visible) |
hook | same | Used to spawn Dust or Gore particle effects. Note that this is called even if the tile is invisible due to echo coating, so check visible if dust should only be spawned if the tile is visible. Tiles that still spawn particle effects while invisible can be useful to builders. Some tiles that spawn dust even when invisible include BubbleMachine, FogMachine, BrazierSuspended, Campfire, Chimney, SillyBalloonMachine, LeafBlock, and PoopBlock. The tileFrameX and tileFrameY values differ from the Tile frame values in that they incorporate the changes from SetDrawPositions and should normally be used instead of TileFrameX and Y directly. This method is only called under the conditions where particle effects are intended to spawn, that being the game is active, not paused, and at the intended frequency determined by the lighting mode. There is no need to check for these conditions in this method. |
void GetTileFlameData(int i, int j, ref TileFlameData tileFlameData) |
hook | same | Use to populate tileFlameData with flame drawing parameters. Currently only supported for tiles drawn using AddSpecialPoint with MultiTileVine, other tiles should draw flames manually by calling Main.instance.TilesRenderer.AddSpecialLegacyPoint in DrawEffects and drawing the flame in SpecialDraw, as shown in ExampleLamp.cs. |
void AdjustMultiTileVineParameters(int i, int j, ref float overrideWindCycle, ref float windPushPowerX, ref float windPushPowerY, ref bool dontRotateTopTiles, ref float totalWindMultiplier, ref Texture2D glowTexture, ref Color glowColor) |
hook | same | Customizes a tile drawn using AddSpecialPoint with MultiTileVine, specifically how the tile reacts to wind and player interactions. The parameters are as follows: overrideWindCycle: windPushPowerX: windPushPowerY: dontRotateTopTiles: totalWindMultiplier: glowTexture: glowColor: |
bool IsTileBiomeSightable(int i, int j, ref Color sightColor) |
hook | not here | Allows you to determine whether this tile glows sightColor while the player has the Biome Sight buff. The player isn't necessarily the local player, but the player being used to view the area (such as when spectating), Main.SceneMetrics.PerspectivePlayer. Return true and assign to sightColor to allow this tile to glow. This is only called on the local client. |
bool PreDrawPlacementPreview(int i, int j, SpriteBatch spriteBatch, ref Rectangle frame, ref Vector2 position, ref Color color, bool validPlacement, ref SpriteEffects spriteEffects) |
hook | not here | Allows you to draw behind this multi-tile's regular placement preview rendering, or change relevant drawing parameters. This is ran for each rendered section of the multi-tile. Make sure to use frame for logic rather than the TileFrameX/Y values of the tile at the provided coordinates, this tile isn't placed yet. Return false to stop this section from drawing normally. Returns true by default. |
void PostDrawPlacementPreview(int i, int j, SpriteBatch spriteBatch, Rectangle frame, Vector2 position, Color color, bool validPlacement, SpriteEffects spriteEffects) |
hook | not here | Allows you to draw in front of this multi-tile's placement preview rendering. This is ran for each rendered section of the multi-tile. Make sure to use frame for logic rather than the TileFrameX/Y values of the tile at the provided coordinates, this tile isn't placed yet. |
void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) |
hook | not here | Allows you to modify the frame of a tile after the vanilla framing code has set TileFrameX and TileFrameY. Useful for offsetting the final frame position without entirely overriding the vanilla framing logic Only called if TileFrame returns true |
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) |
hook | not here | Allows you to change the merge type of the adjacent tiles before TileFrameX and 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 ChecksForMerge in combination with TileMergeAttempt to set the adjacent tile's merge type to -2 Only called if TileFrame returns true |
bool AutoSelect(int i, int j, Item item) |
hook | not here | 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. |
void ChangeWaterfallStyle(ref int style) |
hook | not here | Allows you to change the style of waterfall that passes through or over this type of tile. |
void PostSetupTileMerge() |
hook | not here | Can be used to adjust tile merge related things that are not possible to do in SetStaticDefaults due to timing. |
void OnTileConverted(int i, int j, int fromType, int toType, int conversionType) |
hook | not here | Called when this tile has been converted to another tile type via biome conversion. Check fromType and toType to see the tile types the tile changed between. For ModTile, this will be called when converting both to and from the tile. conversionType is a BiomeConversionID (or Type). |
abstract class Terraria.ModLoader.ModTileEntity : ModType
Tile Entities are Entities tightly coupled with tiles, allowing the possibility of tiles to exhibit cool behavior. Update is called in SP and on Server, not on Clients. Modded tile entities update by default when they override Update. Set RequiresUpdates in the constructor to override this behavior.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Type |
property | same | The numeric type used to identify this kind of tile entity. |
int ID |
property | only here | Its number in the world. |
Point16 Position |
property | only here | The top left tile. |
bool RequiresUpdates |
property | only here | Whether Update runs. |
new ModTileEntity() |
constructor | same | Creates an instance. |
int CountInWorld() |
static method | same | Returns the number of modded tile entities that exist in the world currently being played. |
int Place(int i, int j) |
method | same | A helper method that places this kind of tile entity in the given coordinates for you. |
void Kill(int i, int j) |
method | same | A helper method that removes this kind of tile entity from the given coordinates for you. This is typically used in KillMultiTile. |
int Find(int i, int j) |
method | same | Returns the entity ID of this kind of tile entity at the given coordinates for you. |
bool IsTileValidForEntity(int x, int y) |
hook | same | Whether or not this tile entity is allowed to survive at the given coordinates. You should check whether the tile is active, as well as the tile's type and optionally the frame: Tile tile = Main.tile[x, y]; return tile.HasTile && tile.TileType == ModContent.TileType(); This will be called during world loading and placing the entity on the server. It will not be automatically called when the host tile is killed, so using KillMultiTile to Kill this entity is necessary to ensure the tile entity doesn't mistakenly persist without the host tile.
|
int Hook_AfterPlacement(int i, int j, int type, int style, int direction, int alternate) |
hook | same | This method does not get called by tModLoader, and is only included for you convenience so you do not have to cast the result of Mod.GetTileEntity. |
PlacementHook Generic_HookPostPlaceMyPlayer |
property | same | A generic PlacementHook that should work for the HookPostPlaceMyPlayer of any typical ModTileEntity. Will result in this ModTileEntity being placed in the top left corner of the multitile. |
int Generic_Hook_AfterPlacement(int i, int j, int type, int style, int direction, int alternate) |
method | same | A generic implementation of Hook_AfterPlacement that should work for the HookPostPlaceMyPlayer of any typical ModTileEntity. Will result in this ModTileEntity being placed in the top left corner of the multitile. Use Generic_HookPostPlaceMyPlayer directly or pair this with -1, 0, true as the remaining parameters of PlacementHook. |
void NetPlaceEntityAttempt(int x, int y) |
hook | same | You should never use this. It is only included here for completion's sake. |
void Update() |
hook | only here | Runs each tick on the host. |
void OnNetPlace() |
hook | same | Code that should be run when this tile entity is placed by means of server-syncing. Called on Server only. |
void PreGlobalUpdate() |
hook | same | Code that should be run before all tile entities in the world update. |
void PostGlobalUpdate() |
hook | same | Code that should be run after all tile entities in the world update. |
void OnKill() |
hook | same | This method only gets called in the Kill method. If you plan to use that, you can put code here to make things happen when it is called. |
void SaveData(TagCompound tag) |
hook | only here | Allows you to save custom data for this tile entity. NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization. NOTE: Try to only save data that isn't default values. |
void LoadData(TagCompound tag) |
hook | only here | Allows you to load custom data that you have saved for this tile entity. Try to write defensive loading code that won't crash if something's missing. |
void NetSend(BinaryWriter writer) |
hook | same | Allows you to send custom data for this tile entity between client and server, which will be handled in NetReceive. Called while sending tile data (!lightSend) and when TileEntitySharing is sent (lightSend). Only called on the server. |
void NetReceive(BinaryReader reader) |
hook | same | Receives custom data sent in the NetSend hook. Called while receiving tile data (!lightReceive) and when TileEntitySharing is received (lightReceive). Note that this is called on a new instance that will replace the existing instance at the Position, if any. ID is not necessarily assigned yet when this is called. Only called on the client. |
int NumVanilla |
static field | not here | Internal here. |
ModTileEntity ConstructFromType(int type) |
static method | not here | Returns a new ModTileEntity with the same class, mod, name, and type as the ModTileEntity with the given type. It is very rare that you should have to use this. |
ModTileEntity ConstructFromBase(ModTileEntity tileEntity) |
static method | not here | Returns a new ModTileEntity with the same class, mod, name, and type as the parameter. It is very rare that you should have to use this. |
abstract class Terraria.ModLoader.ModTree : ITree
This class represents a type of modded tree. The tree will share a tile ID with the vanilla trees (5), so that the trees can freely convert between each other if the soil below is converted. This class encapsulates several functions that distinguish each type of tree from each other.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int PlantTileId |
property | same | The tree will share a tile ID with the vanilla trees (5), so that the trees can freely convert between each other if the soil below is converted. |
int VanillaStyleCount |
const | same | |
int VanillaCount |
property | same | How many trees the game has. |
int VanillaTopTextureCount |
const | same | |
TreePaintingSettings TreeShaderSettings |
hook | same | How the tree takes paint. |
int[] GrowsOnTileId |
property | same | The tiles it grows on. |
void SetStaticDefaults() |
hook | same | Sets GrowsOnTileId. |
Asset<Texture2D> GetTexture() |
hook | same | The tree texture. |
TreeTypes CountsAsTreeType |
hook | same | Used mostly for vanilla tree shake loot tables Defaults to Custom. Set to None to prevent the tree from being able to be shaken. |
int CreateDust() |
hook | same | Return the type of dust created when this tree is destroyed. Returns 7 by default. |
int TreeLeaf() |
hook | same | Return the type of gore created when the tree grow, being shook and falling leaves on windy days, returns -1 by default |
bool Shake(int x, int y, ref bool createLeaves) |
hook | same | Executed on tree shake, return false to skip vanilla tree shake drops. The x and y coordinates correspond to the top of the tree, where items usually spawn. |
bool CanDropAcorn() |
hook | same | Whether or not this tree can drop acorns. Returns true by default. |
int SaplingGrowthType(ref int style) |
hook | same | Defines the sapling that can eventually grow into a tree. The type of the sapling should be returned here. Returns 20 and style 0 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. |
int DropWood() |
hook | same | The ID of the item that is dropped in bulk when this tree is destroyed. |
void SetTreeFoliageSettings(int i, int j, Tile tile, int xoffset, ref int treeFrame, int floorY, ref int topTextureFrameWidth, ref int topTextureFrameHeight) |
hook | same | Allows customization of various tree foliage drawing parameters. These control how leafy branches and the tree top are drawn at the i and j coordinates. treeFrame indicates which option for tree top or branch will be drawn. Hallow trees use this to provide many more options (various colors) than the default 3 options by adjusting based on i. floorY is the y tile coordinate of the tile this tree is grown on. topTextureFrameWidth and topTextureFrameHeight dictate the size of the sprite for the tree top. The tree top will be drawn centered above the top tile of the tree. These default to 80 and should be consistent between each tree top option. Branches are 40x40 and are not customizable. xoffset will be 0 for tree tops, 1 for a left branch, and -1 for a right branch. Can be combined with i and floorY to calculate the coordinates of the tile this tree is grown on. |
Asset<Texture2D> GetTopTextures() |
hook | same | Return the texture containing the possible tree tops that can be drawn above this tree. The framing was determined under SetTreeFoliageSettings |
Asset<Texture2D> GetBranchTextures() |
hook | same | Return the texture containing the possible tree branches that can be drawn next to this tree. The framing was determined under SetTreeFoliageSettings |
abstract class Terraria.ModLoader.ModUndergroundBackgroundStyle : ModBackgroundStyle
Each background style determines in its own way how exactly the background is drawn. This class serves as a collection of functions for underground backgrounds.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void FillTextureArray(int[] textureSlots) |
hook | same | Allows you to determine which textures make up the background by assigning their background slots/IDs to the given array. BackgroundTextureLoader.GetBackgroundSlot may be useful here. Index 0 is the texture on the border of the ground and sky layers. Index 1 is the texture drawn between rock and ground layers. Index 2 is the texture on the border of ground and rock layers. Index 3 is the texture drawn in the rock layer. The border images are 160x16 pixels, and the others are 160x96, but it seems like the right 32 pixels of each is a duplicate of the far left 32 pixels. |
abstract class Terraria.ModLoader.ModWall : ModBlockType
This class represents a type of wall that can be added by a mod. Only one instance of this class will ever exist for each type of wall that is added. Any hooks that are called will be called by the instance corresponding to the wall type. The Wall Guide teaches the basics of making a modded wall.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
string LocalizationCategory |
override | same | The folder of this content in the localization files. |
void AddMapEntry(Color color, LocalizedText name) |
method | same | Adds an entry to the minimap for this wall with the given color and display name. This should be called in SetDefaults. |
void AddMapEntry(Color color, LocalizedText name, Func<string, int, int, string> nameFunc) |
method | same | 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. |
void RegisterItemDrop(int itemType) |
method | same | Manually registers the item to drop for this wall. Only necessary if there is no item which places this wall, such as with unsafe walls dropping safe variants. Otherwise, the item placing this wall will be dropped automatically. Use Drop to conditionally prevent or change drops. |
bool Drop(int i, int j, ref int type) |
hook | same | Allows you to customize which items the wall at the given coordinates drops. Return false to stop the game from dropping the tile's default item (the type parameter). Returns true by default. The type passed in is the item type of the loaded item with createWall matching the type of this Wall. If RegisterItemDrop was used, that item will be passed in instead. |
bool CanBeTeleportedTo(int i, int j, Player player, string context) |
hook | same | Whether teleports may land on this wall. |
void KillWall(int i, int j, ref bool fail) |
hook | same | Allows you to determine what happens when the tile at the given coordinates is killed or hit with a hammer. Fail determines whether the tile is mined (whether it is killed). |
void AnimateWall(ref byte frame, ref byte frameCounter) |
hook | same | Allows you to animate your wall. Use frameCounter to keep track of how long the current frame has been active, and use frame to change the current frame. Walls are drawn every 4 frames. |
bool WallFrame(int i, int j, bool randomizeFrame, ref int style, ref int frameNumber) |
hook | same | Called whenever this wall updates due to being placed or being next to a wall that is changed. Return false to stop the game from carrying out its default WallFrame operations. If you return false, make sure to set WallFrameNumber, WallFrameX, and WallFrameY according to the your desired custom framing design. Returns true by default. |
void OnWallConverted(int i, int j, int fromType, int toType, int conversionType) |
hook | same | Called when this wall has been converted to another wall type via biome conversion. Check fromType and toType to see the wall types the wall changed between. For ModWall, this will be called when converting both to and from the wall. conversionType is a BiomeConversionID (or Type). |
abstract class Terraria.ModLoader.ModWaterStyle : ModTexturedType
Represents a style of water that gets drawn, based on factors such as the background. This is used to determine the color of the water, as well as other things as determined by the hooks below.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Slot |
property | same | The ID of the water style. |
string BlockTexture |
hook | same | The texture of the water block. |
string SlopeTexture |
hook | same | The texture of the water slope. |
int ChooseWaterfallStyle() |
hook | same | The ID of the waterfall style the game should use when this water style is in use. |
int GetSplashDust() |
hook | same | The ID of the dust that is created when anything splashes in water. |
int GetDropletGore() |
hook | same | The ID of the gore that represents droplets of water falling down from a block. Return WaterDrip (or another existing droplet gore) or make a custom ModGore that uses LiquidDroplet. |
void LightColorMultiplier(ref float r, ref float g, ref float b) |
hook | same | Allows you to modify the light levels of the tiles behind the water. The light color components will be multiplied by the parameters. |
Color BiomeHairColor() |
hook | same | Allows you to change the hair color resulting from the biome hair dye when this water style is in use. |
Asset<Texture2D> GetRainTexture() |
hook | same | Returns the texture to be used when drawing rain of this water type. Default uses the vanilla rain texture. |
byte GetRainVariant() |
hook | same | Return the variant of rain used. Equal to the offset in the rain texture divided by four. Vanilla rain has three variants per biome, and so vanilla variants range from 0 to 3 * Main.maxLiquidTextures. Default is a random number from 0 to 2, which creates normal vanilla forest biome rain. |
abstract class Terraria.ModLoader.ModWaterfallStyle : ModTexturedType
Represents a style of waterfalls that gets drawn. This is mostly used to determine the color of the waterfall.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int Slot |
property | same | The ID of this waterfall style. |
void AddLight(int i, int j) |
hook | same | Allows you to create light at a tile occupied by a waterfall of this style. |
void ColorMultiplier(ref float r, ref float g, ref float b, float a) |
hook | same | Allows you to determine the color multiplier acting on waterfalls of this style. Useful for waterfalls whose colors change over time. |
static class Terraria.ModLoader.PlantLoader
Finds which tree, palm tree or cactus of a mod grows on a ground.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
T Get<T>(int plantTileID, int growsOnTileID) |
static method | same | The plant of a kind that grows on a ground. |
bool Exists(int plantTileID, int growsOnTileID) |
static method | same | Whether there is one. |
Asset<Texture2D> GetCactusFruitTexture(int type) |
static method | same | The fruit texture of a cactus. |
Asset<Texture2D> GetTexture(int plantId, int tileType) |
static method | not here | Internal here. |
ITree GetTree(int type) |
static method | not here | Internal here. |
TreeTypes GetModTreeType(int type) |
static method | not here | Internal here. |
bool ShakeTree(int x, int y, int type, ref bool createLeaves) |
static method | not here | Internal here. |
void GetTreeLeaf(int type, ref int leafGoreType) |
static method | not here | Internal here. |
void CheckAndInjectModSapling(int x, int y, ref int tileToCreate, ref int previewPlaceStyle) |
static method | not here | Internal here. |
struct Terraria.GameContent.PressurePlateHelper
Tells which pressure plates are being stepped on.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool IsPressed(Point location) |
static method | only here | Whether a pressure plate is being stepped on. |
static class Terraria.ModLoader.PylonLoader
Runs the hooks of GlobalPylon and of mod pylons.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
TeleportPylonType VanillaPylonCount |
static field | same | How many exist, with the game's and every mod's. |
ModPylon GetModPylon(TeleportPylonType pylonType) |
static method | same | Returns the ModPylon associated with the passed in type. Returns null on failure. |
bool PreCanPlacePylon(int x, int y, int tileType, TeleportPylonType pylonType) |
static method | same | Called right before both modded and vanilla pylons determine whether or not they can be placed. Returning false will prevent vanilla checks from taking place, forcefully preventing the pylon from being placed. Returning null will enact vanilla behavior, and returning true will make the check forcefully succeed, regardless of vanilla behavior. Returns null by default. |
bool ValidTeleportCheck_PreNPCCount(TeleportPylonInfo pylonInfo, ref int defaultNecessaryNPCCount) |
static method | same | Called before Step 1 of the ValidTeleportCheck process. This is the first vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their NPC requirements, and returning false will prevent those checks from taking place, forcefully failing the NPCCount step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default. |
bool ValidTeleportCheck_PreBiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) |
static method | same | Called before Step 2 of the ValidTeleportCheck process. This is the third vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their Biome requirements, and returning false will prevent those checks from taking place, forcefully failing the BiomeRequirements step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default. |
void PostValidTeleportCheck(TeleportPylonInfo destinationPylonInfo, TeleportPylonInfo nearbyPylonInfo, ref bool destinationPylonValid, ref bool validNearbyPylonFound, ref string errorKey) |
static method | same | Called after all checks have taken place for all vanilla and modded pylons when a teleportation request is sent (AKA when the player clicks on a pylon on the map). You can (for example) use this to allow teleportation to go through even if one the normal requirements haven't been met, or vice versa; to do this, change destinationPylonValid to true or false respectively (for the given example). |
tModLoader's PylonLoader also has 1 public methods that only run the hooks of the same name. Here those runners are internal. Override the hook in your class instead.
static class Terraria.ModLoader.SceneEffectLoader
This serves as the central class from which SceneEffect functions are supported and carried out.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int VanillaSceneEffectCount |
const | same | How many exist, with the game's and every mod's. |
int Count |
static property | only here | How many exist, with the game's and every mod's. |
void UpdateSceneEffect(Player player) |
static method | same | Picks the scene that applies to the player. |
void UpdateMusic(ref int music, ref SceneEffectPriority priority) |
static method | same | Applies the scene's music, if it has priority. |
void ChooseStyle(out int style, out SceneEffectPriority priority) |
hook | not here | Internal here. |
class Terraria.ModLoader.SceneEffectLoader.SceneEffectInstance
The scene the player is in now: music, water, backgrounds, each with a priority.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool anyActive |
field | same | Whether any scene applies. |
PrioritizedPair waterStyle |
field | same | The winning water style. |
PrioritizedPair undergroundBackground |
field | same | The winning underground background. |
PrioritizedPair surfaceBackground |
field | same | The winning surface background. |
PrioritizedPair music |
field | same | The winning music. |
string mapBackground |
field | same | The winning map background. |
ModSceneEffect mapBackgroundSceneEffect |
field | same | The scene that gave it. |
PrioritizedPair biomeTorchItemType |
field | same | The winning torch. |
PrioritizedPair biomeCampfireItemType |
field | same | The winning campfire. |
TileColorStyle tileColorStyle |
field | same | The winning tile color. |
new SceneEffectInstance() |
constructor | same | Creates an instance. |
struct Terraria.ModLoader.SceneEffectLoader.SceneEffectInstance.PrioritizedPair
A value and the priority that chose it.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
PrioritizedPair Default |
static field | same | No value yet. |
int value |
field | same | The value. |
SceneEffectPriority priority |
field | same | The priority it won with. |
enum Terraria.ModLoader.SceneEffectPriority
This enum dictates from low to high which SceneEffect selections take priority. Setting appropriate priority values is important so that your mod works well with other mods and vanilla selections.
Values: None, BiomeLow, BiomeMedium, BiomeHigh, Environment, Event, BossLow, BossMedium, BossHigh
static class Terraria.ModLoader.SubworldLoader · only in Bunny Loader
Travels between the main world and the dimensions: Enter, Exit, Current. In multiplayer the host asks every player first.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
IReadOnlyList<ModSubworld> Subworlds |
static property | only here | Every registered dimension. |
ModSubworld Current |
static property | only here | The active dimension, null in the main world. |
bool InSubworld |
static property | only here | Whether a dimension is active. |
bool Traveling |
static property | only here | From Enter until the player is in the new world and its transition is over. |
bool IsActive<T>() |
static method | only here | Whether that dimension is the active one. |
bool Enter<T>() |
static method | only here | Starts the trip, or the vote in multiplayer. false on a client, while traveling or when already there. |
bool Enter(ModSubworld subworld) |
static method | only here | Starts the trip, or the vote in multiplayer. false on a client, while traveling or when already there. |
bool Exit() |
static method | only here | Back to the main world. The host's alone in multiplayer. |
abstract class Terraria.ModLoader.Default.TEModdedPylon : ModTileEntity
This is a TML provided Tile Entity that acts extremely similar to vanilla's pylon TEs by default. If you plan to make a pylon tile in any capacity, you must extend this TE at least once.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void NetPlaceEntityAttempt(int x, int y) |
override | same | Places the entity on the host, or takes the tile back. |
bool TryGetModPylon(out ModPylon modPylon) |
method | same | Its ModPylon. |
int Place(int i, int j) |
method | same | Places it and updates the pylon list. |
void Kill(int x, int y) |
method | same | Removes it and updates the pylon list. |
string ToString() |
override | same | The text form of this value. |
bool IsTileValidForEntity(int x, int y) |
override | same | Whether this tile is a pylon's top left. |
int Hook_AfterPlacement(int i, int j, int type, int style, int direction, int alternate) |
override | same | Places the entity after the tile. |
int PlacementPreviewHook_CheckIfCanPlace(int x, int y, int type, int style, int direction, int alternate) |
method | same | Whether a pylon may be placed. |
bool GetModPylonFromCoords(int x, int y, out ModPylon modPylon) |
static method | same | The ModPylon at a position. |
struct Terraria.GameContent.TeleportPylonInfo
A pylon in the world: its position and type.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ModPylon ModPylon |
property | same | Its ModPylon, or null for a pylon of the game. |
struct Terraria.Tile
A data structure used for accessing information about tiles, walls, wires, and liquids at a single position in the world. Vanilla tile code and a mods tile code will be quite different, since tModLoader reworked how tiles function to improve performance. This means that copying vanilla code will leave you with many errors. Running the code through tModPorter will fix most of the issues, however. For your sanity, all of the changes are well documented to make it easier to port vanilla code.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
SlopeType Slope |
property | same | The slope shape of the tile, which can be changed by hammering. Used by SlopeTile and BlockType. Legacy/vanilla equivalent is slope or slope. |
BlockType BlockType |
property | same | The Slope and IsHalfBlock of this tile combined, which can be changed by hammering. Legacy/vanilla equivalent is blockType. |
bool IsHalfBlock |
property | same | Whether a tile is a half block shape, which can be changed by hammering. Used by PoundTile and BlockType. Legacy/vanilla equivalent is halfBrick or halfBrick. |
byte TileColor |
property | same | The PaintID the tile at this position is painted with. Is None if not painted. Legacy/vanilla equivalent is color or color. |
byte WallColor |
property | same | The PaintID the wall at this position is painted with. Is None if not painted. Legacy/vanilla equivalent is wallColor or wallColor. |
int TileFrameNumber |
property | same | The random style number the tile at this position has, which is random number between 0 and 2 (inclusive). This is used in non-tileFrameImportant tiles (aka "Terrain" tiles) to provide visual variation and is not synced in multiplayer nor will it be preserved when saving and loading the world. Legacy/vanilla equivalent is frameNumber or frameNumber. |
bool SkipLiquid |
property | same | Whether the liquid at this position should skip updating for 1 tick. Legacy/vanilla equivalent is skipLiquid or skipLiquid. |
bool CheckingLiquid |
property | same | Whether there is liquid at this position. Legacy/vanilla equivalent is checkingLiquid or checkingLiquid. |
bool RedWire |
property | same | Whether there is red wire at this position. Legacy/vanilla equivalent is wire or wire. |
bool BlueWire |
property | same | Whether there is blue wire at this position. Legacy/vanilla equivalent is wire2 or wire2. |
bool GreenWire |
property | same | Whether there is green wire at this position. Legacy/vanilla equivalent is wire3 or wire3. |
bool YellowWire |
property | same | Whether there is yellow wire at this position. Legacy/vanilla equivalent is wire4 or wire4. |
bool HasWire |
property | same | Whether there is any wire at this position. Legacy/vanilla equivalent is anyWire. |
bool IsTileInvisible |
property | same | Whether the tile at this position is invisible. Used by EchoCoating. Legacy/vanilla equivalent is invisibleBlock or invisibleBlock. |
bool IsWallInvisible |
property | same | Whether the wall at this position is invisible. Used by EchoCoating. Legacy/vanilla equivalent is invisibleWall or invisibleWall. |
bool IsTileFullbright |
property | same | Whether the tile at this position is fully illuminated. Used by GlowPaint. Legacy/vanilla equivalent is fullbrightBlock or fullbrightBlock. |
bool IsWallFullbright |
property | same | Whether the wall at this position is fully illuminated. Used by GlowPaint. Legacy/vanilla equivalent is fullbrightWall or fullbrightWall. |
byte LiquidAmount |
property | differs | The amount of liquid at this position. Ranges from 0, no liquid, to 255, filled with liquid. Legacy/vanilla equivalent is liquid. tML: ref byte LiquidAmount
|
int LiquidType |
property | same | The LiquidID of the liquid at this position. Make sure to check that LiquidAmount is greater than 0. Legacy/vanilla equivalent is liquidType or liquidType. |
ushort TileType |
property | differs | The TileID of the tile at this position. This value is only valid if HasTile is true. Legacy/vanilla equivalent is type. tML: ref ushort TileType
|
short TileFrameX |
property | differs | The X coordinate of the top left corner of the area in the spritesheet for the TileType to be used to draw the tile at this position. For a Framed tile, this value is set automatically according to the framing logic as the world loads or other tiles are placed or mined nearby. See Framed vs FrameImportant for more info. For tileFrameImportant tiles, this value will not change due to tile framing and will be saved and synced in Multiplayer. In either case, TileFrameX and TileFrameY correspond to the coordinates of the top left corner of the area in the spritesheet corresponding to the TileType that should be drawn at this position. Custom drawing logic can adjust these values. Some tiles such as Christmas Tree and Weapon Rack use the higher bits of these fields to do tile-specific behaviors. Modders should not attempt to do similar approaches, but should use ModTileEntitys. Legacy/vanilla equivalent is frameX. tML: ref short TileFrameX
|
short TileFrameY |
property | differs | The Y coordinate of the top left corner of the area in the spritesheet for the TileType to be used to draw the tile at this position. For a Framed tile, this value is set automatically according to the framing logic as the world loads or other tiles are placed or mined nearby. See Framed vs FrameImportant for more info. For tileFrameImportant tiles, this value will not change due to tile framing and will be saved and synced in Multiplayer. In either case, TileFrameX and TileFrameY correspond to the coordinates of the top left corner of the area in the spritesheet corresponding to the TileType that should be drawn at this position. Custom drawing logic can adjust these values. Some tiles such as Christmas Tree and Weapon Rack use the higher bits of these fields to do tile-specific behaviors. Modders should not attempt to do similar approaches, but should use ModTileEntitys. Legacy/vanilla equivalent is frameY. tML: ref short TileFrameY
|
ushort WallType |
property | differs | The WallID of the wall at this position. A value of 0 indicates no wall. Legacy/vanilla equivalent is wall. tML: ref ushort WallType
|
int WallFrameX |
property | same | The X coordinate of the top left corner of the area in the spritesheet for the WallType to be used to draw the wall at this position. Legacy/vanilla equivalent is wallFrameX or wallFrameX. |
int WallFrameY |
property | same | The Y coordinate of the top left corner of the area in the spritesheet for the WallType to be used to draw the wall at this position. Legacy/vanilla equivalent is wallFrameY or wallFrameY. |
int WallFrameNumber |
property | same | The random style number the wall at this position has, which is a random number between 0 and 2 (inclusive). This is used to provide visual variation and is not synced in multiplayer nor will it be preserved when saving and loading the world. Legacy/vanilla equivalent is wallFrameNumber or wallFrameNumber. |
bool HasTile |
property | same | Whether there is a tile at this position. Check this whenever you are accessing data from a tile to avoid getting data from an empty tile. Legacy/vanilla equivalent is active or active. |
bool TopSlope |
property | same | If the top side of a tile is sloped (Slope), meaning the bottom side is solid. (SlopeDownLeft or SlopeDownRight). Legacy/vanilla equivalent is topSlope. |
bool BottomSlope |
property | same | If the bottom side of a tile is sloped (Slope), meaning the top side is solid. (SlopeUpLeft or SlopeUpRight). Legacy/vanilla equivalent is bottomSlope. |
bool LeftSlope |
property | same | If the left side of a tile is sloped (Slope), meaning the right side is solid. (SlopeDownRight or SlopeUpRight). Legacy/vanilla equivalent is leftSlope. |
bool RightSlope |
property | same | If the right side of a tile is sloped (Slope), meaning the left side is solid. (SlopeDownLeft or SlopeUpLeft). Legacy/vanilla equivalent is rightSlope. |
bool HasUnactuatedTile |
property | same | Whether there is a tile at this position that isn't actuated. Legacy/vanilla equivalent is nactive. |
bool HasActuator |
property | same | Whether there is an actuator at this position. Legacy/vanilla equivalent is actuator or actuator. |
bool IsActuated |
property | same | Whether the tile at this position is actuated by an actuator. Legacy/vanilla equivalent is inActive or inActive. |
struct Terraria.TileData · only in Bunny Loader
The tile data of the world.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ref Tile this[Point position] |
indexer | only here | Reads or writes one entry. |
class Terraria.ModLoader.Config.TileDefinition : EntityDefinition
TileDefinition represents a Tile identity.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Func<TagCompound, TileDefinition> DESERIALIZER |
static field | same | Rebuilds this value from a TagCompound. |
bool IsUnloaded |
override | same | Whether its mod is off. |
int Type |
override | same | The content ID of the content this EntityDefinition represents. Will be -1 for IsUnloaded EntityDefinition. |
new TileDefinition() |
constructor | same | Creates an instance. |
new TileDefinition(int type) |
constructor | same | Note: As ModConfig loads before other content, make sure to only use TileDefinition for modded content in ModConfig classes. |
new TileDefinition(string key) |
constructor | same | Creates an instance. |
new TileDefinition(string mod, string name) |
constructor | same | Creates an instance. |
TileDefinition FromString(string s) |
static method | same | Builds this value from its text form. |
TileDefinition Load(TagCompound tag) |
static method | same | Rebuilds the definition from a tag. |
string DisplayName |
override | same | The name shown to the player, as localized text. |
struct Terraria.GameContent.Drawing.TileDrawing
What Bunny Loader adds to the game's tile drawing.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool IsVisible(Tile tile) |
static method | same | Whether the tile shows, with coatings and Echo Sight taken into account. |
WindGrid Wind |
property | not here | The wind grid used to exert wind effects on tiles. |
bool IsTileDangerous(Player perspectivePlayer, int tileX, int tileY) |
static method | not here | Checks if a tile at the given coordinates counts towards tile coloring from the Dangersense buff. Vanilla uses Main.SceneMetrics.PerspectivePlayer for perspectivePlayer
|
struct Terraria.DataStructures.TileEntity
A tile with its own data. TileEntity.TryGet finds one by position. Mods subclass ModTileEntity.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
bool TryGet<T>(int i, int j, out T tileEntity) |
static method | same | Finds the entity of this class at a position. |
bool TryGet<T>(Point16 position, out T tileEntity) |
static method | same | Finds the entity of this class at a position. |
void SaveData(TagCompound tag) |
hook | not here | Allows you to save custom data for this tile entity. NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization. NOTE: Try to only save data that isn't default values. |
void LoadData(TagCompound tag) |
hook | not here | Allows you to load custom data that you have saved for this tile entity. Try to write defensive loading code that won't crash if something's missing. |
void NetSend(BinaryWriter writer) |
hook | not here | Allows you to send custom data for this tile entity between client and server, which will be handled in NetReceive. Called while sending tile data (!lightSend) and when TileEntitySharing is sent (lightSend). Only called on the server. |
void NetReceive(BinaryReader reader) |
hook | not here | Receives custom data sent in the NetSend hook. Called while receiving tile data (!lightReceive) and when TileEntitySharing is received (lightReceive). Note that this is called on a new instance that will replace the existing instance at the Position, if any. ID is not necessarily assigned yet when this is called. Only called on the client. |
struct Terraria.ID.TileID
Tile types. A mod tile's type comes from ModContent.TileType<T>().
| Member | Kind | tModLoader | What it does |
|---|
static class Terraria.ID.TileID.Sets
Tables indexed by tile type.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
ContentTable<FallingBlockProjectileInfo> FallingBlockProjectile |
static field | same | The projectile a falling tile becomes. |
ContentBoolTable Infectable |
static field | only here | What Corruption, Crimson and Hallow spread over. |
ContentIntTable PressurePlate |
static field | only here | The kind of a pressure plate. -1 is not one. |
int[] CountsAsPylon |
static field | only here | The tiles that are pylons. |
bool[] IsValidSpawnPoint |
static property | only here | A player may set a spawn on it. |
bool[] TreeSapling |
static property | only here | Is a sapling. |
bool[] CountsAsHoneyForCrafting |
static property | only here | Counts as honey for recipes. |
bool[] CountsAsLavaForCrafting |
static property | only here | Counts as lava for recipes. |
bool[] MultiTileSway |
static property | same | Sways in the wind as one object. |
bool[] Clock |
static property | only here | Is a clock. |
int[] OpenDoorID |
static property | only here | The tile of this door when open. |
int[] CloseDoorID |
static property | only here | The tile of this door when closed. |
class Terraria.ID.TileID.Sets.FallingBlockProjectileInfo
Used in FallingBlockProjectile.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
new FallingBlockProjectileInfo(int FallingProjectileType, int FallingProjectileDamage) |
constructor | same | Creates an instance. |
int FallingProjectileType |
property | same | The projectile. |
int FallingProjectileDamage |
property | same | Its damage. |
static class Terraria.ModLoader.TileLoader
This serves as the central class from which tile-related functions are supported and carried out.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void RegisterConversion(int tileType, int conversionType, ConvertTile conversionDelegate) |
static method | same | Registers a tile type as having custom biome conversion code for this specific BiomeConversionID. For modded tiles, you can directly use Convert If you need to register conversions that rely on Conversion being fully populated, consider doing it in PostSetupContent
|
void RegisterConversion(int tileType, int conversionType, int toType) |
static method | same | Registers a tile type as having custom biome conversion code for this specific BiomeConversionID. For modded tiles, you can directly use Convert If you need to register conversions that rely on Conversion being fully populated, consider doing it in PostSetupContent
|
void RegisterSimpleConversion(int tileType, int conversionType, int toType, bool purification) |
static method | same | Registers a conversion that replaces tileType with toType when touched by conversionType Also registers tileType as a fallback for toType so that other conversions can convert toType as if it was tileType. If you need to register conversions that rely on Conversion being fully populated, consider doing it in PostSetupContent
|
void RegisterConversionFallback(int tileType, int fallbackType, params int[] exceptForConversionTypes) |
static method | same | Sets a fallback tile type for all conversion types except those in exceptForConversionTypes When Convert is called on the tileType but there is no registsred conversion, the tile will be temporarily replaced with fallbackType and conversion will be reattempted. If the fallbackType also has no conversion, the tile remains unchanged. For example Ebonstone falls back to Stone so a modded conversion that affects Stone can convert Ebonstone without needing to register a conversion for Ebonstone directly. |
void SetConversionFallback(int tileType, int conversionType, int fallbackType) |
static method | same | Sets an individual conversion fallback. For advanced uses only. |
bool TryGetConversionFallback(int tileType, int conversionType, out int fallbackType) |
static method | same | Tries to retrieve the fallbackType corresponding to the provided tileType and conversionType See also: |
bool Convert(int i, int j, int conversionType) |
static method | same | Runs a conversion on this cell. Returns whether it changed. |
int TileCount |
static property | same | How many exist, with the game's and every mod's. |
bool CanGrowModCactus(int type) |
static method | same | Whether a mod cactus grows on this tile. |
Texture2D GetCactusTexture(int type) |
static method | same | The texture of a mod cactus. |
ModTile GetTile(int type) |
static method | same | Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null. |
void ModifySmartInteractCoords(int type, ref int width, ref int height, ref int frameWidth, ref int frameHeight, ref int extraY) |
static method | same | 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. |
string DefaultContainerName(int type, int frameX, int frameY) |
static method | same | Returns the default name for a modded chest or dresser with the provided FrameX and FrameY values. |
bool CanExplode(int i, int j) |
static method | same | 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. |
bool IsLockedChest(int i, int j, int type) |
static method | same | Return true if this Tile corresponds to a chest that is locked. Prevents Quick Stacking items into the chest. |
bool UnlockChest(int i, int j, int type, ref short frameXAdjustment, ref int dustType, ref bool manual) |
static method | same | 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. |
bool LockChest(int i, int j, int type, ref short frameXAdjustment, ref bool manual) |
static method | same | 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. |
int GetItemDropFromTypeAndStyle(int type, int style) |
static method | same | Retrieves the item type that would drop from a tile of the specified type and style. This method is only reliable for modded tile types. This method can be used in GetItemDrops for tiles that have custom tile style logic. If the specified style is not found, a fallback item will be returned if one has been registered through RegisterItemDrop usage. Modders querying modded tile drops should use GetItemDrops directly rather that use this method so that custom drop logic is accounted for. A return of 0 indicates that no item would drop from the tile. |
void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) |
static method | same | 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. |
void SetAnimationFrame(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) |
static method | same | Sets the animation frame. Sets frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type]; and then calls ModTile.AnimateIndividualTile |
int OpenDoorID(Tile tile) |
static method | same | The open version of a door tile. |
int CloseDoorID(Tile tile) |
static method | same | The closed version of a door tile. |
bool IsClosedDoor(Tile tile) |
static method | same | Whether this tile is a closed door. |
bool IsClosedDoor(int type) |
static method | same | Whether this tile is a closed door. |
void CheckModTile(int i, int j, int type) |
static method | not here | Internal here. |
bool IsModMusicBox(Tile tile) |
static method | not here | Internal here. |
void ModifyTorchLuck(Player player, ref float positiveLuck, ref float negativeLuck) |
static method | not here | Internal here. |
bool IsTileBiomeSightable(int i, int j, int type, ref Color sightColor) |
static method | not here | Internal here. |
void AnimateTiles() |
static method | not here | Internal here. |
bool PreDrawPlacementPreview(int i, int j, int type, SpriteBatch spriteBatch, ref Rectangle frame, ref Vector2 position, ref Color color, bool validPlacement, ref SpriteEffects spriteEffects) |
static method | not here | Internal here. |
void PostDrawPlacementPreview(int i, int j, int type, SpriteBatch spriteBatch, Rectangle frame, Vector2 position, Color color, bool validPlacement, SpriteEffects spriteEffects) |
static method | not here | Internal here. |
bool GrowModSapling(int i, int j, int type, bool underground, int treeHeightAddon, bool ignoreWalls) |
static method | not here | Internal here. |
void PostTileFrame(int type, int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) |
static method | not here | Internal here. |
void ModifyFrameMerge(int type, 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) |
static method | not here | Internal here. |
void PickPowerCheck(Tile target, int pickPower, ref int damage) |
static method | not here | Internal here. |
int AutoSelect(int i, int j, Player player) |
static method | not here | Internal here. |
void ChangeWaterfallStyle(int type, ref int style) |
static method | not here | Internal here. |
bool SaplingGrowthType(int soilType, ref int saplingType, ref int style) |
static method | not here | Internal here. |
bool CanGrowModTree(int type) |
static method | not here | Internal here. |
void TreeDust(Tile tile, ref int dust) |
static method | not here | Internal here. |
bool CanDropAcorn(int type) |
static method | not here | Internal here. |
void DropTreeWood(int type, ref int wood) |
static method | not here | Internal here. |
bool CanGrowModPalmTree(int type) |
static method | not here | Internal here. |
void PalmTreeDust(Tile tile, ref int dust) |
static method | not here | Internal here. |
void DropPalmTreeWood(int type, ref int wood) |
static method | not here | Internal here. |
void PostSetupTileMerge() |
static method | not here | Internal here. |
void RecountTiles(SceneMetrics metrics) |
static method | not here | Internal here. |
bool GlobalShakeTree(int x, int y, TreeTypes treeType) |
static method | not here | Internal here. |
tModLoader's TileLoader also has 41 public methods that only run the hooks of the same name. Here those runners are internal. Override the hook in your class instead.
struct Terraria.ObjectData.TileObjectData
The layout of a multi-tile object: size, anchors, styles. Fill TileObjectData.newTile in SetStaticDefaults.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int GetTileStyle(Tile getTile) |
static method | same | Retrieves the tile style corresponding to the passed in Tile. Empty tiles and terrain tiles will return -1. Any Tile of the multitile works. This is most useful in replacing hard-coded math where the tile style is calculated from TileFrameX and TileFrameY directly, such as mouse over icons and other tile style specific behaviors. Other related methods include GetTileData, GetTileData, and GetTileInfo. |
Point16 TopLeft(int i, int j) |
static method | same | The top left tile of the object at a position. |
Point16 TopLeft(Point16 position) |
static method | same | The top left tile of the object at a position. |
bool IsTopLeft(Tile tile) |
static method | same | Returns true if the Tile provided has a placed tile and is the top left tile of a multitile (supports alternate placements and states as well). Returns false otherwise. Can be used for logic that should only run once per multitile, such as custom tile rendering. |
bool IsTopLeft(int i, int j) |
static method | same | Returns true if the Tile at the location provided has a placed tile and is the top left tile of a multitile (supports alternate placements and states as well). Returns false otherwise. Can be used for logic that should only run once per multitile, such as custom tile rendering. |
int[] CoordinateHeights |
property | same | The pixel height of each row. |
void FixNewTile() |
static method | not here | Internal here. |
void GetTileInfo(Tile getTile, ref int style, ref int alternate) |
static method | not here | Retrieves the tile style and alternate placement corresponding to the passed in Tile. Empty tiles and terrain tiles will return without setting the ref parameters. Any Tile of the multitile works. Other related methods include GetTileData, GetTileData, and GetTileStyle. |
struct Terraria.DataStructures.TileRestingInfo
Holds data required for offsetting an entity when it rests on a tile (sitting/sleeping).
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
Entity RestingEntity |
field | same | The resting entity (Player or NPC). Can be null if not available from the context. |
Point AnchorTilePosition |
field | same | The bottom-most position of the resting tile in tile coordinates, affecting logic for resetting (invalid) resting state and used to align the hitbox. |
Vector2 VisualOffset |
field | same | The visual offset of the entity, not affecting any logic. |
int TargetDirection |
field | same | Direction the entity is facing while resting. Is 0 by default for beds. |
int DirectionOffset |
field | same | Length of the entity position offset applied in the X direction based on targetDirection. |
Vector2 FinalOffset |
field | same | Offset applied to the final anchor position. Use with caution, vanilla does not utilize it! |
ExtraSeatInfo ExtraInfo |
field | same | Contains additional information, such as IsAToilet. |
new TileRestingInfo(Entity restingEntity, Point anchorTilePosition, Vector2 visualOffset, int targetDirection, int directionOffset, Vector2 finalOffset, ExtraSeatInfo extraInfo) |
constructor | same | Creates an instance. |
void Deconstruct(out Entity restingEntity, out Point anchorTilePosition, out Vector2 visualOffset, out int targetDirection, out int directionOffset, out Vector2 finalOffset, out ExtraSeatInfo extraInfo) |
method | same | Takes the value apart in a var (a, b) = value assignment. |
static class Terraria.ModLoader.WallLoader
This serves as the central class from which wall-related functions are supported and carried out.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void RegisterConversion(int wallType, int conversionType, ConvertWall conversionDelegate) |
static method | same | Registers a wall type as having custom biome conversion code for this specific BiomeConversionID. For modded walls, you can directly use Convert If you need to register conversions that rely on Conversion being fully populated, consider doing it in PostSetupContent
|
void RegisterConversion(int wallType, int conversionType, int toType) |
static method | same | Registers a wall type as having custom biome conversion code for this specific BiomeConversionID. For modded walls, you can directly use Convert If you need to register conversions that rely on Conversion being fully populated, consider doing it in PostSetupContent
|
void RegisterSimpleConversion(int wallType, int conversionType, int toType, bool purification) |
static method | same | Registers a conversion that replaces wallType with toType when touched by conversionType Also registers wallType as a fallback for toType so that other conversions can convert toType as if it was wallType. If you need to register conversions that rely on Conversion being fully populated, consider doing it in PostSetupContent
|
void RegisterConversionFallback(int wallType, int fallbackType, params int[] exceptForConversionTypes) |
static method | same | Sets a fallback wall type for all conversion types except those in exceptForConversionTypes When Convert is called on the wallType but there is no registsred conversion, the tile will be temporarily replaced with fallbackType and conversion will be reattempted. If the fallbackType also has no conversion, the tile remains unchanged. For example EbonstoneUnsafe falls back to Stone so a modded conversion that affects Stone can convert Ebonstone without needing to register a conversion for Ebonstone directly. |
void SetConversionFallback(int wallType, int conversionType, int fallbackType) |
static method | same | Sets an individual conversion fallback. For advanced uses only. |
bool TryGetConversionFallback(int wallType, int conversionType, out int fallbackType) |
static method | same | Tries to retrieve the fallbackType corresponding to the provided wallType and conversionType See also: |
bool Convert(int i, int j, int conversionType) |
static method | same | Allows you to change what happens when this tile/wall is converted into another biome. If you need to override or add a new conversion to a vanilla tile, use RegisterConversion and RegisterConversion. Purification powder uses a separate conversionType, as it doesn't convert hallowed tiles back to purity tiles. Be sure to check for PurificationPowder as well as Purity when handling corruption/crimson tiles. You can use ConvertTile or ConvertWall to automatically handle tile framing and multiplayer syncing. |
int WallCount |
static property | same | How many exist, with the game's and every mod's. |
ModWall GetWall(int type) |
static method | same | Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null. |
bool CanExplode(int i, int j, int type) |
static method | same | 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. |
void AnimateWalls() |
static method | not here | Internal here. |
tModLoader's WallLoader also has 14 public methods that only run the hooks of the same name. Here those runners are internal. Override the hook in your class instead.
static class Terraria.ModLoader.WaterFallStylesLoader
Registers mod waterfall styles.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int VanillaCount |
const | only here | How many exist, with the game's and every mod's. |
int TotalCount |
static property | only here | How many exist, with the game's and every mod's. |
ModWaterfallStyle Get(int type) |
static method | only here | The style of a number, or null. |
static class Terraria.ModLoader.WaterStylesLoader
Registers mod water styles.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
int VanillaCount |
const | only here | How many exist, with the game's and every mod's. |
int TotalCount |
static property | only here | How many exist, with the game's and every mod's. |
ModWaterStyle Get(int type) |
static method | only here | The style of a number, or null. |
void LightColorMultiplier(int style, float factor, ref float r, ref float g, ref float b) |
static method | same | Runs the style's light hook. |
void UpdateLiquidAlphas() |
method | not here | Internal here. |
void DrawWaterfall(WaterfallManager waterfallManager) |
method | not here | Internal here. |
struct Terraria.WorldGen
What Bunny Loader adds to the game's world generation.
| Member | Kind | tModLoader | What it does |
|---|---|---|---|
void SpreadInfectionToNearbyTile(int x, int y, int conversionType, int range) |
static method | same | Utility method that mimics vanilla behavior for biome spread in hardmode. Call this in RandomUpdate to let your infectious tiles spread around Automatically checks for the journey mode biome spread toggle, hardmode, spread speed decrease after plantera, chlorophyte protection and sunflower protection. |
void ConvertTile(int i, int j, int newType) |
static method | same | Converts the single tile at the given coordinate into a specified new tile type Automatically handles tile framing and multiplayer syncing. |
void ConvertWall(int i, int j, int newType) |
static method | same | Converts the single wall at the given coordinate into a specified new wall type Automatically handles wall framing and multiplayer syncing. |
delegate Terraria.GameContent.Generation.WorldGenLegacyMethod
The body of a PassLegacy.
| Member | Kind | tModLoader | What it does |
|---|
Bunny Loader wiki ·
Discord ·
Repository ·
BL Editor
Written for Bunny Loader 0.5.5-beta and Terraria Mobile 1.4.5.8.6.
Bunny Loader is not affiliated with Re-Logic or 505 Games.
