various changes to the generation + some small fixes
This commit is contained in:
@@ -322,32 +322,21 @@ public class LodBuilder
|
||||
yAbs = height - 1;
|
||||
// We search light on above air block
|
||||
depth = determineBottomPointFrom(chunk, config, xRel, zRel, yAbs, blockPos);
|
||||
blockPos.set(xAbs, yAbs, zAbs);
|
||||
light = getLightValue(chunk, blockPos, hasCeiling, hasSkyLight, topBlock);
|
||||
if (hasCeiling && topBlock)
|
||||
{
|
||||
yAbs = depth;
|
||||
color = generateLodColor(chunk, config, xRel, yAbs, zRel, blockPos);
|
||||
blockPos.set(xAbs, yAbs - 1, zAbs);
|
||||
light = getLightValue(chunk, blockPos, true);
|
||||
} else
|
||||
{
|
||||
color = generateLodColor(chunk, config, xRel, yAbs, zRel, blockPos);
|
||||
blockPos.set(xAbs, yAbs + 1, zAbs);
|
||||
light = getLightValue(chunk, blockPos, false);
|
||||
}
|
||||
lightBlock = light & 0b1111;
|
||||
if (!hasCeiling && topBlock)
|
||||
{
|
||||
if (hasSkyLight)
|
||||
{
|
||||
lightSky = 15; //default max light
|
||||
} else
|
||||
{
|
||||
lightSky = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
lightSky = (light >> 4) & 0b1111;
|
||||
}
|
||||
lightSky = (light >> 4) & 0b1111;
|
||||
|
||||
|
||||
dataToMerge[index * verticalData + count] = DataPointUtil.createDataPoint(height, depth, color, lightSky, lightBlock, generation);
|
||||
topBlock = false;
|
||||
@@ -448,6 +437,8 @@ public class LodBuilder
|
||||
int lightBlock;
|
||||
int lightSky;
|
||||
|
||||
boolean hasCeiling = mc.getClientWorld().dimensionType().hasCeiling();
|
||||
boolean hasSkyLight = mc.getClientWorld().dimensionType().hasSkyLight();
|
||||
|
||||
BlockPos.Mutable blockPos = new BlockPos.Mutable(0, 0, 0);
|
||||
int index = 0;
|
||||
@@ -479,7 +470,7 @@ public class LodBuilder
|
||||
depth = determineBottomPoint(chunk, config, xRel, zRel, blockPos);
|
||||
|
||||
blockPos.set(xAbs, yAbs + 1, zAbs);
|
||||
light = getLightValue(chunk, blockPos, false);
|
||||
light = getLightValue(chunk, blockPos, hasCeiling, hasSkyLight, true);
|
||||
lightBlock = light & 0b1111;
|
||||
//lightSky = (light >> 4) & 0b1111;
|
||||
lightSky = 15; //default max light
|
||||
@@ -595,32 +586,54 @@ public class LodBuilder
|
||||
return colorInt;
|
||||
}
|
||||
|
||||
private int getLightValue(IChunk chunk, BlockPos.Mutable blockPos, boolean ceilingTopBlock)
|
||||
private int getLightValue(IChunk chunk, BlockPos.Mutable blockPos, boolean hasCeiling, boolean hasSkyLight, boolean topBlock)
|
||||
{
|
||||
int skyLight;
|
||||
int blockLight;
|
||||
if (mc.getPlayer() == null)
|
||||
return 0;
|
||||
if (mc.getPlayer().level == null)
|
||||
int blockLight = 0;
|
||||
if (mc.getClientWorld() == null)
|
||||
return 0;
|
||||
|
||||
IWorld world = mc.getPlayer().level;
|
||||
IWorld world = mc.getClientWorld();
|
||||
|
||||
blockLight = world.getBrightness(LightType.BLOCK, blockPos);
|
||||
skyLight = world.getBrightness(LightType.SKY, blockPos);
|
||||
int blockBrightness = world.getBrightness(LightType.BLOCK, blockPos);
|
||||
|
||||
if (ceilingTopBlock)
|
||||
blockPos.set(blockPos.getX(), blockPos.getY() + 1, blockPos.getZ());
|
||||
else
|
||||
if (hasCeiling && topBlock)
|
||||
blockPos.set(blockPos.getX(), blockPos.getY() - 1, blockPos.getZ());
|
||||
else
|
||||
blockPos.set(blockPos.getX(), blockPos.getY() + 1, blockPos.getZ());
|
||||
|
||||
|
||||
if (!hasSkyLight && hasCeiling)
|
||||
{
|
||||
skyLight = 0;
|
||||
}
|
||||
else if(topBlock)
|
||||
{
|
||||
skyLight = 15; //default max light
|
||||
} else
|
||||
{
|
||||
if (chunk.isLightCorrect() && false)
|
||||
{
|
||||
skyLight = world.getBrightness(LightType.SKY, blockPos);
|
||||
} else
|
||||
{
|
||||
if (blockPos.getY() >= mc.getClientWorld().getSeaLevel()-5)
|
||||
{
|
||||
skyLight = 10;
|
||||
} else
|
||||
{
|
||||
skyLight = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockState blockState = chunk.getBlockState(blockPos);
|
||||
|
||||
blockLight = LodUtil.clamp(0, blockLight + blockState.getLightValue(chunk, blockPos), 15);
|
||||
blockLight = blockState.getLightValue(chunk, blockPos);
|
||||
blockLight = LodUtil.clamp(0, blockLight + blockBrightness, 15);
|
||||
|
||||
return blockLight + (skyLight << 4);
|
||||
}
|
||||
|
||||
|
||||
private int getColorTextureForBlock(BlockState blockState, BlockPos blockPos, boolean topTextureRequired)
|
||||
{
|
||||
Block block = blockState.getBlock();
|
||||
@@ -661,6 +674,7 @@ public class LodBuilder
|
||||
int blue = 0;
|
||||
int numberOfGreyPixel = 0;
|
||||
int color;
|
||||
int colorMultiplier;
|
||||
for (int k = 0; k < texture.getFrameCount(); k++)
|
||||
{
|
||||
for (int i = 0; i < texture.getHeight(); i++)
|
||||
@@ -670,17 +684,20 @@ public class LodBuilder
|
||||
if (texture.isTransparent(k, i, j))
|
||||
continue;
|
||||
color = texture.getPixelRGBA(k, i, j);
|
||||
if(Math.max(Math.max(ColorUtil.getBlue(color),ColorUtil.getGreen(color)),ColorUtil.getRed(color)) < 4 + Math.min(Math.min(ColorUtil.getBlue(color),ColorUtil.getGreen(color)),ColorUtil.getRed(color)))
|
||||
if (Math.max(Math.max(ColorUtil.getBlue(color), ColorUtil.getGreen(color)), ColorUtil.getRed(color)) < 4 + Math.min(Math.min(ColorUtil.getBlue(color), ColorUtil.getGreen(color)), ColorUtil.getRed(color)))
|
||||
{
|
||||
numberOfGreyPixel++;
|
||||
}
|
||||
if (block instanceof FlowerBlock && ColorUtil.getGreen(color) > (ColorUtil.getBlue(color) + 30) && ColorUtil.getGreen(color) > (ColorUtil.getRed(color) + 30))
|
||||
continue;
|
||||
count++;
|
||||
alpha += ColorUtil.getAlpha(color);
|
||||
red += ColorUtil.getBlue(color);
|
||||
green += ColorUtil.getGreen(color);
|
||||
blue += ColorUtil.getRed(color);
|
||||
if (block instanceof FlowerBlock && (!(ColorUtil.getGreen(color) > (ColorUtil.getBlue(color) + 30)) || !(ColorUtil.getGreen(color) > (ColorUtil.getRed(color) + 30))))
|
||||
colorMultiplier = 5;
|
||||
else
|
||||
colorMultiplier = 1;
|
||||
count = colorMultiplier + count;
|
||||
alpha += ColorUtil.getAlpha(color) * colorMultiplier;
|
||||
;
|
||||
red += ColorUtil.getBlue(color) * colorMultiplier;
|
||||
green += ColorUtil.getGreen(color) * colorMultiplier;
|
||||
blue += ColorUtil.getRed(color) * colorMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -697,7 +714,7 @@ public class LodBuilder
|
||||
}
|
||||
if (blockState.getBlock().equals(Blocks.TALL_GRASS))
|
||||
System.out.println(ColorUtil.toString(color) + " " + numberOfGreyPixel + " " + count);
|
||||
if (block instanceof TallGrassBlock || (couldHaveGrassTint(block) || couldHaveLeavesTint(block) || couldHaveWaterTint(block)) && (float) (numberOfGreyPixel/count) > 0.75f)
|
||||
if (block instanceof TallGrassBlock || (couldHaveGrassTint(block) || couldHaveLeavesTint(block) || couldHaveWaterTint(block)) && (float) (numberOfGreyPixel / count) > 0.75f)
|
||||
{
|
||||
toTint.replace(block, true);
|
||||
}
|
||||
|
||||
@@ -118,33 +118,67 @@ public class LodWorldGenerator
|
||||
byte detailLevel;
|
||||
int posX;
|
||||
int posZ;
|
||||
boolean nearOrFar = true;
|
||||
boolean stopSwitch = false;
|
||||
int near = 0;
|
||||
int far = 0;
|
||||
|
||||
for (int index = 0; index < posToGenerate.getNumberOfPos(); index++)
|
||||
{
|
||||
if(posToGenerate.getNthDetail(index) == 0)
|
||||
continue;
|
||||
detailLevel = (byte) (posToGenerate.getNthDetail(index) - 1);
|
||||
posX = posToGenerate.getNthPosX(index);
|
||||
posZ = posToGenerate.getNthPosZ(index);
|
||||
|
||||
ChunkPos chunkPos = new ChunkPos(LevelPosUtil.getChunkPos(detailLevel,posX), LevelPosUtil.getChunkPos(detailLevel,posZ));
|
||||
if (numberOfChunksWaitingToGenerate.get() < maxChunkGenRequests)
|
||||
if (posToGenerate.getNthDetail(near, true) != 0 && far < posToGenerate.getNumberOfNearPos())
|
||||
{
|
||||
// prevent generating the same chunk multiple times
|
||||
if (positionWaitingToBeGenerated.contains(chunkPos))
|
||||
detailLevel = (byte) (posToGenerate.getNthDetail(near, true) - 1);
|
||||
posX = posToGenerate.getNthPosX(near, true);
|
||||
posZ = posToGenerate.getNthPosZ(near, true);
|
||||
near++;
|
||||
ChunkPos chunkPos = new ChunkPos(LevelPosUtil.getChunkPos(detailLevel, posX), LevelPosUtil.getChunkPos(detailLevel, posZ));
|
||||
if (numberOfChunksWaitingToGenerate.get() < maxChunkGenRequests)
|
||||
{
|
||||
continue;
|
||||
// prevent generating the same chunk multiple times
|
||||
if (positionWaitingToBeGenerated.contains(chunkPos))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// don't add null chunkPos (which shouldn't happen anyway)
|
||||
// or add more to the generation queue
|
||||
if (chunkPos == null || numberOfChunksWaitingToGenerate.get() >= maxChunkGenRequests)
|
||||
continue;
|
||||
|
||||
positionWaitingToBeGenerated.add(chunkPos);
|
||||
numberOfChunksWaitingToGenerate.addAndGet(1);
|
||||
LodNodeGenWorker genWorker = new LodNodeGenWorker(chunkPos, DetailDistanceUtil.getDistanceGenerationMode(detailLevel), lodBuilder, lodDim, serverWorld);
|
||||
WorldWorkerManager.addWorker(genWorker);
|
||||
}
|
||||
|
||||
// don't add null chunkPos (which shouldn't happen anyway)
|
||||
// or add more to the generation queue
|
||||
if (chunkPos == null || numberOfChunksWaitingToGenerate.get() >= maxChunkGenRequests)
|
||||
continue;
|
||||
|
||||
positionWaitingToBeGenerated.add(chunkPos);
|
||||
numberOfChunksWaitingToGenerate.addAndGet(1);
|
||||
LodNodeGenWorker genWorker = new LodNodeGenWorker(chunkPos, DetailDistanceUtil.getDistanceGenerationMode(detailLevel), lodBuilder, lodDim, serverWorld);
|
||||
WorldWorkerManager.addWorker(genWorker);
|
||||
if (posToGenerate.getNthDetail(far, false) != 0 && far < posToGenerate.getNumberOfFarPos())
|
||||
{
|
||||
detailLevel = (byte) (posToGenerate.getNthDetail(far, false) - 1);
|
||||
posX = posToGenerate.getNthPosX(far, false);
|
||||
posZ = posToGenerate.getNthPosZ(far, false);
|
||||
far++;
|
||||
ChunkPos chunkPos = new ChunkPos(LevelPosUtil.getChunkPos(detailLevel, posX), LevelPosUtil.getChunkPos(detailLevel, posZ));
|
||||
if (numberOfChunksWaitingToGenerate.get() < maxChunkGenRequests)
|
||||
{
|
||||
// prevent generating the same chunk multiple times
|
||||
if (positionWaitingToBeGenerated.contains(chunkPos))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// don't add null chunkPos (which shouldn't happen anyway)
|
||||
// or add more to the generation queue
|
||||
if (chunkPos == null || numberOfChunksWaitingToGenerate.get() >= maxChunkGenRequests)
|
||||
continue;
|
||||
|
||||
positionWaitingToBeGenerated.add(chunkPos);
|
||||
numberOfChunksWaitingToGenerate.addAndGet(1);
|
||||
LodNodeGenWorker genWorker = new LodNodeGenWorker(chunkPos, DetailDistanceUtil.getDistanceGenerationMode(detailLevel), lodBuilder, lodDim, serverWorld);
|
||||
WorldWorkerManager.addWorker(genWorker);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e)
|
||||
|
||||
@@ -534,8 +534,6 @@ public class LodDimension
|
||||
int numbChunksWide = (width) * 32 * 2;
|
||||
for (int i = 0; i < numbChunksWide * numbChunksWide; i++)
|
||||
{
|
||||
|
||||
|
||||
xChunkToCheck = x + playerChunkX;
|
||||
zChunkToCheck = z + playerChunkZ;
|
||||
//distance = LevelPosUtil.maxDistance(LodUtil.CHUNK_DETAIL_LEVEL, xChunkToCheck, zChunkToCheck, playerChunkX, playerChunkZ);
|
||||
@@ -564,7 +562,7 @@ public class LodDimension
|
||||
}
|
||||
break;
|
||||
case FAR_FIRST:
|
||||
posToGenerate = new PosToGenerateContainer((byte) 8, maxDataToGenerate, (int) (maxDataToGenerate * 0.25f), playerPosX, playerPosZ);
|
||||
posToGenerate = new PosToGenerateContainer((byte) 8, maxDataToGenerate, (int) (maxDataToGenerate * 0.25), playerPosX, playerPosZ);
|
||||
int n = regions.length;
|
||||
int xRegion;
|
||||
int zRegion;
|
||||
@@ -843,7 +841,7 @@ public class LodDimension
|
||||
|
||||
int minDistance = LevelPosUtil.minDistance(LodUtil.REGION_DETAIL_LEVEL, x, z, halfWidth, halfWidth);
|
||||
int detail = DetailDistanceUtil.getTreeCutDetailFromDistance(minDistance);
|
||||
int levelToGen = DetailDistanceUtil.getCutLodDetail(detail);
|
||||
int levelToGen = DetailDistanceUtil.getCutLodDetail(detail)+1;
|
||||
int size = 1 << (LodUtil.REGION_DETAIL_LEVEL - levelToGen);
|
||||
int maxVerticalData = DetailDistanceUtil.getMaxVerticalData(levelToGen);
|
||||
int numberOfLods = size * size * maxVerticalData;
|
||||
|
||||
@@ -273,7 +273,7 @@ public class LodRegion
|
||||
{
|
||||
if (doesDataExist(childDetailLevel, childPosX + x, childPosZ + z))
|
||||
{
|
||||
if (!requireCorrectDetailLevel && detailLevel > supposedLevel + 1)
|
||||
if (!requireCorrectDetailLevel)
|
||||
{
|
||||
childrenCount++;
|
||||
} else
|
||||
@@ -286,7 +286,7 @@ public class LodRegion
|
||||
|
||||
//If all the four children exist we go deeper
|
||||
|
||||
if(!requireCorrectDetailLevel && detailLevel > supposedLevel + 1)
|
||||
if(!requireCorrectDetailLevel)
|
||||
{
|
||||
if (childrenCount == 4)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,8 @@ public class PosToGenerateContainer
|
||||
maxNearSize--;
|
||||
}
|
||||
index = posToGenerate.length - farSize;
|
||||
while (index < posToGenerate.length - 1 && LevelPosUtil.compareLevelAndDistance(detailLevel, distance, (byte) (posToGenerate[index + 1][0] - 1), posToGenerate[index + 1][3]) <= 0)
|
||||
while (index < posToGenerate.length - 1 && LevelPosUtil.compareDistance(distance, posToGenerate[index + 1][3]) <= 0)
|
||||
//while (index < posToGenerate.length - 1 && LevelPosUtil.compareLevelAndDistance(detailLevel, distance, (byte) (posToGenerate[index + 1][0] - 1), posToGenerate[index + 1][3]) <= 0)
|
||||
{
|
||||
posToGenerate[index][0] = posToGenerate[index + 1][0];
|
||||
posToGenerate[index][1] = posToGenerate[index + 1][1];
|
||||
@@ -87,50 +88,43 @@ public class PosToGenerateContainer
|
||||
return nearSize+farSize;
|
||||
}
|
||||
|
||||
public int getNthDetail(int n)
|
||||
public int getNumberOfNearPos()
|
||||
{
|
||||
int index;
|
||||
if (n > farSize * 2)
|
||||
index = n - farSize;
|
||||
else if (n % 2 == 0)
|
||||
index = n / 2;
|
||||
else
|
||||
index = posToGenerate.length - n / 2 - 1;
|
||||
return posToGenerate[index][0];
|
||||
return nearSize;
|
||||
}
|
||||
|
||||
public int getNthPosX(int n)
|
||||
public int getNumberOfFarPos()
|
||||
{
|
||||
int index;
|
||||
if (n > farSize * 2)
|
||||
index = n - farSize;
|
||||
else if (n % 2 == 0)
|
||||
index = n / 2;
|
||||
else
|
||||
index = posToGenerate.length - n / 2 - 1;
|
||||
return posToGenerate[index][1];
|
||||
return farSize;
|
||||
}
|
||||
public int getNthPosZ(int n)
|
||||
|
||||
public int getNthDetail(int n, boolean near)
|
||||
{
|
||||
int index;
|
||||
if (n > farSize * 2)
|
||||
index = n - farSize;
|
||||
else if (n % 2 == 0)
|
||||
index = n / 2;
|
||||
if (near)
|
||||
return posToGenerate[n][0];
|
||||
else
|
||||
index = posToGenerate.length - n / 2 - 1;
|
||||
return posToGenerate[index][2];
|
||||
return posToGenerate[maxSize-1-n][0];
|
||||
}
|
||||
public int getNthGeneration(int n)
|
||||
public int getNthPosX(int n, boolean near)
|
||||
{
|
||||
int index;
|
||||
if (n > farSize * 2)
|
||||
index = n - farSize;
|
||||
else if (n % 2 == 0)
|
||||
index = n / 2;
|
||||
if (near)
|
||||
return posToGenerate[n][1];
|
||||
else
|
||||
index = posToGenerate.length - n / 2 - 1;
|
||||
return posToGenerate[index][3];
|
||||
return posToGenerate[maxSize-1-n][1];
|
||||
}
|
||||
public int getNthPosZ(int n, boolean near)
|
||||
{
|
||||
if (near)
|
||||
return posToGenerate[n][2];
|
||||
else
|
||||
return posToGenerate[maxSize-1-n][2];
|
||||
}
|
||||
public int getNthGeneration(int n, boolean near)
|
||||
{
|
||||
if (near)
|
||||
return posToGenerate[n][3];
|
||||
else
|
||||
return posToGenerate[maxSize-1-n][3];
|
||||
}
|
||||
|
||||
public String toString()
|
||||
|
||||
@@ -168,8 +168,14 @@ public class GlProxy
|
||||
|
||||
public static GlProxy getInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new GlProxy();
|
||||
try
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new GlProxy();
|
||||
}catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user