Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
cChunk Class Reference

#include <Chunk.h>

Collaboration diagram for cChunk:
Collaboration graph
[legend]

Classes

struct  sSetBlockQueueItem
 

Public Types

enum  ePresence { cpInvalid , cpQueued , cpPresent }
 Represents the presence state of the chunk. More...
 

Public Member Functions

bool AddClient (cClientHandle *a_Client)
 Adds a client to the chunk; returns true if added, false if already there. More...
 
void AddEntity (OwnedEntity a_Entity)
 
void BroadcastPendingChanges (void)
 Flushes the pending block (entity) queue, and clients' outgoing data buffers. More...
 
bool CanUnload (void) const
 
bool CanUnloadAfterSaving (void) const
 Returns true if the chunk could have been unloaded if it weren't dirty. More...
 
 cChunk (const cChunk &Other)=delete
 
 cChunk (int a_ChunkX, int a_ChunkZ, cChunkMap *a_ChunkMap, cWorld *a_World)
 
void CollectMobCensus (cMobCensus &toFill)
 Recence all mobs proximities to players in order to know what to do with them. More...
 
bool DoWithBlockEntityAt (Vector3i a_Position, cBlockEntityCallback a_Callback)
 Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, and whatever the callback returns if found. More...
 
bool DoWithEntityByID (UInt32 a_EntityID, cEntityCallback a_Callback, bool &a_CallbackResult) const
 Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. More...
 
void FastSetBlock (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
 
void FastSetBlock (Vector3i a_RelPos, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
 
bool ForEachBlockEntity (cBlockEntityCallback a_Callback)
 Calls the callback for each block entity; returns true if all block entities processed, false if the callback aborted by returning true. More...
 
bool ForEachEntity (cEntityCallback a_Callback) const
 Calls the callback for each entity; returns true if all entities processed, false if the callback aborted by returning true. More...
 
bool ForEachEntityInBox (const cBoundingBox &a_Box, cEntityCallback a_Callback) const
 Calls the callback for each entity that has a nonempty intersection with the specified boundingbox. More...
 
const auto & GetAllClients (void) const
 
void GetAllData (cChunkDataCallback &a_Callback) const
 Gets all chunk data, calls the a_Callback's methods for each data type. More...
 
EMCSBiome GetBiomeAt (int a_RelX, int a_RelZ) const
 
BLOCKTYPE GetBlock (int a_RelX, int a_RelY, int a_RelZ) const
 
BLOCKTYPE GetBlock (Vector3i a_RelCoords) const
 
cBlockEntityGetBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ)
 OBSOLETE, use the Vector3i-based overload instead. More...
 
cBlockEntityGetBlockEntity (Vector3i a_AbsPos)
 Returns the block entity at the specified (absolute) coords. More...
 
cBlockEntityGetBlockEntityRel (Vector3i a_RelPos)
 Returns the block entity at the specified (relative) coords. More...
 
void GetBlockInfo (Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_Meta, NIBBLETYPE &a_SkyLight, NIBBLETYPE &a_BlockLight) const
 
NIBBLETYPE GetBlockLight (int a_RelX, int a_RelY, int a_RelZ) const
 
NIBBLETYPE GetBlockLight (Vector3i a_RelPos) const
 Get the level of artificial light illuminating the block (0 - 15) More...
 
void GetBlockTypeMeta (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
 
void GetBlockTypeMeta (Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
 
bool GetChunkAndRelByAbsolute (const Vector3d &a_Position, cChunk **a_Chunk, Vector3i &a_Rel)
 Convert absolute coordinates into relative coordinates. More...
 
bool GetChunkAndRelByAbsolute (const Vector3i &a_Position, cChunk **a_Chunk, Vector3i &a_Rel)
 Convert absolute coordinates into relative coordinates. More...
 
cFireSimulatorChunkDataGetFireSimulatorData (void)
 
int GetHeight (int a_X, int a_Z) const
 
cFluidSimulatorDataGetLavaSimulatorData (void) const
 
NIBBLETYPE GetMeta (int a_RelX, int a_RelY, int a_RelZ) const
 
NIBBLETYPE GetMeta (Vector3i a_RelPos) const
 
cChunkGetNeighborChunk (int a_BlockX, int a_BlockZ)
 Returns the chunk into which the specified block belongs, by walking the neighbors. More...
 
cChunkCoords GetPos () const
 
int GetPosX (void) const
 
int GetPosZ (void) const
 
cRedstoneSimulatorChunkDataGetRedstoneSimulatorData (void) const
 
cChunkGetRelNeighborChunk (int a_RelX, int a_RelZ)
 Returns the chunk into which the relatively-specified block belongs, by walking the neighbors. More...
 
cChunkGetRelNeighborChunkAdjustCoords (Vector3i &a_RelPos) const
 Returns the chunk into which the relatively-specified block belongs. More...
 
cSandSimulatorChunkDataGetSandSimulatorData (void)
 
NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const
 
NIBBLETYPE GetSkyLight (Vector3i a_RelPos) const
 Get the level of sky light illuminating the block (0 - 15) independent of daytime. More...
 
NIBBLETYPE GetSkyLightAltered (int a_RelX, int a_RelY, int a_RelZ) const
 
NIBBLETYPE GetSkyLightAltered (Vector3i a_RelPos) const
 Get the level of sky light illuminating the block (0 - 15), taking daytime into a account. More...
 
NIBBLETYPE GetTimeAlteredLight (NIBBLETYPE a_Skylight) const
 Light alterations based on time. More...
 
cFluidSimulatorDataGetWaterSimulatorData (void) const
 
cWorldGetWorld (void) const
 
bool HasAnyClients (void) const
 Returns true if theres any client in the chunk; false otherwise. More...
 
bool HasClient (cClientHandle *a_Client)
 Returns true if the specified client is present in this chunk. More...
 
bool HasEntity (UInt32 a_EntityID) const
 
bool IsDirty (void) const
 Returns true iff the chunk has changed since it was last saved. More...
 
bool IsLightValid (void) const
 
bool IsQueued (void) const
 Returns true iff the chunk is in the queue for loading / generating. More...
 
bool IsSlimeChunk () const
 Returns true if slimes should spawn in the chunk. More...
 
bool IsValid (void) const
 Returns true iff the chunk block data is valid (loaded / generated) More...
 
bool IsWeatherSunnyAt (int a_RelX, int a_RelZ) const
 Returns true if it is sunny at the specified location. More...
 
bool IsWeatherWetAt (int a_RelX, int a_RelZ) const
 Returns true if it is raining or storming at the specified location, taking into account biomes. More...
 
bool IsWeatherWetAt (Vector3i a_Position) const
 Returns true if it is raining or storming at the specified location, and the rain reaches (the bottom of) the specified block position. More...
 
void MarkDirty (void)
 
void MarkLoaded (void)
 
void MarkLoadFailed (void)
 Queues the chunk for generating. More...
 
void MarkRegenerating (void)
 Marks all clients attached to this chunk as wanting this chunk. More...
 
void MarkSaved (void)
 
void MarkSaving (void)
 
void OnUnload ()
 Called when the chunkmap unloads unused chunks. More...
 
Vector3i PositionToWorldPosition (int a_RelX, int a_RelY, int a_RelZ)
 
void PositionToWorldPosition (int a_RelX, int a_RelY, int a_RelZ, int &a_BlockX, int &a_BlockY, int &a_BlockZ)
 
Vector3i PositionToWorldPosition (Vector3i a_RelPos)
 
Vector3i RelativeToAbsolute (Vector3i a_RelBlockPosition) const
 Converts the coord relative to this chunk into an absolute coord. More...
 
void RemoveClient (cClientHandle *a_Client)
 Removes the specified client from the chunk; ignored if client not in chunk. More...
 
OwnedEntity RemoveEntity (cEntity &a_Entity)
 Releases ownership of the given entity if it was found in this chunk. More...
 
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle &a_Client)
 
void SendBlockTo (int a_RelX, int a_RelY, int a_RelZ, cClientHandle *a_Client)
 
void SetAllData (SetChunkData &&a_SetChunkData)
 Sets all chunk data as either loaded from the storage or generated. More...
 
void SetAlwaysTicked (bool a_AlwaysTicked)
 Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter. More...
 
void SetAreaBiome (int a_MinRelX, int a_MaxRelX, int a_MinRelZ, int a_MaxRelZ, EMCSBiome a_Biome)
 Sets the biome in the specified relative coords area. More...
 
void SetBiomeAt (int a_RelX, int a_RelZ, EMCSBiome a_Biome)
 Sets the biome at the specified relative coords. More...
 
void SetBlock (Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
void SetLight (const cChunkDef::BlockNibbles &a_BlockLight, const cChunkDef::BlockNibbles &a_SkyLight)
 
void SetMeta (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
 
void SetMeta (Vector3i a_RelPos, NIBBLETYPE a_Meta)
 
void SetNextBlockToTick (const Vector3i a_RelPos)
 Causes the specified block to be ticked on the next Tick() call. More...
 
void SetPresence (ePresence a_Presence)
 Sets the chunk's presence. More...
 
bool ShouldBeTicked (void) const
 Returns true if the chunk should be ticked in the tick-thread. More...
 
void SpawnMobs (cMobSpawner &a_MobSpawner)
 Try to Spawn Monsters inside chunk. More...
 
void Stay (bool a_Stay=true)
 Sets or resets the internal flag that prevents chunk from being unloaded. More...
 
void Tick (std::chrono::milliseconds a_Dt)
 
void TickBlock (const Vector3i a_RelPos)
 Ticks a single block. More...
 
bool UnboundedRelFastSetBlock (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelFastSetBlock (Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 Same as FastSetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UnboundedRelGetBlock (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelGetBlock (Vector3i a_RelCoords, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
 Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UnboundedRelGetBlockBlockLight (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_BlockLight) const
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelGetBlockBlockLight (Vector3i a_RelPos, NIBBLETYPE &a_BlockLight) const
 Same as GetBlockBlockLight(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UnboundedRelGetBlockLights (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_BlockLight, NIBBLETYPE &a_SkyLight) const
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelGetBlockLights (Vector3i a_RelPos, NIBBLETYPE &a_BlockLight, NIBBLETYPE &a_SkyLight) const
 Queries both BlockLight and SkyLight, relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UnboundedRelGetBlockMeta (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_BlockMeta) const
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelGetBlockMeta (Vector3i a_RelPos, NIBBLETYPE &a_BlockMeta) const
 Same as GetBlockMeta(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UnboundedRelGetBlockSkyLight (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE &a_SkyLight) const
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelGetBlockSkyLight (Vector3i a_RelPos, NIBBLETYPE &a_SkyLight) const
 Same as GetBlockSkyLight(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UnboundedRelGetBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType) const
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelGetBlockType (Vector3i a_RelCoords, BLOCKTYPE &a_BlockType) const
 Same as GetBlockType(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UnboundedRelSetBlock (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 OBSOLETE, use the Vector3i-based overload. More...
 
bool UnboundedRelSetBlock (Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 Same as SetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded. More...
 
bool UseBlockEntity (cPlayer *a_Player, int a_X, int a_Y, int a_Z)
 Use block entity on coordinate. More...
 
void WriteBlockArea (cBlockArea &a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
 Writes the specified cBlockArea at the coords specified. More...
 
 ~cChunk ()
 

Private Types

typedef std::vector< sSetBlockQueueItemsSetBlockQueueVector
 

Private Member Functions

void AddBlockEntity (OwnedBlockEntity a_BlockEntity)
 Takes ownership of a block entity, which MUST actually reside in this chunk. More...
 
void ApplyWeatherToTop (void)
 Adds snow to the top of snowy biomes and hydrates farmland / fills cauldrons in rainy biomes. More...
 
void CheckBlocks ()
 Checks the block scheduled for checking in m_ToTickBlocks[]. More...
 
void GetRandomBlockCoords (int &a_X, int &a_Y, int &a_Z)
 
void GetThreeRandomNumbers (int &a_X, int &a_Y, int &a_Z, int a_MaxX, int a_MaxY, int a_MaxZ)
 
int GrowPlantAt (Vector3i a_RelPos, int a_NumStages=1)
 Grows the plant at the specified position by at most a_NumStages. More...
 
bool HasPlayerEntities () const
 Check m_Entities for cPlayer objects. More...
 
void MoveEntityToNewChunk (OwnedEntity a_Entity)
 Called by Tick() when an entity moves out of this chunk into a neighbor; moves the entity and sends spawn / despawn packet to clients. More...
 
cItems PickupsFromBlock (Vector3i a_RelPos, const cEntity *a_Digger, const cItem *a_Tool)
 Returns the pickups that would be produced, if the specified block was dug up by a_Digger using a_Tool. More...
 
void TickBlocks (void)
 Ticks several random blocks in the chunk. More...
 
void WakeUpSimulators (void)
 Wakes up each simulator for its specific blocks; through all the blocks in the chunk. More...
 

Private Attributes

unsigned m_AlwaysTicked
 If greater than zero, the chunk is ticked even if it has no clients. More...
 
cChunkDef::BiomeMap m_BiomeMap
 
ChunkBlockData m_BlockData
 
cBlockEntities m_BlockEntities
 
std::queue< Vector3im_BlocksToCheck
 A queue of relative positions to call cBlockHandler::Check on. More...
 
Vector3i m_BlockToTick
 Relative coords of the block to tick first in the next Tick() call. More...
 
cChunkMapm_ChunkMap
 
std::vector< OwnedEntitym_Entities
 
cFireSimulatorChunkData m_FireSimulatorData
 
cChunkDef::HeightMap m_HeightMap
 
bool m_IsDirty
 
bool m_IsLightValid
 
bool m_IsSaving
 
cFluidSimulatorDatam_LavaSimulatorData
 
ChunkLightData m_LightData
 
std::vector< cClientHandle * > m_LoadedByClient
 
cChunkm_NeighborXM
 
cChunkm_NeighborXP
 
cChunkm_NeighborZM
 
cChunkm_NeighborZP
 
std::vector< cBlockEntity * > m_PendingSendBlockEntities
 Block entities that have been touched and need to be sent to all clients. More...
 
sSetBlockVector m_PendingSendBlocks
 Blocks that have changed and need to be sent to all clients. More...
 
int m_PosX
 
int m_PosZ
 
ePresence m_Presence
 Holds the presence status of the chunk - if it is present, or in the loader / generator queue, or unloaded. More...
 
cRedstoneSimulatorChunkDatam_RedstoneSimulatorData
 
cSandSimulatorChunkData m_SandSimulatorData
 
unsigned m_StayCount
 Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded. More...
 
cFluidSimulatorDatam_WaterSimulatorData
 
cWorldm_World
 

Friends

class cChunkMap
 

Detailed Description

Definition at line 35 of file Chunk.h.

Member Typedef Documentation

◆ sSetBlockQueueVector

typedef std::vector<sSetBlockQueueItem> cChunk::sSetBlockQueueVector
private

Definition at line 476 of file Chunk.h.

Member Enumeration Documentation

◆ ePresence

Represents the presence state of the chunk.

Enumerator
cpInvalid 

The chunk is not present at all and is not queued in the loader / generator.

cpQueued 

The chunk is not present, but is queued for loading / generation.

cpPresent 

The chunk is present.

Definition at line 40 of file Chunk.h.

Constructor & Destructor Documentation

◆ cChunk() [1/2]

cChunk::cChunk ( int  a_ChunkX,
int  a_ChunkZ,
cChunkMap a_ChunkMap,
cWorld a_World 
)

Definition at line 41 of file Chunk.cpp.

◆ cChunk() [2/2]

cChunk::cChunk ( const cChunk Other)
delete

◆ ~cChunk()

cChunk::~cChunk ( )

Definition at line 86 of file Chunk.cpp.

Member Function Documentation

◆ AddBlockEntity()

void cChunk::AddBlockEntity ( OwnedBlockEntity  a_BlockEntity)
private

Takes ownership of a block entity, which MUST actually reside in this chunk.

Definition at line 1402 of file Chunk.cpp.

◆ AddClient()

bool cChunk::AddClient ( cClientHandle a_Client)

Adds a client to the chunk; returns true if added, false if already there.

Definition at line 1520 of file Chunk.cpp.

◆ AddEntity()

void cChunk::AddEntity ( OwnedEntity  a_Entity)

Definition at line 1582 of file Chunk.cpp.

◆ ApplyWeatherToTop()

void cChunk::ApplyWeatherToTop ( void  )
private

Adds snow to the top of snowy biomes and hydrates farmland / fills cauldrons in rainy biomes.

Definition at line 871 of file Chunk.cpp.

◆ BroadcastPendingChanges()

void cChunk::BroadcastPendingChanges ( void  )

Flushes the pending block (entity) queue, and clients' outgoing data buffers.

Definition at line 120 of file Chunk.cpp.

◆ CanUnload()

bool cChunk::CanUnload ( void  ) const

Definition at line 207 of file Chunk.cpp.

◆ CanUnloadAfterSaving()

bool cChunk::CanUnloadAfterSaving ( void  ) const

Returns true if the chunk could have been unloaded if it weren't dirty.

Definition at line 221 of file Chunk.cpp.

◆ CheckBlocks()

void cChunk::CheckBlocks ( )
private

Checks the block scheduled for checking in m_ToTickBlocks[].

Definition at line 812 of file Chunk.cpp.

◆ CollectMobCensus()

void cChunk::CollectMobCensus ( cMobCensus toFill)

Recence all mobs proximities to players in order to know what to do with them.

Definition at line 546 of file Chunk.cpp.

◆ DoWithBlockEntityAt()

bool cChunk::DoWithBlockEntityAt ( Vector3i  a_Position,
cBlockEntityCallback  a_Callback 
)

Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, and whatever the callback returns if found.

Definition at line 1737 of file Chunk.cpp.

◆ DoWithEntityByID()

bool cChunk::DoWithEntityByID ( UInt32  a_EntityID,
cEntityCallback  a_Callback,
bool &  a_CallbackResult 
) const

Calls the callback if the entity with the specified ID is found, with the entity object as the callback param.

Returns true if entity found.

Definition at line 1700 of file Chunk.cpp.

◆ FastSetBlock() [1/2]

void cChunk::FastSetBlock ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE  a_BlockType,
BLOCKTYPE  a_BlockMeta 
)

Definition at line 1296 of file Chunk.cpp.

◆ FastSetBlock() [2/2]

void cChunk::FastSetBlock ( Vector3i  a_RelPos,
BLOCKTYPE  a_BlockType,
BLOCKTYPE  a_BlockMeta 
)
inline

Definition at line 141 of file Chunk.h.

◆ ForEachBlockEntity()

bool cChunk::ForEachBlockEntity ( cBlockEntityCallback  a_Callback)

Calls the callback for each block entity; returns true if all block entities processed, false if the callback aborted by returning true.

Definition at line 1718 of file Chunk.cpp.

◆ ForEachEntity()

bool cChunk::ForEachEntity ( cEntityCallback  a_Callback) const

Calls the callback for each entity; returns true if all entities processed, false if the callback aborted by returning true.

Definition at line 1657 of file Chunk.cpp.

◆ ForEachEntityInBox()

bool cChunk::ForEachEntityInBox ( const cBoundingBox a_Box,
cEntityCallback  a_Callback 
) const

Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.

Returns true if all entities processed, false if the callback aborted by returning true.

Definition at line 1674 of file Chunk.cpp.

◆ GetAllClients()

const auto& cChunk::GetAllClients ( void  ) const
inline

Definition at line 443 of file Chunk.h.

◆ GetAllData()

void cChunk::GetAllData ( cChunkDataCallback &  a_Callback) const

Gets all chunk data, calls the a_Callback's methods for each data type.

Definition at line 307 of file Chunk.cpp.

◆ GetBiomeAt()

EMCSBiome cChunk::GetBiomeAt ( int  a_RelX,
int  a_RelZ 
) const
inline

Definition at line 191 of file Chunk.h.

◆ GetBlock() [1/2]

BLOCKTYPE cChunk::GetBlock ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
) const
inline

Definition at line 146 of file Chunk.h.

◆ GetBlock() [2/2]

BLOCKTYPE cChunk::GetBlock ( Vector3i  a_RelCoords) const
inline

Definition at line 147 of file Chunk.h.

◆ GetBlockEntity() [1/2]

cBlockEntity* cChunk::GetBlockEntity ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ 
)
inline

OBSOLETE, use the Vector3i-based overload instead.

Returns the block entity at the specified (absolute) coords. Returns nullptr if no such BE or outside this chunk.

Definition at line 425 of file Chunk.h.

◆ GetBlockEntity() [2/2]

cBlockEntity * cChunk::GetBlockEntity ( Vector3i  a_AbsPos)

Returns the block entity at the specified (absolute) coords.

Returns nullptr if no such BE or outside this chunk.

Definition at line 1418 of file Chunk.cpp.

◆ GetBlockEntityRel()

cBlockEntity * cChunk::GetBlockEntityRel ( Vector3i  a_RelPos)

Returns the block entity at the specified (relative) coords.

Returns nullptr if no such BE. Asserts that the position is a valid relative position.

Definition at line 1436 of file Chunk.cpp.

◆ GetBlockInfo()

void cChunk::GetBlockInfo ( Vector3i  a_RelPos,
BLOCKTYPE a_BlockType,
NIBBLETYPE a_Meta,
NIBBLETYPE a_SkyLight,
NIBBLETYPE a_BlockLight 
) const

Definition at line 1767 of file Chunk.cpp.

◆ GetBlockLight() [1/2]

NIBBLETYPE cChunk::GetBlockLight ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
) const
inline

Definition at line 303 of file Chunk.h.

◆ GetBlockLight() [2/2]

NIBBLETYPE cChunk::GetBlockLight ( Vector3i  a_RelPos) const
inline

Get the level of artificial light illuminating the block (0 - 15)

Definition at line 302 of file Chunk.h.

◆ GetBlockTypeMeta() [1/2]

void cChunk::GetBlockTypeMeta ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE a_BlockType,
NIBBLETYPE a_BlockMeta 
) const
inline

Definition at line 150 of file Chunk.h.

◆ GetBlockTypeMeta() [2/2]

void cChunk::GetBlockTypeMeta ( Vector3i  a_RelPos,
BLOCKTYPE a_BlockType,
NIBBLETYPE a_BlockMeta 
) const

Definition at line 1757 of file Chunk.cpp.

◆ GetChunkAndRelByAbsolute() [1/2]

bool cChunk::GetChunkAndRelByAbsolute ( const Vector3d a_Position,
cChunk **  a_Chunk,
Vector3i a_Rel 
)

Convert absolute coordinates into relative coordinates.

Returns false on failure to obtain a valid chunk. Returns true otherwise.

Parameters
a_PositionThe position you'd like to convert, a_Position need not be in the calling chunk and can safely be out of its bounds, but for best performance, it should not be too far from the calling chunk.
a_ChunkReturns the chunk in which a_Position is in. If a_Position is within the calling chunk's bounds, returns the calling chunk. For best performance, a_Position shouldn't be too far from the calling chunk.
a_RelReturns the converted relative position. Note that it is relative to the returned a_Chunk. The vector will not be modified if the function returns false.

Definition at line 1779 of file Chunk.cpp.

◆ GetChunkAndRelByAbsolute() [2/2]

bool cChunk::GetChunkAndRelByAbsolute ( const Vector3i a_Position,
cChunk **  a_Chunk,
Vector3i a_Rel 
)

Convert absolute coordinates into relative coordinates.

Returns false on failure to obtain a valid chunk. Returns true otherwise.

Parameters
a_PositionThe position you'd like to convert, a_Position need not be in the calling chunk and can safely be out of its bounds, but for best performance, it should not be too far from the calling chunk.
a_ChunkReturns the chunk in which a_Position is in. If a_Position is within the calling chunk's bounds, returns the calling chunk. For best performance, a_Position shouldn't be too far from the calling chunk.
a_RelReturns the converted relative position. Note that it is relative to the returned a_Chunk. The vector will not be modified if the function returns false.

Definition at line 1788 of file Chunk.cpp.

◆ GetFireSimulatorData()

cFireSimulatorChunkData& cChunk::GetFireSimulatorData ( void  )
inline

Definition at line 412 of file Chunk.h.

◆ GetHeight()

int cChunk::GetHeight ( int  a_X,
int  a_Z 
) const

Definition at line 1177 of file Chunk.cpp.

◆ GetLavaSimulatorData()

cFluidSimulatorData* cChunk::GetLavaSimulatorData ( void  ) const
inline

Definition at line 414 of file Chunk.h.

◆ GetMeta() [1/2]

NIBBLETYPE cChunk::GetMeta ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
) const
inline

Definition at line 279 of file Chunk.h.

◆ GetMeta() [2/2]

NIBBLETYPE cChunk::GetMeta ( Vector3i  a_RelPos) const
inline

Definition at line 284 of file Chunk.h.

◆ GetNeighborChunk()

cChunk * cChunk::GetNeighborChunk ( int  a_BlockX,
int  a_BlockZ 
)

Returns the chunk into which the specified block belongs, by walking the neighbors.

Will return self if appropriate. Returns nullptr if not reachable through neighbors.

Definition at line 1806 of file Chunk.cpp.

◆ GetPos()

cChunkCoords cChunk::GetPos ( ) const
inline

Definition at line 133 of file Chunk.h.

◆ GetPosX()

int cChunk::GetPosX ( void  ) const
inline

Definition at line 131 of file Chunk.h.

◆ GetPosZ()

int cChunk::GetPosZ ( void  ) const
inline

Definition at line 132 of file Chunk.h.

◆ GetRandomBlockCoords()

void cChunk::GetRandomBlockCoords ( int &  a_X,
int &  a_Y,
int &  a_Z 
)
private

Definition at line 598 of file Chunk.cpp.

◆ GetRedstoneSimulatorData()

cRedstoneSimulatorChunkData* cChunk::GetRedstoneSimulatorData ( void  ) const
inline

Definition at line 416 of file Chunk.h.

◆ GetRelNeighborChunk()

cChunk * cChunk::GetRelNeighborChunk ( int  a_RelX,
int  a_RelZ 
)

Returns the chunk into which the relatively-specified block belongs, by walking the neighbors.

Will return self if appropriate. Returns nullptr if not reachable through neighbors.

Definition at line 1818 of file Chunk.cpp.

◆ GetRelNeighborChunkAdjustCoords()

cChunk * cChunk::GetRelNeighborChunkAdjustCoords ( Vector3i a_RelPos) const

Returns the chunk into which the relatively-specified block belongs.

Also modifies the relative coords from this-relative to return-relative. Will return self if appropriate. Will try walking the neighbors first; if that fails, will query the chunkmap.

Definition at line 1885 of file Chunk.cpp.

◆ GetSandSimulatorData()

cSandSimulatorChunkData& cChunk::GetSandSimulatorData ( void  )
inline

Definition at line 415 of file Chunk.h.

◆ GetSkyLight() [1/2]

NIBBLETYPE cChunk::GetSkyLight ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
) const
inline

Definition at line 307 of file Chunk.h.

◆ GetSkyLight() [2/2]

NIBBLETYPE cChunk::GetSkyLight ( Vector3i  a_RelPos) const
inline

Get the level of sky light illuminating the block (0 - 15) independent of daytime.

Definition at line 306 of file Chunk.h.

◆ GetSkyLightAltered() [1/2]

NIBBLETYPE cChunk::GetSkyLightAltered ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
) const
inline

Definition at line 311 of file Chunk.h.

◆ GetSkyLightAltered() [2/2]

NIBBLETYPE cChunk::GetSkyLightAltered ( Vector3i  a_RelPos) const
inline

Get the level of sky light illuminating the block (0 - 15), taking daytime into a account.

Definition at line 310 of file Chunk.h.

◆ GetThreeRandomNumbers()

void cChunk::GetThreeRandomNumbers ( int &  a_X,
int &  a_Y,
int &  a_Z,
int  a_MaxX,
int  a_MaxY,
int  a_MaxZ 
)
private

Definition at line 577 of file Chunk.cpp.

◆ GetTimeAlteredLight()

NIBBLETYPE cChunk::GetTimeAlteredLight ( NIBBLETYPE  a_Skylight) const

Light alterations based on time.

Definition at line 1977 of file Chunk.cpp.

◆ GetWaterSimulatorData()

cFluidSimulatorData* cChunk::GetWaterSimulatorData ( void  ) const
inline

Definition at line 413 of file Chunk.h.

◆ GetWorld()

cWorld* cChunk::GetWorld ( void  ) const
inline

Definition at line 135 of file Chunk.h.

◆ GrowPlantAt()

int cChunk::GrowPlantAt ( Vector3i  a_RelPos,
int  a_NumStages = 1 
)
private

Grows the plant at the specified position by at most a_NumStages.

The block's Grow handler is invoked. Returns the number of stages the plant has grown, 0 if not a plant.

Definition at line 999 of file Chunk.cpp.

◆ HasAnyClients()

bool cChunk::HasAnyClients ( void  ) const

Returns true if theres any client in the chunk; false otherwise.

Definition at line 1573 of file Chunk.cpp.

◆ HasClient()

bool cChunk::HasClient ( cClientHandle a_Client)

Returns true if the specified client is present in this chunk.

Definition at line 1564 of file Chunk.cpp.

◆ HasEntity()

bool cChunk::HasEntity ( UInt32  a_EntityID) const

Definition at line 1641 of file Chunk.cpp.

◆ HasPlayerEntities()

bool cChunk::HasPlayerEntities ( ) const
private

Check m_Entities for cPlayer objects.

Definition at line 192 of file Chunk.cpp.

◆ IsDirty()

bool cChunk::IsDirty ( void  ) const
inline

Returns true iff the chunk has changed since it was last saved.

Definition at line 71 of file Chunk.h.

◆ IsLightValid()

bool cChunk::IsLightValid ( void  ) const
inline

Definition at line 83 of file Chunk.h.

◆ IsQueued()

bool cChunk::IsQueued ( void  ) const
inline

Returns true iff the chunk is in the queue for loading / generating.

Definition at line 61 of file Chunk.h.

◆ IsSlimeChunk()

bool cChunk::IsSlimeChunk ( ) const

Returns true if slimes should spawn in the chunk.

Definition at line 1988 of file Chunk.cpp.

◆ IsValid()

bool cChunk::IsValid ( void  ) const
inline

Returns true iff the chunk block data is valid (loaded / generated)

Definition at line 58 of file Chunk.h.

◆ IsWeatherSunnyAt()

bool cChunk::IsWeatherSunnyAt ( int  a_RelX,
int  a_RelZ 
) const

Returns true if it is sunny at the specified location.

This takes into account biomes.

Definition at line 1187 of file Chunk.cpp.

◆ IsWeatherWetAt() [1/2]

bool cChunk::IsWeatherWetAt ( int  a_RelX,
int  a_RelZ 
) const

Returns true if it is raining or storming at the specified location, taking into account biomes.

Definition at line 1196 of file Chunk.cpp.

◆ IsWeatherWetAt() [2/2]

bool cChunk::IsWeatherWetAt ( Vector3i  a_Position) const

Returns true if it is raining or storming at the specified location, and the rain reaches (the bottom of) the specified block position.

Definition at line 1206 of file Chunk.cpp.

◆ MarkDirty()

void cChunk::MarkDirty ( void  )
inline

Definition at line 265 of file Chunk.h.

◆ MarkLoaded()

void cChunk::MarkLoaded ( void  )

Definition at line 282 of file Chunk.cpp.

◆ MarkLoadFailed()

void cChunk::MarkLoadFailed ( void  )

Queues the chunk for generating.

Definition at line 292 of file Chunk.cpp.

◆ MarkRegenerating()

void cChunk::MarkRegenerating ( void  )

Marks all clients attached to this chunk as wanting this chunk.

Also sets presence to cpQueued.

Definition at line 176 of file Chunk.cpp.

◆ MarkSaved()

void cChunk::MarkSaved ( void  )

Definition at line 269 of file Chunk.cpp.

◆ MarkSaving()

void cChunk::MarkSaving ( void  )

Definition at line 260 of file Chunk.cpp.

◆ MoveEntityToNewChunk()

void cChunk::MoveEntityToNewChunk ( OwnedEntity  a_Entity)
private

Called by Tick() when an entity moves out of this chunk into a neighbor; moves the entity and sends spawn / despawn packet to clients.

Definition at line 768 of file Chunk.cpp.

◆ OnUnload()

void cChunk::OnUnload ( )

Called when the chunkmap unloads unused chunks.

Notifies contained entities that they are being unloaded and should for example, broadcast a destroy packet. Not called during server shutdown; such cleanup during shutdown is unnecessary.

Definition at line 235 of file Chunk.cpp.

◆ PickupsFromBlock()

cItems cChunk::PickupsFromBlock ( Vector3i  a_RelPos,
const cEntity a_Digger,
const cItem a_Tool 
)
private

Returns the pickups that would be produced, if the specified block was dug up by a_Digger using a_Tool.

Doesn't dig the block, only queries the block handlers and then plugins for the pickups.

Definition at line 964 of file Chunk.cpp.

◆ PositionToWorldPosition() [1/3]

Vector3i cChunk::PositionToWorldPosition ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
)

Definition at line 1968 of file Chunk.cpp.

◆ PositionToWorldPosition() [2/3]

void cChunk::PositionToWorldPosition ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
int &  a_BlockX,
int &  a_BlockY,
int &  a_BlockZ 
)

Definition at line 1957 of file Chunk.cpp.

◆ PositionToWorldPosition() [3/3]

Vector3i cChunk::PositionToWorldPosition ( Vector3i  a_RelPos)
inline

Definition at line 257 of file Chunk.h.

◆ RelativeToAbsolute()

Vector3i cChunk::RelativeToAbsolute ( Vector3i  a_RelBlockPosition) const
inline

Converts the coord relative to this chunk into an absolute coord.

Doesn't check relative coord validity.

Definition at line 450 of file Chunk.h.

◆ RemoveClient()

void cChunk::RemoveClient ( cClientHandle a_Client)

Removes the specified client from the chunk; ignored if client not in chunk.

Definition at line 1536 of file Chunk.cpp.

◆ RemoveEntity()

OwnedEntity cChunk::RemoveEntity ( cEntity a_Entity)

Releases ownership of the given entity if it was found in this chunk.

Returns an owning reference to the found entity.

Definition at line 1602 of file Chunk.cpp.

◆ SendBlockEntity()

void cChunk::SendBlockEntity ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
cClientHandle a_Client 
)

Definition at line 1943 of file Chunk.cpp.

◆ SendBlockTo()

void cChunk::SendBlockTo ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
cClientHandle a_Client 
)

Definition at line 1373 of file Chunk.cpp.

◆ SetAllData()

void cChunk::SetAllData ( SetChunkData &&  a_SetChunkData)

Sets all chunk data as either loaded from the storage or generated.

BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted. Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk.

Definition at line 331 of file Chunk.cpp.

◆ SetAlwaysTicked()

void cChunk::SetAlwaysTicked ( bool  a_AlwaysTicked)

Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter.

If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of whether it has any clients or not. When this is set, the chunk never unloads. This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long as at least one requests is active the chunk will be ticked).

Definition at line 1456 of file Chunk.cpp.

◆ SetAreaBiome()

void cChunk::SetAreaBiome ( int  a_MinRelX,
int  a_MaxRelX,
int  a_MinRelZ,
int  a_MaxRelZ,
EMCSBiome  a_Biome 
)

Sets the biome in the specified relative coords area.

All the coords are inclusive. Sends the chunk to all relevant clients.

Definition at line 1498 of file Chunk.cpp.

◆ SetBiomeAt()

void cChunk::SetBiomeAt ( int  a_RelX,
int  a_RelZ,
EMCSBiome  a_Biome 
)

Sets the biome at the specified relative coords.

Doesn't resend the chunk to clients.

Definition at line 1488 of file Chunk.cpp.

◆ SetBlock()

void cChunk::SetBlock ( Vector3i  a_RelBlockPos,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 1263 of file Chunk.cpp.

◆ SetLight()

void cChunk::SetLight ( const cChunkDef::BlockNibbles a_BlockLight,
const cChunkDef::BlockNibbles a_SkyLight 
)

Definition at line 402 of file Chunk.cpp.

◆ SetMeta() [1/2]

void cChunk::SetMeta ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
NIBBLETYPE  a_Meta 
)
inline

Definition at line 286 of file Chunk.h.

◆ SetMeta() [2/2]

void cChunk::SetMeta ( Vector3i  a_RelPos,
NIBBLETYPE  a_Meta 
)
inline

Definition at line 291 of file Chunk.h.

◆ SetNextBlockToTick()

void cChunk::SetNextBlockToTick ( const Vector3i  a_RelPos)
inline

Causes the specified block to be ticked on the next Tick() call.

Plugins can use this via the cWorld:SetNextBlockToTick() API. Only one block coord per chunk may be set, a second call overwrites the first call

Definition at line 274 of file Chunk.h.

◆ SetPresence()

void cChunk::SetPresence ( cChunk::ePresence  a_Presence)

Sets the chunk's presence.

Wakes up any calls to cChunkMap::GetHeight() when setting to cpPresent.

Definition at line 163 of file Chunk.cpp.

◆ ShouldBeTicked()

bool cChunk::ShouldBeTicked ( void  ) const

Returns true if the chunk should be ticked in the tick-thread.

Checks if there are any clients and if the always-tick flag is set

Definition at line 1447 of file Chunk.cpp.

◆ SpawnMobs()

void cChunk::SpawnMobs ( cMobSpawner a_MobSpawner)

Try to Spawn Monsters inside chunk.

Definition at line 611 of file Chunk.cpp.

◆ Stay()

void cChunk::Stay ( bool  a_Stay = true)

Sets or resets the internal flag that prevents chunk from being unloaded.

The flag is cumulative - it can be set multiple times and then needs to be un-set that many times before the chunk is unloadable again.

Definition at line 529 of file Chunk.cpp.

◆ Tick()

void cChunk::Tick ( std::chrono::milliseconds  a_Dt)

Definition at line 685 of file Chunk.cpp.

◆ TickBlock()

void cChunk::TickBlock ( const Vector3i  a_RelPos)

Ticks a single block.

Used by cWorld::TickQueuedBlocks() to tick the queued blocks

Definition at line 757 of file Chunk.cpp.

◆ TickBlocks()

void cChunk::TickBlocks ( void  )
private

Ticks several random blocks in the chunk.

Definition at line 834 of file Chunk.cpp.

◆ UnboundedRelFastSetBlock() [1/2]

bool cChunk::UnboundedRelFastSetBlock ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)
inline

OBSOLETE, use the Vector3i-based overload.

Same as FastSetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 404 of file Chunk.h.

◆ UnboundedRelFastSetBlock() [2/2]

bool cChunk::UnboundedRelFastSetBlock ( Vector3i  a_RelPos,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Same as FastSetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1156 of file Chunk.cpp.

◆ UnboundedRelGetBlock() [1/2]

bool cChunk::UnboundedRelGetBlock ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE a_BlockType,
NIBBLETYPE a_BlockMeta 
) const
inline

OBSOLETE, use the Vector3i-based overload.

Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 320 of file Chunk.h.

◆ UnboundedRelGetBlock() [2/2]

bool cChunk::UnboundedRelGetBlock ( Vector3i  a_RelCoords,
BLOCKTYPE a_BlockType,
NIBBLETYPE a_BlockMeta 
) const

Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1008 of file Chunk.cpp.

◆ UnboundedRelGetBlockBlockLight() [1/2]

bool cChunk::UnboundedRelGetBlockBlockLight ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
NIBBLETYPE a_BlockLight 
) const
inline

OBSOLETE, use the Vector3i-based overload.

Same as GetBlockBlockLight(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 356 of file Chunk.h.

◆ UnboundedRelGetBlockBlockLight() [2/2]

bool cChunk::UnboundedRelGetBlockBlockLight ( Vector3i  a_RelPos,
NIBBLETYPE a_BlockLight 
) const

Same as GetBlockBlockLight(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1071 of file Chunk.cpp.

◆ UnboundedRelGetBlockLights() [1/2]

bool cChunk::UnboundedRelGetBlockLights ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
NIBBLETYPE a_BlockLight,
NIBBLETYPE a_SkyLight 
) const
inline

OBSOLETE, use the Vector3i-based overload.

Queries both BlockLight and SkyLight, relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 380 of file Chunk.h.

◆ UnboundedRelGetBlockLights() [2/2]

bool cChunk::UnboundedRelGetBlockLights ( Vector3i  a_RelPos,
NIBBLETYPE a_BlockLight,
NIBBLETYPE a_SkyLight 
) const

Queries both BlockLight and SkyLight, relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1113 of file Chunk.cpp.

◆ UnboundedRelGetBlockMeta() [1/2]

bool cChunk::UnboundedRelGetBlockMeta ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
NIBBLETYPE a_BlockMeta 
) const
inline

OBSOLETE, use the Vector3i-based overload.

Same as GetBlockMeta(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 344 of file Chunk.h.

◆ UnboundedRelGetBlockMeta() [2/2]

bool cChunk::UnboundedRelGetBlockMeta ( Vector3i  a_RelPos,
NIBBLETYPE a_BlockMeta 
) const

Same as GetBlockMeta(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1050 of file Chunk.cpp.

◆ UnboundedRelGetBlockSkyLight() [1/2]

bool cChunk::UnboundedRelGetBlockSkyLight ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
NIBBLETYPE a_SkyLight 
) const
inline

OBSOLETE, use the Vector3i-based overload.

Same as GetBlockSkyLight(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 368 of file Chunk.h.

◆ UnboundedRelGetBlockSkyLight() [2/2]

bool cChunk::UnboundedRelGetBlockSkyLight ( Vector3i  a_RelPos,
NIBBLETYPE a_SkyLight 
) const

Same as GetBlockSkyLight(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1092 of file Chunk.cpp.

◆ UnboundedRelGetBlockType() [1/2]

bool cChunk::UnboundedRelGetBlockType ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE a_BlockType 
) const
inline

OBSOLETE, use the Vector3i-based overload.

Same as GetBlockType(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 332 of file Chunk.h.

◆ UnboundedRelGetBlockType() [2/2]

bool cChunk::UnboundedRelGetBlockType ( Vector3i  a_RelCoords,
BLOCKTYPE a_BlockType 
) const

Same as GetBlockType(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1029 of file Chunk.cpp.

◆ UnboundedRelSetBlock() [1/2]

bool cChunk::UnboundedRelSetBlock ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)
inline

OBSOLETE, use the Vector3i-based overload.

Same as SetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 392 of file Chunk.h.

◆ UnboundedRelSetBlock() [2/2]

bool cChunk::UnboundedRelSetBlock ( Vector3i  a_RelPos,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Same as SetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case) Returns true on success, false if queried chunk not loaded.

Definition at line 1135 of file Chunk.cpp.

◆ UseBlockEntity()

bool cChunk::UseBlockEntity ( cPlayer a_Player,
int  a_X,
int  a_Y,
int  a_Z 
)

Use block entity on coordinate.

returns true if the use was successful, return false to use the block as a "normal" block

Definition at line 1474 of file Chunk.cpp.

◆ WakeUpSimulators()

void cChunk::WakeUpSimulators ( void  )
private

Wakes up each simulator for its specific blocks; through all the blocks in the chunk.

Definition at line 1233 of file Chunk.cpp.

◆ WriteBlockArea()

void cChunk::WriteBlockArea ( cBlockArea a_Area,
int  a_MinBlockX,
int  a_MinBlockY,
int  a_MinBlockZ,
int  a_DataTypes 
)

Writes the specified cBlockArea at the coords specified.

Note that the coords may extend beyond the chunk!

Definition at line 420 of file Chunk.cpp.

Friends And Related Function Documentation

◆ cChunkMap

friend class cChunkMap
friend

Definition at line 460 of file Chunk.h.

Member Data Documentation

◆ m_AlwaysTicked

unsigned cChunk::m_AlwaysTicked
private

If greater than zero, the chunk is ticked even if it has no clients.

Manipulated by the SetAlwaysTicked() function, allows for nested calls of the function. This is the support for plugin-accessible chunk tick forcing.

Definition at line 537 of file Chunk.h.

◆ m_BiomeMap

cChunkDef::BiomeMap cChunk::m_BiomeMap
private

Definition at line 516 of file Chunk.h.

◆ m_BlockData

ChunkBlockData cChunk::m_BlockData
private

Definition at line 512 of file Chunk.h.

◆ m_BlockEntities

cBlockEntities cChunk::m_BlockEntities
private

Definition at line 503 of file Chunk.h.

◆ m_BlocksToCheck

std::queue<Vector3i> cChunk::m_BlocksToCheck
private

A queue of relative positions to call cBlockHandler::Check on.

Processed at the end of each tick by CheckBlocks.

Definition at line 498 of file Chunk.h.

◆ m_BlockToTick

Vector3i cChunk::m_BlockToTick
private

Relative coords of the block to tick first in the next Tick() call.

Plugins can use this to force a tick in a specific block, using cWorld:SetNextBlockToTick() API.

Definition at line 520 of file Chunk.h.

◆ m_ChunkMap

cChunkMap* cChunk::m_ChunkMap
private

Definition at line 510 of file Chunk.h.

◆ m_Entities

std::vector<OwnedEntity> cChunk::m_Entities
private

Definition at line 502 of file Chunk.h.

◆ m_FireSimulatorData

cFireSimulatorChunkData cChunk::m_FireSimulatorData
private

Definition at line 528 of file Chunk.h.

◆ m_HeightMap

cChunkDef::HeightMap cChunk::m_HeightMap
private

Definition at line 515 of file Chunk.h.

◆ m_IsDirty

bool cChunk::m_IsDirty
private

Definition at line 483 of file Chunk.h.

◆ m_IsLightValid

bool cChunk::m_IsLightValid
private

Definition at line 482 of file Chunk.h.

◆ m_IsSaving

bool cChunk::m_IsSaving
private

Definition at line 484 of file Chunk.h.

◆ m_LavaSimulatorData

cFluidSimulatorData* cChunk::m_LavaSimulatorData
private

Definition at line 530 of file Chunk.h.

◆ m_LightData

ChunkLightData cChunk::m_LightData
private

Definition at line 513 of file Chunk.h.

◆ m_LoadedByClient

std::vector<cClientHandle *> cChunk::m_LoadedByClient
private

Definition at line 501 of file Chunk.h.

◆ m_NeighborXM

cChunk* cChunk::m_NeighborXM
private

Definition at line 522 of file Chunk.h.

◆ m_NeighborXP

cChunk* cChunk::m_NeighborXP
private

Definition at line 523 of file Chunk.h.

◆ m_NeighborZM

cChunk* cChunk::m_NeighborZM
private

Definition at line 524 of file Chunk.h.

◆ m_NeighborZP

cChunk* cChunk::m_NeighborZP
private

Definition at line 525 of file Chunk.h.

◆ m_PendingSendBlockEntities

std::vector<cBlockEntity *> cChunk::m_PendingSendBlockEntities
private

Block entities that have been touched and need to be sent to all clients.

Because block changes are buffered and we need to happen after them, this buffer exists too. Pointers to block entities that were destroyed are guaranteed to be removed from this array by SetAllData, SetBlock, WriteBlockArea.

Definition at line 494 of file Chunk.h.

◆ m_PendingSendBlocks

sSetBlockVector cChunk::m_PendingSendBlocks
private

Blocks that have changed and need to be sent to all clients.

The protocol has a provision for coalescing block changes, and this is the buffer. It will collect the block changes that occur in a tick, before being flushed in BroadcastPendingSendBlocks.

Definition at line 489 of file Chunk.h.

◆ m_PosX

int cChunk::m_PosX
private

Definition at line 508 of file Chunk.h.

◆ m_PosZ

int cChunk::m_PosZ
private

Definition at line 508 of file Chunk.h.

◆ m_Presence

ePresence cChunk::m_Presence
private

Holds the presence status of the chunk - if it is present, or in the loader / generator queue, or unloaded.

Definition at line 480 of file Chunk.h.

◆ m_RedstoneSimulatorData

cRedstoneSimulatorChunkData* cChunk::m_RedstoneSimulatorData
private

Definition at line 532 of file Chunk.h.

◆ m_SandSimulatorData

cSandSimulatorChunkData cChunk::m_SandSimulatorData
private

Definition at line 531 of file Chunk.h.

◆ m_StayCount

unsigned cChunk::m_StayCount
private

Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded.

Definition at line 506 of file Chunk.h.

◆ m_WaterSimulatorData

cFluidSimulatorData* cChunk::m_WaterSimulatorData
private

Definition at line 529 of file Chunk.h.

◆ m_World

cWorld* cChunk::m_World
private

Definition at line 509 of file Chunk.h.


The documentation for this class was generated from the following files: