From 9ab67716bc2cda5cca860969979ad918e42d6aed Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Fri, 9 Sep 2022 14:16:58 +0800 Subject: [PATCH] Fix lighting --- .../common/wrappers/chunk/ChunkWrapper.java | 31 +++++++------------ coreSubProjects | 2 +- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java index 0614f6be1..682454e44 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java @@ -22,6 +22,7 @@ package com.seibel.lod.common.wrappers.chunk; import com.seibel.lod.common.wrappers.block.BlockStateWrapper; import com.seibel.lod.core.enums.ELodDirection; import com.seibel.lod.core.objects.DHBlockPos; +import com.seibel.lod.core.objects.DHChunkPos; import com.seibel.lod.core.util.LevelPosUtil; import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper; @@ -60,6 +61,7 @@ import javax.annotation.Nullable; public class ChunkWrapper implements IChunkWrapper { private final ChunkAccess chunk; + private final DHChunkPos chunkPos; private final LevelReader lightSource; private final ILevelWrapper wrappedLevel; @@ -69,6 +71,7 @@ public class ChunkWrapper implements IChunkWrapper this.chunk = chunk; this.lightSource = lightSource; this.wrappedLevel = wrappedLevel; + chunkPos = new DHChunkPos(chunk.getPos().x, chunk.getPos().z); } @Override @@ -120,7 +123,12 @@ public class ChunkWrapper implements IChunkWrapper QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); #endif } - + + @Override + public DHChunkPos getChunkPos() { + return chunkPos; + } + public ChunkAccess getChunk() { return chunk; } @@ -184,31 +192,16 @@ public class ChunkWrapper implements IChunkWrapper #endif } - public boolean isWaterLogged(int x, int y, int z) - { - BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); - - //This type of block is always in water - return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock)) - && (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)); - } - - @Override - public int getEmittedBrightness(int x, int y, int z) - { - return chunk.getLightEmission(new BlockPos(x,y,z)); - } - @Override public int getBlockLight(int x, int y, int z) { if (lightSource == null) return -1; - return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); + return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x + getMinX(),y,z + getMinZ())); } @Override public int getSkyLight(int x, int y, int z) { if (lightSource == null) return -1; - return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); + return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x + getMinX(),y,z + getMinZ())); } @Override @@ -217,7 +210,7 @@ public class ChunkWrapper implements IChunkWrapper for (int dx = -1; dx <= 1; dx++) { for (int dz = -1; dz <= 1; dz++) { if (dx==0 && dz==0) continue; - if (lightSource.getChunk(dx+getChunkPosX(), dz+getChunkPosZ(), ChunkStatus.BIOMES, false) == null) return false; + if (lightSource.getChunk(dx+chunk.getPos().x, dz+chunk.getPos().z, ChunkStatus.BIOMES, false) == null) return false; } } return true; diff --git a/coreSubProjects b/coreSubProjects index 0e001dd2d..1dadf056d 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 0e001dd2d36e4a150ffcc1d4c4237f5a345478cf +Subproject commit 1dadf056daa66f6283897e087e3a516c9c829735