Cuberite
A lightweight, fast and extensible game server for Minecraft
ChunkDef.h
Go to the documentation of this file.
1 
2 // ChunkDef.h
3 
4 // Interfaces to helper types for chunk definitions. Most modules want to include this instead of cChunk.h
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "BiomeDef.h"
13 
14 
15 
16 // Used to smoothly convert to new axis ordering. One will be removed when deemed stable.
17 #define AXIS_ORDER_YZX 1 // Original (1.1-)
18 #define AXIS_ORDER_XZY 2 // New (1.2+)
19 #define AXIS_ORDER AXIS_ORDER_XZY
20 
21 
22 
23 
24 
25 // fwd
26 class cBlockEntity;
27 class cEntity;
28 class cClientHandle;
29 class cBlockEntity;
30 class cChunkCoords;
31 
32 using OwnedEntity = std::unique_ptr<cEntity>;
33 using cEntityList = std::vector<OwnedEntity>;
34 
35 
36 
37 
38 // tolua_begin
39 
41 typedef unsigned char BLOCKTYPE;
42 
44 typedef unsigned char NIBBLETYPE;
45 
47 typedef unsigned char HEIGHTTYPE;
48 
49 // tolua_end
50 
51 
52 
53 
54 
56 {
57 public:
58  int m_ChunkX;
59  int m_ChunkZ;
60 
61  cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
62 
63 
64  bool operator == (const cChunkCoords & a_Other) const
65  {
66  return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
67  }
68 
69 
70  bool operator != (const cChunkCoords & a_Other) const
71  {
72  return !(operator == (a_Other));
73  }
74 
75 
77  bool operator < (const cChunkCoords & a_Other) const
78  {
79  if (a_Other.m_ChunkX == m_ChunkX)
80  {
81  return (m_ChunkZ < a_Other.m_ChunkZ);
82  }
83  else
84  {
85  return (m_ChunkX < a_Other.m_ChunkX);
86  }
87  }
88 
89 
91  AString ToString() const
92  {
93  return Printf("[%d, %d]", m_ChunkX, m_ChunkZ);
94  }
95 } ;
96 
97 
98 
99 
100 
103 {
104 public:
105 
106  // Chunk dimensions:
107  static const int Width = 16;
108  static const int Height = 256;
109  static const int NumBlocks = Width * Height * Width;
110 
111  static const int SectionHeight = 16;
112  static const size_t NumSections = (cChunkDef::Height / SectionHeight);
113 
116 
121 
124 
127 
128 
130  inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ)
131  {
132  UNUSED(a_Y);
133  BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ);
134 
135  a_X = a_X - a_ChunkX * Width;
136  a_Z = a_Z - a_ChunkZ * Width;
137  }
138 
139 
142  inline static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition)
143  {
144  cChunkCoords chunkPos = BlockToChunk(a_BlockPosition);
145  return AbsoluteToRelative(a_BlockPosition, chunkPos);
146  }
147 
148 
150  inline static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition, cChunkCoords a_ChunkPos)
151  {
152  return { a_BlockPosition.x - a_ChunkPos.m_ChunkX * Width, a_BlockPosition.y, a_BlockPosition.z - a_ChunkPos.m_ChunkZ * Width };
153  }
154 
155 
157  inline static Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition, cChunkCoords a_ChunkCoords)
158  {
159  return Vector3i(
160  a_RelBlockPosition.x + a_ChunkCoords.m_ChunkX * Width,
161  a_RelBlockPosition.y,
162  a_RelBlockPosition.z + a_ChunkCoords.m_ChunkZ * Width
163  );
164  }
165 
166 
168  inline static bool IsValidHeight(Vector3i a_BlockPosition)
169  {
170  return ((a_BlockPosition.y >= 0) && (a_BlockPosition.y < Height));
171  }
172 
173 
175  inline static bool IsValidWidth(int a_Width)
176  {
177  return ((a_Width >= 0) && (a_Width < Width));
178  }
179 
180 
182  inline static bool IsValidRelPos(Vector3i a_RelPos)
183  {
184  return (
185  IsValidWidth(a_RelPos.x) &&
186  IsValidHeight(a_RelPos) &&
187  IsValidWidth(a_RelPos.z)
188  );
189  }
190 
191 
193  inline static void BlockToChunk(int a_X, int a_Z, int & a_ChunkX, int & a_ChunkZ)
194  {
195  // This version is deprecated in favor of the vector version
196  // If you're developing new code, use the other version.
197  const auto ChunkCoords = BlockToChunk({ a_X, 0, a_Z });
198  a_ChunkX = ChunkCoords.m_ChunkX;
199  a_ChunkZ = ChunkCoords.m_ChunkZ;
200  }
201 
202 
204  inline static cChunkCoords BlockToChunk(const Vector3i a_Position)
205  {
206  return { FAST_FLOOR_DIV(a_Position.x, Width), FAST_FLOOR_DIV(a_Position.z, Width) };
207  }
208 
209 
210  inline static size_t MakeIndex(int x, int y, int z)
211  {
212  ASSERT(IsValidRelPos({ x, y, z }));
213 
214  #if AXIS_ORDER == AXIS_ORDER_XZY
215  // For some reason, NOT using the Horner schema is faster. Weird.
216  return static_cast<size_t>(x + (z * Width) + (y * Width * Width)); // 1.2 uses XZY
217  #elif AXIS_ORDER == AXIS_ORDER_YZX
218  return static_cast<size_t>(y + (z * Width) + (x * Height * Width)); // 1.1 uses YZX
219  #endif
220  }
221 
222 
223  inline static size_t MakeIndex(Vector3i a_RelPos)
224  {
225  return MakeIndex(a_RelPos.x, a_RelPos.y, a_RelPos.z);
226  }
227 
228 
229  inline static Vector3i IndexToCoordinate(size_t index)
230  {
231  #if AXIS_ORDER == AXIS_ORDER_XZY
232  return Vector3i( // 1.2
233  static_cast<int>(index % cChunkDef::Width), // X
234  static_cast<int>(index / (cChunkDef::Width * cChunkDef::Width)), // Y
235  static_cast<int>((index / cChunkDef::Width) % cChunkDef::Width) // Z
236  );
237  #elif AXIS_ORDER == AXIS_ORDER_YZX
238  return Vector3i( // 1.1
239  static_cast<int>(index / (cChunkDef::Height * cChunkDef::Width)), // X
240  static_cast<int>(index % cChunkDef::Height), // Y
241  static_cast<int>((index / cChunkDef::Height) % cChunkDef::Width) // Z
242  );
243  #endif
244  }
245 
246 
247  inline static void SetBlock(BLOCKTYPE * a_BlockTypes, int a_X, int a_Y, int a_Z, BLOCKTYPE a_Type)
248  {
249  ASSERT((a_X >= 0) && (a_X < Width));
250  ASSERT((a_Y >= 0) && (a_Y < Height));
251  ASSERT((a_Z >= 0) && (a_Z < Width));
252  a_BlockTypes[MakeIndex(a_X, a_Y, a_Z)] = a_Type;
253  }
254 
255 
256  inline static void SetBlock(BLOCKTYPE * a_BlockTypes, int a_Index, BLOCKTYPE a_Type)
257  {
258  ASSERT((a_Index >= 0) && (a_Index <= NumBlocks));
259  a_BlockTypes[a_Index] = a_Type;
260  }
261 
262 
263  inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, Vector3i a_RelPos)
264  {
265  ASSERT(IsValidRelPos(a_RelPos));
266  return a_BlockTypes[MakeIndex(a_RelPos)];
267  }
268 
269 
270  inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_X, int a_Y, int a_Z)
271  {
272  ASSERT((a_X >= 0) && (a_X < Width));
273  ASSERT((a_Y >= 0) && (a_Y < Height));
274  ASSERT((a_Z >= 0) && (a_Z < Width));
275  return a_BlockTypes[MakeIndex(a_X, a_Y, a_Z)];
276  }
277 
278 
279  inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_Idx)
280  {
281  ASSERT((a_Idx >= 0) && (a_Idx < NumBlocks));
282  return a_BlockTypes[a_Idx];
283  }
284 
285 
286  inline static HEIGHTTYPE GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z)
287  {
288  ASSERT((a_X >= 0) && (a_X < Width));
289  ASSERT((a_Z >= 0) && (a_Z < Width));
290  return a_HeightMap[a_X + Width * a_Z];
291  }
292 
293 
294  inline static void SetHeight(HeightMap & a_HeightMap, int a_X, int a_Z, HEIGHTTYPE a_Height)
295  {
296  ASSERT((a_X >= 0) && (a_X < Width));
297  ASSERT((a_Z >= 0) && (a_Z < Width));
298  a_HeightMap[a_X + Width * a_Z] = a_Height;
299  }
300 
301 
302  inline static EMCSBiome GetBiome(const BiomeMap & a_BiomeMap, int a_X, int a_Z)
303  {
304  ASSERT((a_X >= 0) && (a_X < Width));
305  ASSERT((a_Z >= 0) && (a_Z < Width));
306  return a_BiomeMap[a_X + Width * a_Z];
307  }
308 
309 
310  inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
311  {
312  ASSERT((a_X >= 0) && (a_X < Width));
313  ASSERT((a_Z >= 0) && (a_Z < Width));
314  a_BiomeMap[a_X + Width * a_Z] = a_Biome;
315  }
316 
317 
318  static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, int x, int y, int z)
319  {
320  if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
321  {
322  return ExpandNibble(a_Buffer, MakeIndex(x, y, z));
323  }
324  ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!");
325  return 0;
326  }
327 
328 
329  inline static void PackNibble(NIBBLETYPE * const a_Buffer, const size_t a_Index, const NIBBLETYPE a_Nibble)
330  {
331  ASSERT((a_Nibble & 0xF) == a_Nibble); // Only the lower bits should be set
332 
333  a_Buffer[a_Index / 2] = static_cast<NIBBLETYPE>(
334  (a_Buffer[a_Index / 2] & (0xf0 >> ((a_Index & 1) * 4))) | // The untouched nibble
335  ((a_Nibble & 0x0f) << ((a_Index & 1) * 4)) // The nibble being set
336  );
337  }
338 
339 
340  inline static NIBBLETYPE ExpandNibble(const NIBBLETYPE * const a_Buffer, const size_t a_Index)
341  {
342  return (a_Buffer[a_Index / 2] >> ((a_Index & 1) * 4)) & 0x0f;
343  }
344 } ;
345 
346 
347 
348 
349 
353 {
354 public:
355 
356  virtual ~cClientDiffCallback() {}
357 
359  virtual void Removed(cClientHandle * a_Client) = 0;
360 
362  virtual void Added(cClientHandle * a_Client) = 0;
363 } ;
364 
365 
366 
367 
368 
369 struct sSetBlock
370 {
375 
376  sSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta):
377  m_RelX(a_BlockX),
378  m_RelY(a_BlockY),
379  m_RelZ(a_BlockZ),
380  m_BlockType(a_BlockType),
381  m_BlockMeta(a_BlockMeta)
382  {
384  }
385 
386  sSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
387  sSetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockType, a_BlockMeta)
388  {
389  }
390 
391  sSetBlock(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
392  m_RelX(a_RelX), m_RelY(a_RelY), m_RelZ(a_RelZ),
393  m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ),
394  m_BlockType(a_BlockType),
395  m_BlockMeta(a_BlockMeta)
396  {
397  ASSERT((a_RelX >= 0) && (a_RelX < cChunkDef::Width));
398  ASSERT((a_RelZ >= 0) && (a_RelZ < cChunkDef::Width));
399  }
400 
402  int GetX(void) const { return m_RelX + cChunkDef::Width * m_ChunkX; }
403 
406  int GetY(void) const { return m_RelY; }
407 
409  int GetZ(void) const { return m_RelZ + cChunkDef::Width * m_ChunkZ; }
410 
413  {
414  return Vector3i(GetX(), GetY(), GetZ());
415  }
416 
419  {
420  return Vector3i(m_RelX, m_RelY, m_RelZ);
421  }
422 };
423 
424 typedef std::vector<sSetBlock> sSetBlockVector;
425 
426 typedef std::list<cChunkCoords> cChunkCoordsList;
427 typedef std::vector<cChunkCoords> cChunkCoordsVector;
428 
429 
430 
431 
432 
436 {
437 public:
438  size_t operator () (const cChunkCoords & a_Coords) const
439  {
440  return (static_cast<size_t>(a_Coords.m_ChunkX) << 16) ^ static_cast<size_t>(a_Coords.m_ChunkZ);
441  }
442 };
443 
444 
445 
446 
447 
450 {
451 public:
452 
453  virtual ~cChunkCoordCallback() {}
454 
456  virtual void Call(cChunkCoords a_Coords, bool a_IsSuccess) = 0;
457 } ;
458 
459 
460 
461 
462 
464 template <typename X> class cCoordWithData
465 {
466 public:
467  int x;
468  int y;
469  int z;
470  X Data;
471 
472  cCoordWithData(int a_X, int a_Y, int a_Z) :
473  x(a_X), y(a_Y), z(a_Z), Data()
474  {
475  }
476 
477  cCoordWithData(int a_X, int a_Y, int a_Z, const X & a_Data) :
478  x(a_X), y(a_Y), z(a_Z), Data(a_Data)
479  {
480  }
481 } ;
482 
484 
485 typedef std::list<cCoordWithInt> cCoordWithIntList;
486 typedef std::vector<cCoordWithInt> cCoordWithIntVector;
cClientHandle
Definition: ClientHandle.h:49
BiomeDef.h
cChunkDef::Width
static const int Width
Definition: ChunkDef.h:107
cChunkDef::NumSections
static const size_t NumSections
Definition: ChunkDef.h:112
Vector3::x
T x
Definition: Vector3.h:17
sSetBlockVector
std::vector< sSetBlock > sSetBlockVector
Definition: ChunkDef.h:424
sSetBlock::sSetBlock
sSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Definition: ChunkDef.h:386
Vector3i
Vector3< int > Vector3i
Definition: Vector3.h:487
cChunkDef
Constants used throughout the code, useful typedefs and utility functions.
Definition: ChunkDef.h:102
cChunkDef::NumBlocks
static const int NumBlocks
Definition: ChunkDef.h:109
cChunkDef::SetBiome
static void SetBiome(BiomeMap &a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
Definition: ChunkDef.h:310
cChunkDef::BlockToChunk
static cChunkCoords BlockToChunk(const Vector3i a_Position)
The Y coordinate of a_Pos is ignored.
Definition: ChunkDef.h:204
cChunkCoords::cChunkCoords
cChunkCoords(int a_ChunkX, int a_ChunkZ)
Definition: ChunkDef.h:61
cChunkDef::SetHeight
static void SetHeight(HeightMap &a_HeightMap, int a_X, int a_Z, HEIGHTTYPE a_Height)
Definition: ChunkDef.h:294
cChunkDef::BiomeMap
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
Definition: ChunkDef.h:120
OwnedEntity
std::unique_ptr< cEntity > OwnedEntity
Definition: ChunkDef.h:32
cClientDiffCallback::Removed
virtual void Removed(cClientHandle *a_Client)=0
Called for clients that are in Chunk1 and not in Chunk2,.
cChunkDef::SetBlock
static void SetBlock(BLOCKTYPE *a_BlockTypes, int a_Index, BLOCKTYPE a_Type)
Definition: ChunkDef.h:256
cChunkCoordsList
std::list< cChunkCoords > cChunkCoordsList
Definition: ChunkDef.h:426
cChunkCoordsVector
std::vector< cChunkCoords > cChunkCoordsVector
Definition: ChunkDef.h:427
cChunkDef::GetBlock
static BLOCKTYPE GetBlock(const BLOCKTYPE *a_BlockTypes, int a_Idx)
Definition: ChunkDef.h:279
cChunkDef::Height
static const int Height
Definition: ChunkDef.h:108
cChunkDef::PackNibble
static void PackNibble(NIBBLETYPE *const a_Buffer, const size_t a_Index, const NIBBLETYPE a_Nibble)
Definition: ChunkDef.h:329
cChunkDef::GetBlock
static BLOCKTYPE GetBlock(const BLOCKTYPE *a_BlockTypes, int a_X, int a_Y, int a_Z)
Definition: ChunkDef.h:270
cChunkCoords::m_ChunkX
int m_ChunkX
Definition: ChunkDef.h:58
cChunkCoordCallback::Call
virtual void Call(cChunkCoords a_Coords, bool a_IsSuccess)=0
Called with the chunk's coords, and an optional operation status flag for operations that support it.
cChunkDef::BlockToChunk
static void BlockToChunk(int a_X, int a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords to chunk coords:
Definition: ChunkDef.h:193
cChunkCoords::operator==
bool operator==(const cChunkCoords &a_Other) const
Definition: ChunkDef.h:64
cChunkDef::IsValidRelPos
static bool IsValidRelPos(Vector3i a_RelPos)
Validates a chunk relative coordinate.
Definition: ChunkDef.h:182
cChunkDef::GetNibble
static NIBBLETYPE GetNibble(const NIBBLETYPE *a_Buffer, int x, int y, int z)
Definition: ChunkDef.h:318
cChunkDef::AbsoluteToRelative
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:
Definition: ChunkDef.h:130
cChunkDef::GetBlock
static BLOCKTYPE GetBlock(const BLOCKTYPE *a_BlockTypes, Vector3i a_RelPos)
Definition: ChunkDef.h:263
ASSERT
#define ASSERT(x)
Definition: Globals.h:273
NIBBLETYPE
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
sSetBlock
Definition: ChunkDef.h:369
Vector3::z
T z
Definition: Vector3.h:17
sSetBlock::m_RelX
int m_RelX
Definition: ChunkDef.h:371
cCoordWithData::cCoordWithData
cCoordWithData(int a_X, int a_Y, int a_Z, const X &a_Data)
Definition: ChunkDef.h:477
cChunkDef::SetBlock
static void SetBlock(BLOCKTYPE *a_BlockTypes, int a_X, int a_Y, int a_Z, BLOCKTYPE a_Type)
Definition: ChunkDef.h:247
sSetBlock::GetX
int GetX(void) const
Returns the absolute X coord of the stored block.
Definition: ChunkDef.h:402
cChunkCoords::operator!=
bool operator!=(const cChunkCoords &a_Other) const
Definition: ChunkDef.h:70
cChunkCoordCallback
Interface class used as a callback for operations that involve chunk coords.
Definition: ChunkDef.h:449
cCoordWithData::z
int z
Definition: ChunkDef.h:469
cChunkDef::GetHeight
static HEIGHTTYPE GetHeight(const HeightMap &a_HeightMap, int a_X, int a_Z)
Definition: ChunkDef.h:286
cClientDiffCallback
Interface class used for comparing clients of two chunks.
Definition: ChunkDef.h:352
sSetBlock::m_RelZ
int m_RelZ
Definition: ChunkDef.h:371
sSetBlock::m_ChunkZ
int m_ChunkZ
Definition: ChunkDef.h:372
HEIGHTTYPE
unsigned char HEIGHTTYPE
The type used by the heightmap.
Definition: ChunkDef.h:47
cChunkDef::IsValidHeight
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
Definition: ChunkDef.h:168
cChunkCoordsHash::operator()
size_t operator()(const cChunkCoords &a_Coords) const
Definition: ChunkDef.h:438
cCoordWithIntList
std::list< cCoordWithInt > cCoordWithIntList
Definition: ChunkDef.h:485
cChunkDef::SectionHeight
static const int SectionHeight
Definition: ChunkDef.h:111
EMCSBiome
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
Definition: BiomeDef.h:17
sSetBlock::sSetBlock
sSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Definition: ChunkDef.h:376
cCoordWithData::y
int y
Definition: ChunkDef.h:468
cChunkCoords::ToString
AString ToString() const
Returns a string that describes the chunk coords, suitable for logging.
Definition: ChunkDef.h:91
cCoordWithData::Data
X Data
Definition: ChunkDef.h:470
cChunkDef::HeightMap
HEIGHTTYPE HeightMap[Width *Width]
The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the hig...
Definition: ChunkDef.h:115
sSetBlock::m_BlockType
BLOCKTYPE m_BlockType
Definition: ChunkDef.h:373
cClientDiffCallback::~cClientDiffCallback
virtual ~cClientDiffCallback()
Definition: ChunkDef.h:356
sSetBlock::m_ChunkX
int m_ChunkX
Definition: ChunkDef.h:372
cChunkDef::BlockTypes
BLOCKTYPE BlockTypes[NumBlocks]
The type used for block type operations and storage, AXIS_ORDER ordering.
Definition: ChunkDef.h:123
BLOCKTYPE
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
cChunkDef::ExpandNibble
static NIBBLETYPE ExpandNibble(const NIBBLETYPE *const a_Buffer, const size_t a_Index)
Definition: ChunkDef.h:340
Printf
AString & Printf(AString &a_Dst, const char *a_Format, const Args &... a_Args)
Definition: StringUtils.h:26
cChunkCoordCallback::~cChunkCoordCallback
virtual ~cChunkCoordCallback()
Definition: ChunkDef.h:453
sSetBlock::GetY
int GetY(void) const
Returns the absolute Y coord of the stored block.
Definition: ChunkDef.h:406
cCoordWithInt
cCoordWithData< int > cCoordWithInt
Definition: ChunkDef.h:483
sSetBlock::GetRelativePos
Vector3i GetRelativePos() const
Returns the relative position of the stored block within its chunk.
Definition: ChunkDef.h:418
sSetBlock::m_BlockMeta
NIBBLETYPE m_BlockMeta
Definition: ChunkDef.h:374
cEntity
Definition: Entity.h:75
cChunkCoords
Definition: ChunkDef.h:55
cChunkDef::MakeIndex
static size_t MakeIndex(int x, int y, int z)
Definition: ChunkDef.h:210
cChunkDef::AbsoluteToRelative
static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition, cChunkCoords a_ChunkPos)
Converts the absolute coords into coords relative to the specified chunk.
Definition: ChunkDef.h:150
FAST_FLOOR_DIV
#define FAST_FLOOR_DIV(x, div)
Faster than (int)floorf((float)x / (float)div)
Definition: Globals.h:235
cChunkCoordsHash
A simple hash function for chunk coords, we assume that chunk coords won't use more than 16 bits,...
Definition: ChunkDef.h:435
UNUSED
#define UNUSED
Definition: Globals.h:72
Vector3::y
T y
Definition: Vector3.h:17
cCoordWithData::x
int x
Definition: ChunkDef.h:467
cChunkCoords::operator<
bool operator<(const cChunkCoords &a_Other) const
Simple comparison, to support ordering.
Definition: ChunkDef.h:77
cChunkDef::BlockNibbles
NIBBLETYPE BlockNibbles[NumBlocks/2]
The type used for block data in nibble format, AXIS_ORDER ordering.
Definition: ChunkDef.h:126
cChunkDef::IsValidWidth
static bool IsValidWidth(int a_Width)
Validates a width-coordinate.
Definition: ChunkDef.h:175
sSetBlock::sSetBlock
sSetBlock(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Definition: ChunkDef.h:391
cChunkDef::RelativeToAbsolute
static Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition, cChunkCoords a_ChunkCoords)
Converts relative block coordinates into absolute coordinates with a known chunk location.
Definition: ChunkDef.h:157
cCoordWithData::cCoordWithData
cCoordWithData(int a_X, int a_Y, int a_Z)
Definition: ChunkDef.h:472
AString
std::string AString
Definition: StringUtils.h:11
Vector3< int >
sSetBlock::GetZ
int GetZ(void) const
Returns the absolute Z coord of the stored block.
Definition: ChunkDef.h:409
sSetBlock::GetAbsolutePos
Vector3i GetAbsolutePos() const
Returns the absolute coords of the stored block.
Definition: ChunkDef.h:412
cChunkDef::MakeIndex
static size_t MakeIndex(Vector3i a_RelPos)
Definition: ChunkDef.h:223
cChunkCoords::m_ChunkZ
int m_ChunkZ
Definition: ChunkDef.h:59
cChunkDef::AbsoluteToRelative
static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition)
Converts the specified absolute position into a relative position within its chunk.
Definition: ChunkDef.h:142
sSetBlock::m_RelY
int m_RelY
Definition: ChunkDef.h:371
cChunkDef::GetBiome
static EMCSBiome GetBiome(const BiomeMap &a_BiomeMap, int a_X, int a_Z)
Definition: ChunkDef.h:302
cClientDiffCallback::Added
virtual void Added(cClientHandle *a_Client)=0
Called for clients that are in Chunk2 and not in Chunk1.
cEntityList
std::vector< OwnedEntity > cEntityList
Definition: ChunkDef.h:33
cBlockEntity
Definition: BlockEntity.h:24
cCoordWithData
Generic template that can store any kind of data together with a triplet of 3 coords.
Definition: ChunkDef.h:464
cCoordWithIntVector
std::vector< cCoordWithInt > cCoordWithIntVector
Definition: ChunkDef.h:486
cChunkDef::IndexToCoordinate
static Vector3i IndexToCoordinate(size_t index)
Definition: ChunkDef.h:229