|
8 | 8 | import ca.spottedleaf.starlight.common.util.CoordinateUtils; |
9 | 9 | import ca.spottedleaf.starlight.common.util.WorldUtil; |
10 | 10 | import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; |
| 11 | +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; |
11 | 12 | import net.minecraft.core.BlockPos; |
12 | 13 | import net.minecraft.core.SectionPos; |
13 | 14 | import net.minecraft.world.level.ChunkPos; |
@@ -110,13 +111,26 @@ public void updateSectionStatus(final SectionPos pos, final boolean notReady) { |
110 | 111 | this.lightEngine.sectionChange(pos, notReady); |
111 | 112 | } |
112 | 113 |
|
| 114 | + @Unique |
| 115 | + protected final LongOpenHashSet scalablelux$lightingEnabledChunks = new LongOpenHashSet(); |
| 116 | + |
113 | 117 | /** |
114 | | - * @reason Avoid messing with the vanilla light engine state |
115 | | - * @author Spottedleaf |
| 118 | + * @reason Run compatibolity hook |
| 119 | + * @author ishland |
116 | 120 | */ |
117 | 121 | @Overwrite |
118 | 122 | 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 | + } |
120 | 134 | } |
121 | 135 |
|
122 | 136 | /** |
@@ -195,7 +209,7 @@ public int getRawBrightness(final BlockPos pos, final int ambientDarkness) { |
195 | 209 | @Overwrite |
196 | 210 | public boolean lightOnInColumn(final long pos) { |
197 | 211 | 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); |
199 | 213 | } |
200 | 214 |
|
201 | 215 | @Unique |
|
0 commit comments