mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-02 05:49:06 +02:00
Add quirk for stone_slab rename
The old stone_slab block from pre-1.14 has been renamed to smooth_stone_slab, and the name stone_slab was reused for a new block. Resolve the palette entry depending on the chunk's dataVersion.
This commit is contained in:
parent
359ace4932
commit
ae68c3bab4
4 changed files with 24 additions and 9 deletions
|
@ -44,12 +44,12 @@ const Resource::BlockType * Section::getBlockStateAt(size_t, size_t, size_t) con
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<Section> Section::makeSection(const std::shared_ptr<const NBT::CompoundTag> §ion) {
|
||||
std::unique_ptr<Section> Section::makeSection(const std::shared_ptr<const NBT::CompoundTag> §ion, uint32_t dataVersion) {
|
||||
std::shared_ptr<const NBT::LongArrayTag> blockStates = section->get<NBT::LongArrayTag>("BlockStates");
|
||||
if (blockStates) {
|
||||
const std::shared_ptr<const NBT::ListTag> palette = assertValue(section->get<NBT::ListTag>("Palette"));
|
||||
|
||||
return std::unique_ptr<Section>(new PaletteSection(section, std::move(blockStates), palette));
|
||||
return std::unique_ptr<Section>(new PaletteSection(section, std::move(blockStates), palette, dataVersion));
|
||||
}
|
||||
|
||||
std::shared_ptr<const NBT::ByteArrayTag> blocks = section->get<NBT::ByteArrayTag>("Blocks");
|
||||
|
@ -71,10 +71,18 @@ const Resource::BlockType * LegacySection::getBlockStateAt(size_t x, size_t y, s
|
|||
}
|
||||
|
||||
|
||||
const Resource::BlockType * PaletteSection::lookup(const std::string &name, uint32_t dataVersion) {
|
||||
if (dataVersion < 1900 && name == "minecraft:stone_slab")
|
||||
return Resource::BlockType::lookup("minecraft:smooth_stone_slab");
|
||||
|
||||
return Resource::BlockType::lookup(name);
|
||||
}
|
||||
|
||||
PaletteSection::PaletteSection(
|
||||
const std::shared_ptr<const NBT::CompoundTag> §ion,
|
||||
std::shared_ptr<const NBT::LongArrayTag> &&blockStates0,
|
||||
const std::shared_ptr<const NBT::ListTag> &paletteData
|
||||
const std::shared_ptr<const NBT::ListTag> &paletteData,
|
||||
uint32_t dataVersion
|
||||
) : Section(section), blockStates(blockStates0) {
|
||||
if (blockStates->getLength() % 64)
|
||||
throw std::invalid_argument("corrupt section data");
|
||||
|
@ -90,7 +98,7 @@ PaletteSection::PaletteSection(
|
|||
const NBT::CompoundTag &paletteEntry = *assertValue(dynamic_cast<const NBT::CompoundTag *>(entry.get()));
|
||||
std::string name = assertValue(paletteEntry.get<NBT::StringTag>("Name"))->getValue();
|
||||
|
||||
const Resource::BlockType *type = Resource::BlockType::lookup(name);
|
||||
const Resource::BlockType *type = lookup(name, dataVersion);
|
||||
if (!type)
|
||||
std::fprintf(stderr, "Warning: unknown block type: %s\n", name.c_str());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue