Table of Contents

Interface ICoreAPICommon

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

API Methods common to the server and client

public interface ICoreAPICommon

Properties

DataBasePath

Returns the root path of the games data folder

string DataBasePath { get; }

Property Value

string

ObjectCache

Can be used to store non-persistent, game wide data. E.g. used for firewood piles to pregenerate all meshes only once during startup

Dictionary<string, object> ObjectCache { get; }

Property Value

Dictionary<string, object>

Methods

GetOrCreateDataPath(string)

Returns the path to given foldername inside the games data folder. Ensures that the folder exists

string GetOrCreateDataPath(string foldername)

Parameters

foldername string

Returns

string

LoadModConfig(string)

JsonObject LoadModConfig(string filename)

Parameters

filename string

Returns

JsonObject

LoadModConfig<T>(string)

Milo kept asking for a standardized way to load and store mod configuration data, so here you go :P Recommendation: Surround this call with a try/catch in case the user made a typo while changing the configuration Returns null if the file does not exist

T LoadModConfig<T>(string filename)

Parameters

filename string

Returns

T

Type Parameters

T

RegisterBlockBehaviorClass(string, Type)

Register a new block behavior class. Must happen before any blocks are loaded. Be sure to register it on the client and server side.

void RegisterBlockBehaviorClass(string className, Type blockBehaviorType)

Parameters

className string
blockBehaviorType Type

RegisterBlockClass(string, Type)

Register a new Blockclass. Must happen before any blocks are loaded. Be sure to register it on the client and server side.

void RegisterBlockClass(string className, Type blockType)

Parameters

className string

Class to register

blockType Type

Name of the class

RegisterBlockEntityBehaviorClass(string, Type)

Register a new block entity behavior class. Must happen before any blocks are loaded. Be sure to register it on the client and server side.

void RegisterBlockEntityBehaviorClass(string className, Type blockEntityBehaviorType)

Parameters

className string
blockEntityBehaviorType Type

RegisterBlockEntityClass(string, Type)

Register a new BlockEntity Class. Must happen before any blocks are loaded. Be sure to register it on the client and server side.

void RegisterBlockEntityClass(string className, Type blockentityType)

Parameters

className string
blockentityType Type

RegisterCollectibleBehaviorClass(string, Type)

Registers a new collectible behavior class, which can be used for items or for blocks.

void RegisterCollectibleBehaviorClass(string className, Type blockBehaviorType)

Parameters

className string
blockBehaviorType Type

RegisterColorMap(ColorMap)

Registers a new color map. Typically used to color in-game blocks with a texture - i.e. climate and seasonal coloring

void RegisterColorMap(ColorMap map)

Parameters

map ColorMap

RegisterCropBehavior(string, Type)

Register a new crop behavior

void RegisterCropBehavior(string className, Type type)

Parameters

className string
type Type

RegisterEntity(string, Type)

Registers a non-block entity. Be sure to register it on the client and server side.

void RegisterEntity(string className, Type entity)

Parameters

className string
entity Type

RegisterEntityBehaviorClass(string, Type)

Registers a non-block entity behavior. Be sure to register it on the client and server side.

void RegisterEntityBehaviorClass(string className, Type entityBehavior)

Parameters

className string
entityBehavior Type

RegisterItemClass(string, Type)

Register a new Item Class. Must happen before any blocks are loaded. Be sure to register it on the client and server side.

void RegisterItemClass(string className, Type itemType)

Parameters

className string
itemType Type

RegisterMountable(string, GetMountableDelegate)

Register a new block behavior class. Must happen before any blocks are loaded. Be sure to register it on the client and server side. Make your your delegate also set tree.SetString("className", "[your className]");

void RegisterMountable(string className, GetMountableDelegate mountableInstancer)

Parameters

className string
mountableInstancer GetMountableDelegate

RegisterRecipeRegistry<T>(string)

Registers a recipe registry

T RegisterRecipeRegistry<T>(string recipeRegistryCode) where T : RecipeRegistryBase

Parameters

recipeRegistryCode string

Returns

T

Type Parameters

T

StoreModConfig(JsonObject, string)

void StoreModConfig(JsonObject jobj, string filename)

Parameters

jobj JsonObject
filename string

StoreModConfig<T>(T, string)

Milo kept asking for a standardized way to load and store mod configuration data, so here you go :P For T just make a class with all fields public - this is your configuration class. Be sure to set useful default values for your settings

void StoreModConfig<T>(T jsonSerializeableData, string filename)

Parameters

jsonSerializeableData T
filename string

Type Parameters

T