Skip to content

Commit 3508687

Browse files
committed
fix: properly implement setLightEnabled and lightOnInColumn
1 parent f0a6b3f commit 3508687

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/main/java/ca/spottedleaf/starlight/mixin/common/lightengine/LevelLightEngineMixin.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import ca.spottedleaf.starlight.common.util.CoordinateUtils;
99
import ca.spottedleaf.starlight.common.util.WorldUtil;
1010
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
11+
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
1112
import net.minecraft.core.BlockPos;
1213
import net.minecraft.core.SectionPos;
1314
import net.minecraft.world.level.ChunkPos;
@@ -110,13 +111,26 @@ public void updateSectionStatus(final SectionPos pos, final boolean notReady) {
110111
this.lightEngine.sectionChange(pos, notReady);
111112
}
112113

114+
@Unique
115+
protected final LongOpenHashSet scalablelux$lightingEnabledChunks = new LongOpenHashSet();
116+
113117
/**
114-
* @reason Avoid messing with the vanilla light engine state
115-
* @author Spottedleaf
118+
* @reason Run compatibolity hook
119+
* @author ishland
116120
*/
117121
@Overwrite
118122
public void setLightEnabled(final ChunkPos pos, final boolean lightEnabled) {
119-
// not invoked by the client
123+
// not invoked by the client - Spottedleaf
124+
// surely not - ishland
125+
126+
// store state for implementation of lightOnInColumn()
127+
// needed for proper culling of chunks in the client
128+
final long key = pos.toLong();
129+
if (lightEnabled) {
130+
this.scalablelux$lightingEnabledChunks.add(key);
131+
} else {
132+
this.scalablelux$lightingEnabledChunks.remove(key);
133+
}
120134
}
121135

122136
/**
@@ -195,7 +209,7 @@ public int getRawBrightness(final BlockPos pos, final int ambientDarkness) {
195209
@Overwrite
196210
public boolean lightOnInColumn(final long pos) {
197211
final long key = CoordinateUtils.getChunkKey(SectionPos.x(pos), SectionPos.z(pos));
198-
return (!this.lightEngine.hasBlockLight() || this.blockLightMap.get(key) != null) && (!this.lightEngine.hasSkyLight() || this.skyLightMap.get(key) != null);
212+
return this.scalablelux$lightingEnabledChunks.contains(key) || (!this.lightEngine.hasBlockLight() || this.blockLightMap.get(key) != null) && (!this.lightEngine.hasSkyLight() || this.skyLightMap.get(key) != null);
199213
}
200214

201215
@Unique

0 commit comments

Comments
 (0)