Class ModSystem
Base of a system, which is part of a code mod. Takes care of setting up, registering and handling all sorts of things. You may choose to split up a mod into multiple distinct systems if you so choose, but there may also be just one.
Inheritance
Namespace: Vintagestory.API.Common
Assembly: VintagestoryAPI.dll
Syntax
public abstract class ModSystem : object
Properties
| Improve this Doc View SourceAllowRuntimeReload
When the server reloads mods at runtime, should this mod also be reloaded. Return false e.g. for any mod that adds blocks.
Declaration
public virtual bool AllowRuntimeReload { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Mod
Gets the Mod this mod system is part of.
Declaration
public Mod Mod { get; }
Property Value
Type | Description |
---|---|
Mod |
Methods
| Improve this Doc View SourceAssetsLoaded(ICoreAPI)
Called on the server or the client; implementing code may need to check which side it is.
On a server, called only after all mods have called Start(), and after asset JSONs have been read from disk and patched, but before runphase ModsAndConfigReady.
Asset files are now available to load using api.Assets.TryGet() calls or similar. It is not guaranteed that the actual in-game assets (including blocks and items) are yet registered!
If called from a modsystem, what has been registered at this stage depends on the ExecuteOrder(). After 0.2, blocks and items have been registered. After 0.6, recipes have been registered.
If implementing this, and if your code requires that blocks, items and entities have been registered first, make sure your ModSystem has set an appropriate ExecuteOrder()!!
Declaration
public virtual void AssetsLoaded(ICoreAPI api)
Parameters
Type | Name | Description |
---|---|---|
ICoreAPI | api |
Dispose()
If this mod allows runtime reloading, you must implement this method to unregister any listeners / handlers
Declaration
public virtual void Dispose()
ExecuteOrder()
Declaration
public virtual double ExecuteOrder()
Returns
Type | Description |
---|---|
System.Double |
ShouldLoad(EnumAppSide)
Returns if this mod should be loaded for the given app side.
Declaration
public virtual bool ShouldLoad(EnumAppSide forSide)
Parameters
Type | Name | Description |
---|---|---|
EnumAppSide | forSide |
Returns
Type | Description |
---|---|
System.Boolean |
Start(ICoreAPI)
Start method, called on both server and client after all mods already received a call to StartPre(), but before Blocks/Items/Entities/Recipes etc are loaded and some time before StartServerSide / StartClientSide.
Typically used to register for events and network packets etc
Typically also used in a mod's core to register the classes for your blocks, items, entities, blockentities, behaviors etc, prior to loading assets
Do not make calls to api.Assets at this stage, the assets may not be found, resulting in errors (even if the json file exists on disk). Use AssetsLoaded() stage instead.
Declaration
public virtual void Start(ICoreAPI api)
Parameters
Type | Name | Description |
---|---|---|
ICoreAPI | api |
StartClientSide(ICoreClientAPI)
Full start to the mod on the client side.
Note, in multiplayer games, the server assets (blocks, items, entities, recipes) have not yet been received and so no blocks etc. are yet registered
For code that must run only after we have blocks,items,entities and recipes all registered and loaded, add your method to event BlockTexturesLoaded
Declaration
public virtual void StartClientSide(ICoreClientAPI api)
Parameters
Type | Name | Description |
---|---|---|
ICoreClientAPI | api |
StartPre(ICoreAPI)
Called during intial mod loading, called before any mod receives the call to Start()
Declaration
public virtual void StartPre(ICoreAPI api)
Parameters
Type | Name | Description |
---|---|---|
ICoreAPI | api |
StartServerSide(ICoreServerAPI)
Full start to the mod on the server side
In 1.17+ do NOT use this to add or update behaviors or attributes or other fixed properties of any block, item or entity, in code (additional to what is read from JSON).
It is already too late to do that here, it will not be seen client-side. Instead, code which needs to do that should be registered for event sapi.Event.AssetsFinalizers. See VSSurvivalMod system BlockReinforcement.cs for an example.
Declaration
public virtual void StartServerSide(ICoreServerAPI api)
Parameters
Type | Name | Description |
---|---|---|
ICoreServerAPI | api |