summaryrefslogtreecommitdiffstats
path: root/src/World/Chunk.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World/Chunk.hpp')
-rw-r--r--src/World/Chunk.hpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/World/Chunk.hpp b/src/World/Chunk.hpp
index d063d48..22054db 100644
--- a/src/World/Chunk.hpp
+++ b/src/World/Chunk.hpp
@@ -27,6 +27,7 @@
#pragma once
+#include "Block.hpp"
#include "../Buffer.hpp"
#include "../UniqueCPtr.hpp"
#include "../NBT/CompoundTag.hpp"
@@ -43,7 +44,18 @@ class Chunk : public std::shared_ptr<const NBT::CompoundTag> {
public:
static const size_t SIZE = 16;
+ struct Blocks {
+ Block blocks[SIZE][SIZE];
+ };
+
private:
+ static size_t getIndex(size_t x, size_t y, size_t z) {
+ if (x >= SIZE || y >= SIZE || z >= SIZE)
+ throw std::range_error("Chunk::getIndex(): bad coordinates");
+
+ return 256*y + 16*z + x;
+ }
+
size_t len;
UniqueCPtr<uint8_t[]> data;
@@ -56,15 +68,8 @@ private:
void parseChunk();
void analyzeChunk();
- size_t getIndex(size_t x, size_t y, size_t z) {
- if (x >= SIZE || y >= SIZE || z >= SIZE)
- throw std::range_error("Chunk::getIndex(): bad coordinates");
-
- return 256*y + 16*z + x;
- }
-
- uint8_t getBlockAt(const std::shared_ptr<const NBT::CompoundTag> &section, size_t x, size_t y, size_t z);
- uint8_t getDataAt(const std::shared_ptr<const NBT::CompoundTag> &section, size_t x, size_t y, size_t z);
+ uint8_t getBlockAt(const std::shared_ptr<const NBT::CompoundTag> &section, size_t x, size_t y, size_t z) const;
+ uint8_t getDataAt(const std::shared_ptr<const NBT::CompoundTag> &section, size_t x, size_t y, size_t z) const;
public:
Chunk(Buffer buffer);
@@ -72,6 +77,8 @@ public:
const NBT::ListTag<NBT::CompoundTag> & getSections() const {
return *sections;
}
+
+ Blocks getTopLayer() const;
};
}