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

Constants used throughout the code, useful typedefs and utility functions. More...

#include <ChunkDef.h>

Public Types

typedef EMCSBiome BiomeMap[Width *Width]
 The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need not correspond to client representation!) idx = x + Width * z. More...
 
typedef NIBBLETYPE BlockNibbles[NumBlocks/2]
 The type used for block data in nibble format, AXIS_ORDER ordering. More...
 
typedef BLOCKTYPE BlockTypes[NumBlocks]
 The type used for block type operations and storage, AXIS_ORDER ordering. More...
 
typedef HEIGHTTYPE HeightMap[Width *Width]
 The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column. More...
 

Static Public Member Functions

static void AbsoluteToRelative (int &a_X, int &a_Y, int &a_Z, int &a_ChunkX, int &a_ChunkZ)
 Converts absolute block coords into relative (chunk + block) coords: More...
 
static Vector3i AbsoluteToRelative (Vector3i a_BlockPosition)
 Converts the specified absolute position into a relative position within its chunk. More...
 
static Vector3i AbsoluteToRelative (Vector3i a_BlockPosition, cChunkCoords a_ChunkPos)
 Converts the absolute coords into coords relative to the specified chunk. More...
 
static cChunkCoords BlockToChunk (const Vector3i a_Position)
 The Y coordinate of a_Pos is ignored. More...
 
static void BlockToChunk (int a_X, int a_Z, int &a_ChunkX, int &a_ChunkZ)
 Converts absolute block coords to chunk coords: More...
 
static NIBBLETYPE ExpandNibble (const NIBBLETYPE *const a_Buffer, const size_t a_Index)
 
static EMCSBiome GetBiome (const BiomeMap &a_BiomeMap, int a_X, int a_Z)
 
static BLOCKTYPE GetBlock (const BLOCKTYPE *a_BlockTypes, int a_Idx)
 
static BLOCKTYPE GetBlock (const BLOCKTYPE *a_BlockTypes, int a_X, int a_Y, int a_Z)
 
static BLOCKTYPE GetBlock (const BLOCKTYPE *a_BlockTypes, Vector3i a_RelPos)
 
static HEIGHTTYPE GetHeight (const HeightMap &a_HeightMap, int a_X, int a_Z)
 
static NIBBLETYPE GetNibble (const NIBBLETYPE *a_Buffer, int x, int y, int z)
 
static Vector3i IndexToCoordinate (size_t index)
 
static bool IsValidHeight (Vector3i a_BlockPosition)
 Validates a height-coordinate. More...
 
static bool IsValidRelPos (Vector3i a_RelPos)
 Validates a chunk relative coordinate. More...
 
static bool IsValidWidth (int a_Width)
 Validates a width-coordinate. More...
 
static size_t MakeIndex (int x, int y, int z)
 
static size_t MakeIndex (Vector3i a_RelPos)
 
static void PackNibble (NIBBLETYPE *const a_Buffer, const size_t a_Index, const NIBBLETYPE a_Nibble)
 
static Vector3i RelativeToAbsolute (Vector3i a_RelBlockPosition, cChunkCoords a_ChunkCoords)
 Converts relative block coordinates into absolute coordinates with a known chunk location. More...
 
static void SetBiome (BiomeMap &a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
 
static void SetBlock (BLOCKTYPE *a_BlockTypes, int a_Index, BLOCKTYPE a_Type)
 
static void SetBlock (BLOCKTYPE *a_BlockTypes, int a_X, int a_Y, int a_Z, BLOCKTYPE a_Type)
 
static void SetHeight (HeightMap &a_HeightMap, int a_X, int a_Z, HEIGHTTYPE a_Height)
 

Static Public Attributes

static const int Height = 256
 
static const int NumBlocks = Width * Height * Width
 
static const size_t NumSections = (cChunkDef::Height / SectionHeight)
 
static const int SectionHeight = 16
 
static const int Width = 16
 

Detailed Description

Constants used throughout the code, useful typedefs and utility functions.

Definition at line 119 of file ChunkDef.h.

Member Typedef Documentation

◆ BiomeMap

typedef EMCSBiome cChunkDef::BiomeMap[Width *Width]

The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need not correspond to client representation!) idx = x + Width * z.

Definition at line 137 of file ChunkDef.h.

◆ BlockNibbles

typedef NIBBLETYPE cChunkDef::BlockNibbles[NumBlocks/2]

The type used for block data in nibble format, AXIS_ORDER ordering.

Definition at line 143 of file ChunkDef.h.

◆ BlockTypes

typedef BLOCKTYPE cChunkDef::BlockTypes[NumBlocks]

The type used for block type operations and storage, AXIS_ORDER ordering.

Definition at line 140 of file ChunkDef.h.

◆ HeightMap

typedef HEIGHTTYPE cChunkDef::HeightMap[Width *Width]

The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column.

Definition at line 132 of file ChunkDef.h.

Member Function Documentation

◆ AbsoluteToRelative() [1/3]

static void cChunkDef::AbsoluteToRelative ( int &  a_X,
int &  a_Y,
int &  a_Z,
int &  a_ChunkX,
int &  a_ChunkZ 
)
inlinestatic

Converts absolute block coords into relative (chunk + block) coords:

Definition at line 147 of file ChunkDef.h.

◆ AbsoluteToRelative() [2/3]

static Vector3i cChunkDef::AbsoluteToRelative ( Vector3i  a_BlockPosition)
inlinestatic

Converts the specified absolute position into a relative position within its chunk.

Use BlockToChunk to query the chunk coords.

Definition at line 159 of file ChunkDef.h.

◆ AbsoluteToRelative() [3/3]

static Vector3i cChunkDef::AbsoluteToRelative ( Vector3i  a_BlockPosition,
cChunkCoords  a_ChunkPos 
)
inlinestatic

Converts the absolute coords into coords relative to the specified chunk.

Definition at line 167 of file ChunkDef.h.

◆ BlockToChunk() [1/2]

static cChunkCoords cChunkDef::BlockToChunk ( const Vector3i  a_Position)
inlinestatic

The Y coordinate of a_Pos is ignored.

Definition at line 221 of file ChunkDef.h.

◆ BlockToChunk() [2/2]

static void cChunkDef::BlockToChunk ( int  a_X,
int  a_Z,
int &  a_ChunkX,
int &  a_ChunkZ 
)
inlinestatic

Converts absolute block coords to chunk coords:

Definition at line 210 of file ChunkDef.h.

◆ ExpandNibble()

static NIBBLETYPE cChunkDef::ExpandNibble ( const NIBBLETYPE *const  a_Buffer,
const size_t  a_Index 
)
inlinestatic

Definition at line 357 of file ChunkDef.h.

◆ GetBiome()

static EMCSBiome cChunkDef::GetBiome ( const BiomeMap a_BiomeMap,
int  a_X,
int  a_Z 
)
inlinestatic

Definition at line 319 of file ChunkDef.h.

◆ GetBlock() [1/3]

static BLOCKTYPE cChunkDef::GetBlock ( const BLOCKTYPE a_BlockTypes,
int  a_Idx 
)
inlinestatic

Definition at line 296 of file ChunkDef.h.

◆ GetBlock() [2/3]

static BLOCKTYPE cChunkDef::GetBlock ( const BLOCKTYPE a_BlockTypes,
int  a_X,
int  a_Y,
int  a_Z 
)
inlinestatic

Definition at line 287 of file ChunkDef.h.

◆ GetBlock() [3/3]

static BLOCKTYPE cChunkDef::GetBlock ( const BLOCKTYPE a_BlockTypes,
Vector3i  a_RelPos 
)
inlinestatic

Definition at line 280 of file ChunkDef.h.

◆ GetHeight()

static HEIGHTTYPE cChunkDef::GetHeight ( const HeightMap a_HeightMap,
int  a_X,
int  a_Z 
)
inlinestatic

Definition at line 303 of file ChunkDef.h.

◆ GetNibble()

static NIBBLETYPE cChunkDef::GetNibble ( const NIBBLETYPE a_Buffer,
int  x,
int  y,
int  z 
)
inlinestatic

Definition at line 335 of file ChunkDef.h.

◆ IndexToCoordinate()

static Vector3i cChunkDef::IndexToCoordinate ( size_t  index)
inlinestatic

Definition at line 246 of file ChunkDef.h.

◆ IsValidHeight()

static bool cChunkDef::IsValidHeight ( Vector3i  a_BlockPosition)
inlinestatic

Validates a height-coordinate.

Returns false if height-coordinate is out of height bounds

Definition at line 185 of file ChunkDef.h.

◆ IsValidRelPos()

static bool cChunkDef::IsValidRelPos ( Vector3i  a_RelPos)
inlinestatic

Validates a chunk relative coordinate.

Returns false if the coordiante is out of bounds for a chunk.

Definition at line 199 of file ChunkDef.h.

◆ IsValidWidth()

static bool cChunkDef::IsValidWidth ( int  a_Width)
inlinestatic

Validates a width-coordinate.

Returns false if width-coordiante is out of width bounds

Definition at line 192 of file ChunkDef.h.

◆ MakeIndex() [1/2]

static size_t cChunkDef::MakeIndex ( int  x,
int  y,
int  z 
)
inlinestatic

Definition at line 227 of file ChunkDef.h.

◆ MakeIndex() [2/2]

static size_t cChunkDef::MakeIndex ( Vector3i  a_RelPos)
inlinestatic

Definition at line 240 of file ChunkDef.h.

◆ PackNibble()

static void cChunkDef::PackNibble ( NIBBLETYPE *const  a_Buffer,
const size_t  a_Index,
const NIBBLETYPE  a_Nibble 
)
inlinestatic

Definition at line 346 of file ChunkDef.h.

◆ RelativeToAbsolute()

static Vector3i cChunkDef::RelativeToAbsolute ( Vector3i  a_RelBlockPosition,
cChunkCoords  a_ChunkCoords 
)
inlinestatic

Converts relative block coordinates into absolute coordinates with a known chunk location.

Definition at line 174 of file ChunkDef.h.

◆ SetBiome()

static void cChunkDef::SetBiome ( BiomeMap a_BiomeMap,
int  a_X,
int  a_Z,
EMCSBiome  a_Biome 
)
inlinestatic

Definition at line 327 of file ChunkDef.h.

◆ SetBlock() [1/2]

static void cChunkDef::SetBlock ( BLOCKTYPE a_BlockTypes,
int  a_Index,
BLOCKTYPE  a_Type 
)
inlinestatic

Definition at line 273 of file ChunkDef.h.

◆ SetBlock() [2/2]

static void cChunkDef::SetBlock ( BLOCKTYPE a_BlockTypes,
int  a_X,
int  a_Y,
int  a_Z,
BLOCKTYPE  a_Type 
)
inlinestatic

Definition at line 264 of file ChunkDef.h.

◆ SetHeight()

static void cChunkDef::SetHeight ( HeightMap a_HeightMap,
int  a_X,
int  a_Z,
HEIGHTTYPE  a_Height 
)
inlinestatic

Definition at line 311 of file ChunkDef.h.

Member Data Documentation

◆ Height

const int cChunkDef::Height = 256
static

Definition at line 125 of file ChunkDef.h.

◆ NumBlocks

const int cChunkDef::NumBlocks = Width * Height * Width
static

Definition at line 126 of file ChunkDef.h.

◆ NumSections

const size_t cChunkDef::NumSections = (cChunkDef::Height / SectionHeight)
static

Definition at line 129 of file ChunkDef.h.

◆ SectionHeight

const int cChunkDef::SectionHeight = 16
static

Definition at line 128 of file ChunkDef.h.

◆ Width

const int cChunkDef::Width = 16
static

Definition at line 124 of file ChunkDef.h.


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