1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "Chunk.hpp"
#include "BlockSide.hpp"
namespace MC::World {
void Chunk::set(uint32_t x, uint32_t y, uint32_t z, BlockData data) {
m_blocks.at(pos(x, y, z)) = data;
}
Chunk::BlockData Chunk::get(uint32_t x, uint32_t y, uint32_t z) const {
return m_blocks.at(pos(x, y, z));
}
bool Chunk::is_empty(uint32_t x, uint32_t y, uint32_t z) const {
return get(x, y, z).empty();
}
Vector<3> Chunk::position() const {
return m_position;
}
bool Chunk::is_valid_position(uint32_t x, uint32_t y, uint32_t z) {
return x < Width && y < Height && z < Width;
}
uint64_t Chunk::pos(uint32_t x, uint32_t y, uint32_t z) {
return x + Width * y + Width * Height * z;
}
}
|