summaryrefslogtreecommitdiffstats
path: root/src/World/Chunk.hpp
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-02-01 05:54:42 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-02-01 05:54:42 +0100
commit18ed3d4c5df83336229357cf8e468c8db7c4f7ca (patch)
treeee26235a63f72aff76349476cbc7a79a91c6d245 /src/World/Chunk.hpp
parentd9226363114d446f5af0f53345be8811a3ed8d42 (diff)
downloadMinedMap-18ed3d4c5df83336229357cf8e468c8db7c4f7ca.tar
MinedMap-18ed3d4c5df83336229357cf8e468c8db7c4f7ca.zip
Further chunk parsing
Diffstat (limited to 'src/World/Chunk.hpp')
-rw-r--r--src/World/Chunk.hpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/World/Chunk.hpp b/src/World/Chunk.hpp
index 639d1a7..36628b4 100644
--- a/src/World/Chunk.hpp
+++ b/src/World/Chunk.hpp
@@ -46,13 +46,24 @@ private:
size_t len;
UniqueCPtr<uint8_t[]> data;
+ std::shared_ptr<const NBT::CompoundTag> level;
+ std::shared_ptr<const NBT::ListTag<NBT::CompoundTag>> sections;
+
unsigned maxY;
void inflateChunk(uint8_t *data, size_t len);
void parseChunk();
void analyzeChunk();
- std::shared_ptr<const NBT::ListTag<NBT::CompoundTag>> sections;
+ 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);
public:
Chunk(uint8_t *buffer, size_t buflen);