Merge remote-tracking branch 'origin/main'

This commit is contained in:
coolGi
2023-08-20 02:54:40 +09:30
3 changed files with 15 additions and 18 deletions
@@ -38,9 +38,19 @@ public class LodDataBuilder
// FIXME: The +1 offset to reproduce the old behavior. Remove this when we get per-face lighting
byte light = (byte) ((chunkWrapper.getBlockLight(x, lastY + 1, z) << 4) + chunkWrapper.getSkyLight(x, lastY + 1, z));
// using a height map to reduce how many empty blocks positions we have to check would be preferable, but there are some world generators
// that don't work well with that, so we have to check the whole column
int y = chunkWrapper.getMaxBuildHeight();
// determine the starting Y Pos
int y = chunkWrapper.getLightBlockingHeightMapValue(x,z);
// go up until we reach open air or the world limit
IBlockStateWrapper topBlockState = chunkWrapper.getBlockState(x, y, z);
while (!topBlockState.isAir() && y < chunkWrapper.getMaxBuildHeight())
{
// This is necessary in some edge cases with snow layers and some other blocks that may not appear in the height map but do block light.
// Interestingly this doesn't appear to be the case in the DhLightingEngine, if this same logic is added there the lighting breaks for the affected blocks.
y++;
topBlockState = chunkWrapper.getBlockState(x, y, z);
}
for (; y >= chunkWrapper.getMinBuildHeight(); y--)
{
@@ -448,7 +448,7 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
// Skip updating the cache if the data file is already up-to-date
FullDataMetaFile dataFile = this.fullDataSourceProvider.getFileIfExist(file.pos);
if (!ALWAYS_INVALIDATE_CACHE && dataFile != null && dataFile.baseMetaData.checksum == file.baseMetaData.dataVersion.get()) {
LOGGER.info("Skipping render cache update for {}", file.pos);
LOGGER.debug("Skipping render cache update for {}", file.pos);
renderSource.localVersion.incrementAndGet();
return CompletableFuture.completedFuture(null);
}
@@ -103,21 +103,8 @@ public class DhLightingEngine
for (int relZ = 0; relZ < LodUtil.CHUNK_WIDTH; relZ++)
{
// get the light
int maxY = Math.max(chunk.getLightBlockingHeightMapValue(relX, relZ), chunk.getSolidHeightMapValue(relX, relZ));
IBlockStateWrapper blockState = chunk.getBlockState(relX, maxY, relZ);
// go up until we reach open air or the world limit
while (!blockState.isAir() && maxY < chunk.getMaxBuildHeight())
{
// this shouldn't normally be necessary, but in the off change the height map is wrong,
// (like with a modded world generator)
// this should prevent generating skylights inside the ground
maxY++;
blockState = chunk.getBlockState(relX, maxY, relZ);
}
int maxY = chunk.getLightBlockingHeightMapValue(relX, relZ);
DhBlockPos skyLightPos = new DhBlockPos(chunk.getMinBlockX() + relX, maxY, chunk.getMinBlockZ() + relZ);
if (skyLightPos.y < chunk.getMinBuildHeight() || skyLightPos.y > chunk.getMaxBuildHeight())
{
// this shouldn't normally happen