62 LOGWARNING(
"cChunkMap::WakeUpSimulators(int, int, int) is deprecated, use cChunkMap::WakeUpSimulators(Vector3i) instead.");
78 int a_ChunkX,
int a_ChunkZ,
96 int GetHeight (
int a_BlockX,
int a_BlockZ);
97 bool TryGetHeight (
int a_BlockX,
int a_BlockZ,
int & a_Height);
176 void AddPlayer(std::unique_ptr<cPlayer> a_Player);
212 void PrepareChunk(
int a_ChunkX,
int a_ChunkZ, std::unique_ptr<cChunkCoordCallback> a_CallAfter = {});
227 bool ForEachChunkInRect(
int a_MinChunkX,
int a_MaxChunkX,
int a_MinChunkZ,
int a_MaxChunkZ, cChunkDataCallback & a_Callback);
236 void GetChunkStats(
int & a_NumChunksValid,
int & a_NumChunksDirty)
const;
254 void Tick(std::chrono::milliseconds a_Dt);
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
std::vector< sSetBlock > sSetBlockVector
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
std::unique_ptr< cEntity > OwnedEntity
unsigned char BLOCKTYPE
The datatype used by blockdata.
void LOGWARNING(std::string_view a_Format, const Args &... args)
Represents two sets of coords, minimum and maximum for each direction.
Wraps the chunk coords into a single structure.
NIBBLETYPE BlockNibbles[NumBlocks/2]
The type used for block data in nibble format, AXIS_ORDER ordering.
Interface class used for comparing clients of two chunks.
bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome)
Sets the biome at the specified coords.
bool ForEachLoadedChunk(cFunctionRef< bool(int, int)> a_Callback) const
Calls the callback for each loaded chunk.
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
void UntrackInDeadlockDetect(cDeadlockDetect &a_DeadlockDetect)
Removes this chunkmap's CS from the DeadlockDetect's tracked CSs.
cChunk & GetChunk(int a_ChunkX, int a_ChunkZ)
Constructs a chunk and queues it for loading / generating if not valid, returning it.
void PrepareChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_CallAfter={})
Queues the chunk for preparing - making sure that it's generated and lit.
void SpawnMobs(cMobSpawner &a_MobSpawner)
Try to Spawn Monsters inside all Chunks.
bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome)
Sets the biome at the area.
void ChunkValidated(void)
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specifie...
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle &a_Client)
Sends the block entity, if it is at the coords specified, to a_Client.
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback a_Callback)
Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn'...
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos) const
NIBBLETYPE GetBlockSkyLight(Vector3i a_BlockPos) const
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ)
void MarkChunkRegenerating(int a_ChunkX, int a_ChunkZ)
Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::Regener...
cItems PickupsFromBlock(Vector3i a_BlockPos, const cEntity *a_Digger, const cItem *a_Tool)
Returns all the pickups that would result if the a_Digger dug up the block at a_BlockPos using a_Tool...
void SaveAllChunks(void) const
bool IsChunkValid(int a_ChunkX, int a_ChunkZ) const
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ)
std::map< cChunkCoords, cChunk > m_Chunks
A map of chunk coordinates to chunks.
void SetChunkData(SetChunkData &&a_SetChunkData)
Sets the chunk data as either loaded from the storage or generated.
void RemoveClientFromChunks(cClientHandle *a_Client)
Removes the client from all chunks it is present in.
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ)
Marks the chunk as failed-to-load.
NIBBLETYPE GetBlockBlockLight(Vector3i a_BlockPos) const
void GenerateChunk(int a_ChunkX, int a_ChunkZ)
Queues the chunk for generating.
void GetChunkStats(int &a_NumChunksValid, int &a_NumChunksDirty) const
Returns the number of valid chunks and the number of dirty chunks.
void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle *a_Client)
Removes the client from the chunk.
void AddChunkStay(cChunkStay &a_ChunkStay)
Adds a new cChunkStay descendant to the internal list of ChunkStays; loads its chunks.
void AddEntity(OwnedEntity a_Entity)
Adds the entity to its appropriate chunk, takes ownership of the entity pointer.
void SetNextBlockToTick(const Vector3i a_BlockPos)
Causes the specified block to be ticked on the next Tick() call.
void MarkChunkDirty(int a_ChunkX, int a_ChunkZ)
bool GetBlockInfo(Vector3i, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight) const
cChunk * FindChunk(int a_ChunkX, int a_ChunkZ)
Locates a chunk ptr in the chunkmap; doesn't create it when not found; assumes m_CSChunks is locked.
bool UseBlockEntity(cPlayer *a_Player, int a_X, int a_Y, int a_Z)
a_Player rclked block entity at the coords specified, handle it returns true if the use was successfu...
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_BlockMeta)
Sets the meta for the specified block, while keeping the blocktype.
void TickBlock(const Vector3i a_BlockPos)
Ticks a single block.
void ReplaceTreeBlocks(const sSetBlockVector &a_Blocks)
Special function used for growing trees, replaces only blocks that tree may overwrite.
bool WriteBlockArea(cBlockArea &a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
Writes the block area into the specified coords.
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
cWorld * GetWorld(void) const
bool ForEachEntity(cEntityCallback a_Callback) const
Calls the callback for each entity in the entire world; returns true if all entities processed,...
bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback)
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback)
Calls the callback for the block entity at the specified coords.
void DelChunkStay(cChunkStay &a_ChunkStay)
Removes the specified cChunkStay descendant from the internal list of ChunkStays.
OwnedEntity RemoveEntity(cEntity &a_Entity)
Removes the entity from its appropriate chunk Returns an owning reference to the found entity.
void TrackInDeadlockDetect(cDeadlockDetect &a_DeadlockDetect, const AString &a_WorldName)
Adds this chunkmap's CS to the DeadlockDetect's tracked CSs.
void CollectPickupsByEntity(cEntity &a_Entity)
Makes the specified entity collect all the pickups around them.
bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) const
void MarkChunkSaved(int a_ChunkX, int a_ChunkZ)
void WakeUpSimulators(Vector3i a_Block)
Wakes up simulators for the specified block.
bool GetBlocks(sSetBlockVector &a_Blocks, bool a_ContinueOnFailure)
Retrieves block types and metas of the specified blocks.
bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const
Returns true iff the chunk is in the loader / generator queue.
bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback a_Callback)
Calls the callback for each block entity in the specified chunk.
bool HasEntity(UInt32 a_EntityID) const
Returns true if the entity with specified ID is present in the chunks.
bool DigBlock(Vector3i a_BlockPos)
Removes the block at the specified coords and wakes up simulators.
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
std::list< cChunkStay * > cChunkStays
bool TryGetHeight(int a_BlockX, int a_BlockZ, int &a_Height)
bool AddChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle *a_Client)
Adds client to a chunk, if not already present; returns true if added, false if present.
void Tick(std::chrono::milliseconds a_Dt)
cChunkStays m_ChunkStays
The cChunkStay descendants that are currently enabled in this chunkmap.
bool ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback a_Callback)
Calls the callback for each entity in the specified chunk; returns true if all entities processed,...
EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ) const
Returns the biome at the specified coords.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
void UnloadUnusedChunks(void)
int GrowPlantAt(Vector3i a_BlockPos, int a_NumStages=1)
Grows the plant at the specified position by at most a_NumStages.
int GetHeight(int a_BlockX, int a_BlockZ)
bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
Calls the callback for the chunk at the block position specified, with ChunkMapCS locked; returns fal...
void CollectMobCensus(cMobCensus &a_ToFill)
Make a Mob census, of all mobs, their family, their chunk and their distance to closest player.
cCriticalSection & GetCS(void) const
Returns the CS for locking the chunkmap; only cWorld::cLock may use this function!
cCriticalSection m_CSChunks
size_t GetNumChunks(void) const
bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback &a_Callback)
Calls the callback for each chunk in the coords specified (all cords are inclusive).
size_t GetNumUnusedDirtyChunks(void) const
Returns the number of unused dirty chunks.
void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, const cPlayer &a_Player)
Sends the block at the specified coords to the specified player.
bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) const
cChunk & ConstructChunk(int a_ChunkX, int a_ChunkZ)
Returns or creates and returns a chunk pointer corresponding to the given chunk coordinates.
bool DoWithEntityByID(UInt32 a_EntityID, cEntityCallback a_Callback) const
Calls the callback if the entity with the specified ID is found, with the entity object as the callba...
bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const
void ChunkLighted(int a_ChunkX, int a_ChunkZ, const cChunkDef::BlockNibbles &a_BlockLight, const cChunkDef::BlockNibbles &a_SkyLight)
bool GetChunkData(cChunkCoords a_Coords, cChunkDataCallback &a_Callback) const
Calls the callback with the chunk's data, if available (with ChunkCS locked).
void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback &a_Callback)
Compares clients of two chunks, calls the callback accordingly.
void AddPlayer(std::unique_ptr< cPlayer > a_Player)
Adds the player to its appropriate chunk, takes ownership of the player pointer.
cChunkMap(cWorld *a_World)
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in...
This class bridges a vector of cItem for safe access via Lua.
This class is used to collect information, for each Mob, what is the distance of the closest player i...
This class is used to determine which monster can be spawned in which place it is essentially static ...
Contains the data for a loaded / generated chunk, ready to be set into a cWorld.