mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
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
This commit is contained in:
parent
91cf4f0392
commit
1c4ca26d6e
1 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue