Cuberite
A lightweight, fast and extensible game server for Minecraft
src
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
10
void
SetChunkData::UpdateHeightMap
()
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
{
19
BLOCKTYPE
BlockType
=
BlockData
.
GetBlock
({x, y, z});
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
}
BlockType.h
E_BLOCK_AIR
@ E_BLOCK_AIR
Definition:
BlockType.h:10
HEIGHTTYPE
unsigned char HEIGHTTYPE
The type used by the heightmap.
Definition:
ChunkDef.h:47
BLOCKTYPE
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition:
ChunkDef.h:41
Entity.h
Globals.h
BlockType
BlockType
Definition:
BlockTypes.h:4
SetChunkData.h
ChunkBlockData::GetBlock
BLOCKTYPE GetBlock(Vector3i a_Position) const
Definition:
ChunkData.h:80
cChunkDef::Width
static const int Width
Definition:
ChunkDef.h:124
cChunkDef::Height
static const int Height
Definition:
ChunkDef.h:125
SetChunkData::BlockData
ChunkBlockData BlockData
Definition:
SetChunkData.h:22
SetChunkData::UpdateHeightMap
void UpdateHeightMap()
Recalculates the HeightMap based on BlockData contents.
Definition:
SetChunkData.cpp:10
SetChunkData::HeightMap
cChunkDef::HeightMap HeightMap
Definition:
SetChunkData.h:26
Generated on Fri Oct 25 2024 05:01:18 for Cuberite by
1.9.1