mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-04-20 03:25:09 +02:00
Don't fall on empty Sections
This commit is contained in:
parent
6719ccdbe1
commit
281603dc5a
3 changed files with 15 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2015, 2018, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||
Copyright (c) 2019, Roman Shishkin <spark@uwtech.org>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2015-2018, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||
Copyright (c) 2019, Roman Shishkin <spark@uwtech.org>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -54,10 +55,12 @@ Chunk::Chunk(const ChunkData *data) {
|
|||
for (auto &sTag : *sectionsTag) {
|
||||
auto s = std::dynamic_pointer_cast<const NBT::CompoundTag>(sTag);
|
||||
std::unique_ptr<Section> section = Section::makeSection(s);
|
||||
if (section != nullptr) {
|
||||
size_t Y = section->getY();
|
||||
sections.resize(Y);
|
||||
sections.push_back(std::move(section));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Chunk::getBlock(Block *block, const Section *section, size_t x, size_t y, size_t z, uint8_t prev_light) const {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2015-2018, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||
Copyright (c) 2019, Roman Shishkin <spark@uwtech.org>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -49,10 +50,14 @@ std::unique_ptr<Section> Section::makeSection(const std::shared_ptr<const NBT::C
|
|||
return std::unique_ptr<Section>(new PaletteSection(section, std::move(blockStates), palette));
|
||||
}
|
||||
|
||||
std::shared_ptr<const NBT::ByteArrayTag> blocks = assertValue(section->get<NBT::ByteArrayTag>("Blocks"));
|
||||
std::shared_ptr<const NBT::ByteArrayTag> blocks = section->get<NBT::ByteArrayTag>("BlockStates");
|
||||
if (blocks) {
|
||||
std::shared_ptr<const NBT::ByteArrayTag> data = assertValue(section->get<NBT::ByteArrayTag>("Data"));
|
||||
|
||||
return std::unique_ptr<Section>(new LegacySection(section, std::move(blocks), std::move(data)));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue