Return 0 for light values if a dimenion does not have them

Fixes https://github.com/PaperMC/Starlight/issues/99
This commit is contained in:
Spottedleaf 2021-12-08 22:01:02 -08:00
parent 758e2a7ee2
commit 0e91b6ae9b
1 changed files with 13 additions and 2 deletions

View File

@ -3067,10 +3067,10 @@ index 0000000000000000000000000000000000000000..1b0d92c68407cdb09ed8aac271b625d9
+}
diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java
new file mode 100644
index 0000000000000000000000000000000000000000..7fe174f379ec8bb6a3e51251a5ed0e9ff64cf27b
index 0000000000000000000000000000000000000000..ef8dcbb6bbc0769e9ccfdadb05e6a46c070eda98
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java
@@ -0,0 +1,654 @@
@@ -0,0 +1,665 @@
+package ca.spottedleaf.starlight.common.light;
+
+import ca.spottedleaf.starlight.common.util.CoordinateUtils;
@ -3127,6 +3127,9 @@ index 0000000000000000000000000000000000000000..7fe174f379ec8bb6a3e51251a5ed0e9f
+
+ public final LevelLightEngine lightEngine;
+
+ private final boolean hasBlockLight;
+ private final boolean hasSkyLight;
+
+ public StarLightInterface(final LightChunkGetter lightAccess, final boolean hasSkyLight, final boolean hasBlockLight, final LevelLightEngine lightEngine) {
+ this.lightAccess = lightAccess;
+ this.world = lightAccess == null ? null : (Level)lightAccess.getLevel();
@ -3145,6 +3148,8 @@ index 0000000000000000000000000000000000000000..7fe174f379ec8bb6a3e51251a5ed0e9f
+ this.maxLightSection = WorldUtil.getMaxLightSection(this.world);
+ }
+ this.lightEngine = lightEngine;
+ this.hasBlockLight = hasBlockLight;
+ this.hasSkyLight = hasSkyLight;
+ this.skyReader = !hasSkyLight ? LayerLightEventListener.DummyLightLayerEventListener.INSTANCE : new LayerLightEventListener() {
+ @Override
+ public void checkBlock(final BlockPos blockPos) {
@ -3253,6 +3258,9 @@ index 0000000000000000000000000000000000000000..7fe174f379ec8bb6a3e51251a5ed0e9f
+ }
+
+ protected int getSkyLightValue(final BlockPos blockPos, final ChunkAccess chunk) {
+ if (!this.hasSkyLight) {
+ return 0;
+ }
+ final int x = blockPos.getX();
+ int y = blockPos.getY();
+ final int z = blockPos.getZ();
@ -3320,6 +3328,9 @@ index 0000000000000000000000000000000000000000..7fe174f379ec8bb6a3e51251a5ed0e9f
+ }
+
+ protected int getBlockLightValue(final BlockPos blockPos, final ChunkAccess chunk) {
+ if (!this.hasBlockLight) {
+ return 0;
+ }
+ final int y = blockPos.getY();
+ final int cy = y >> 4;
+