summaryrefslogtreecommitdiffstats
path: root/src/World/Chunk.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-07-21 18:07:45 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-07-21 18:11:59 +0200
commitf1f783877f0f8338a225244faff4e40efe10a4ce (patch)
treee071d5df7024fbc3c72713517672f217096ea47f /src/World/Chunk.cpp
parent315bb38444b8e363b4d8f2702d45d42fa585f619 (diff)
downloadMinedMap-f1f783877f0f8338a225244faff4e40efe10a4ce.tar
MinedMap-f1f783877f0f8338a225244faff4e40efe10a4ce.zip
NBT: rework type system
Diffstat (limited to 'src/World/Chunk.cpp')
-rw-r--r--src/World/Chunk.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp
index 07e38a4..38ca496 100644
--- a/src/World/Chunk.cpp
+++ b/src/World/Chunk.cpp
@@ -44,8 +44,9 @@ Chunk::Chunk(const ChunkData *data) {
std::shared_ptr<const NBT::ByteTag> lightPopulatedTag = level->get<NBT::ByteTag>("LightPopulated");
bool lightPopulated = lightPopulatedTag && lightPopulatedTag->getValue();
- sections = assertValue(level->get<NBT::ListTag<NBT::CompoundTag>>("Sections"));
- maxY = (assertValue(sections->back()->get<NBT::ByteTag>("Y"))->getValue() + 1) * SIZE;
+ sections = assertValue(level->get<NBT::ListTag>("Sections"));
+ const NBT::CompoundTag *lastSection = assertValue(dynamic_cast<const NBT::CompoundTag *>(sections->back().get()));
+ maxY = (assertValue(lastSection->get<NBT::ByteTag>("Y"))->getValue() + 1) * SIZE;
std::shared_ptr<const NBT::ByteArrayTag> biomeTag = assertValue(level->get<NBT::ByteArrayTag>("Biomes"));
@@ -65,7 +66,8 @@ Chunk::Chunk(const ChunkData *data) {
std::memset(blockBlockLight.get(), 0, maxY * SIZE * SIZE / 2);
- for (auto &section : *sections) {
+ for (auto &sectionTag : *sections) {
+ const NBT::CompoundTag *section = assertValue(dynamic_cast<const NBT::CompoundTag *>(sectionTag.get()));
std::shared_ptr<const NBT::ByteArrayTag> blocks = assertValue(section->get<NBT::ByteArrayTag>("Blocks"));
std::shared_ptr<const NBT::ByteArrayTag> data = assertValue(section->get<NBT::ByteArrayTag>("Data"));
size_t Y = assertValue(section->get<NBT::ByteTag>("Y"))->getValue();