Skip to content

Instantly share code, notes, and snippets.

@25A0
Created March 28, 2019 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 25A0/0363e8b7128b365cde65cec609ac6e55 to your computer and use it in GitHub Desktop.
Save 25A0/0363e8b7128b365cde65cec609ac6e55 to your computer and use it in GitHub Desktop.
mapcrafter naïve patch for new 1.14 chunk format
diff --git a/src/mapcraftercore/mc/chunk.cpp b/src/mapcraftercore/mc/chunk.cpp
index 12f318b..6c78f41 100644
--- a/src/mapcraftercore/mc/chunk.cpp
+++ b/src/mapcraftercore/mc/chunk.cpp
@@ -173,7 +173,7 @@ bool Chunk::readNBT(mc::BlockStateRegistry& block_registry, const char* data, si
const nbt::TagString& tag = level.findTag<nbt::TagString>("Status");
// completely generated chunks in fresh 1.13 worlds usually have status 'fullchunk' or 'postprocessed'
// however, chunks of converted <1.13 worlds don't use these, but the state 'mobs_spawned'
- if (!(tag.payload == "fullchunk" || tag.payload == "postprocessed" || tag.payload == "mobs_spawned")) {
+ if (!(tag.payload == "fullchunk" || tag.payload == "full" || tag.payload == "postprocessed" || tag.payload == "mobs_spawned")) {
return true;
}
}
@@ -210,8 +210,6 @@ bool Chunk::readNBT(mc::BlockStateRegistry& block_registry, const char* data, si
if (!section_tag.hasTag<nbt::TagByte>("Y")
// || !section_tag.hasArray<nbt::TagByteArray>("Blocks", 4096)
// || !section_tag.hasArray<nbt::TagByteArray>("Data", 2048)
- || !section_tag.hasArray<nbt::TagByteArray>("BlockLight", 2048)
- || !section_tag.hasArray<nbt::TagByteArray>("SkyLight", 2048)
|| !section_tag.hasArray<nbt::TagLongArray>("BlockStates")
|| !section_tag.hasTag<nbt::TagList>("Palette"))
continue;
@@ -248,9 +246,6 @@ bool Chunk::readNBT(mc::BlockStateRegistry& block_registry, const char* data, si
palette_lookup[i] = block_registry.getBlockID(block);
}
- const nbt::TagByteArray& block_light = section_tag.findTag<nbt::TagByteArray>("BlockLight");
- const nbt::TagByteArray& sky_light = section_tag.findTag<nbt::TagByteArray>("SkyLight");
-
// create a ChunkSection-object
ChunkSection section;
section.y = y.payload;
@@ -273,8 +268,16 @@ bool Chunk::readNBT(mc::BlockStateRegistry& block_registry, const char* data, si
continue;
}
- std::copy(block_light.payload.begin(), block_light.payload.end(), section.block_light);
- std::copy(sky_light.payload.begin(), sky_light.payload.end(), section.sky_light);
+ if(section_tag.hasArray<nbt::TagByteArray>("BlockLight", 2048))
+ {
+ const nbt::TagByteArray& block_light = section_tag.findTag<nbt::TagByteArray>("BlockLight");
+ std::copy(block_light.payload.begin(), block_light.payload.end(), section.block_light);
+ }
+ if(section_tag.hasArray<nbt::TagByteArray>("SkyLight", 2048))
+ {
+ const nbt::TagByteArray& sky_light = section_tag.findTag<nbt::TagByteArray>("SkyLight");
+ std::copy(sky_light.payload.begin(), sky_light.payload.end(), section.sky_light);
+ }
// add this section to the section list
section_offsets[section.y] = sections.size();
@neonfishingrod
Copy link

how do i use this lol

@ni5am
Copy link

ni5am commented Jun 19, 2019

It works well. Thank you :)

@25A0
Copy link
Author

25A0 commented Jun 19, 2019

@ni5am You're welcome!
Note that this patch is now integrated into the 1.13 branch of Mapcrafter (thanks to @miclav). You should simply switch to that branch instead of applying this patch manually :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment