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

#include <ChunkDesc.h>

Collaboration diagram for cChunkDesc:
Collaboration graph
[legend]

Public Types

typedef NIBBLETYPE BlockNibbleBytes[cChunkDef::NumBlocks]
 Uncompressed block metas, 1 meta per byte. More...
 
typedef Byte Shape[256 *16 *16]
 The datatype used to represent the entire chunk worth of shape. More...
 

Public Member Functions

 cChunkDesc (cChunkCoords a_Coords)
 
void CompressBlockMetas (cChunkDef::BlockNibbles &a_DestMetas)
 Compresses the metas from the BlockArea format (1 meta per byte) into regular format (2 metas per byte) More...
 
void FillBlocks (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
void FillRelCuboid (const cCuboid &a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 Fills the relative cuboid with specified block; allows cuboid out of range of this chunk. More...
 
void FillRelCuboid (int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 Fills the relative cuboid with specified block; allows cuboid out of range of this chunk. More...
 
void FloorRelCuboid (const cCuboid &a_RelCuboid, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta)
 Replaces the blocks in the cuboid by the dst blocks if they are considered non-floor (air, water); allows cuboid out of range of this chunk. More...
 
void FloorRelCuboid (int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta)
 Replaces the blocks in the cuboid by the dst blocks if they are considered non-floor (air, water); allows cuboid out of range of this chunk. More...
 
EMCSBiome GetBiome (int a_RelX, int a_RelZ) const
 
const cChunkDef::BiomeMapGetBiomeMap () const
 
cChunkDef::BiomeMapGetBiomeMap (void)
 
cBlockEntitiesGetBlockEntities (void)
 
cBlockEntityGetBlockEntity (int a_RelX, int a_RelY, int a_RelZ)
 Returns the block entity at the specified coords. More...
 
NIBBLETYPE GetBlockMeta (int a_RelX, int a_RelY, int a_RelZ) const
 
BlockNibbleBytesGetBlockMetasUncompressed (void)
 
BLOCKTYPE GetBlockType (int a_RelX, int a_RelY, int a_RelZ) const
 
void GetBlockTypeMeta (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
 Returns the BlockType and BlockMeta at the specified coords. More...
 
const cChunkDef::BlockTypesGetBlockTypes () const
 
cChunkDef::BlockTypesGetBlockTypes (void)
 
cChunkCoords GetChunkCoords () const
 
int GetChunkX () const
 
int GetChunkZ () const
 
cEntityListGetEntities (void)
 
HEIGHTTYPE GetHeight (int a_RelX, int a_RelZ) const
 
const cChunkDef::HeightMapGetHeightMap () const
 
cChunkDef::HeightMapGetHeightMap (void)
 
HEIGHTTYPE GetMaxHeight (void) const
 Returns the maximum height value in the heightmap. More...
 
HEIGHTTYPE GetMinHeight (void) const
 Returns the minimum height value in the heightmap. More...
 
void GetShapeFromHeight (Shape &a_Shape) const
 Sets the shape in a_Shape to match the heightmap stored currently in m_HeightMap. More...
 
bool IsUsingDefaultBiomes (void) const
 
bool IsUsingDefaultComposition (void) const
 
bool IsUsingDefaultFinish (void) const
 
bool IsUsingDefaultHeight (void) const
 
void RandomFillRelCuboid (const cCuboid &a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_RandomSeed, int a_ChanceOutOf10k)
 Fills the relative cuboid with specified block with a random chance; allows cuboid out of range of this chunk. More...
 
void RandomFillRelCuboid (int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_RandomSeed, int a_ChanceOutOf10k)
 Fills the relative cuboid with specified block with a random chance; allows cuboid out of range of this chunk. More...
 
void ReadBlockArea (cBlockArea &a_Dest, int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ)
 Reads an area from the chunk into a cBlockArea, blocktypes and blockmetas. More...
 
void ReplaceRelCuboid (const cCuboid &a_RelCuboid, BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta)
 Replaces the specified src blocks in the cuboid by the dst blocks; allows cuboid out of range of this chunk. More...
 
void ReplaceRelCuboid (int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ, BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta)
 Replaces the specified src blocks in the cuboid by the dst blocks; allows cuboid out of range of this chunk. More...
 
void SetBiome (int a_RelX, int a_RelZ, EMCSBiome a_BiomeID)
 
void SetBlockMeta (int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta)
 
void SetBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
 
void SetBlockTypeMeta (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
void SetChunkCoords (cChunkCoords a_Coords)
 
void SetHeight (int a_RelX, int a_RelZ, HEIGHTTYPE a_Height)
 
void SetHeightFromShape (const Shape &a_Shape)
 Sets the heightmap to match the given shape data. More...
 
void SetUseDefaultBiomes (bool a_bUseDefaultBiomes)
 
void SetUseDefaultComposition (bool a_bUseDefaultComposition)
 
void SetUseDefaultFinish (bool a_bUseDefaultFinish)
 
void SetUseDefaultHeight (bool a_bUseDefaultHeight)
 
void UpdateHeightmap (void)
 Updates the heightmap to match the current contents. More...
 
void VerifyHeightmap (void)
 Verifies that the heightmap corresponds to blocktype contents; if not, asserts on that column. More...
 
void WriteBlockArea (const cBlockArea &a_BlockArea, int a_RelX, int a_RelY, int a_RelZ, cBlockArea::eMergeStrategy a_MergeStrategy=cBlockArea::msOverwrite)
 Writes the block area into the chunk, with its origin set at the specified relative coords. More...
 
 ~cChunkDesc ()
 

Static Public Member Functions

static bool GetShapeIsSolidAt (const Shape &a_Shape, int a_X, int a_Y, int a_Z)
 
static size_t MakeShapeIndex (int a_X, int a_Y, int a_Z)
 Returns the index into the internal shape array for the specified coords. More...
 
static void SetShapeIsSolidAt (Shape &a_Shape, int a_X, int a_Y, int a_Z, bool a_IsSolid)
 

Private Attributes

cChunkDef::BiomeMap m_BiomeMap
 
cBlockArea m_BlockArea
 
cBlockEntities m_BlockEntities
 
bool m_bUseDefaultBiomes
 
bool m_bUseDefaultComposition
 
bool m_bUseDefaultFinish
 
bool m_bUseDefaultHeight
 
cChunkCoords m_Coords
 
cEntityList m_Entities
 
cChunkDef::HeightMap m_HeightMap
 

Detailed Description

Definition at line 27 of file ChunkDesc.h.

Member Typedef Documentation

◆ BlockNibbleBytes

typedef NIBBLETYPE cChunkDesc::BlockNibbleBytes[cChunkDef::NumBlocks]

Uncompressed block metas, 1 meta per byte.

Definition at line 39 of file ChunkDesc.h.

◆ Shape

typedef Byte cChunkDesc::Shape[256 *16 *16]

The datatype used to represent the entire chunk worth of shape.

0 = air 1 = solid Indexed as [y + 256 * x + 256 * 16 * z].

Definition at line 36 of file ChunkDesc.h.

Constructor & Destructor Documentation

◆ cChunkDesc()

cChunkDesc::cChunkDesc ( cChunkCoords  a_Coords)

Definition at line 16 of file ChunkDesc.cpp.

◆ ~cChunkDesc()

cChunkDesc::~cChunkDesc ( )

Definition at line 36 of file ChunkDesc.cpp.

Member Function Documentation

◆ CompressBlockMetas()

void cChunkDesc::CompressBlockMetas ( cChunkDef::BlockNibbles a_DestMetas)

Compresses the metas from the BlockArea format (1 meta per byte) into regular format (2 metas per byte)

Definition at line 637 of file ChunkDesc.cpp.

◆ FillBlocks()

void cChunkDesc::FillBlocks ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 54 of file ChunkDesc.cpp.

◆ FillRelCuboid() [1/2]

void cChunkDesc::FillRelCuboid ( const cCuboid a_RelCuboid,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)
inline

Fills the relative cuboid with specified block; allows cuboid out of range of this chunk.

Definition at line 141 of file ChunkDesc.h.

◆ FillRelCuboid() [2/2]

void cChunkDesc::FillRelCuboid ( int  a_MinX,
int  a_MaxX,
int  a_MinY,
int  a_MaxY,
int  a_MinZ,
int  a_MaxZ,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Fills the relative cuboid with specified block; allows cuboid out of range of this chunk.

Definition at line 431 of file ChunkDesc.cpp.

◆ FloorRelCuboid() [1/2]

void cChunkDesc::FloorRelCuboid ( const cCuboid a_RelCuboid,
BLOCKTYPE  a_DstType,
NIBBLETYPE  a_DstMeta 
)
inline

Replaces the blocks in the cuboid by the dst blocks if they are considered non-floor (air, water); allows cuboid out of range of this chunk.

Definition at line 185 of file ChunkDesc.h.

◆ FloorRelCuboid() [2/2]

void cChunkDesc::FloorRelCuboid ( int  a_MinX,
int  a_MaxX,
int  a_MinY,
int  a_MaxY,
int  a_MinZ,
int  a_MaxZ,
BLOCKTYPE  a_DstType,
NIBBLETYPE  a_DstMeta 
)

Replaces the blocks in the cuboid by the dst blocks if they are considered non-floor (air, water); allows cuboid out of range of this chunk.

Definition at line 498 of file ChunkDesc.cpp.

◆ GetBiome()

EMCSBiome cChunkDesc::GetBiome ( int  a_RelX,
int  a_RelZ 
) const

Definition at line 126 of file ChunkDesc.cpp.

◆ GetBiomeMap() [1/2]

const cChunkDef::BiomeMap& cChunkDesc::GetBiomeMap ( ) const
inline

Definition at line 243 of file ChunkDesc.h.

◆ GetBiomeMap() [2/2]

cChunkDef::BiomeMap& cChunkDesc::GetBiomeMap ( void  )
inline

Definition at line 234 of file ChunkDesc.h.

◆ GetBlockEntities()

cBlockEntities& cChunkDesc::GetBlockEntities ( void  )
inline

Definition at line 241 of file ChunkDesc.h.

◆ GetBlockEntity()

cBlockEntity * cChunkDesc::GetBlockEntity ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
)

Returns the block entity at the specified coords.

If there is no block entity at those coords, tries to create one, based on the block type If the blocktype doesn't support a block entity, returns nullptr.

Definition at line 573 of file ChunkDesc.cpp.

◆ GetBlockMeta()

NIBBLETYPE cChunkDesc::GetBlockMeta ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
) const

Definition at line 99 of file ChunkDesc.cpp.

◆ GetBlockMetasUncompressed()

BlockNibbleBytes& cChunkDesc::GetBlockMetasUncompressed ( void  )
inline

Definition at line 238 of file ChunkDesc.h.

◆ GetBlockType()

BLOCKTYPE cChunkDesc::GetBlockType ( int  a_RelX,
int  a_RelY,
int  a_RelZ 
) const

Definition at line 90 of file ChunkDesc.cpp.

◆ GetBlockTypeMeta()

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

Returns the BlockType and BlockMeta at the specified coords.

Exported to Lua manually to avoid extra parameters generated by ToLua++.

Definition at line 72 of file ChunkDesc.cpp.

◆ GetBlockTypes() [1/2]

const cChunkDef::BlockTypes& cChunkDesc::GetBlockTypes ( void  ) const
inline

Definition at line 244 of file ChunkDesc.h.

◆ GetBlockTypes() [2/2]

cChunkDef::BlockTypes& cChunkDesc::GetBlockTypes ( void  )
inline

Definition at line 235 of file ChunkDesc.h.

◆ GetChunkCoords()

cChunkCoords cChunkDesc::GetChunkCoords ( ) const
inline

Definition at line 54 of file ChunkDesc.h.

◆ GetChunkX()

int cChunkDesc::GetChunkX ( void  ) const
inline

Definition at line 49 of file ChunkDesc.h.

◆ GetChunkZ()

int cChunkDesc::GetChunkZ ( void  ) const
inline

Definition at line 50 of file ChunkDesc.h.

◆ GetEntities()

cEntityList& cChunkDesc::GetEntities ( void  )
inline

Definition at line 240 of file ChunkDesc.h.

◆ GetHeight()

HEIGHTTYPE cChunkDesc::GetHeight ( int  a_RelX,
int  a_RelZ 
) const

Definition at line 144 of file ChunkDesc.cpp.

◆ GetHeightMap() [1/2]

const cChunkDef::HeightMap& cChunkDesc::GetHeightMap ( ) const
inline

Definition at line 245 of file ChunkDesc.h.

◆ GetHeightMap() [2/2]

cChunkDef::HeightMap& cChunkDesc::GetHeightMap ( void  )
inline

Definition at line 239 of file ChunkDesc.h.

◆ GetMaxHeight()

HEIGHTTYPE cChunkDesc::GetMaxHeight ( void  ) const

Returns the maximum height value in the heightmap.

Definition at line 397 of file ChunkDesc.cpp.

◆ GetMinHeight()

HEIGHTTYPE cChunkDesc::GetMinHeight ( void  ) const

Returns the minimum height value in the heightmap.

Definition at line 414 of file ChunkDesc.cpp.

◆ GetShapeFromHeight()

void cChunkDesc::GetShapeFromHeight ( Shape a_Shape) const

Sets the shape in a_Shape to match the heightmap stored currently in m_HeightMap.

Definition at line 175 of file ChunkDesc.cpp.

◆ GetShapeIsSolidAt()

static bool cChunkDesc::GetShapeIsSolidAt ( const Shape a_Shape,
int  a_X,
int  a_Y,
int  a_Z 
)
inlinestatic

Definition at line 102 of file ChunkDesc.h.

◆ IsUsingDefaultBiomes()

bool cChunkDesc::IsUsingDefaultBiomes ( void  ) const

Definition at line 208 of file ChunkDesc.cpp.

◆ IsUsingDefaultComposition()

bool cChunkDesc::IsUsingDefaultComposition ( void  ) const

Definition at line 244 of file ChunkDesc.cpp.

◆ IsUsingDefaultFinish()

bool cChunkDesc::IsUsingDefaultFinish ( void  ) const

Definition at line 262 of file ChunkDesc.cpp.

◆ IsUsingDefaultHeight()

bool cChunkDesc::IsUsingDefaultHeight ( void  ) const

Definition at line 226 of file ChunkDesc.cpp.

◆ MakeShapeIndex()

static size_t cChunkDesc::MakeShapeIndex ( int  a_X,
int  a_Y,
int  a_Z 
)
inlinestatic

Returns the index into the internal shape array for the specified coords.

Definition at line 91 of file ChunkDesc.h.

◆ RandomFillRelCuboid() [1/2]

void cChunkDesc::RandomFillRelCuboid ( const cCuboid a_RelCuboid,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
int  a_RandomSeed,
int  a_ChanceOutOf10k 
)
inline

Fills the relative cuboid with specified block with a random chance; allows cuboid out of range of this chunk.

Definition at line 208 of file ChunkDesc.h.

◆ RandomFillRelCuboid() [2/2]

void cChunkDesc::RandomFillRelCuboid ( int  a_MinX,
int  a_MaxX,
int  a_MinY,
int  a_MaxY,
int  a_MinZ,
int  a_MaxZ,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
int  a_RandomSeed,
int  a_ChanceOutOf10k 
)

Fills the relative cuboid with specified block with a random chance; allows cuboid out of range of this chunk.

Definition at line 537 of file ChunkDesc.cpp.

◆ ReadBlockArea()

void cChunkDesc::ReadBlockArea ( cBlockArea a_Dest,
int  a_MinRelX,
int  a_MaxRelX,
int  a_MinRelY,
int  a_MaxRelY,
int  a_MinRelZ,
int  a_MaxRelZ 
)

Reads an area from the chunk into a cBlockArea, blocktypes and blockmetas.

Definition at line 280 of file ChunkDesc.cpp.

◆ ReplaceRelCuboid() [1/2]

void cChunkDesc::ReplaceRelCuboid ( const cCuboid a_RelCuboid,
BLOCKTYPE  a_SrcType,
NIBBLETYPE  a_SrcMeta,
BLOCKTYPE  a_DstType,
NIBBLETYPE  a_DstMeta 
)
inline

Replaces the specified src blocks in the cuboid by the dst blocks; allows cuboid out of range of this chunk.

Definition at line 161 of file ChunkDesc.h.

◆ ReplaceRelCuboid() [2/2]

void cChunkDesc::ReplaceRelCuboid ( int  a_MinX,
int  a_MaxX,
int  a_MinY,
int  a_MaxY,
int  a_MinZ,
int  a_MaxZ,
BLOCKTYPE  a_SrcType,
NIBBLETYPE  a_SrcMeta,
BLOCKTYPE  a_DstType,
NIBBLETYPE  a_DstMeta 
)

Replaces the specified src blocks in the cuboid by the dst blocks; allows cuboid out of range of this chunk.

Definition at line 461 of file ChunkDesc.cpp.

◆ SetBiome()

void cChunkDesc::SetBiome ( int  a_RelX,
int  a_RelZ,
EMCSBiome  a_BiomeID 
)

Definition at line 117 of file ChunkDesc.cpp.

◆ SetBlockMeta()

void cChunkDesc::SetBlockMeta ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 108 of file ChunkDesc.cpp.

◆ SetBlockType()

void cChunkDesc::SetBlockType ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE  a_BlockType 
)

Definition at line 81 of file ChunkDesc.cpp.

◆ SetBlockTypeMeta()

void cChunkDesc::SetBlockTypeMeta ( int  a_RelX,
int  a_RelY,
int  a_RelZ,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 63 of file ChunkDesc.cpp.

◆ SetChunkCoords()

void cChunkDesc::SetChunkCoords ( cChunkCoords  a_Coords)

Definition at line 45 of file ChunkDesc.cpp.

◆ SetHeight()

void cChunkDesc::SetHeight ( int  a_RelX,
int  a_RelZ,
HEIGHTTYPE  a_Height 
)

Definition at line 135 of file ChunkDesc.cpp.

◆ SetHeightFromShape()

void cChunkDesc::SetHeightFromShape ( const Shape a_Shape)

Sets the heightmap to match the given shape data.

Note that this ignores overhangs; the method is mostly used by old composition generators.

Definition at line 153 of file ChunkDesc.cpp.

◆ SetShapeIsSolidAt()

static void cChunkDesc::SetShapeIsSolidAt ( Shape a_Shape,
int  a_X,
int  a_Y,
int  a_Z,
bool  a_IsSolid 
)
inlinestatic

Definition at line 96 of file ChunkDesc.h.

◆ SetUseDefaultBiomes()

void cChunkDesc::SetUseDefaultBiomes ( bool  a_bUseDefaultBiomes)

Definition at line 199 of file ChunkDesc.cpp.

◆ SetUseDefaultComposition()

void cChunkDesc::SetUseDefaultComposition ( bool  a_bUseDefaultComposition)

Definition at line 235 of file ChunkDesc.cpp.

◆ SetUseDefaultFinish()

void cChunkDesc::SetUseDefaultFinish ( bool  a_bUseDefaultFinish)

Definition at line 253 of file ChunkDesc.cpp.

◆ SetUseDefaultHeight()

void cChunkDesc::SetUseDefaultHeight ( bool  a_bUseDefaultHeight)

Definition at line 217 of file ChunkDesc.cpp.

◆ UpdateHeightmap()

void cChunkDesc::UpdateHeightmap ( void  )

Updates the heightmap to match the current contents.

Useful for plugins when writing custom block areas into the chunk

Definition at line 612 of file ChunkDesc.cpp.

◆ VerifyHeightmap()

void cChunkDesc::VerifyHeightmap ( void  )

Verifies that the heightmap corresponds to blocktype contents; if not, asserts on that column.

Definition at line 652 of file ChunkDesc.cpp.

◆ WriteBlockArea()

void cChunkDesc::WriteBlockArea ( const cBlockArea a_BlockArea,
int  a_RelX,
int  a_RelY,
int  a_RelZ,
cBlockArea::eMergeStrategy  a_MergeStrategy = cBlockArea::msOverwrite 
)

Writes the block area into the chunk, with its origin set at the specified relative coords.

Area's data overwrite everything in the chunk.

Definition at line 271 of file ChunkDesc.cpp.

Member Data Documentation

◆ m_BiomeMap

cChunkDef::BiomeMap cChunkDesc::m_BiomeMap
private

Definition at line 258 of file ChunkDesc.h.

◆ m_BlockArea

cBlockArea cChunkDesc::m_BlockArea
private

Definition at line 259 of file ChunkDesc.h.

◆ m_BlockEntities

cBlockEntities cChunkDesc::m_BlockEntities
private

Definition at line 262 of file ChunkDesc.h.

◆ m_bUseDefaultBiomes

bool cChunkDesc::m_bUseDefaultBiomes
private

Definition at line 264 of file ChunkDesc.h.

◆ m_bUseDefaultComposition

bool cChunkDesc::m_bUseDefaultComposition
private

Definition at line 266 of file ChunkDesc.h.

◆ m_bUseDefaultFinish

bool cChunkDesc::m_bUseDefaultFinish
private

Definition at line 267 of file ChunkDesc.h.

◆ m_bUseDefaultHeight

bool cChunkDesc::m_bUseDefaultHeight
private

Definition at line 265 of file ChunkDesc.h.

◆ m_Coords

cChunkCoords cChunkDesc::m_Coords
private

Definition at line 256 of file ChunkDesc.h.

◆ m_Entities

cEntityList cChunkDesc::m_Entities
private

Definition at line 261 of file ChunkDesc.h.

◆ m_HeightMap

cChunkDef::HeightMap cChunkDesc::m_HeightMap
private

Definition at line 260 of file ChunkDesc.h.


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