tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.ModLoader.ModSystem Class Reference

ModSystem is an abstract class that your classes can derive from. It contains general-use hooks, and, unlike Mod, can have unlimited amounts of types deriving from it. More...

Inherits Terraria.ModLoader.ModType.

Inherited by Terraria.ModLoader.Default.LegacyUnloadedTilesSystem, and Terraria.ModLoader.Default.UnloadedSystem.

Public Member Functions

virtual bool HijackGetData (ref byte messageType, ref BinaryReader reader, int playerNumber)
 Allows you to modify net message / packet information that is received before the game can act on it. More...
 
virtual bool HijackSendData (int whoAmI, int msgType, int remoteClient, int ignoreClient, NetworkText text, int number, float number2, float number3, float number4, int number5, int number6, int number7)
 Hijacks the send data method. Only use if you absolutely know what you are doing. If any hooks return true, the message is not sent. More...
 
virtual void LoadWorldData (TagCompound tag)
 Allows you to load custom data you have saved for this system in the currently loading world. More...
 
virtual void ModifyHardmodeTasks (List< GenPass > list)
 Similar to ModifyWorldGenTasks, but occurs in-game when Hardmode starts. Can be used to modify which tasks should be done and/or add custom tasks. By default the list will only contain 4 items, the vanilla hardmode tasks called "Hardmode Good", "Hardmode Evil", "Hardmode Walls", and "Hardmode Announcment" More...
 
virtual void ModifyInterfaceLayers (List< GameInterfaceLayer > layers)
 Allows you to modify the elements of the in-game interface that get drawn. GameInterfaceLayer can be found in the Terraria.UI namespace. Check https://github.com/tModLoader/tModLoader/wiki/Vanilla-Interface-layers-values for vanilla interface layer names More...
 
virtual void ModifyLightingBrightness (ref float scale)
 Allows you to modify overall brightness of lights. Can be used to create effects similiar to what night vision and darkness (de)buffs give you. Values too high or too low might result in glitches. For night vision effect use scale 1.03 More...
 
virtual void ModifyScreenPosition ()
 Use this hook to modify Main.screenPosition after weapon zoom and camera lerp have taken place. More...
 
virtual void ModifySunLightColor (ref Color tileColor, ref Color backgroundColor)
 Allows you to modify color of light the sun emits. More...
 
virtual void ModifyTimeRate (ref double timeRate, ref double tileUpdateRate, ref double eventUpdateRate)
 Called after all other time calculations. Can be used to modify the speed at which time should progress per tick in seconds, along with the rate at which the tiles in the world and the events in the world should update with it. All fields are measured in in-game minutes per real-life second (min/sec). You may want to consider Main.fastForwardTime and CreativePowerManager.Instance.GetPower<CreativePowers.FreezeTime>().Enabled here. More...
 
virtual void ModifyTransformMatrix (ref SpriteViewMatrix Transform)
 Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.) More...
 
virtual void ModifyWorldGenTasks (List< GenPass > tasks, ref float totalWeight)
 A more advanced option to PostWorldGen, this method allows you modify the list of Generation Passes before a new world begins to be generated. For example, removing the "Planting Trees" pass will cause a world to generate without trees. Placing a new Generation Pass before the "Dungeon" pass will prevent the the mod's pass from cutting into the dungeon. More...
 
virtual void NetReceive (BinaryReader reader)
 Allows you to do things with custom data that is received between clients and server. More...
 
virtual void NetSend (BinaryWriter writer)
 Allows you to send custom data between clients and server. This is useful for syncing information such as bosses that have been defeated. More...
 
virtual void OnModLoad ()
 This hook is called right after Mod.Load(), which is guaranteed to be called after all content has been autoloaded. More...
 
virtual void OnWorldLoad ()
 Called whenever a world is loaded. This can be used to initialize data structures, etc. More...
 
virtual void OnWorldUnload ()
 Called whenever a world is unloaded. Use this to deinitialize world-related data structures, etc. More...
 
virtual void PostDrawFullscreenMap (ref string mouseText)
 Called while the fullscreen map is active. Allows custom drawing to the map. More...
 
virtual void PostDrawInterface (SpriteBatch spriteBatch)
 Called after interface is drawn but right before mouse and mouse hover text is drawn. Allows for drawing interface. More...
 
virtual void PostDrawTiles ()
 Called after drawing Tiles. Can be used for drawing a tile overlay akin to wires. Note that spritebatch should be begun and ended within this method. More...
 
virtual void PostSetupContent ()
 Allows you to load things in your system after the mod's content has been setup (arrays have been resized to fit the content, etc). More...
 
virtual void PostUpdateDusts ()
 Called after Dusts get updated. More...
 
virtual void PostUpdateEverything ()
 Called after the Network got updated, this is the last hook that happens in an update. More...
 
virtual void PostUpdateGores ()
 Called after Gores get updated. More...
 
virtual void PostUpdateInput ()
 Called after the input keys are polled. Allows for modifying things like scroll wheel if your custom drawing should capture that. More...
 
virtual void PostUpdateInvasions ()
 Called after Invasions get updated. This hook is not called for multiplayer clients. More...
 
virtual void PostUpdateItems ()
 Called after Items get updated. More...
 
virtual void PostUpdateNPCs ()
 Called after NPCs get updated. More...
 
virtual void PostUpdatePlayers ()
 Called after Players get updated. More...
 
virtual void PostUpdateProjectiles ()
 Called after Projectiles get updated. More...
 
virtual void PostUpdateTime ()
 Called after Time gets updated. More...
 
virtual void PostUpdateWorld ()
 Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. This hook is not called for multiplayer clients. More...
 
virtual void PostWorldGen ()
 Use this method to place tiles in the world after world generation is complete. More...
 
virtual void PreSaveAndQuit ()
 Called in SP or Client when the Save and Quit button is pressed. One use for this hook is clearing out custom UI slots to return items to the player.
More...
 
virtual void PreUpdateDusts ()
 Called before Dusts get updated. More...
 
virtual void PreUpdateEntities ()
 Use this if you want to do something before anything in the World gets updated. Called after UI updates, but before anything in the World (Players, NPCs, Projectiles, Tiles) gets updated. More...
 
virtual void PreUpdateGores ()
 Called before Gores get updated. More...
 
virtual void PreUpdateInvasions ()
 Called before Invasions get updated. This hook is not called for multiplayer clients. More...
 
virtual void PreUpdateItems ()
 Called before Items get updated. More...
 
virtual void PreUpdateNPCs ()
 Called before NPCs get updated. More...
 
virtual void PreUpdatePlayers ()
 Called before Players get updated. More...
 
virtual void PreUpdateProjectiles ()
 Called before Projectiles get updated. More...
 
virtual void PreUpdateTime ()
 Called before Time gets updated. More...
 
virtual void PreUpdateWorld ()
 Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. This hook is not called for multiplayer clients. More...
 
virtual void PreWorldGen ()
 Allows a mod to run code before a world is generated. More...
 
virtual void ResetNearbyTileEffects ()
 Use this to reset any fields you set in any of your ModTile.NearbyEffects hooks back to their default values. More...
 
virtual TagCompound SaveWorldData ()
 Allows you to save custom data for this system in the current world. Useful for things like saving world specific flags. For example, if your mod adds a boss and you want certain NPC to only spawn once it has been defeated, this is where you would store the information that that boss has been defeated in this world. Returns null by default. More...
 
sealed override void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
sealed override void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void TileCountsAvailable (ReadOnlySpan< int > tileCounts)
 Allows you to store information about how many of each tile is nearby the player. This is useful for counting how many tiles of a certain custom biome there are.
The tileCounts parameter is a read-only span (treat this as an array) that stores the tile count indexed by tile type. More...
 
virtual void UpdateUI (GameTime gameTime)
 Ran every update and suitable for calling Update for UserInterface classes More...
 
- Public Member Functions inherited from Terraria.ModLoader.ModType
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 void Unload ()
 Allows you to safely unload things you added in Load. More...
 

Protected Member Functions

override void Register ()
 If you make a new ModType, seal this override. More...
 

Additional Inherited Members

- Properties inherited from Terraria.ModLoader.ModType
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
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...
 

Detailed Description

ModSystem is an abstract class that your classes can derive from. It contains general-use hooks, and, unlike Mod, can have unlimited amounts of types deriving from it.

Member Function Documentation

◆ HijackGetData()

virtual bool Terraria.ModLoader.ModSystem.HijackGetData ( ref byte  messageType,
ref BinaryReader  reader,
int  playerNumber 
)
virtual

Allows you to modify net message / packet information that is received before the game can act on it.

Parameters
messageTypeType of the message.
readerThe reader.
playerNumberThe player number the message is from.

◆ HijackSendData()

virtual bool Terraria.ModLoader.ModSystem.HijackSendData ( int  whoAmI,
int  msgType,
int  remoteClient,
int  ignoreClient,
NetworkText  text,
int  number,
float  number2,
float  number3,
float  number4,
int  number5,
int  number6,
int  number7 
)
virtual

Hijacks the send data method. Only use if you absolutely know what you are doing. If any hooks return true, the message is not sent.

◆ LoadWorldData()

virtual void Terraria.ModLoader.ModSystem.LoadWorldData ( TagCompound  tag)
virtual

Allows you to load custom data you have saved for this system in the currently loading world.

Reimplemented in Terraria.ModLoader.Default.UnloadedSystem.

◆ ModifyHardmodeTasks()

virtual void Terraria.ModLoader.ModSystem.ModifyHardmodeTasks ( List< GenPass list)
virtual

Similar to ModifyWorldGenTasks, but occurs in-game when Hardmode starts. Can be used to modify which tasks should be done and/or add custom tasks. By default the list will only contain 4 items, the vanilla hardmode tasks called "Hardmode Good", "Hardmode Evil", "Hardmode Walls", and "Hardmode Announcment"

◆ ModifyInterfaceLayers()

virtual void Terraria.ModLoader.ModSystem.ModifyInterfaceLayers ( List< GameInterfaceLayer layers)
virtual

Allows you to modify the elements of the in-game interface that get drawn. GameInterfaceLayer can be found in the Terraria.UI namespace. Check https://github.com/tModLoader/tModLoader/wiki/Vanilla-Interface-layers-values for vanilla interface layer names

Parameters
layersThe layers.

◆ ModifyLightingBrightness()

virtual void Terraria.ModLoader.ModSystem.ModifyLightingBrightness ( ref float  scale)
virtual

Allows you to modify overall brightness of lights. Can be used to create effects similiar to what night vision and darkness (de)buffs give you. Values too high or too low might result in glitches. For night vision effect use scale 1.03

Parameters
scaleBrightness scale

◆ ModifyScreenPosition()

virtual void Terraria.ModLoader.ModSystem.ModifyScreenPosition ( )
virtual

Use this hook to modify Main.screenPosition after weapon zoom and camera lerp have taken place.

◆ ModifySunLightColor()

virtual void Terraria.ModLoader.ModSystem.ModifySunLightColor ( ref Color  tileColor,
ref Color  backgroundColor 
)
virtual

Allows you to modify color of light the sun emits.

Parameters
tileColorTile lighting color
backgroundColorBackground lighting color

◆ ModifyTimeRate()

virtual void Terraria.ModLoader.ModSystem.ModifyTimeRate ( ref double  timeRate,
ref double  tileUpdateRate,
ref double  eventUpdateRate 
)
virtual

Called after all other time calculations. Can be used to modify the speed at which time should progress per tick in seconds, along with the rate at which the tiles in the world and the events in the world should update with it. All fields are measured in in-game minutes per real-life second (min/sec). You may want to consider Main.fastForwardTime and CreativePowerManager.Instance.GetPower<CreativePowers.FreezeTime>().Enabled here.

Parameters
timeRateThe speed at which time flows in min/sec.
tileUpdateRateThe speed at which tiles in the world update in min/sec.
eventUpdateRateThe speed at which various events in the world (weather changes, fallen star/fairy spawns, etc.) update in min/sec.

◆ ModifyTransformMatrix()

virtual void Terraria.ModLoader.ModSystem.ModifyTransformMatrix ( ref SpriteViewMatrix  Transform)
virtual

Allows you to set the transformation of the screen that is drawn. (Translations, rotations, scales, etc.)

◆ ModifyWorldGenTasks()

virtual void Terraria.ModLoader.ModSystem.ModifyWorldGenTasks ( List< GenPass tasks,
ref float  totalWeight 
)
virtual

A more advanced option to PostWorldGen, this method allows you modify the list of Generation Passes before a new world begins to be generated. For example, removing the "Planting Trees" pass will cause a world to generate without trees. Placing a new Generation Pass before the "Dungeon" pass will prevent the the mod's pass from cutting into the dungeon.

◆ NetReceive()

virtual void Terraria.ModLoader.ModSystem.NetReceive ( BinaryReader  reader)
virtual

Allows you to do things with custom data that is received between clients and server.

◆ NetSend()

virtual void Terraria.ModLoader.ModSystem.NetSend ( BinaryWriter  writer)
virtual

Allows you to send custom data between clients and server. This is useful for syncing information such as bosses that have been defeated.

◆ OnModLoad()

virtual void Terraria.ModLoader.ModSystem.OnModLoad ( )
virtual

This hook is called right after Mod.Load(), which is guaranteed to be called after all content has been autoloaded.

◆ OnWorldLoad()

virtual void Terraria.ModLoader.ModSystem.OnWorldLoad ( )
virtual

Called whenever a world is loaded. This can be used to initialize data structures, etc.

Reimplemented in Terraria.ModLoader.Default.UnloadedSystem.

◆ OnWorldUnload()

virtual void Terraria.ModLoader.ModSystem.OnWorldUnload ( )
virtual

Called whenever a world is unloaded. Use this to deinitialize world-related data structures, etc.

◆ PostDrawFullscreenMap()

virtual void Terraria.ModLoader.ModSystem.PostDrawFullscreenMap ( ref string  mouseText)
virtual

Called while the fullscreen map is active. Allows custom drawing to the map.

Parameters
mouseTextThe mouse text.

◆ PostDrawInterface()

virtual void Terraria.ModLoader.ModSystem.PostDrawInterface ( SpriteBatch  spriteBatch)
virtual

Called after interface is drawn but right before mouse and mouse hover text is drawn. Allows for drawing interface.

Note: This hook should no longer be used. It is better to use the ModifyInterfaceLayers hook.

Parameters
spriteBatchThe sprite batch.

◆ PostDrawTiles()

virtual void Terraria.ModLoader.ModSystem.PostDrawTiles ( )
virtual

Called after drawing Tiles. Can be used for drawing a tile overlay akin to wires. Note that spritebatch should be begun and ended within this method.

◆ PostSetupContent()

virtual void Terraria.ModLoader.ModSystem.PostSetupContent ( )
virtual

Allows you to load things in your system after the mod's content has been setup (arrays have been resized to fit the content, etc).

◆ PostUpdateDusts()

virtual void Terraria.ModLoader.ModSystem.PostUpdateDusts ( )
virtual

Called after Dusts get updated.

◆ PostUpdateEverything()

virtual void Terraria.ModLoader.ModSystem.PostUpdateEverything ( )
virtual

Called after the Network got updated, this is the last hook that happens in an update.

◆ PostUpdateGores()

virtual void Terraria.ModLoader.ModSystem.PostUpdateGores ( )
virtual

Called after Gores get updated.

◆ PostUpdateInput()

virtual void Terraria.ModLoader.ModSystem.PostUpdateInput ( )
virtual

Called after the input keys are polled. Allows for modifying things like scroll wheel if your custom drawing should capture that.

◆ PostUpdateInvasions()

virtual void Terraria.ModLoader.ModSystem.PostUpdateInvasions ( )
virtual

Called after Invasions get updated. This hook is not called for multiplayer clients.

◆ PostUpdateItems()

virtual void Terraria.ModLoader.ModSystem.PostUpdateItems ( )
virtual

Called after Items get updated.

◆ PostUpdateNPCs()

virtual void Terraria.ModLoader.ModSystem.PostUpdateNPCs ( )
virtual

Called after NPCs get updated.

◆ PostUpdatePlayers()

virtual void Terraria.ModLoader.ModSystem.PostUpdatePlayers ( )
virtual

Called after Players get updated.

◆ PostUpdateProjectiles()

virtual void Terraria.ModLoader.ModSystem.PostUpdateProjectiles ( )
virtual

Called after Projectiles get updated.

◆ PostUpdateTime()

virtual void Terraria.ModLoader.ModSystem.PostUpdateTime ( )
virtual

Called after Time gets updated.

◆ PostUpdateWorld()

virtual void Terraria.ModLoader.ModSystem.PostUpdateWorld ( )
virtual

Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. This hook is not called for multiplayer clients.

◆ PostWorldGen()

virtual void Terraria.ModLoader.ModSystem.PostWorldGen ( )
virtual

Use this method to place tiles in the world after world generation is complete.

◆ PreSaveAndQuit()

virtual void Terraria.ModLoader.ModSystem.PreSaveAndQuit ( )
virtual

Called in SP or Client when the Save and Quit button is pressed. One use for this hook is clearing out custom UI slots to return items to the player.

◆ PreUpdateDusts()

virtual void Terraria.ModLoader.ModSystem.PreUpdateDusts ( )
virtual

Called before Dusts get updated.

◆ PreUpdateEntities()

virtual void Terraria.ModLoader.ModSystem.PreUpdateEntities ( )
virtual

Use this if you want to do something before anything in the World gets updated. Called after UI updates, but before anything in the World (Players, NPCs, Projectiles, Tiles) gets updated.

When Main.autoPause is true or Main.FrameSkipMode is 0 or 2, the game may do a partial update. This means that it only updates menus and some animations, but not the World or Entities. This hook - and every hook after it - only gets called on frames with a full update.

◆ PreUpdateGores()

virtual void Terraria.ModLoader.ModSystem.PreUpdateGores ( )
virtual

Called before Gores get updated.

◆ PreUpdateInvasions()

virtual void Terraria.ModLoader.ModSystem.PreUpdateInvasions ( )
virtual

Called before Invasions get updated. This hook is not called for multiplayer clients.

◆ PreUpdateItems()

virtual void Terraria.ModLoader.ModSystem.PreUpdateItems ( )
virtual

Called before Items get updated.

◆ PreUpdateNPCs()

virtual void Terraria.ModLoader.ModSystem.PreUpdateNPCs ( )
virtual

Called before NPCs get updated.

◆ PreUpdatePlayers()

virtual void Terraria.ModLoader.ModSystem.PreUpdatePlayers ( )
virtual

Called before Players get updated.

◆ PreUpdateProjectiles()

virtual void Terraria.ModLoader.ModSystem.PreUpdateProjectiles ( )
virtual

Called before Projectiles get updated.

◆ PreUpdateTime()

virtual void Terraria.ModLoader.ModSystem.PreUpdateTime ( )
virtual

Called before Time gets updated.

◆ PreUpdateWorld()

virtual void Terraria.ModLoader.ModSystem.PreUpdateWorld ( )
virtual

Use this method to have things happen in the world. In vanilla Terraria, a good example of code suitable for this hook is how Falling Stars fall to the ground during the night. This hook is not called for multiplayer clients.

◆ PreWorldGen()

virtual void Terraria.ModLoader.ModSystem.PreWorldGen ( )
virtual

Allows a mod to run code before a world is generated.

◆ Register()

override void Terraria.ModLoader.ModSystem.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements Terraria.ModLoader.ModType.

◆ ResetNearbyTileEffects()

virtual void Terraria.ModLoader.ModSystem.ResetNearbyTileEffects ( )
virtual

Use this to reset any fields you set in any of your ModTile.NearbyEffects hooks back to their default values.

◆ SaveWorldData()

virtual TagCompound Terraria.ModLoader.ModSystem.SaveWorldData ( )
virtual

Allows you to save custom data for this system in the current world. Useful for things like saving world specific flags. For example, if your mod adds a boss and you want certain NPC to only spawn once it has been defeated, this is where you would store the information that that boss has been defeated in this world. Returns null by default.

Reimplemented in Terraria.ModLoader.Default.UnloadedSystem.

◆ SetStaticDefaults()

sealed override void Terraria.ModLoader.ModSystem.SetStaticDefaults ( )
virtual

Allows you to modify the properties after initial loading has completed.

Reimplemented from Terraria.ModLoader.ModType.

◆ SetupContent()

sealed override void Terraria.ModLoader.ModSystem.SetupContent ( )
virtual

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

Reimplemented from Terraria.ModLoader.ModType.

◆ TileCountsAvailable()

virtual void Terraria.ModLoader.ModSystem.TileCountsAvailable ( ReadOnlySpan< int >  tileCounts)
virtual

Allows you to store information about how many of each tile is nearby the player. This is useful for counting how many tiles of a certain custom biome there are.
The tileCounts parameter is a read-only span (treat this as an array) that stores the tile count indexed by tile type.

◆ UpdateUI()

virtual void Terraria.ModLoader.ModSystem.UpdateUI ( GameTime  gameTime)
virtual

Ran every update and suitable for calling Update for UserInterface classes