cleaned up code around light
This commit is contained in:
@@ -396,11 +396,8 @@ public class LodBuilder
|
||||
/** Gets the light value for the given block position */
|
||||
private int getLightValue(IChunkWrapper chunk, int x, int y, int z, boolean hasCeiling, boolean hasSkyLight, boolean topBlock)
|
||||
{
|
||||
int skyLight = 0;
|
||||
int skyLight;
|
||||
int blockLight;
|
||||
// 1 means the lighting is a guess
|
||||
int isDefault = 0;
|
||||
|
||||
|
||||
int blockBrightness = chunk.getEmittedBrightness(x, y, z);
|
||||
// get the air block above or below this block
|
||||
@@ -410,77 +407,59 @@ public class LodBuilder
|
||||
y++;
|
||||
|
||||
blockLight = chunk.getBlockLight(x, y, z);
|
||||
if (hasSkyLight)
|
||||
skyLight = chunk.getSkyLight(x, y, z);
|
||||
else
|
||||
skyLight = 0;
|
||||
skyLight = hasSkyLight ? chunk.getSkyLight(x, y, z) : 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)
|
||||
if (blockLight == -1 || skyLight == -1)
|
||||
{
|
||||
// server world sky light (always accurate)
|
||||
blockLight = world.getBlockLight(x,y,z);
|
||||
|
||||
if (topBlock && !hasCeiling && hasSkyLight)
|
||||
skyLight = DEFAULT_MAX_LIGHT;
|
||||
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
|
||||
skyLight = hasSkyLight ? world.getSkyLight(x, y, z) : 0;
|
||||
|
||||
if (!topBlock && skyLight == 15)
|
||||
{
|
||||
// we are on predicted terrain, and we don't know what the light here is,
|
||||
// lets just take a guess
|
||||
skyLight = 12;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hasSkyLight)
|
||||
skyLight = world.getSkyLight(x,y,z);
|
||||
//else
|
||||
// skyLight = 0;
|
||||
}
|
||||
if (!topBlock && skyLight == 15)
|
||||
{
|
||||
// we are on predicted terrain, and we don't know what the light here is,
|
||||
// lets just take a guess
|
||||
if (y >= MC.getWrappedClientWorld().getSeaLevel() - 5)
|
||||
world = MC.getWrappedClientWorld();
|
||||
if (world == null)
|
||||
{
|
||||
skyLight = 6;
|
||||
blockLight = 0;
|
||||
skyLight = 12;
|
||||
}
|
||||
else
|
||||
skyLight = 6;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
world = MC.getWrappedClientWorld();
|
||||
if (world==null)
|
||||
{
|
||||
blockLight = 0;
|
||||
skyLight = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
// client world sky light (almost never accurate)
|
||||
blockLight = world.getBlockLight(x,y,z);
|
||||
// estimate what the lighting should be
|
||||
if (hasSkyLight || !hasCeiling)
|
||||
{
|
||||
if (topBlock)
|
||||
skyLight = DEFAULT_MAX_LIGHT;
|
||||
else
|
||||
// client world sky light (almost never accurate)
|
||||
blockLight = world.getBlockLight(x, y, z);
|
||||
// estimate what the lighting should be
|
||||
if (hasSkyLight || !hasCeiling)
|
||||
{
|
||||
if (hasSkyLight)
|
||||
skyLight = world.getSkyLight(x,y,z);
|
||||
//else
|
||||
// skyLight = 0;
|
||||
if (!chunk.isLightCorrect() && (skyLight == 0 || skyLight == 15))
|
||||
if (topBlock)
|
||||
skyLight = DEFAULT_MAX_LIGHT;
|
||||
else
|
||||
{
|
||||
// we don't know what the light here is,
|
||||
// lets just take a guess
|
||||
if (y >= MC.getWrappedClientWorld().getSeaLevel() - 5)
|
||||
if (hasSkyLight)
|
||||
skyLight = world.getSkyLight(x, y, z);
|
||||
//else
|
||||
// skyLight = 0;
|
||||
if (!chunk.isLightCorrect() && (skyLight == 0 || skyLight == 15))
|
||||
{
|
||||
skyLight = 6;
|
||||
// we don't know what the light here is,
|
||||
// lets just take a guess
|
||||
skyLight = 12;
|
||||
}
|
||||
else
|
||||
skyLight = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,8 +467,7 @@ public class LodBuilder
|
||||
}
|
||||
|
||||
blockLight = LodUtil.clamp(0, Math.max(blockLight, blockBrightness), DEFAULT_MAX_LIGHT);
|
||||
|
||||
return blockLight + (skyLight << 4) + (isDefault << 8);
|
||||
return blockLight + (skyLight << 4);
|
||||
}
|
||||
|
||||
/** Returns a color int for the given block. */
|
||||
|
||||
@@ -185,11 +185,15 @@ public class DataPointUtil
|
||||
return (byte) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* this used to take into account default light flag, but thanks to leetom this is no longer necessary
|
||||
*/
|
||||
public static byte getLightSkyAlt(long dataPoint)
|
||||
{
|
||||
if (skyLightPlayer == 0 && ((dataPoint >>> FLAG_SHIFT) & FLAG_MASK) == 1)
|
||||
return 0;
|
||||
else
|
||||
//if (skyLightPlayer == 0 && ((dataPoint >>> FLAG_SHIFT) & FLAG_MASK) == 1)
|
||||
// return 0;
|
||||
//else
|
||||
return (byte) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
|
||||
}
|
||||
|
||||
@@ -505,7 +509,6 @@ public class DataPointUtil
|
||||
byte tempGenMode = DistanceGenerationMode.FULL.complexity;
|
||||
allEmpty = true;
|
||||
allVoid = true;
|
||||
allDefault = true;
|
||||
long data = 0;
|
||||
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -544,8 +547,6 @@ public class DataPointUtil
|
||||
tempBlue += getBlue(data);
|
||||
tempLightBlock += getLightBlock(data);
|
||||
tempLightSky += getLightSky(data);
|
||||
if (!getFlag(data))
|
||||
allDefault = false;
|
||||
}
|
||||
tempGenMode = (byte) Math.min(tempGenMode, getGenerationMode(data));
|
||||
}
|
||||
@@ -576,7 +577,7 @@ public class DataPointUtil
|
||||
//{
|
||||
// add simplification at the end due to color
|
||||
//}
|
||||
dataPoint[j] = createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, height, depth, tempLightSky, tempLightBlock, tempGenMode, allDefault);
|
||||
dataPoint[j] = createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, height, depth, tempLightSky, tempLightBlock, tempGenMode, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user