tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.ModWorld Class Reference

A ModWorld instance represents an extension of a World. You can store fields in the ModWorld classes to keep track of mod-specific information on the world. It also contains hooks to insert your code into the world generation process. More...

Public Member Functions

virtual bool Autoload (ref string name)
 Allows you to automatically add a ModWorld instead of using Mod.AddModWorld. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this to either force or stop an autoload, or change the name that identifies this type of ModWorld. More...
 
virtual void ChooseWaterStyle (ref int style)
 Allows you to change the water style (determines water color) that is currently being used. More...
 
virtual void Initialize ()
 Called whenever the world is loaded. This can be used to initialize data structures, etc. More...
 
virtual void Load (TagCompound tag)
 Allows you to load custom data you have saved for this world. More...
 
virtual void LoadLegacy (BinaryReader reader)
 Allows you to load pre-v0.9 custom data you have saved for this 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 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 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 PostUpdate ()
 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 called every frame. More...
 
virtual void PostWorldGen ()
 Use this method to place tiles in the world after world generation is complete. More...
 
virtual void PreUpdate ()
 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 called every frame. 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 Save ()
 Allows you to save custom data for this 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...
 
virtual void TileCountsAvailable (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 stores the tile count indexed by tile type. More...
 

Properties

Mod mod [get, set]
 The mod that added this type of ModWorld. More...
 
string Name [get, set]
 The name of this ModWorld. Used for distinguishing between multiple ModWorlds added by a single Mod. More...
 

Detailed Description

A ModWorld instance represents an extension of a World. You can store fields in the ModWorld classes to keep track of mod-specific information on the world. It also contains hooks to insert your code into the world generation process.

Definition at line 11 of file ModWorld.cs.

Member Function Documentation

◆ Autoload()

virtual bool Terraria.ModLoader.ModWorld.Autoload ( ref string  name)
virtual

Allows you to automatically add a ModWorld instead of using Mod.AddModWorld. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this to either force or stop an autoload, or change the name that identifies this type of ModWorld.

Definition at line 32 of file ModWorld.cs.

32 {
33 return mod.Properties.Autoload;
34 }
ModProperties Properties
Definition: Mod.cs:52
Mod mod
The mod that added this type of ModWorld.
Definition: ModWorld.cs:16
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.ModWorld.mod, and Terraria.ModLoader.Mod.Properties.

Referenced by Terraria.ModLoader.Mod.AutoloadModWorld().

+ Here is the caller graph for this function:

◆ ChooseWaterStyle()

virtual void Terraria.ModLoader.ModWorld.ChooseWaterStyle ( ref int  style)
virtual

Allows you to change the water style (determines water color) that is currently being used.

Definition at line 118 of file ModWorld.cs.

118 {
119 }

Referenced by Terraria.ModLoader.WorldHooks.ChooseWaterStyle().

+ Here is the caller graph for this function:

◆ Initialize()

virtual void Terraria.ModLoader.ModWorld.Initialize ( )
virtual

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

Definition at line 39 of file ModWorld.cs.

39 {
40 }

◆ Load()

virtual void Terraria.ModLoader.ModWorld.Load ( TagCompound  tag)
virtual

Allows you to load custom data you have saved for this world.

Definition at line 52 of file ModWorld.cs.

52 {
53 }

◆ LoadLegacy()

virtual void Terraria.ModLoader.ModWorld.LoadLegacy ( BinaryReader  reader)
virtual

Allows you to load pre-v0.9 custom data you have saved for this world.

Definition at line 58 of file ModWorld.cs.

58 {
59 }

◆ ModifyHardmodeTasks()

virtual void Terraria.ModLoader.ModWorld.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"

Definition at line 124 of file ModWorld.cs.

124 {
125 }

Referenced by Terraria.ModLoader.WorldHooks.ModifyHardmodeTasks().

+ Here is the caller graph for this function:

◆ ModifyWorldGenTasks()

virtual void Terraria.ModLoader.ModWorld.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.

Definition at line 82 of file ModWorld.cs.

82 {
83 }

Referenced by Terraria.ModLoader.WorldHooks.ModifyWorldGenTasks().

+ Here is the caller graph for this function:

◆ NetReceive()

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

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

Definition at line 70 of file ModWorld.cs.

70 {
71 }

◆ NetSend()

virtual void Terraria.ModLoader.ModWorld.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.

Definition at line 64 of file ModWorld.cs.

64 {
65 }

◆ PostDrawTiles()

virtual void Terraria.ModLoader.ModWorld.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.

Definition at line 130 of file ModWorld.cs.

130 {
131 }

Referenced by Terraria.ModLoader.WorldHooks.PostDrawTiles().

+ Here is the caller graph for this function:

◆ PostUpdate()

virtual void Terraria.ModLoader.ModWorld.PostUpdate ( )
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 called every frame.

Definition at line 106 of file ModWorld.cs.

106 {
107 }

Referenced by Terraria.ModLoader.WorldHooks.PostUpdate().

+ Here is the caller graph for this function:

◆ PostWorldGen()

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

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

Definition at line 88 of file ModWorld.cs.

88 {
89 }

Referenced by Terraria.ModLoader.WorldHooks.PostWorldGen().

+ Here is the caller graph for this function:

◆ PreUpdate()

virtual void Terraria.ModLoader.ModWorld.PreUpdate ( )
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 called every frame.

Definition at line 100 of file ModWorld.cs.

100 {
101 }

Referenced by Terraria.ModLoader.WorldHooks.PreUpdate().

+ Here is the caller graph for this function:

◆ PreWorldGen()

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

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

Definition at line 76 of file ModWorld.cs.

76 {
77 }

Referenced by Terraria.ModLoader.WorldHooks.PreWorldGen().

+ Here is the caller graph for this function:

◆ ResetNearbyTileEffects()

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

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

Definition at line 94 of file ModWorld.cs.

94 {
95 }

Referenced by Terraria.ModLoader.WorldHooks.ResetNearbyTileEffects().

+ Here is the caller graph for this function:

◆ Save()

virtual TagCompound Terraria.ModLoader.ModWorld.Save ( )
virtual

Allows you to save custom data for this 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.

Definition at line 45 of file ModWorld.cs.

45 {
46 return null;
47 }

◆ TileCountsAvailable()

virtual void Terraria.ModLoader.ModWorld.TileCountsAvailable ( 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 stores the tile count indexed by tile type.

Definition at line 112 of file ModWorld.cs.

112 {
113 }

Referenced by Terraria.ModLoader.WorldHooks.TileCountsAvailable().

+ Here is the caller graph for this function:

Property Documentation

◆ mod

Mod Terraria.ModLoader.ModWorld.mod
getset

The mod that added this type of ModWorld.

Definition at line 16 of file ModWorld.cs.

16 {
17 get;
18 internal set;
19 }

Referenced by Terraria.ModLoader.ModWorld.Autoload().

◆ Name

string Terraria.ModLoader.ModWorld.Name
getset

The name of this ModWorld. Used for distinguishing between multiple ModWorlds added by a single Mod.

Definition at line 24 of file ModWorld.cs.

24 {
25 get;
26 internal set;
27 }

Referenced by Terraria.ModLoader.Mod.AutoloadModWorld().