13
0
geforkt von Mirrors/Paper

Make starlight light read non-fatal if it throws

Brings behavior in line with the mod, we shouldn't kill the chunk
if the light data is corrupt, we can regenerate the light data
Dieser Commit ist enthalten in:
Spottedleaf 2022-06-10 21:08:37 -07:00
Ursprung 91cf4f0392
Commit 1c4ca26d6e

Datei anzeigen

@ -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
}
}