Cuberite
A lightweight, fast and extensible game server for Minecraft
SetChunkData.cpp
Go to the documentation of this file.
1 #include "Globals.h"
2 #include "SetChunkData.h"
3 #include "BlockType.h"
4 #include "Entities/Entity.h"
5 
6 
7 
8 
9 
11 {
12  for (int x = 0; x < cChunkDef::Width; x++)
13  {
14  for (int z = 0; z < cChunkDef::Width; z++)
15  {
16  HEIGHTTYPE Height = 0;
17  for (HEIGHTTYPE y = cChunkDef::Height - 1; y > 0; y--)
18  {
20  if (BlockType != E_BLOCK_AIR)
21  {
22  Height = y;
23  break;
24  }
25  } // for y
26  auto idx = x + cChunkDef::Width * z;
27  HeightMap[idx] = Height;
28  } // for z
29  } // for x
30 }
@ E_BLOCK_AIR
Definition: BlockType.h:10
unsigned char HEIGHTTYPE
The type used by the heightmap.
Definition: ChunkDef.h:47
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
BlockType
Definition: BlockTypes.h:4
BLOCKTYPE GetBlock(Vector3i a_Position) const
Definition: ChunkData.h:80
static const int Width
Definition: ChunkDef.h:124
static const int Height
Definition: ChunkDef.h:125
ChunkBlockData BlockData
Definition: SetChunkData.h:22
void UpdateHeightMap()
Recalculates the HeightMap based on BlockData contents.
cChunkDef::HeightMap HeightMap
Definition: SetChunkData.h:26