Interface IWorldManagerAPI
- Namespace
- Vintagestory.API.Server
- Assembly
- VintagestoryAPI.dll
Methods to modify the game world
public interface IWorldManagerAPI
- Extension Methods
Properties
AllLoadedChunks
Returns a (cloned) list of all currently loaded chunks. The key is the 3d index of the chunk, can be turned into an x/y/z coord. Warning: This locks the loaded chunk dictionary during the clone, preventing other threads from updating it. In other words: Using this method often will have a significant performance impact.
Dictionary<long, IServerChunk> AllLoadedChunks { get; }
Property Value
AllLoadedMapRegions
Returns a (cloned) list of all currently loaded map regions. The key is the 2d index of the map region, can be turned into an x/z coord
Dictionary<long, IMapRegion> AllLoadedMapRegions { get; }
Property Value
AllLoadedMapchunks
Returns a (cloned) list of all currently loaded map chunks. The key is the 2d index of the map chunk, can be turned into an x/z coord
Dictionary<long, IMapChunk> AllLoadedMapchunks { get; }
Property Value
AutoGenerateChunks
Completely disables automatic generation of chunks that normally builds up a radius of chunks around the player.
bool AutoGenerateChunks { get; set; }
Property Value
ChunkDeletionsInQueue
int ChunkDeletionsInQueue { get; }
Property Value
ChunkSize
Width/Length/Height in blocks of a chunk on the server
int ChunkSize { get; }
Property Value
CurrentGeneratingChunkCount
Amount of chunk columns currently in the generating queue
int CurrentGeneratingChunkCount { get; }
Property Value
CurrentPlayStyle
The currently selected playstyle
PlayStyle CurrentPlayStyle { get; }
Property Value
CurrentWorldName
The current world filename
string CurrentWorldName { get; }
Property Value
DefaultSpawnPosition
Retrieves the default spawnpoint (x/y/z coordinate)
int[] DefaultSpawnPosition { get; }
Property Value
- int[]
Default spawnpoint
MapSizeX
Width of the current world
int MapSizeX { get; }
Property Value
MapSizeY
Height of the current world
int MapSizeY { get; }
Property Value
MapSizeZ
Length of the current world
int MapSizeZ { get; }
Property Value
RegionSize
Width/Length/Height in blocks of a region on the server
int RegionSize { get; }
Property Value
SaveGame
The worlds savegame object. If you change these values they will be permanently stored
ISaveGame SaveGame { get; }
Property Value
Seed
Get the seed used to generate the current world
int Seed { get; }
Property Value
- int
The map seed
SendChunks
Disables sending of normal chunks to all players except for force loaded ones using ForceLoadChunkColumn
bool SendChunks { get; set; }
Property Value
Methods
BroadcastChunk(int, int, int, bool)
Send or Resend a loaded chunk to all connected players. Has no effect when the chunk is not loaded
void BroadcastChunk(int chunkX, int chunkY, int chunkZ, bool onlyIfInRange = true)
Parameters
chunkX
intchunkY
intchunkZ
intonlyIfInRange
boolIf true, the chunk will not be sent to connected players that are out of range from that chunk
ChunkIndex3D(int, int, int)
long ChunkIndex3D(int chunkX, int chunkY, int chunkZ)
Parameters
Returns
CreateChunkColumnForDimension(int, int, int)
Creates columns of empty chunks in the specified dimension
void CreateChunkColumnForDimension(int cx, int cz, int dim)
Parameters
DeleteChunkColumn(int, int)
Deletes a column of chunks at given coordinate from the save file. Also deletes the map chunk at the same coordinate (but keeps the map region). Also unloads the chunk in the same process. Also deletes all entities in this chunk
void DeleteChunkColumn(int chunkX, int chunkZ)
Parameters
DeleteMapRegion(int, int)
Deletes a map region at given coordinate from the save file
void DeleteMapRegion(int regionX, int regionZ)
Parameters
ForceSendChunkColumn(IServerPlayer, int, int, int)
API access to force send a chunk column in any dimension
void ForceSendChunkColumn(IServerPlayer player, int cx, int cz, int dimension)
Parameters
player
IServerPlayercx
intcz
intdimension
int
FullRelight(BlockPos, BlockPos)
Does a complete relighting of the cuboid deliminated by given min/max pos. Completely resends all affected chunk columns to all connected nearby clients.
void FullRelight(BlockPos minPos, BlockPos maxPos)
Parameters
FullRelight(BlockPos, BlockPos, bool)
Does a complete relighting of the cuboid deliminated by given min/max pos. Can completely resend all affected chunk columns to all connected nearby clients.
void FullRelight(BlockPos minPos, BlockPos maxPos, bool sendToClients)
Parameters
GetBlockAccessor(bool, bool, bool, bool)
Retrieve a customized interface to access blocks in the loaded game world.
[Obsolete("Use api.World.GetBlockAccessor instead")]
IBlockAccessor GetBlockAccessor(bool synchronize, bool relight, bool strict, bool debug = false)
Parameters
synchronize
boolWhether or not a call to Setblock should send the update also to all connected clients
relight
boolWhether or not to relight the chunk after a call to SetBlock and the light values changed by that
strict
boolLog an error message if GetBlock/SetBlock was called to an unloaded chunk
debug
boolIf strict, crashes the server if a unloaded chunk was crashed, prints an exception and exports a png image of the current loaded chunks
Returns
GetBlockAccessorBulkUpdate(bool, bool, bool)
Retrieve a customized interface to access blocks in the loaded game world. Does not to relight/sync on a SetBlock until Commit() is called. On commit all touched blocks are relit/synced at once. This method should be used when setting many blocks (e.g. tree generation, explosion, etc.).
[Obsolete("Use api.World.GetBlockAccessorBulkUpdate instead")]
IBulkBlockAccessor GetBlockAccessorBulkUpdate(bool synchronize, bool relight, bool debug = false)
Parameters
synchronize
boolWhether or not a call to Setblock should send the update also to all connected clients
relight
boolWhether or not to relight the chunk after the a call to SetBlock and the light values changed by that
debug
bool
Returns
GetBlockAccessorPrefetch(bool, bool)
Same as GetBlockAccessor but you have to call PrefetchBlocks() before using GetBlock(). It pre-loads all blocks in given area resulting in faster GetBlock() access
[Obsolete("Use api.World.GetBlockAccessorPrefetch instead")]
IBlockAccessorPrefetch GetBlockAccessorPrefetch(bool synchronize, bool relight)
Parameters
synchronize
boolWhether or not a call to Setblock should send the update also to all connected clients
relight
boolWhether or not to relight the chunk after a call to SetBlock and the light values changed by that
Returns
GetBlockAccessorRevertable(bool, bool, bool)
Same as GetBlockAccessorBulkUpdate, additionally, each Commit() stores the previous state and you can perform undo/redo operations on these.
[Obsolete("Use api.World.GetBlockAccessorRevertable instead")]
IBlockAccessorRevertable GetBlockAccessorRevertable(bool synchronize, bool relight, bool debug = false)
Parameters
synchronize
boolWhether or not a call to Setblock should send the update also to all connected clients
relight
boolWhether or not to relight the chunk after a call to SetBlock and the light values changed by that
debug
bool
Returns
GetBlockId(AssetLocation)
Get the ID of a certain BlockType
int GetBlockId(AssetLocation name)
Parameters
name
AssetLocationName of the BlockType
Returns
- int
ID of the BlockType
GetCachingBlockAccessor(bool, bool)
Same as the normal block accessor but remembers the previous chunk that was accessed. This can give you a 10-50% performance boosts when you scan many blocks in tight loops DONT FORGET: Call .Begin() before getting/setting in a tight loop. Not calling it can cause the game to crash
[Obsolete("Use api.World.GetCachingBlockAccessor instead")]
ICachingBlockAccessor GetCachingBlockAccessor(bool synchronize, bool relight)
Parameters
Returns
GetChunk(int, int, int)
Gets the Server chunk at given coordinate. Returns null if it's not loaded or does not exist yet
IServerChunk GetChunk(int chunkX, int chunkY, int chunkZ)
Parameters
Returns
GetChunk(long)
Gets the Server chunk at given coordinate. Returns null if it's not loaded or does not exist yet
IServerChunk GetChunk(long index3d)
Parameters
index3d
long
Returns
GetChunk(BlockPos)
Gets the Server chunk at given coordinate. Returns null if it's not loaded or does not exist yet
IServerChunk GetChunk(BlockPos pos)
Parameters
pos
BlockPos
Returns
GetMapChunk(int, int)
Gets the Server map chunk at given coordinate. Returns null if it's not loaded or does not exist yet
IServerMapChunk GetMapChunk(int chunkX, int chunkZ)
Parameters
Returns
GetMapChunk(long)
Gets the Server map chunk at given coordinate index. Returns null if it's not loaded or does not exist yet
IMapChunk GetMapChunk(long index2d)
Parameters
index2d
long
Returns
GetMapRegion(int, int)
Gets the Server map region at given coordinate. Returns null if it's not loaded or does not exist yet
IMapRegion GetMapRegion(int regionX, int regionZ)
Parameters
Returns
GetMapRegion(long)
Gets the Server map region at given coordinate. Returns null if it's not loaded or does not exist yet
IMapRegion GetMapRegion(long index2d)
Parameters
index2d
long
Returns
GetNextUniqueId()
Returns a number that is guaranteed to be unique for the current world every time it is called. Curently use for entity herding behavior.
long GetNextUniqueId()
Returns
GetSurfacePosY(int, int)
Finds the first y position that is solid ground to stand on. Returns null if the chunk is not loaded.
int? GetSurfacePosY(int posX, int posZ)
Parameters
Returns
- int?
HasChunk(int, int, int, IServerPlayer)
Returns true if the server sent chunk at given coords to player and has it not unloaded yet
bool HasChunk(int chunkX, int chunkY, int chunkZ, IServerPlayer player)
Parameters
chunkX
intchunkY
intchunkZ
intplayer
IServerPlayer
Returns
LoadChunkColumn(int, int, bool)
Asynchronly normal priority load a chunk column at given coordinate. No effect when already loaded.
void LoadChunkColumn(int chunkX, int chunkZ, bool keepLoaded = false)
Parameters
chunkX
intchunkZ
intkeepLoaded
boolIf true, the chunk will never get unloaded unless UnloadChunkColumn() is called
LoadChunkColumnFast(int, int, int, int, ChunkLoadOptions)
Asynchronly high priority load an area of chunk columns at given coordinates. Make sure that X1<=X2 and Z1<=Z2
[Obsolete("Use LoadChunkColumnPriority()")]
void LoadChunkColumnFast(int chunkX1, int chunkZ1, int chunkX2, int chunkZ2, ChunkLoadOptions options = null)
Parameters
chunkX1
intchunkZ1
intchunkX2
intchunkZ2
intoptions
ChunkLoadOptionsAdditional loading options
LoadChunkColumnFast(int, int, ChunkLoadOptions)
Asynchronly high priority load a chunk column at given coordinate.
[Obsolete("Use LoadChunkColumnPriority()")]
void LoadChunkColumnFast(int chunkX, int chunkZ, ChunkLoadOptions options = null)
Parameters
chunkX
intchunkZ
intoptions
ChunkLoadOptionsAdditional loading options
LoadChunkColumnForDimension(int, int, int)
Loads chunk columns for the specified dimension
void LoadChunkColumnForDimension(int cx, int cz, int dim)
Parameters
LoadChunkColumnPriority(int, int, int, int, ChunkLoadOptions)
Asynchronly high priority load an area of chunk columns at given coordinates. Make sure that X1<=X2 and Z1<=Z2
void LoadChunkColumnPriority(int chunkX1, int chunkZ1, int chunkX2, int chunkZ2, ChunkLoadOptions options = null)
Parameters
chunkX1
intchunkZ1
intchunkX2
intchunkZ2
intoptions
ChunkLoadOptionsAdditional loading options
LoadChunkColumnPriority(int, int, ChunkLoadOptions)
Asynchronly high priority load a chunk column at given coordinate.
void LoadChunkColumnPriority(int chunkX, int chunkZ, ChunkLoadOptions options = null)
Parameters
chunkX
intchunkZ
intoptions
ChunkLoadOptionsAdditional loading options
MapChunkIndex2D(int, int)
long MapChunkIndex2D(int chunkX, int chunkZ)
Parameters
Returns
MapChunkPosFromChunkIndex2D(long)
Vec2i MapChunkPosFromChunkIndex2D(long index2d)
Parameters
index2d
long
Returns
MapRegionIndex2D(int, int)
long MapRegionIndex2D(int regionX, int regionZ)
Parameters
Returns
MapRegionIndex2DByBlockPos(int, int)
long MapRegionIndex2DByBlockPos(int posX, int posZ)
Parameters
Returns
MapRegionPosFromIndex2D(long)
Vec3i MapRegionPosFromIndex2D(long index2d)
Parameters
index2d
long
Returns
PeekChunkColumn(int, int, ChunkPeekOptions)
Generates chunk at given coordinate, completely bypassing any existing world data and caching methods, in other words generates, a chunk from scratch without keeping it in the list of loaded chunks
void PeekChunkColumn(int chunkX, int chunkZ, ChunkPeekOptions options)
Parameters
chunkX
intchunkZ
intoptions
ChunkPeekOptions
ResendMapChunk(int, int, bool)
Send or resent a loaded map chunk to all connected players. Has no effect when the map chunk is not loaded
void ResendMapChunk(int chunkX, int chunkZ, bool onlyIfInRange)
Parameters
SendChunk(int, int, int, IServerPlayer, bool)
Send or Resend a loaded chunk to a connected player. Has no effect when the chunk is not loaded
void SendChunk(int chunkX, int chunkY, int chunkZ, IServerPlayer player, bool onlyIfInRange = true)
Parameters
chunkX
intchunkY
intchunkZ
intplayer
IServerPlayeronlyIfInRange
boolIf true, the chunk will not be sent to connected players that are out of range from that chunk
SetBlockLightLevels(float[])
Allows setting a 32 float array that defines the brightness of each block light level. Has to be set before any players join or any chunks are generated.
void SetBlockLightLevels(float[] lightLevels)
Parameters
lightLevels
float[]
SetDefaultSpawnPosition(int, int, int)
Permanently sets the default spawnpoint
void SetDefaultSpawnPosition(int x, int y, int z)
Parameters
x
intX coordinate of new spawnpoint
y
intY coordinate of new spawnpoint
z
intZ coordinate of new spawnpoint
SetSeaLevel(int)
Sets the default sea level for the world to be generated. Currently used by the client to calculate the correct temperature/rainfall values for climate tinting.
void SetSeaLevel(int sealevel)
Parameters
sealevel
int
SetSunBrightness(int)
Sets the default light range of sunlight. Default is 24. Has to be set before any players join or any chunks are generated.
void SetSunBrightness(int lightlevel)
Parameters
lightlevel
int
SetSunLightLevels(float[])
Allows setting a 32 float array that defines the brightness of each sun light level. Has to be set before any players join or any chunks are generated.
void SetSunLightLevels(float[] lightLevels)
Parameters
lightLevels
float[]
SunFloodChunkColumnForWorldGen(IWorldChunk[], int, int)
Floods the chunk column with sunlight. Only works on full chunk columns.
void SunFloodChunkColumnForWorldGen(IWorldChunk[] chunks, int chunkX, int chunkZ)
Parameters
chunks
IWorldChunk[]chunkX
intchunkZ
int
SunFloodChunkColumnNeighboursForWorldGen(IWorldChunk[], int, int)
Spreads the chunk columns light into neighbour chunks and vice versa. Only works on full chunk columns.
void SunFloodChunkColumnNeighboursForWorldGen(IWorldChunk[] chunks, int chunkX, int chunkZ)
Parameters
chunks
IWorldChunk[]chunkX
intchunkZ
int
TestChunkExists(int, int, int, Action<bool>)
Asynchrounly checks if this chunk is currently loaded or in the savegame database. Calls the callback method with true or false once done looking up. Does not load the actual chunk data.
void TestChunkExists(int chunkX, int chunkY, int chunkZ, Action<bool> onTested)
Parameters
TestMapChunkExists(int, int, Action<bool>)
Asynchrounly checks if this map chunk is currently loaded or in the savegame database. Calls the callback method with true or false once done looking up. Does not load the actual map chunk data.
void TestMapChunkExists(int chunkX, int chunkZ, Action<bool> onTested)
Parameters
TestMapRegionExists(int, int, Action<bool>)
Asynchrounly checks if this mapregion is currently loaded or in the savegame database. Calls the callback method with true or false once done looking up. Does not load the actual map region data.
void TestMapRegionExists(int regionX, int regionZ, Action<bool> onTested)
Parameters
UnloadChunkColumn(int, int)
Unloads a column of chunks at given coordinate independent of any nearby players and sends an appropriate unload packet to the player
void UnloadChunkColumn(int chunkX, int chunkZ)