mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Fix oversized chunk merging
This commit is contained in:
parent
1dc66f14fb
commit
4641f37f4d
2 changed files with 14 additions and 19 deletions
|
@ -190,12 +190,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return chunk;
|
||||
+ }
|
||||
+ CompoundTag oversizedLevel = oversizedData.getCompound("Level");
|
||||
+ CompoundTag level = chunk.getCompound("Level");
|
||||
+
|
||||
+ mergeChunkList(level, oversizedLevel, "Entities");
|
||||
+ mergeChunkList(level, oversizedLevel, "TileEntities");
|
||||
+
|
||||
+ chunk.put("Level", level);
|
||||
+ mergeChunkList(chunk, oversizedLevel, "entities", "Entities");
|
||||
+ mergeChunkList(chunk, oversizedLevel, "block_entities", "TileEntities");
|
||||
+
|
||||
+ return chunk;
|
||||
+ } catch (Throwable throwable) {
|
||||
|
@ -205,9 +202,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void mergeChunkList(CompoundTag level, CompoundTag oversizedLevel, String key) {
|
||||
+ private static void mergeChunkList(CompoundTag level, CompoundTag oversizedLevel, String key, String oversizedKey) {
|
||||
+ ListTag levelList = level.getList(key, 10);
|
||||
+ ListTag oversizedList = oversizedLevel.getList(key, 10);
|
||||
+ ListTag oversizedList = oversizedLevel.getList(oversizedKey, 10);
|
||||
+
|
||||
+ if (!oversizedList.isEmpty()) {
|
||||
+ levelList.addAll(oversizedList);
|
||||
|
|
|
@ -4128,8 +4128,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void saveLightHookReal(final Level world, final ChunkAccess chunk, final CompoundTag nbt) {
|
||||
+ if (nbt == null) {
|
||||
+ private static void saveLightHookReal(final Level world, final ChunkAccess chunk, final CompoundTag tag) {
|
||||
+ if (tag == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
|
@ -4139,18 +4139,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ SWMRNibbleArray[] blockNibbles = chunk.getBlockNibbles();
|
||||
+ SWMRNibbleArray[] skyNibbles = chunk.getSkyNibbles();
|
||||
+
|
||||
+ CompoundTag level = nbt.getCompound("Level");
|
||||
+ boolean lit = chunk.isLightCorrect() || !(world instanceof ServerLevel);
|
||||
+ // diff start - store our tag for whether light data is init'd
|
||||
+ if (lit) {
|
||||
+ level.putBoolean("isLightOn", false);
|
||||
+ tag.putBoolean("isLightOn", false);
|
||||
+ }
|
||||
+ // diff end - store our tag for whether light data is init'd
|
||||
+ ChunkStatus status = ChunkStatus.byName(level.getString("Status"));
|
||||
+ ChunkStatus status = ChunkStatus.byName(tag.getString("Status"));
|
||||
+
|
||||
+ CompoundTag[] sections = new CompoundTag[maxSection - minSection + 1];
|
||||
+
|
||||
+ ListTag sectionsStored = level.getList("Sections", 10);
|
||||
+ ListTag sectionsStored = tag.getList("sections", 10);
|
||||
+
|
||||
+ for (int i = 0; i < sectionsStored.size(); ++i) {
|
||||
+ CompoundTag sectionStored = sectionsStored.getCompound(i);
|
||||
|
@ -4207,9 +4206,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ sectionsStored.add(section);
|
||||
+ }
|
||||
+ }
|
||||
+ level.put("Sections", sectionsStored);
|
||||
+ tag.put("sections", sectionsStored);
|
||||
+ if (lit) {
|
||||
+ level.putInt(STARLIGHT_VERSION_TAG, STARLIGHT_LIGHT_VERSION); // only mark as fully lit after we have successfully injected our data
|
||||
+ tag.putInt(STARLIGHT_VERSION_TAG, STARLIGHT_LIGHT_VERSION); // only mark as fully lit after we have successfully injected our data
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
@ -4237,12 +4236,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+
|
||||
+ // start copy from from the original method
|
||||
+ CompoundTag levelTag = tag.getCompound("Level");
|
||||
+ boolean lit = levelTag.get("isLightOn") != null && levelTag.getInt(STARLIGHT_VERSION_TAG) == STARLIGHT_LIGHT_VERSION;
|
||||
+ boolean lit = tag.get("isLightOn") != null && tag.getInt(STARLIGHT_VERSION_TAG) == STARLIGHT_LIGHT_VERSION;
|
||||
+ boolean canReadSky = world.dimensionType().hasSkyLight();
|
||||
+ ChunkStatus status = ChunkStatus.byName(tag.getCompound("Level").getString("Status"));
|
||||
+ ChunkStatus status = ChunkStatus.byName(tag.getString("Status"));
|
||||
+ if (lit && status.isOrAfter(ChunkStatus.LIGHT)) { // diff - we add the status check here
|
||||
+ ListTag sections = levelTag.getList("Sections", 10);
|
||||
+ ListTag sections = tag.getList("sections", 10);
|
||||
+
|
||||
+ for (int i = 0; i < sections.size(); ++i) {
|
||||
+ CompoundTag sectionData = sections.getCompound(i);
|
||||
|
|
Loading…
Reference in a new issue