Interface IServerEventAPI
- Namespace
- Vintagestory.API.Server
- Assembly
- VintagestoryAPI.dll
Contains methods to hook into various server processes
public interface IServerEventAPI : IEventAPI
- Inherited Members
- Extension Methods
Methods
ChunkColumnGeneration(ChunkColumnGenerationDelegate, EnumWorldGenPass, string)
Vintagestory uses this method to generate the basic terrain (base terrain + rock strata + caves) in full columns. Only called once in pass EnumWorldGenPass.TerrainNoise. Register to this event if you need acces to a whole chunk column during inital generation.
void ChunkColumnGeneration(ChunkColumnGenerationDelegate handler, EnumWorldGenPass pass, string forWorldType)
Parameters
handler
ChunkColumnGenerationDelegatepass
EnumWorldGenPassforWorldType
stringFor which world types to use this generator
GetRegisteredWorldGenHandlers(string)
Returns the list of currently registered map chunk generator handlers for given world type. Returns an array of handler lists. Each element in the array represents all the handlers for one worldgenpass (see EnumWorldGenPass) When world type is null, all handlers are returned
IWorldGenHandler GetRegisteredWorldGenHandlers(string worldType)
Parameters
worldType
string"standard" for the vanilla world generator
Returns
GetWorldgenBlockAccessor(WorldGenThreadDelegate)
If you require neighbour chunk data during world generation, you have to register to this event to receive access to the chunk generator thread. This method is only called once during server startup.
void GetWorldgenBlockAccessor(WorldGenThreadDelegate handler)
Parameters
handler
WorldGenThreadDelegate
InitWorldGenerator(Action, string)
Triggered before the first chunk, map chunk or map region is generated, given that the passed on world type has been selected. Called right after the save game has been loaded.
void InitWorldGenerator(Action handler, string forWorldType)
Parameters
MapChunkGeneration(MapChunkGeneratorDelegate, string)
Event that is triggered whenever a new column of chunks is being generated. It is always called before the ChunkGenerator event
void MapChunkGeneration(MapChunkGeneratorDelegate handler, string forWorldType)
Parameters
handler
MapChunkGeneratorDelegateforWorldType
stringFor which world types to use this generator
MapRegionGeneration(MapRegionGeneratorDelegate, string)
Event that is triggered whenever a new 16x16 section of column of chunks is being generated. It is always called before the ChunkGenerator and before the MapChunkGeneration event
void MapRegionGeneration(MapRegionGeneratorDelegate handler, string forWorldType)
Parameters
handler
MapRegionGeneratorDelegateforWorldType
stringFor which world types to use this generator
ServerRunPhase(EnumServerRunPhase, Action)
Triggered whenever the server enters a new run phase. Since mods are only loaded during run phase "LoadGamePre" registering to any earlier event will get triggered.
void ServerRunPhase(EnumServerRunPhase runPhase, Action handler)
Parameters
runPhase
EnumServerRunPhasehandler
Action
Timer(Action, double)
Registers a method to be called every given interval
void Timer(Action handler, double interval)
Parameters
TriggerTrySpawnEntity(IBlockAccessor, ref EntityProperties, Vec3d, long)
bool TriggerTrySpawnEntity(IBlockAccessor blockAccessor, ref EntityProperties properties, Vec3d position, long herdId)
Parameters
blockAccessor
IBlockAccessorproperties
EntityPropertiesposition
Vec3dherdId
long
Returns
TriggerWorldgenHook(string, IBlockAccessor, BlockPos, string)
Trigger the special worldgen hook, with the name "hook", if it exists
void TriggerWorldgenHook(string hook, IBlockAccessor blockAccessor, BlockPos pos, string param)
Parameters
hook
stringblockAccessor
IBlockAccessorpos
BlockPosparam
string
WorldgenHook(WorldGenHookDelegate, string, string)
Registers a method to be called by certain special worldgen triggers, for example Resonance Archives entrance staircase
void WorldgenHook(WorldGenHookDelegate handler, string forWorldType, string hook)
Parameters
handler
WorldGenHookDelegateforWorldType
stringhook
string
Events
AfterActiveSlotChanged
Fired after a player changes their active slot (such as selected hotbar slot).
event Action<IServerPlayer, ActiveSlotChangeEventArgs> AfterActiveSlotChanged
Event Type
AssetsFinalizers
Triggered after assets have been loaded and parsed and registered, but before they are declared to be ready - e.g. you can add more behaviors here, or make other code-based changes to properties read from JSONs
Note: modsystems should register for this in a Start() method not StartServerSide(): the AssetsFinalizer event is fired before StartServerSide() is reached
[Obsolete("Override Method Modsystem.AssetsFinalize instead")]
event Action AssetsFinalizers
Event Type
BeforeActiveSlotChanged
Fired before a player changes their active slot (such as selected hotbar slot). Allows for the event to be cancelled depending on the return value.
event Func<IServerPlayer, ActiveSlotChangeEventArgs, EnumHandling> BeforeActiveSlotChanged
Event Type
BeginChunkColumnLoadChunkThread
Called when just loaded (or generated) a full chunkcolumn
event ChunkColumnBeginLoadChunkThread BeginChunkColumnLoadChunkThread
Event Type
BreakBlock
Called when a block should got broken now (that has been broken by a player). Set handling to PreventDefault to handle the block breaking yourself. Otherwise the engine will break the block (= either call heldItemstack.Collectible.OnBlockBrokenWith when player holds something in his hands or block.OnBlockBroken).
event BlockBreakDelegate BreakBlock
Event Type
CanPlaceOrBreakBlock
Registers a handler to be called every time a player places a block. The methods return value determines if the player may place/break this block. When returning false the client will be notified and the action reverted
event CanPlaceOrBreakDelegate CanPlaceOrBreakBlock
Event Type
CanUseBlock
Registers a handler to be called every time a player uses a block. The methods return value determines if the player may place/break this block.
event CanUseDelegate CanUseBlock
Event Type
ChunkColumnLoaded
Called whenever the server loaded from disk or fully generated a chunkcolumn
event ChunkColumnLoadedDelegate ChunkColumnLoaded
Event Type
ChunkColumnUnloaded
Called just before a chunk column is about to get unloaded. On shutdown this method is called for all loaded chunks, so this method can get called tens of thousands of times there, beware
event ChunkColumnUnloadDelegate ChunkColumnUnloaded
Event Type
DidBreakBlock
Registers a method to be called every time a player deletes a block. Called after the block was already broken
event BlockBrokenDelegate DidBreakBlock
Event Type
DidPlaceBlock
Registers a method to be called every time a player places a block
event BlockPlacedDelegate DidPlaceBlock
Event Type
DidUseBlock
Registers a method to be called every time a player uses a block
event BlockUsedDelegate DidUseBlock
Event Type
GameWorldSave
Triggered before the game world data is being saved to disk
event Action GameWorldSave
Event Type
OnPlayerInteractEntity
Called when a player interacts with an entity
event OnInteractDelegate OnPlayerInteractEntity
Event Type
OnTrySpawnEntity
Called when the server attempts to spawn given entity. Return false to deny spawning.
event TrySpawnEntityDelegate OnTrySpawnEntity
Event Type
PlayerChat
Called when a player wrote a chat message
event PlayerChatDelegate PlayerChat
Event Type
PlayerCreate
Called when a new player joins
event PlayerDelegate PlayerCreate
Event Type
PlayerDeath
Called when a player died
event PlayerDeathDelegate PlayerDeath
Event Type
PlayerDisconnect
Called whenever a player disconnects (timeout, leave, disconnect, kick, etc.).
event PlayerDelegate PlayerDisconnect
Event Type
PlayerJoin
Called when a player joins
event PlayerDelegate PlayerJoin
Event Type
PlayerLeave
Called when a player intentionally leaves
event PlayerDelegate PlayerLeave
Event Type
PlayerNowPlaying
Called when a player joins and his client is now fully loaded and ready to play
event PlayerDelegate PlayerNowPlaying
Event Type
PlayerRespawn
Called when a player got respawned
event PlayerDelegate PlayerRespawn
Event Type
PlayerSwitchGameMode
Whenever a player switched his game mode or has it switched for him
event PlayerDelegate PlayerSwitchGameMode
Event Type
SaveGameCreated
Triggered after a savegame has been created - i.e. when a new world was created
event Action SaveGameCreated
Event Type
SaveGameLoaded
Triggered after the game world data has been loaded. At this point all blocks are loaded and the Map size is known.
In 1.17+ do NOT use this server event 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).
Instead, code which needs to do that should be registered for event sapi.Event.AssetsFinalizers. See VSSurvivalMod system BlockReinforcement.cs for an example.
event Action SaveGameLoaded
Event Type
ServerResume
Called when something wants to resume execution of the server, e.g. the autosave system
event ResumeServerDelegate ServerResume
Event Type
ServerSuspend
Called when something wants to pause the server, e.g. the autosave system. This method will be called every 50ms until all delegates return Ready state. Timeout is 60 seconds.
event SuspendServerDelegate ServerSuspend
Event Type
WorldgenStartup
Triggered when starting up worldgen during server startup (as the final stage of the WorldReady EnumServerRunPhase)
event Action WorldgenStartup