ModWorld
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.
Methods
- Autoload(System.String@)()
- 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.
- Initialize()
- Called whenever the world is loaded. This can be used to initialize data structures, etc.
- 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.
- Load(Terraria.ModLoader.IO.TagCompound)()
- Allows you to load custom data you have saved for this world.
- LoadLegacy(System.IO.BinaryReader)()
- Allows you to load pre-v0.9 custom data you have saved for this world.
- NetSend(System.IO.BinaryWriter)()
- Allows you to send custom data between clients and server. This is useful for syncing information such as bosses that have been defeated.
- NetReceive(System.IO.BinaryReader)()
- Allows you to do things with custom data that is received between clients and server.
- PreWorldGen()
- Allows a mod to run code before a world is generated.
- ModifyWorldGenTasks(System.Collections.Generic.List{Terraria.World.Generation.GenPass},System.Single@)()
- 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.
- PostWorldGen()
- Use this method to place tiles in the world after world generation is complete.
- ResetNearbyTileEffects()
- Use this to reset any fields you set in any of your ModTile.NearbyEffects hooks back to their default values.
- 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.
- 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.
- TileCountsAvailable(System.Int32[])()
- 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.
- ChooseWaterStyle(System.Int32@)()
- Allows you to change the water style (determines water color) that is currently being used.
- ModifyHardmodeTasks(System.Collections.Generic.List{Terraria.World.Generation.GenPass})()
- 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"
- 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.