diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp index 7af7923..f94c763 100644 --- a/src/World/Chunk.cpp +++ b/src/World/Chunk.cpp @@ -43,15 +43,6 @@ Chunk::Chunk(const ChunkData *data) { if (!sectionsTag) return; - biomeBytes = level->get("Biomes"); - biomeInts = level->get("Biomes"); - assertValue(biomeBytes || biomeInts); - - if (biomeBytes && biomeBytes->getLength() != SIZE*SIZE) - throw std::invalid_argument("corrupt biome data"); - else if (biomeInts && biomeInts->getLength() != SIZE*SIZE) - throw std::invalid_argument("corrupt biome data"); - for (auto &sTag : *sectionsTag) { auto s = std::dynamic_pointer_cast(sTag); std::unique_ptr
section = Section::makeSection(s); @@ -61,6 +52,17 @@ Chunk::Chunk(const ChunkData *data) { sections.push_back(std::move(section)); } } + + if (!sections.empty()) { + biomeBytes = level->get("Biomes"); + biomeInts = level->get("Biomes"); + assertValue(biomeBytes || biomeInts); + + if (biomeBytes && biomeBytes->getLength() != SIZE*SIZE) + throw std::invalid_argument("corrupt biome data"); + else if (biomeInts && biomeInts->getLength() != SIZE*SIZE) + throw std::invalid_argument("corrupt biome data"); + } } bool Chunk::getBlock(Block *block, const Section *section, size_t x, size_t y, size_t z, uint8_t prev_light) const {