mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
World: Section: add support for Int tag section Y values
For some reason, MC1.18 sometimes uses Int instead of Byte tags for section Y values after "optimize world". Add support for this (but still only accept values that fit in a int8_t).
This commit is contained in:
parent
d18e004743
commit
a2fe33ef1f
1 changed files with 11 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "Section.hpp"
|
||||
#include "../Resource/Biome.hpp"
|
||||
#include "../NBT/ByteTag.hpp"
|
||||
#include "../NBT/IntTag.hpp"
|
||||
#include "../NBT/StringTag.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
@ -17,7 +18,16 @@ namespace MinedMap {
|
|||
namespace World {
|
||||
|
||||
Section::Section(const std::shared_ptr<const NBT::CompoundTag> §ion) {
|
||||
Y = int8_t(assertValue(section->get<NBT::ByteTag>("Y"))->getValue());
|
||||
const std::shared_ptr<const NBT::ByteTag> YByteTag = section->get<NBT::ByteTag>("Y");
|
||||
if (YByteTag) {
|
||||
Y = int8_t(YByteTag->getValue());
|
||||
} else {
|
||||
const std::shared_ptr<const NBT::IntTag> YIntTag = assertValue(section->get<NBT::IntTag>("Y"));
|
||||
int32_t value = YIntTag->getValue();
|
||||
if (int8_t(value) != value)
|
||||
throw std::invalid_argument("unsupported section Y coordinate");
|
||||
Y = value;
|
||||
}
|
||||
blockLight = section->get<NBT::ByteArrayTag>("BlockLight");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue