Made IChunkWrapper also has the ability to return light data

This commit is contained in:
tom lee
2022-01-08 22:51:23 +08:00
parent a402fa5f0b
commit 8b761ca31a
2 changed files with 21 additions and 9 deletions
@@ -399,7 +399,6 @@ public class LodBuilder
// 1 means the lighting is a guess
int isDefault = 0;
IWorldWrapper world = MC.getWrappedServerWorld();
int blockBrightness = chunk.getEmittedBrightness(x, y, z);
// get the air block above or below this block
@@ -408,12 +407,24 @@ public class LodBuilder
else
y++;
blockLight = chunk.getBlockLight(x, y, z);
if (hasSkyLight)
skyLight = chunk.getSkyLight(x, y, z);
else
skyLight = 0;
if (blockLight != -1 && skyLight != -1) {
blockLight = LodUtil.clamp(0, Math.max(blockLight, blockBrightness), DEFAULT_MAX_LIGHT);
return blockLight + (skyLight << 4) + (isDefault << 8);
}
IWorldWrapper world = MC.getWrappedServerWorld();
if (world != null)
{
// server world sky light (always accurate)
blockLight = world.getBlockLight(x,y,z);
if (topBlock && !hasCeiling && hasSkyLight)
skyLight = DEFAULT_MAX_LIGHT;
else
@@ -429,11 +440,10 @@ public class LodBuilder
// lets just take a guess
if (y >= MC.getWrappedClientWorld().getSeaLevel() - 5)
{
skyLight = 12;
isDefault = 1;
skyLight = 6;
}
else
skyLight = 0;
skyLight = 6;
}
}
else
@@ -442,8 +452,7 @@ public class LodBuilder
if (world==null)
{
blockLight = 0;
skyLight = 12;
isDefault = 1;
skyLight = 6;
}
else
{
@@ -466,11 +475,10 @@ public class LodBuilder
// lets just take a guess
if (y >= MC.getWrappedClientWorld().getSeaLevel() - 5)
{
skyLight = 12;
isDefault = 1;
skyLight = 6;
}
else
skyLight = 0;
skyLight = 6;
}
}
}
@@ -55,4 +55,8 @@ public interface IChunkWrapper
boolean isWaterLogged(int x, int y, int z);
int getEmittedBrightness(int x, int y, int z);
int getBlockLight(int x, int y, int z);
int getSkyLight(int x, int y, int z);
}