From 7b0a56c3e8a26439a4c9cebe9e48fb06cab803e1 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 25 Dec 2020 13:27:51 -0800 Subject: [PATCH] Starlight 0.0.2-RC3 1. Fix chunk relighting In order to make relighting more reliable, move the emptiness map lookups to their own cache. This allows us to not clobber/use emptiness map values for chunks that were not relight during the call. More importantly, fix a typo where we supplied the wrong chunk argument to the emptiness change function for chunk neighbours - this caused the nibbles for the target chunk to be clobbered. 2. Fix broken edge checks While edge checks are not currently used, it doesn't mean they should be broken. Edge checks should be able to happen on null nibbles for block lighting (sky lighting will not have nibbles marked null during edge checks). 3. Make handleEmptySectionChanges non-relaxed serverside For the server, it should be that the chunks in 1 radius are loaded during this call. 4. Fix incorrect neighbour nibble init logic We need to be copying the whole array, not just the first 9 values. 5. Fix potential missed updateVisible calls rewriteNibbleCacheForSkylight could set a value in the cache to null and not update the nibble. Now the call will call updateVisible when removing nibbles from the cache. 6. Fix skylight propagation on the -1 chunk section Allow sources to be set up on y=-16, and fix light retrieval for y < -16 --- README.md | 2 +- gradle.properties | 2 +- .../common/light/BlockStarLightEngine.java | 5 ++ .../common/light/SkyStarLightEngine.java | 45 +++++++++-------- .../common/light/StarLightEngine.java | 50 ++++++++++++------- .../common/light/StarLightInterface.java | 33 +++++++----- .../mixin/client/world/ClientWorldMixin.java | 1 - .../lightengine/LightingProviderMixin.java | 16 +++--- src/main/resources/fabric.mod.json | 2 +- 9 files changed, 92 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 88b04661..5732a722 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Starlight (BETA) +Starlight (Fabric) (BETA) == Fabric mod for completely rewriting the vanilla light engine. diff --git a/gradle.properties b/gradle.properties index 15316895..0611a5b7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.16.4 yarn_mappings=1.16.4+build.7 loader_version=0.10.8 # Mod Properties -mod_version=0.0.2-RC2 +mod_version=0.0.2-RC3 maven_group=ca.spottedleaf.starlight archives_base_name=starlight # Dependencies diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java index e72ccef9..15ea1e86 100644 --- a/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java +++ b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java @@ -37,6 +37,11 @@ protected boolean canUseChunk(final Chunk chunk) { return chunk.getStatus().isAtLeast(ChunkStatus.LIGHT) && (this.isClientSide || chunk.isLightOn()); } + @Override + protected boolean[][] getEmptinessMap(final Chunk chunk) { + return null; + } + @Override protected void handleEmptySectionChanges(final ChunkProvider lightAccess, final Chunk chunk, final Boolean[] emptinessChanges, final boolean unlit) {} diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java index 5853ec46..16bbeb51 100644 --- a/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java +++ b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java @@ -49,6 +49,8 @@ protected void handleEmptySectionChanges(final ChunkProvider lightAccess, final final int chunkX = chunk.getPos().x; final int chunkZ = chunk.getPos().z; + final boolean[][] chunkEmptinessMap = this.getEmptinessMap(chunkX, chunkZ); + // index = (cx + 2) + 5*(cz + 2) long loadedNeighboursBitset = 0L; long unloadedNeighbourBitset = 0L; @@ -60,7 +62,7 @@ protected void handleEmptySectionChanges(final ChunkProvider lightAccess, final continue; } - final boolean[][] neighbourEmptinessMap = ((ExtendedChunk)neighbour).getEmptinessMap(); + final boolean[][] neighbourEmptinessMap = this.getEmptinessMap(dx + chunkX, dz + chunkZ); for (int i = 0; i < neighbourEmptinessMap.length; ++i) { // index = (cx + 1) + 3*(cz + 1) final int dx2 = (i % 3) - 1; @@ -80,14 +82,11 @@ protected void handleEmptySectionChanges(final ChunkProvider lightAccess, final loadedNeighboursBitset |= 1L << ((0 + 2) + 5*(0 + 2)); final boolean[] needsDeInitCheck = new boolean[9]; - final boolean needsInit = ((ExtendedChunk)chunk).getEmptinessMap()[ExtendedChunk.getEmptinessMapIndex(0, 0)] == null; + final boolean needsInit = unlit || chunkEmptinessMap[ExtendedChunk.getEmptinessMapIndex(0, 0)] == null; if (needsInit) { - ((ExtendedChunk)chunk).getEmptinessMap()[ExtendedChunk.getEmptinessMapIndex(0, 0)] = new boolean[16]; + chunkEmptinessMap[ExtendedChunk.getEmptinessMapIndex(0, 0)] = new boolean[16];; } - // index = (cx + 2) + 5*(cz + 2) - final boolean[][] chunkEmptinessMap = ((ExtendedChunk)chunk).getEmptinessMap(); - // this chunk is new, so we need to init neighbours // because this chunk might have been modified inbetween loading/saving, we have to rewrite the emptiness map // for our neighbours, so don't bother checking if they exist & whether they even needed a de-init recalc @@ -99,19 +98,20 @@ protected void handleEmptySectionChanges(final ChunkProvider lightAccess, final // when it does though, it'll come by and initialise our map for it continue; } + final boolean[][] neighbourEmptinessMap = this.getEmptinessMap(dx + chunkX, dz + chunkZ); if (needsInit && (dx | dz) != 0) { // init neighbour - neighbour.getEmptinessMap()[ExtendedChunk.getEmptinessMapIndex(-dx, -dz)] = new boolean[16]; + neighbourEmptinessMap[ExtendedChunk.getEmptinessMapIndex(-dx, -dz)] = new boolean[16]; - if (neighbour.getEmptinessMap()[ExtendedChunk.getEmptinessMapIndex(0, 0)] != null) { + if (neighbourEmptinessMap[ExtendedChunk.getEmptinessMapIndex(0, 0)] != null) { // init ourselves System.arraycopy( - neighbour.getEmptinessMap()[ExtendedChunk.getEmptinessMapIndex(0, 0)], + neighbourEmptinessMap[ExtendedChunk.getEmptinessMapIndex(0, 0)], 0, chunkEmptinessMap[ExtendedChunk.getEmptinessMapIndex(dx, dz)] = new boolean[16], 0, - 9 + 16 ); } } @@ -161,7 +161,7 @@ protected void handleEmptySectionChanges(final ChunkProvider lightAccess, final } // update neighbour map - neighbour.getEmptinessMap()[ExtendedChunk.getEmptinessMapIndex(-dx, -dz)][sectionY] = empty; + this.getEmptinessMap(dx + chunkX, dz + chunkZ)[ExtendedChunk.getEmptinessMapIndex(-dx, -dz)][sectionY] = empty; } } } @@ -176,11 +176,11 @@ protected void handleEmptySectionChanges(final ChunkProvider lightAccess, final final int neighbourX = (i % 3) - 1 + chunkX; final int neighbourZ = (i / 3) - 1 + chunkZ; - final boolean[][] neighbourEmptinessMap = ((ExtendedChunk)this.getChunkInCache(neighbourX, neighbourZ)).getEmptinessMap(); + final boolean[][] neighbourEmptinessMap = this.getEmptinessMap(neighbourX, neighbourZ); for (int sectionY = 16; sectionY >= -1; --sectionY) { final SWMRNibbleArray nibble = this.getNibbleFromCache(neighbourX, sectionY, neighbourZ); - if (nibble.isNullNibbleUpdating()) { + if (nibble == null || nibble.isNullNibbleUpdating()) { // already null continue; } @@ -234,8 +234,7 @@ protected final void initNibbleForLitChunk(final SWMRNibbleArray currNibble, fin return; } - final boolean[] emptinessMap = ((ExtendedChunk)this.getChunkInCache(chunkX, chunkZ)) - .getEmptinessMap()[ExtendedChunk.getEmptinessMapIndex(0, 0)]; + final boolean[] emptinessMap = this.getEmptinessMap(chunkX, chunkZ)[ExtendedChunk.getEmptinessMapIndex(0, 0)]; // are we above this chunk's lowest empty section? int lowestY = -2; @@ -284,6 +283,7 @@ protected final void rewriteNibbleCacheForSkylight(final Chunk chunk) { if (nibble != null && nibble.isNullNibbleUpdating()) { // stop propagation in these areas this.nibbleCache[index] = null; + nibble.updateVisible(); } } } @@ -361,6 +361,11 @@ protected SWMRNibbleArray[] getNibblesOnChunk(final Chunk chunk) { return ((ExtendedChunk)chunk).getSkyNibbles(); } + @Override + protected boolean[][] getEmptinessMap(final Chunk chunk) { + return ((ExtendedChunk)chunk).getEmptinessMap(); + } + @Override protected void setNibbles(final Chunk chunk, final SWMRNibbleArray[] to) { ((ExtendedChunk)chunk).setSkyNibbles(to); @@ -472,7 +477,7 @@ protected void propagateBlockChanges(final ChunkProvider lightAccess, final Chun // ensure section is checked this.checkNullSection(columnX >> 4, maxPropagationY >> 4, columnZ >> 4, true); - for (int currY = maxPropagationY; currY >= -15; --currY) { + for (int currY = maxPropagationY; currY >= (-1 << 4); --currY) { if ((currY & 15) == 15) { // ensure section is checked this.checkNullSection(columnX >> 4, (currY >> 4), columnZ >> 4, true); @@ -611,7 +616,7 @@ protected void lightChunk(final ChunkProvider lightAccess, final Chunk chunk, fi final int maxZ = worldChunkZ + 16; for (int currZ = minZ; currZ <= maxZ; ++currZ) { for (int currX = minX; currX <= maxX; ++currX) { - int maxY = -33; + int maxY = ((-1 -1) << 4); // ensure the section below is always checked this.checkNullSection(currX >> 4, highestNonEmptySection, currZ >> 4, false); @@ -725,12 +730,12 @@ protected void lightChunk(final ChunkProvider lightAccess, final Chunk chunk, fi // not required to propagate here, but this will reduce the hit of the edge checks this.performLightIncrease(lightAccess); - for (int y = -1; y <= 16; ++y) { + for (int y = 16; y >= -1; --y) { this.checkNullSection(chunkX, y, chunkZ, false); } this.checkChunkEdges(lightAccess, chunk, -1, 16); } else { - for (int y = -1; y <= highestNonEmptySection; ++y) { + for (int y = highestNonEmptySection; y >= -1; --y) { this.checkNullSection(chunkX, y, chunkZ, false); } this.propagateNeighbourLevels(lightAccess, chunk, -1, highestNonEmptySection); @@ -797,7 +802,7 @@ protected final int tryPropagateSkylight(final BlockView world, final int worldX above = AIR_BLOCK_STATE; } - for (;startY >= -15; --startY) { + for (;startY >= (-1 << 4); --startY) { if ((startY & 15) == 15) { // ensure this section is always checked this.checkNullSection(worldX >> 4, startY >> 4, worldZ >> 4, extrudeInitialised); diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java index fde15b6e..b60dad7c 100644 --- a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java +++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java @@ -98,6 +98,9 @@ public AxisDirection getOpposite() { // index = x + (z * 5) protected final Chunk[] chunkCache = new Chunk[5 * 5]; + // index = x + (z * 5) + protected final boolean[][][] emptinessMapCache = new boolean[5 * 5][][]; + protected final BlockPos.Mutable mutablePos1 = new BlockPos.Mutable(); protected final BlockPos.Mutable mutablePos2 = new BlockPos.Mutable(); protected final BlockPos.Mutable mutablePos3 = new BlockPos.Mutable(); @@ -176,6 +179,7 @@ protected final void setupCaches(final ChunkProvider chunkProvider, final int ce this.setChunkInCache(cx, cz, chunk); this.setBlocksForChunkInCache(cx, cz, chunk.getSectionArray()); this.setNibblesForChunkInCache(cx, cz, this.getNibblesOnChunk(chunk)); + this.setEmptinessMapCache(cx, cz, this.getEmptinessMap(chunk)); } } } @@ -247,6 +251,7 @@ protected final void destroyCaches() { Arrays.fill(this.sectionCache, null); Arrays.fill(this.nibbleCache, null); Arrays.fill(this.chunkCache, null); + Arrays.fill(this.emptinessMapCache, null); if (this.isClientSide) { Arrays.fill(this.notifyUpdateCache, false); } @@ -349,6 +354,14 @@ protected final void setLightLevel(final int sectionIndex, final int localIndex, } } + protected final boolean[][] getEmptinessMap(final int chunkX, final int chunkZ) { + return this.emptinessMapCache[chunkX + 5*chunkZ + this.chunkIndexOffset]; + } + + protected final void setEmptinessMapCache(final int chunkX, final int chunkZ, final boolean[][] emptinessMap) { + this.emptinessMapCache[chunkX + 5*chunkZ + this.chunkIndexOffset] = emptinessMap; + } + public static SWMRNibbleArray[] getFilledEmptyLight() { final SWMRNibbleArray[] ret = getEmptyLightArray(); @@ -363,13 +376,14 @@ public static SWMRNibbleArray[] getEmptyLightArray() { return new SWMRNibbleArray[16 - (-1) + 1]; } + protected abstract boolean[][] getEmptinessMap(final Chunk chunk); + protected abstract SWMRNibbleArray[] getNibblesOnChunk(final Chunk chunk); protected abstract void setNibbles(final Chunk chunk, final SWMRNibbleArray[] to); protected abstract boolean canUseChunk(final Chunk chunk); - // TODO include section changes public final void blocksChangedInChunk(final ChunkProvider lightAccess, final int chunkX, final int chunkZ, final Set positions, final Boolean[] changedSections) { this.setupCaches(lightAccess, chunkX * 16 + 7, 128, chunkZ * 16 + 7, this.isClientSide); @@ -410,7 +424,7 @@ protected void checkChunkEdge(final ChunkProvider lightAccess, final Chunk chunk final SWMRNibbleArray neighbourNibble = this.getNibbleFromCache(chunkX + neighbourOffX, chunkY, chunkZ + neighbourOffZ); - if (neighbourNibble == null || neighbourNibble.isNullNibbleUpdating()) { + if (neighbourNibble == null) { continue; } @@ -527,7 +541,7 @@ protected final void propagateNeighbourLevels(final ChunkProvider lightAccess, f for (int currSectionY = toSection; currSectionY >= fromSection; --currSectionY) { final SWMRNibbleArray currNibble = this.getNibbleFromCache(chunkX, currSectionY, chunkZ); - if (this.skylightPropagator && currNibble == null) { + if (currNibble == null) { continue; } for (final AxisDirection direction : ONLY_HORIZONTAL_DIRECTIONS) { @@ -537,16 +551,7 @@ protected final void propagateNeighbourLevels(final ChunkProvider lightAccess, f final SWMRNibbleArray neighbourNibble = this.getNibbleFromCache(chunkX + neighbourOffX, currSectionY, chunkZ + neighbourOffZ); - if (neighbourNibble == null || neighbourNibble.isNullNibbleUpdating()) { - continue; - } - - if (this.skylightPropagator && currNibble.isNullNibbleUpdating()) { - // TODO in what situation does this happen? Pretty sure it's erroneous. - continue; - } - - if (!neighbourNibble.isInitialisedUpdating()) { + if (neighbourNibble == null || !neighbourNibble.isInitialisedUpdating()) { // can't pull from 0 continue; } @@ -588,9 +593,9 @@ protected final void propagateNeighbourLevels(final ChunkProvider lightAccess, f for (int currY = currSectionY << 4, maxY = currY | 15; currY <= maxY; ++currY) { for (int i = 0, currX = startX, currZ = startZ; i < 16; ++i, currX += incX, currZ += incZ) { final int level = neighbourNibble.getUpdating( - (currX & 15) | - (currZ & 15) << 4 | - (currY & 15) << 8 + (currX & 15) + | ((currZ & 15) << 4) + | ((currY & 15) << 8) ); if (level <= 1) { @@ -627,7 +632,7 @@ public static Boolean[] getEmptySectionsForChunk(final Chunk chunk) { public final void handleEmptySectionChanges(final ChunkProvider lightAccess, final int chunkX, final int chunkZ, final Boolean[] emptinessChanges) { - this.setupCaches(lightAccess, chunkX * 16 + 7, 128, chunkZ * 16 + 7, true); + this.setupCaches(lightAccess, chunkX * 16 + 7, 128, chunkZ * 16 + 7, this.isClientSide); if (this.isClientSide) { // force current chunk into cache final Chunk chunk = (Chunk)lightAccess.getChunk(chunkX, chunkZ); @@ -638,6 +643,7 @@ public final void handleEmptySectionChanges(final ChunkProvider lightAccess, fin this.setChunkInCache(chunkX, chunkZ, chunk); this.setBlocksForChunkInCache(chunkX, chunkZ, chunk.getSectionArray()); this.setNibblesForChunkInCache(chunkX, chunkZ, this.getNibblesOnChunk(chunk)); + this.setEmptinessMapCache(chunkX, chunkZ, this.getEmptinessMap(chunk)); } try { final Chunk chunk = this.getChunkInCache(chunkX, chunkZ); @@ -701,6 +707,7 @@ public final void light(final ChunkProvider lightAccess, final int chunkX, final this.setChunkInCache(chunkX, chunkZ, chunk); this.setBlocksForChunkInCache(chunkX, chunkZ, chunk.getSectionArray()); this.setNibblesForChunkInCache(chunkX, chunkZ, this.getNibblesOnChunk(chunk)); + this.setEmptinessMapCache(chunkX, chunkZ, this.getEmptinessMap(chunk)); try { this.handleEmptySectionChanges(lightAccess, chunk, emptySections, true); @@ -721,10 +728,13 @@ protected final void relightChunk(final ChunkProvider lightAccess, final Chunk c this.setupEncodeOffset(chunkPos.x * 16 + 7, 128, chunkPos.z * 16 + 7); try { + final SWMRNibbleArray[] chunkNibbles = getFilledEmptyLight(); + this.setChunkInCache(chunkPos.x, chunkPos.z, chunk); this.setBlocksForChunkInCache(chunkPos.x, chunkPos.z, chunk.getSectionArray()); - final SWMRNibbleArray[] chunkNibbles = getFilledEmptyLight(); this.setNibblesForChunkInCache(chunkPos.x, chunkPos.z, chunkNibbles); + this.setEmptinessMapCache(chunkPos.x, chunkPos.z, new boolean[9][]); + this.handleEmptySectionChanges(lightAccess, chunk, getEmptySectionsForChunk(chunk), true); this.lightChunk(lightAccess, chunk, false); @@ -745,7 +755,9 @@ protected final void relightChunk(final ChunkProvider lightAccess, final Chunk c this.setChunkInCache(cx, cz, neighbourChunk); this.setBlocksForChunkInCache(cx, cz, neighbourChunk.getSectionArray()); this.setNibblesForChunkInCache(cx, cz, getFilledEmptyLight()); - this.handleEmptySectionChanges(lightAccess, chunk, getEmptySectionsForChunk(neighbourChunk), true); + this.setEmptinessMapCache(cx, cz, new boolean[9][]); + + this.handleEmptySectionChanges(lightAccess, neighbourChunk, getEmptySectionsForChunk(neighbourChunk), true); this.lightChunk(lightAccess, neighbourChunk, false); } } diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java index 15a15a0b..4f71d6cf 100644 --- a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java +++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java @@ -64,22 +64,29 @@ public ChunkNibbleArray getLightSection(final ChunkSectionPos pos) { return null; } - return ((ExtendedChunk)chunk).getSkyNibbles()[pos.getY() + 1].toVanillaNibble(); + return ((ExtendedChunk)chunk).getSkyNibbles()[sectionY + 1].toVanillaNibble(); } @Override public int getLightLevel(final BlockPos blockPos) { - final Chunk chunk = StarLightInterface.this.getAnyChunkNow(blockPos.getX() >> 4, blockPos.getZ() >> 4); + final int x = blockPos.getX(); + int y = blockPos.getY(); + final int z = blockPos.getZ(); + + final Chunk chunk = StarLightInterface.this.getAnyChunkNow(x >> 4, z >> 4); if (chunk == null || (!StarLightInterface.this.isClientSide && !chunk.isLightOn()) || !chunk.getStatus().isAtLeast(ChunkStatus.LIGHT)) { return 15; } - final int sectionY = blockPos.getY() >> 4; + int sectionY = y >> 4; if (sectionY > 16) { return 15; - } else if (sectionY < -1) { - return 0; + } + + if (sectionY < -1) { + y = -16; + sectionY = -1; } final SWMRNibbleArray[] nibbles = ((ExtendedChunk)chunk).getSkyNibbles(); @@ -87,11 +94,11 @@ public int getLightLevel(final BlockPos blockPos) { if (StarLightInterface.this.isClientSide) { if (!immediate.isNullNibbleUpdating()) { - return immediate.getUpdating(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + return immediate.getUpdating(x, y, z); } } else { if (!immediate.isNullNibbleVisible()) { - return immediate.getVisible(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + return immediate.getVisible(x, y, z); } } @@ -123,11 +130,11 @@ public int getLightLevel(final BlockPos blockPos) { final SWMRNibbleArray nibble = nibbles[currY + 1]; if (StarLightInterface.this.isClientSide) { if (!nibble.isNullNibbleUpdating()) { - return nibble.getUpdating(blockPos.getX(), 0, blockPos.getZ()); + return nibble.getUpdating(x, 0, z); } } else { if (!nibble.isNullNibbleVisible()) { - return nibble.getVisible(blockPos.getX(), 0, blockPos.getZ()); + return nibble.getVisible(x, 0, z); } } } @@ -138,18 +145,18 @@ public int getLightLevel(final BlockPos blockPos) { @Override public void setSectionStatus(final ChunkSectionPos pos, final boolean notReady) { - return; // don't care. + StarLightInterface.this.sectionChange(pos, notReady); } }; this.blockReader = !hasBlockLight ? ChunkLightingView.Empty.INSTANCE : new ChunkLightingView() { @Override - public ChunkNibbleArray getLightSection(ChunkSectionPos pos) { + public ChunkNibbleArray getLightSection(final ChunkSectionPos pos) { final Chunk chunk = StarLightInterface.this.getAnyChunkNow(pos.getX(), pos.getZ()); return chunk != null ? ((ExtendedChunk)chunk).getBlockNibbles()[pos.getY() + 1].toVanillaNibble() : null; } @Override - public int getLightLevel(BlockPos blockPos) { + public int getLightLevel(final BlockPos blockPos) { final int cx = blockPos.getX() >> 4; final int cy = blockPos.getY() >> 4; final int cz = blockPos.getZ() >> 4; @@ -174,7 +181,7 @@ public int getLightLevel(BlockPos blockPos) { @Override public void setSectionStatus(final ChunkSectionPos pos, final boolean notReady) { - return; // don't care. + return; // block engine doesn't care } }; } diff --git a/src/main/java/ca/spottedleaf/starlight/mixin/client/world/ClientWorldMixin.java b/src/main/java/ca/spottedleaf/starlight/mixin/client/world/ClientWorldMixin.java index 66043eb1..9ecc036b 100644 --- a/src/main/java/ca/spottedleaf/starlight/mixin/client/world/ClientWorldMixin.java +++ b/src/main/java/ca/spottedleaf/starlight/mixin/client/world/ClientWorldMixin.java @@ -14,7 +14,6 @@ import org.spongepowered.asm.mixin.Mixin; import java.util.function.Supplier; -@Environment(EnvType.CLIENT) @Mixin(ClientWorld.class) public abstract class ClientWorldMixin extends World implements ExtendedWorld { diff --git a/src/main/java/ca/spottedleaf/starlight/mixin/common/lightengine/LightingProviderMixin.java b/src/main/java/ca/spottedleaf/starlight/mixin/common/lightengine/LightingProviderMixin.java index 63498905..0026ced4 100644 --- a/src/main/java/ca/spottedleaf/starlight/mixin/common/lightengine/LightingProviderMixin.java +++ b/src/main/java/ca/spottedleaf/starlight/mixin/common/lightengine/LightingProviderMixin.java @@ -134,10 +134,10 @@ public void setSectionStatus(final ChunkSectionPos pos, final boolean notReady) } @Unique - protected final Long2ObjectOpenHashMap blockLight = new Long2ObjectOpenHashMap<>(); + protected final Long2ObjectOpenHashMap blockLightMap = new Long2ObjectOpenHashMap<>(); @Unique - protected final Long2ObjectOpenHashMap skyLight = new Long2ObjectOpenHashMap<>(); + protected final Long2ObjectOpenHashMap skyLightMap = new Long2ObjectOpenHashMap<>(); @Unique protected final Long2ObjectOpenHashMap queuedChunkLoads = new Long2ObjectOpenHashMap<>(); @@ -156,8 +156,8 @@ public void setSectionStatus(final ChunkSectionPos pos, final boolean notReady) public void setColumnEnabled(final ChunkPos pos, final boolean lightEnabled) { final Chunk chunk = this.getLightEngine().getAnyChunkNow(pos.x, pos.z); if (chunk != null) { - final SWMRNibbleArray[] blockNibbles = this.blockLight.get(CoordinateUtils.getChunkKey(pos)); - final SWMRNibbleArray[] skyNibbles = this.skyLight.get(CoordinateUtils.getChunkKey(pos)); + final SWMRNibbleArray[] blockNibbles = this.blockLightMap.get(CoordinateUtils.getChunkKey(pos)); + final SWMRNibbleArray[] skyNibbles = this.skyLightMap.get(CoordinateUtils.getChunkKey(pos)); if (blockNibbles != null) { ((ExtendedChunk)chunk).setBlockNibbles(blockNibbles); } @@ -167,8 +167,8 @@ public void setColumnEnabled(final ChunkPos pos, final boolean lightEnabled) { this.queuedChunkLoads.put(CoordinateUtils.getChunkKey(pos), StarLightEngine.getEmptySectionsForChunk(chunk)); } else if (!lightEnabled) { - this.blockLight.remove(CoordinateUtils.getChunkKey(pos)); - this.skyLight.remove(CoordinateUtils.getChunkKey(pos)); + this.blockLightMap.remove(CoordinateUtils.getChunkKey(pos)); + this.skyLightMap.remove(CoordinateUtils.getChunkKey(pos)); this.queuedChunkLoads.remove(CoordinateUtils.getChunkKey(pos)); this.queuedEdgeChecksBlock.remove(CoordinateUtils.getChunkKey(pos)); this.queuedEdgeChecksSky.remove(CoordinateUtils.getChunkKey(pos)); @@ -195,7 +195,7 @@ public void enqueueSectionData(final LightType lightType, final ChunkSectionPos final Chunk chunk = this.getLightEngine().getAnyChunkNow(pos.getX(), pos.getZ()); switch (lightType) { case BLOCK: { - final SWMRNibbleArray[] blockNibbles = this.blockLight.computeIfAbsent(CoordinateUtils.getChunkKey(pos), (final long keyInMap) -> { + final SWMRNibbleArray[] blockNibbles = this.blockLightMap.computeIfAbsent(CoordinateUtils.getChunkKey(pos), (final long keyInMap) -> { return StarLightEngine.getFilledEmptyLight(); }); @@ -217,7 +217,7 @@ public void enqueueSectionData(final LightType lightType, final ChunkSectionPos break; } case SKY: { - final SWMRNibbleArray[] skyNibbles = this.skyLight.computeIfAbsent(CoordinateUtils.getChunkKey(pos), (final long keyInMap) -> { + final SWMRNibbleArray[] skyNibbles = this.skyLightMap.computeIfAbsent(CoordinateUtils.getChunkKey(pos), (final long keyInMap) -> { return StarLightEngine.getFilledEmptyLight(); }); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a2b6069b..2da41239 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,6 +18,6 @@ "accessWidener" : "starlight.accesswidener", "depends": { "fabricloader": ">=0.10.8", - "minecraft": "1.16.4" + "minecraft": ">=1.16.0" } }