From fc1fc8fbbc9dd9534f40de348210ea66b6defe42 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 1 Feb 2015 03:21:57 +0100 Subject: Use template argument for list subtype, extract further information from chunks --- src/World/Chunk.cpp | 4 ++++ src/World/Chunk.hpp | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'src/World') diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp index f3a140d..fb46466 100644 --- a/src/World/Chunk.cpp +++ b/src/World/Chunk.cpp @@ -95,6 +95,10 @@ Chunk::Chunk(uint8_t *buffer, size_t buflen) { if (!(*this) || tag.first != "") throw std::invalid_argument("invalid root tag"); + + sections = (*this)->get>("Level", "Sections"); + if (!sections) + throw std::invalid_argument("no sections found"); } } diff --git a/src/World/Chunk.hpp b/src/World/Chunk.hpp index 7c485eb..3ed6cf4 100644 --- a/src/World/Chunk.hpp +++ b/src/World/Chunk.hpp @@ -29,6 +29,7 @@ #include "../UniqueCPtr.hpp" #include "../NBT/CompoundTag.hpp" +#include "../NBT/ListTag.hpp" #include #include @@ -44,8 +45,14 @@ public: private: static std::pair, size_t> inflateChunk(uint8_t *data, size_t len); + std::shared_ptr> sections; + public: Chunk(uint8_t *buffer, size_t buflen); + + const NBT::ListTag & getSections() const { + return *sections; + } }; } -- cgit v1.2.3