tModLoader v2022.09
A mod to make and play Terraria mods
Terraria.ModLoader.ModPylon Class Reference

Extension to

See also
ModTile

that streamlines the process of creating a modded Pylon. Has all of ModTile's hooks for customization, but additional hooks for Pylon functionality. More...

Inherits Terraria.ModLoader.ModTile.

Public Member Functions

virtual bool CanPlacePylon ()
 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. More...
 
bool DefaultDrawMapIcon (ref MapOverlayDrawContext context, Asset< Texture2D > mapIcon, Vector2 drawCenter, Color drawColor, float deselectedScale, float selectedScale)
 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. More...
 
void DefaultDrawPylonCrystal (SpriteBatch spriteBatch, int i, int j, Asset< Texture2D > crystalTexture, Asset< Texture2D > crystalHighlightTexture, Vector2 crystalOffset, Color pylonShadowColor, Color dustColor, int dustChanceDenominator, int crystalVerticalFrameCount)
 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. More...
 
void DefaultDrawPylonCrystal (SpriteBatch spriteBatch, int i, int j, Asset< Texture2D > crystalTexture, Color crystalDrawColor, int frameHeight, int crystalHorizontalFrameCount, int crystalVerticalFrameCount)
 
void DefaultMapClickHandle (bool mouseIsHovering, TeleportPylonInfo pylonInfo, string hoveringTextKey, ref string mouseOverText)
 Handles mouse clicking on the map icon the exact way that vanilla handles it. In normal circumstances, this should be called directly after DefaultDrawMapIcon. More...
 
override void DrawEffects (int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
 Allows you to make stuff happen whenever the tile at the given coordinates is drawn. For example, creating dust or changing the color the tile is drawn in. SpecialDraw will only be called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint here. More...
 
virtual void DrawMapIcon (ref MapOverlayDrawContext context, ref string mouseOverText, TeleportPylonInfo pylonInfo, bool isNearPylon, Color drawColor, float deselectedScale, float selectedScale)
 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

See also
MapOverlayDrawContext

's Draw Method. By default, doesn't draw anything. More...

 
override bool HasSmartInteract (int i, int j, SmartInteractScanSettings settings)
 Whether or not the smart interact function can select this tile. Useful for things like chests. Defaults to false. More...
 
virtual ? int IsPylonForSale (int npcType, Player player, bool isNPCHappyEnough)
 Whether or not this Pylon should be sold by the specified NPC type and with the given player. This should return the ITEM TYPE of the item that places this ModPylon, if one exists. If you don't want anything to be put up for sale, return null.
Returns null by default. More...
 
virtual void ModifyTeleportationPosition (TeleportPylonInfo destinationPylonInfo, ref Vector2 teleportationPosition)
 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. More...
 
override bool RightClick (int i, int j)
 Allows you to make something happen when this tile is right-clicked by the player. Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default. More...
 
override bool TileFrame (int i, int j, ref bool resetFrame, ref bool noBreak)
 Called whenever this tile updates due to being placed or being next to a tile that is changed. Return false to stop the game from carrying out its default TileFrame operations. Returns true by default. More...
 
virtual bool ValidTeleportCheck_AnyDanger (TeleportPylonInfo pylonInfo)
 Step 2 of the ValidTeleportCheck process. This is the second vanilla check that is called when checking the destination pylon. This check should be where you check if there is any "Danger" nearby, such as bosses or if there is an event happening. It is unlikely you will need to use this. By default, returns true if there are not any events happening (Lunar Pillars do not count) and there are no bosses currently alive. More...
 
virtual bool ValidTeleportCheck_BiomeRequirements (TeleportPylonInfo pylonInfo, SceneMetrics sceneData)
 Step 3 of the ValidTeleportCheck process. This is the fourth 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. More...
 
virtual void ValidTeleportCheck_DestinationPostCheck (TeleportPylonInfo destinationPylonInfo, ref bool destinationPylonValid, ref string errorKey)
 The 4th 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. More...
 
virtual void ValidTeleportCheck_NearbyPostCheck (TeleportPylonInfo nearbyPylonInfo, ref bool destinationPylonValid, ref bool anyNearbyValidPylon, ref string errorKey)
 The 5th 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. More...
 
virtual bool ValidTeleportCheck_NPCCount (TeleportPylonInfo pylonInfo, int defaultNecessaryNPCCount)
 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. More...
 
- Public Member Functions inherited from Terraria.ModLoader.ModTile
void AddMapEntry (Color color, LocalizedText name, Func< string, int, int, string > nameFunc)
 Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.
 
void AddMapEntry (Color color, LocalizedText name=null)
 Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults.
 
void AddMapEntry (Color color, ModTranslation name)
 Adds an entry to the minimap for this tile with the given color and display name. This should be called in SetDefaults.
 
void AddMapEntry (Color color, ModTranslation name, Func< string, int, int, string > nameFunc)
 Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.
 
void AddToArray (ref int[] array)
 A convenient method for adding this tile's Type to the given array. This can be used with the arrays in TileID.Sets.RoomNeeds.
 
virtual void AnimateIndividualTile (int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
 Animates an individual tile. i and j are the coordinates of the Tile in question. frameXOffset and frameYOffset should be used to specify an offset from the tiles frameX and frameY. "frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type];" will already be set before this hook is called, taking into account the TileID-wide animation set via AnimateTile. Use this hook for off-sync animations (lightning bug in a bottle), temporary animations (trap chests), or TileEntities to achieve unique animation behaviors without having to manually draw the tile via PreDraw. More...
 
virtual void AnimateTile (ref int frame, ref int frameCounter)
 Allows you to animate your tile. Use frameCounter to keep track of how long the current frame has been active, and use frame to change the current frame. This is called once an update. Use AnimateIndividualTile to animate specific tile instances directly. More...
 
virtual bool AutoSelect (int i, int j, Item item)
 Allows you to determine whether the given item can become selected when the cursor is hovering over this tile and the auto selection keybind is pressed. More...
 
virtual bool CanKillTile (int i, int j, ref bool blockDamaged)
 Allows you to determine whether or not the tile at the given coordinates can be hit by anything. Returns true by default. blockDamaged currently has no use. More...
 
virtual void ChangeWaterfallStyle (ref int style)
 Allows you to change the style of waterfall that passes through or over this type of tile. More...
 
virtual void DrawEffects (int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
 Allows you to make stuff happen whenever the tile at the given coordinates is drawn. For example, creating dust or changing the color the tile is drawn in. SpecialDraw will only be called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint here. More...
 
virtual bool Drop (int i, int j)
 Allows you to customize which items the tile at the given coordinates drops. Remember that the x, y (i, j) coordinates are in tile coordinates, you will need to multiply them by 16 if you want to drop an item using them. Return false to stop the game from dropping the tile's default item. Returns true by default. Please note that this hook currently only works for 1x1 tiles. More...
 
virtual void DropCritterChance (int i, int j, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance)
 Allows you to modify the chance the tile at the given coordinates has of spawning a certain critter when the tile is killed. More...
 
virtual void FloorVisuals (Player player)
 Allows you to make something happen when a player stands on this type of tile. For example, you can make the player slide as if on ice. More...
 
virtual float GetTorchLuck (Player player)
 Only called for torches, when there is one nearby. Use this to contribute to vanilla torch luck calculations. Typical return values are 1f for a torch in its biome, 0.5f for a weak positive torch, -1f for a torch in an opposing biome, and -0.5f for a weak negative torch. More...
 
virtual bool HasSmartInteract (int i, int j, SmartInteractScanSettings settings)
 Whether or not the smart interact function can select this tile. Useful for things like chests. Defaults to false. More...
 
virtual bool HasWalkDust ()
 Whether or not this tile creates dust when the player walks on it. Returns false by default.
 
virtual void HitWire (int i, int j)
 Allows you to make something happen when a wire current passes through this tile. Both Wiring.SkipWire(int, int) and NetMessage.SendTileSquare(int, int, int, int, TileChangeType) are usually required in the logic used in this method to correctly work.
Only called on the server and single player. All wiring happens on the world, not multiplayer clients. More...
 
virtual bool IsLockedChest (int i, int j)
 Return true if this Tile corresponds to a chest that is locked. Prevents Quick Stacking items into the chest. More...
 
virtual bool IsTileDangerous (int i, int j, Player player)
 Allows you to determine whether this tile glows red when the given player has the Dangersense buff.
This is only called on the local client. More...
 
virtual bool IsTileSpelunkable (int i, int j)
 Allows you to customize whether this tile can glow yellow while having the Spelunker buff, and is also detected by various pets.
This is only called if Main.tileSpelunker[type] is false. More...
 
virtual void KillMultiTile (int i, int j, int frameX, int frameY)
 This hook is called exactly once whenever a block encompassing multiple tiles is destroyed. You can use it to make your multi-tile block drop a single item, for example. More...
 
virtual void KillTile (int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
 Allows you to determine what happens when the tile at the given coordinates is killed or hit with a pickaxe. Fail determines whether the tile is mined, effectOnly makes it so that only dust is created, and noItem stops items from dropping. More...
 
virtual void ModifySittingTargetInfo (int i, int j, ref TileRestingInfo info)
 Modify the parameters for the entity sitting on this furniture tile with its type registered to TileID.Sets.CanBeSatOnForPlayers.
This is also called on NPCs sitting on this tile! To access the entity (player or NPC), use info.restingEntity.
This gets called when calling PlayerSittingHelper.SitDown, when the town NPC decides to sit, and each tick while the player is sitting on a suitable furniture. i and j derived from "(entity.Bottom + new Vector2(0f, -2f)).ToTileCoordinates()" or from the tile coordinates the player clicked on.
Formula: anchorTilePosition.ToWorldCoordinates(8f, 16f) + finalOffset + new Vector2(0, targetDirection * directionOffset). More...
 
virtual void ModifySleepingTargetInfo (int i, int j, ref TileRestingInfo info)
 Modify the visual player offset when sleeping on this tile with its type registered to TileID.Sets.CanBeSleptIn.
This gets called when calling PlayerSleepingHelper.SetIsSleepingAndAdjustPlayerRotation, and each tick while the player is resting in the bed, i and j derived from "(player.Bottom + new Vector2(0f, -2f)).ToTileCoordinates()" or from the tile coordinates the player clicked on.
Formula: new Point(anchorTilePosition.X, anchorTilePosition.Y + 1).ToWorldCoordinates(8f, 16f) + finalOffset + new Vector2(0, targetDirection * directionOffset). More...
 
virtual void ModifySmartInteractCoords (ref int width, ref int height, ref int frameWidth, ref int frameHeight, ref int extraY)
 Allows you to modify the smart interact parameters for the tile. Parameters already preset by deriving from TileObjectData defined for the tile.
Example usage: Beds/Dressers which have separate interactions based on where to click. More...
 
virtual void MouseOver (int i, int j)
 Allows you to make something happen when the mouse hovers over this tile. Useful for showing item icons or text on the mouse. More...
 
virtual void MouseOverFar (int i, int j)
 Allows you to make something happen when the mouse hovers over this tile, even when the player is far away. Useful for showing what's written on signs, etc. More...
 
virtual void NearbyEffects (int i, int j, bool closer)
 Allows you to make things happen when this tile is within a certain range of the player (around the same range water fountains and music boxes work). The closer parameter is whether or not the tile is within the range at which aesthetics like monoliths and music boxes and clocks work. It is false for campfires and heart lanterns. More...
 
virtual void PostSetDefaults ()
 Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main.tileObsidianKill.
 
virtual bool RightClick (int i, int j)
 Allows you to make something happen when this tile is right-clicked by the player. Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default. More...
 
virtual void SetDrawPositions (int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY)
 Allows you to customize the position in which this tile is drawn. Width refers to the width of one frame of the tile, offsetY refers to how many pixels below its actual position the tile should be drawn, height refers to the height of one frame of the tile. More...
 
virtual void SetSpriteEffects (int i, int j, ref SpriteEffects spriteEffects)
 Allows you to determine whether or not the tile will draw itself flipped in the world. More...
 
sealed override void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual bool Slope (int i, int j)
 Allows you to control how hammers slope this tile. Return true to allow it to slope normally. Returns true by default. Called on the local Client and Single Player. More...
 
virtual void SpecialDraw (int i, int j, SpriteBatch spriteBatch)
 Special Draw. Only called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint during DrawEffects. Useful for drawing things that would otherwise be impossible to draw due to draw order, such as items in item frames. More...
 
virtual bool TileFrame (int i, int j, ref bool resetFrame, ref bool noBreak)
 Called whenever this tile updates due to being placed or being next to a tile that is changed. Return false to stop the game from carrying out its default TileFrame operations. Returns true by default. More...
 
virtual bool UnlockChest (int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual)
 Allows customization of how a chest unlock is accomplished. By default, frameXAdjustment will be -36, shifting the frameX over to the left by 1 chest style. If your chests are in a different order, adjust frameXAdjustment accordingly. This hook is called on the client, and if successful will be called on the server and other clients as the action is synced. Make sure that the logic is consistent and not dependent on local player data. More...
 
virtual void WalkDust (ref int dustType, ref bool makeDust, ref Color color)
 Allows you to modify the dust created when the player walks on this tile. The makeDust parameter is whether or not to make dust; you can randomly set this to false to reduce the amount of dust produced. More...
 
- Public Member Functions inherited from Terraria.ModLoader.ModBlockType
virtual bool CanExplode (int i, int j)
 Whether or not the tile/wall at the given coordinates can be killed by an explosion (ie. bombs). Returns true by default; return false to stop an explosion from destroying it. More...
 
virtual bool CanPlace (int i, int j)
 Allows you to stop this tile/wall from being placed at the given coordinates. Return false to stop the tile/wall from being placed. Returns true by default. More...
 
virtual bool CreateDust (int i, int j, ref int type)
 Allows you to modify the default type of dust created when the tile/wall at the given coordinates is hit. Return false to stop the default dust (the type parameter) from being created. Returns true by default. More...
 
ModTranslation CreateMapEntryName (string key=null)
 Creates a ModTranslation object that you can use in AddMapEntry. More...
 
virtual ushort GetMapOption (int i, int j)
 Allows you to choose which minimap entry the tile/wall at the given coordinates will use. 0 is the first entry added by AddMapEntry, 1 is the second entry, etc. Returns 0 by default. More...
 
virtual bool KillSound (int i, int j, bool fail)
 Allows you to customize which sound you want to play when the tile/wall at the given coordinates is hit. Return false to stop the game from playing its default sound for the tile/wall. Returns true by default. More...
 
virtual void ModifyLight (int i, int j, ref float r, ref float g, ref float b)
 Allows you to determine how much light this tile/wall emits.
If it is a tile, make sure you set Main.tileLighted[Type] to true in SetDefaults for this to work.
If it is a wall, it can also let you light up the block in front of this wall.
See Terraria.Graphics.Light.TileLightScanner.ApplyTileLight(Tile, int, int, ref Terraria.Utilities.FastRandom, ref Microsoft.Xna.Framework.Vector3) for vanilla tile light values to use as a reference.
More...
 
virtual void NumDust (int i, int j, bool fail, ref int num)
 Allows you to change how many dust particles are created when the tile/wall at the given coordinates is hit. More...
 
virtual void PlaceInWorld (int i, int j, Item item)
 Allows you to do something when this tile/wall is placed. Called on the local Client and Single Player. More...
 
virtual void PostDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things in front of the tile/wall at the given coordinates. This can also be used to do things such as creating dust. More...
 
virtual bool PreDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things behind the tile/wall at the given coordinates. Return false to stop the game from drawing the tile normally. Returns true by default. More...
 
virtual void RandomUpdate (int i, int j)
 Called whenever the world randomly decides to update this tile/wall in a given tick. Useful for things such as growing or spreading. More...
 
override void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed.
This is where you would set the properties of this tile/wall. Many properties are stored as arrays throughout Terraria's code.
For example:

  • Main.tileSolid[Type] = true;
  • Main.tileSolidTop[Type] = true;
  • Main.tileBrick[Type] = true;
  • Main.tileBlockLight[Type] = true;
More...
 
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More...
 
abstract void Load (Mod mod)
 Called when loading the type. More...
 
abstract void Unload ()
 Called during unloading when needed. More...
 
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 

Properties

TeleportPylonType PylonType [get, set]
 What type of Pylon this ModPylon represents. More...
 
- Properties inherited from Terraria.ModLoader.ModTile
int[] AdjTiles = new int[0] [get, set]
 An array of the IDs of tiles that this tile can be considered as when looking for crafting stations.
 
int AnimationFrameHeight [get, set]
 The height of a group of animation frames for this tile. Defaults to 0, which disables animations.
 
int ChestDrop [get, set]
 The ID of the item that drops when this chest is destroyed. Defaults to 0. Honestly, this is only really used when the chest limit is reached on a server.
 
int CloseDoorID = -1 [get, set]
 The ID of the tile that this door transforms into when it is closed. Defaults to -1, which means this tile isn't a door.
 
ModTranslation ContainerName [get, set]
 The translations for the name that is displayed when this tile is opened as a chest or dresser. This won't be used if you don't add your tile to TileID.Sets.BasicChest or TileID.Sets.BasicDresser.
 
int DresserDrop [get, set]
 The ID of the item that drops when this dresser is destroyed. Defaults to 0. Honestly, this is only really used when the chest limit is reached on a server.
 
virtual string HighlightTexture [get]
 The highlight texture used when this tile is selected by smart interact. Defaults to adding "_Highlight" onto the main texture.
 
bool IsDoor [get]
 
float MineResist = 1f [get, set]
 A multiplier describing how much this block resists harvesting. Higher values will make it take longer to harvest. Defaults to 1f.
 
int MinPick [get, set]
 The minimum pickaxe power required for pickaxes to mine this block. Defaults to 0.
 
int OpenDoorID = -1 [get, set]
 The ID of the tile that this door transforms into when it is opened. Defaults to -1, which means this tile isn't a door.
 
- Properties inherited from Terraria.ModLoader.ModBlockType
int DustType [get, set]
 The default type of dust made when this tile/wall is hit. Defaults to 0.
 
SoundStyleHitSound = SoundID.Dig [get, set]
 The default style of sound made when this tile/wall is hit.
Defaults to SoundID.Dig, which is the sound used for tiles such as dirt and sand.
 
int ItemDrop [get, set]
 The default type of item dropped when this tile/wall is killed. Defaults to 0, which means no item.
 
ushort Type [get, set]
 The internal ID of this type of tile/wall.
 
ushort VanillaFallbackOnModDeletion = 0 [get, set]
 The vanilla ID of what should replace the instance when a user unloads and subsequently deletes data from your mod in their save file. Defaults to 0.
 
- Properties inherited from Terraria.ModLoader.ModTexturedType
virtual string Texture [get]
 The file name of this type's texture file in the mod loader's file space.
 
- Properties inherited from Terraria.ModLoader.ModType< TEntity, TModType >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from Terraria.ModLoader.IModType
string FullName [get]
 => $"{Mod.Name}/{Name}" More...
 
Mod Mod [get]
 The mod this belongs to. More...
 
string Name [get]
 The internal name of this instance. More...
 
- Properties inherited from Terraria.ModLoader.ModType< TEntity >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Terraria.ModLoader.ModTile
sealed override void Register ()
 If you make a new ModType, seal this override. More...
 
- Protected Member Functions inherited from Terraria.ModLoader.ModType< TEntity, TModType >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 
- Protected Member Functions inherited from Terraria.ModLoader.ModType< TEntity >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 

Detailed Description

Extension to

See also
ModTile

that streamlines the process of creating a modded Pylon. Has all of ModTile's hooks for customization, but additional hooks for Pylon functionality.

One of the key features of this class is the ValidTeleportCheck process. At first glance it can look a bit messy, however here is a rough break-down of the call process to help you if you're lost:
1) Game queries if the specified player is near a Pylon (

See also
TeleportPylonsSystem.IsPlayerNearAPylon, ValidTeleportCheck_DestinationPostCheck, Player.InInteractionRange, ValidTeleportCheck_NearbyPostCheck, GlobalPylon, GlobalPylon.PostValidTeleportCheck, ModifyTeleportationPosition

)
2) Assuming Step 1 has passed, game queries if the DESTINATION PYLON (the pylon the player CLICKED on the map) has enough NPCs nearby (NPCCount step)
3) Assuming Step 2 has passed, game queries if there is ANY DANGER at ALL across the entire map, ignoring the lunar pillar event (AnyDanger step)
4) Assuming Step 3 has passed, game queries if the DESTINATION PYLON is in the Lihzahrd Temple before Plantera is defeated.
5) Assuming Step 4 has passed, game queries if the DESTINATION PYLON meets its biome specifications for whatever type of pylon it is (BiomeRequirements step)
6) Regardless of all the past checks, if the DESTINATION PYLON is a modded one, is called on it.
7) The game queries all pylons on the map and checks if any of them are in interaction distance with the player (), and if so, checks Step 2 on it. If Step 2 passes, Step 5 is then called on it as well (NPCCount & BiomeRequirements step). If Step 5 also passes, the loop breaks and no further pylons are checked, and for the next steps, the pylon that succeeded will be the designated NEARBY PYLON.
8) Regardless of all the past checks, if the designated NEARBY PYLON is a modded one, is called on it.
9) Any instances run .
10) Finally, if all previous checks pass AND the DESTINATION pylon is a modded one, is called on it, right before the player is teleported.

Member Function Documentation

◆ CanPlacePylon()

virtual bool Terraria.ModLoader.ModPylon.CanPlacePylon ( )
virtual

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.

Note that in Multiplayer environments, granted that any GlobalPylon instances do not return false in

See also
GlobalPylon.PreCanPlacePylon

, this is called first on the client, and then is subsequently called & double checked on the server.
If the server disagrees with the client that the given pylon CANNOT be placed for any given reason, the server will reject the placement and subsequently break the associated tile.

◆ DefaultDrawMapIcon()

bool Terraria.ModLoader.ModPylon.DefaultDrawMapIcon ( ref MapOverlayDrawContext  context,
Asset< Texture2D >  mapIcon,
Vector2  drawCenter,
Color  drawColor,
float  deselectedScale,
float  selectedScale 
)

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.

Parameters
contextThe draw context that will allow for drawing on thj
mapIconThe icon that is to be drawn on the map.
drawCenterThe position in TILE coordinates for where the CENTER of the map icon should be.
drawColorThe color to draw the icon as.
deselectedScaleThe scale to draw the map icon when it is not selected (not being hovered over).
selectedScaleThe scale to draw the map icon when it IS selected (being hovered over).

◆ DefaultDrawPylonCrystal()

void Terraria.ModLoader.ModPylon.DefaultDrawPylonCrystal ( SpriteBatch  spriteBatch,
int  i,
int  j,
Asset< Texture2D >  crystalTexture,
Asset< Texture2D >  crystalHighlightTexture,
Vector2  crystalOffset,
Color  pylonShadowColor,
Color  dustColor,
int  dustChanceDenominator,
int  crystalVerticalFrameCount 
)

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.

Parameters
spriteBatchThe sprite batch that will draw the crystal.
iThe X tile coordinate to start drawing from.
jThe Y tile coordinate to start drawing from.
crystalTextureThe texture of the crystal that will actually be drawn.
crystalHighlightTextureThe texture of the smart cursor highlight for the corresponding crystal texture.
crystalOffsetThe offset of the actual position of the crystal. Assuming that a pylon tile itself and the crystals are equivalent to vanilla's sizes, this value should be Vector2(0, -12).
pylonShadowColorThe color of the "shadow" that is drawn on top of the crystal texture.
dustColorThe color of the dust that emanates from the crystal.
dustChanceDenominatorEvery draw call, this is this the denominator value of a Main.rand.NextBool() (1/denominator chance) check for whether or not a dust particle will spawn. 4 is the value vanilla uses.
crystalVerticalFrameCountHow many vertical frames the crystal texture has.

◆ DefaultMapClickHandle()

void Terraria.ModLoader.ModPylon.DefaultMapClickHandle ( bool  mouseIsHovering,
TeleportPylonInfo  pylonInfo,
string  hoveringTextKey,
ref string  mouseOverText 
)

Handles mouse clicking on the map icon the exact way that vanilla handles it. In normal circumstances, this should be called directly after DefaultDrawMapIcon.

Parameters
mouseIsHoveringWhether or not the map icon is currently being hovered over.
pylonInfoThe information pertaining to the current pylon being drawn.
hoveringTextKeyThe localization key that will be used to display text on the mouse, granted the mouse is currently hovering over the map icon.
mouseOverTextThe reference to the string value that actually changes the mouse text value.

◆ DrawEffects()

override void Terraria.ModLoader.ModPylon.DrawEffects ( int  i,
int  j,
SpriteBatch  spriteBatch,
ref TileDrawInfo  drawData 
)
virtual

Allows you to make stuff happen whenever the tile at the given coordinates is drawn. For example, creating dust or changing the color the tile is drawn in. SpecialDraw will only be called if coordinates are added using Main.instance.TilesRenderer.AddSpecialLegacyPoint here.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
spriteBatch
drawDataVarious information about the tile that is being drawn, such as color, framing, glow textures, etc.

Reimplemented from Terraria.ModLoader.ModTile.

◆ DrawMapIcon()

virtual void Terraria.ModLoader.ModPylon.DrawMapIcon ( ref MapOverlayDrawContext  context,
ref string  mouseOverText,
TeleportPylonInfo  pylonInfo,
bool  isNearPylon,
Color  drawColor,
float  deselectedScale,
float  selectedScale 
)
virtual

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

See also
MapOverlayDrawContext

's Draw Method. By default, doesn't draw anything.

Parameters
contextThe current map context on which you can draw.
mouseOverTextThe text that will overlay on the mouse when the icon is being hovered over.
pylonInfoThe pylon that is currently needing its icon to be drawn.
isNearPylonWhether or not the player is currently near a pylon.
drawColorThe draw color of the icon. This is bright white when the player is near a Pylon, but gray and translucent otherwise.
deselectedScaleThe scale of the icon if it is NOT currently being hovered over. In vanilla, this is 1f, or 100%.
selectedScaleThe scale of the icon if it IS currently being over. In vanilla, this is 2f, or 200%.

◆ HasSmartInteract()

override bool Terraria.ModLoader.ModPylon.HasSmartInteract ( int  i,
int  j,
SmartInteractScanSettings  settings 
)
virtual

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

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

Reimplemented from Terraria.ModLoader.ModTile.

◆ IsPylonForSale()

virtual ? int Terraria.ModLoader.ModPylon.IsPylonForSale ( int  npcType,
Player  player,
bool  isNPCHappyEnough 
)
virtual

Whether or not this Pylon should be sold by the specified NPC type and with the given player. This should return the ITEM TYPE of the item that places this ModPylon, if one exists. If you don't want anything to be put up for sale, return null.
Returns null by default.

Parameters
npcTypeThe type of the NPC currently being spoken to to determine the shop of.
playerThe current player asking said NPC type what they have for sale.
isNPCHappyEnoughWhether or not this NPC is "happy enough", by vanilla standards. You can ignore this if you don't care about happiness. For reference, Vanilla defines "happy enough" as the player earning a 10% discount or more, or in code:
Main.LocalPlayer.currentShoppingSettings.PriceAdjustment <= 0.8999999761581421;

◆ ModifyTeleportationPosition()

virtual void Terraria.ModLoader.ModPylon.ModifyTeleportationPosition ( TeleportPylonInfo  destinationPylonInfo,
ref Vector2  teleportationPosition 
)
virtual

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.

You shouldn't need to use this method if your pylon is the same size as a normal vanilla pylons (3x4 tiles).

Parameters
destinationPylonInfoThe information of the pylon the player intends to teleport to.
teleportationPositionThe position (IN WORLD COORDINATES) of where the player ends up when the teleportation occurs.

◆ RightClick()

override bool Terraria.ModLoader.ModPylon.RightClick ( int  i,
int  j 
)
virtual

Allows you to make something happen when this tile is right-clicked by the player. Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default.

Parameters
iThe x position in tile coordinates.
jThe y position in tile coordinates.
Returns
Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default.

Reimplemented from Terraria.ModLoader.ModTile.

◆ TileFrame()

override bool Terraria.ModLoader.ModPylon.TileFrame ( int  i,
int  j,
ref bool  resetFrame,
ref bool  noBreak 
)
virtual

Called whenever this tile updates due to being placed or being next to a tile that is changed. Return false to stop the game from carrying out its default TileFrame operations. Returns true by default.

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

Reimplemented from Terraria.ModLoader.ModTile.

◆ ValidTeleportCheck_AnyDanger()

virtual bool Terraria.ModLoader.ModPylon.ValidTeleportCheck_AnyDanger ( TeleportPylonInfo  pylonInfo)
virtual

Step 2 of the ValidTeleportCheck process. This is the second vanilla check that is called when checking the destination pylon. This check should be where you check if there is any "Danger" nearby, such as bosses or if there is an event happening. It is unlikely you will need to use this. By default, returns true if there are not any events happening (Lunar Pillars do not count) and there are no bosses currently alive.

Note that it's important you put the right checks in the right ValidTeleportCheck step, as whatever one returns false (if any) will determine the error message sent to the player.
If you're confused about the order of which the ValidTeleportCheck methods are called, check out the XML summary on the ModPylon class.

Parameters
pylonInfoThe internal information pertaining to the current pylon being teleported TO.

◆ ValidTeleportCheck_BiomeRequirements()

virtual bool Terraria.ModLoader.ModPylon.ValidTeleportCheck_BiomeRequirements ( TeleportPylonInfo  pylonInfo,
SceneMetrics  sceneData 
)
virtual

Step 3 of the ValidTeleportCheck process. This is the fourth 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.

Note that it's important you put the right checks in the right ValidTeleportCheck step, as whatever one returns false (if any) will determine the error message sent to the player.
If you're confused about the order of which the ValidTeleportCheck methods are called, check out the XML summary on the ModPylon class.

Parameters
pylonInfoThe internal information pertaining to the current pylon being teleported to or from.
sceneDataThe scene metrics data AT THE LOCATION of the destination pylon, NOT the player.

◆ ValidTeleportCheck_DestinationPostCheck()

virtual void Terraria.ModLoader.ModPylon.ValidTeleportCheck_DestinationPostCheck ( TeleportPylonInfo  destinationPylonInfo,
ref bool  destinationPylonValid,
ref string  errorKey 
)
virtual

The 4th 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.

Parameters
destinationPylonInfoThe Pylon information for the Pylon that the player is attempt to teleport to.
destinationPylonValidWhether or not after all of the checks, the destination Pylon is valid.
errorKeyThe localization key for the message sent to the player if destinationPylonValid is false.

◆ ValidTeleportCheck_NearbyPostCheck()

virtual void Terraria.ModLoader.ModPylon.ValidTeleportCheck_NearbyPostCheck ( TeleportPylonInfo  nearbyPylonInfo,
ref bool  destinationPylonValid,
ref bool  anyNearbyValidPylon,
ref string  errorKey 
)
virtual

The 5th 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.

Parameters
nearbyPylonInfoThe pylon information of the pylon the player in question is standing NEAR. This always has a value.
destinationPylonValidWhether or not after all of the checks, the destination Pylon is valid.
anyNearbyValidPylonWhether or not after all of the checks, there is a Pylon nearby to the player that is valid.
errorKeyThe localization key for the message sent to the player if destinationPylonValid is false.

◆ ValidTeleportCheck_NPCCount()

virtual bool Terraria.ModLoader.ModPylon.ValidTeleportCheck_NPCCount ( TeleportPylonInfo  pylonInfo,
int  defaultNecessaryNPCCount 
)
virtual

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.

Note that it's important you put the right checks in the right ValidTeleportCheck step, as whatever one returns false (if any) will determine the error message sent to the player.
If you're confused about the order of which the ValidTeleportCheck methods are called, check out the XML summary on the ModPylon class.

Parameters
pylonInfoThe internal information pertaining to the current pylon being teleported to or from.
defaultNecessaryNPCCountThe default amount of NPCs nearby required to satisfy a VANILLA pylon.

Property Documentation

◆ PylonType

TeleportPylonType Terraria.ModLoader.ModPylon.PylonType
getset

What type of Pylon this ModPylon represents.

The TeleportPylonType enum only has string names up until Count (9). The very first modded pylon to be added will technically be accessible with the enum type of "Count" since that value isn't an actual "type" of pylon, and modded pylons are assigned IDs starting with the Count value (9). All other modded pylons added after 9 (i.e 10+) will have no enum name, and will only every be referred to by their number values.