diff --git a/patches/server/Rewrite-the-light-engine.patch b/patches/server/Rewrite-the-light-engine.patch index f088ec057c..47fe6666cf 100644 --- a/patches/server/Rewrite-the-light-engine.patch +++ b/patches/server/Rewrite-the-light-engine.patch @@ -5097,7 +5097,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (!flag2) { + // Paper start - rewrite the light engine + if (flag) { ++ try { + if ((flag3 || flag4) && !flag2) { ++ // Paper end - rewrite the light engine tasksToExecuteOnMain.add(() -> { // Paper - delay this task since we're executing off-main lightengine.retainData(chunkPos, true); }); // Paper - delay this task since we're executing off-main @@ -5112,11 +5114,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - lightengine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, b0), blockLight, true); - }); - // Paper end - delay this task since we're executing off-main ++ // Paper start - rewrite the light engine + // this is where our diff is + blockNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(sectionData.getByteArray("BlockLight").clone(), sectionData.getInt(BLOCKLIGHT_STATE_TAG)); // clone for data safety + } else { + blockNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(null, sectionData.getInt(BLOCKLIGHT_STATE_TAG)); } ++ // Paper end - rewrite the light engine if (flag4) { - // Paper start - delay this task since we're executing off-main @@ -5125,6 +5129,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - lightengine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, b0), skyLight, true); - }); - // Paper end - delay this task since we're executing off-mai ++ // Paper start - rewrite the light engine + // we store under the same key so mod programs editing nbt + // can still read the data, hopefully. + // however, for compatibility we store chunks as unlit so vanilla @@ -5134,6 +5139,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } else { + skyNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(null, sectionData.getInt(SKYLIGHT_STATE_TAG)); } ++ // Paper end - rewrite the light engine ++ // Paper start - rewrite the light engine ++ } catch (Exception ex) { ++ LOGGER.warn("Failed to load light data for chunk " + chunkPos + " in world '" + world.getWorld().getName() + "', light will be regenerated", ex); ++ flag = false; ++ } + // Paper end - rewrite light engine } }