diff --git a/src/main/java/com/seibel/lod/builders/LodBuilder.java b/src/main/java/com/seibel/lod/builders/LodBuilder.java
index 99faf7fe3..9e3673fa7 100644
--- a/src/main/java/com/seibel/lod/builders/LodBuilder.java
+++ b/src/main/java/com/seibel/lod/builders/LodBuilder.java
@@ -242,10 +242,17 @@ public class LodBuilder
BlockPos.Mutable blockPos = new BlockPos.Mutable(0, 0, 0);
int index = 0;
- dataToMerge = new long[size * size][1024];
+ if(dataToMerge == null){
+ dataToMerge = new long[size * size][DataPointUtil.WORLD_HEIGHT];
+ }
+ //dataToMerge = new long[size * size][1024];
+
for (index = 0; index < size * size; index++)
{
-
+ for(int i = 0; i < dataToMerge[index].length; i++)
+ {
+ dataToMerge[index][i] = 0;
+ }
xRel = Math.floorMod(index, size) + startX;
zRel = Math.floorDiv(index, size) + startZ;
xAbs = chunkPos.getMinBlockX() + xRel;
@@ -549,6 +556,12 @@ public class LodBuilder
} else if (blockState == Blocks.NETHERRACK.defaultBlockState())
{
colorInt = LodUtil.NETHERRACK_COLOR_INT;
+ } else if (blockState == Blocks.WARPED_NYLIUM.defaultBlockState())
+ {
+ colorInt = LodUtil.WARPED_NYLIUM_COLOR_INT;
+ } else if (blockState == Blocks.CRIMSON_NYLIUM.defaultBlockState())
+ {
+ colorInt = LodUtil.CRIMSON_NYLIUM_COLOR_INT;
} else if (blockState == Blocks.BEDROCK.defaultBlockState())
{
colorInt = getColorForBiome(x, z, biome);
diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java
index 3aa000667..7d590c7fb 100644
--- a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java
+++ b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java
@@ -62,21 +62,31 @@ public class CubicLodTemplate extends AbstractLodTemplate
posZ * width,
bufferCenterBlockPos);
int color;
- int time = (int) (MinecraftWrapper.INSTANCE.getPlayer().level.getDayTime() - 13000);
- if(time < 0)
+ boolean hasSkyLight = MinecraftWrapper.INSTANCE.getPlayer().level.dimensionType().hasSkyLight();
+ //USE THIS IN THE boolean hasCeiling = MinecraftWrapper.INSTANCE.getPlayer().level.dimensionType().hasCeiling();
+ if (hasSkyLight)
{
- color = DataPointUtil.getColor(data);
+ int time = (int) (MinecraftWrapper.INSTANCE.getPlayer().level.getDayTime() - 13000);
+ if (time < 0)
+ {
+ color = DataPointUtil.getColor(data);
+ } else
+ {
+ /*TODO implement a smoother transition for light from day to night */
+ color = DataPointUtil.getLightColor(data,4);
+ }
}else{
- /*TODO implement a smoother transition for light from day to night */
- color = DataPointUtil.getLightColor(data);
+ color = DataPointUtil.getLightColor(data,1);
}
if (debugging != DebugMode.OFF)
+
{
color = LodUtil.DEBUG_DETAIL_LEVEL_COLORS[detailLevel].getRGB();
}
if (box != null)
+
{
addBoundingBoxToBuffer(buffer, box, color, bufferCenterBlockPos, adjData);
}
@@ -100,7 +110,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
// it uses doubles to specify its location, unlike the model view matrix
// which only uses floats
double x = -bufferCenterBlockPos.getX();
- double z = -bufferCenterBlockPos.getZ();;
+ double z = -bufferCenterBlockPos.getZ();
box.set(width, height - depth, width);
box.move((int) (xOffset + x), (int) (yOffset + depth), (int) (zOffset + z));
}
@@ -217,7 +227,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
addPosAndColor(buffer, minX, minY, maxZ, red, green, blue, alpha);
addPosAndColor(buffer, minX, maxY, maxZ, red, green, blue, alpha);
addPosAndColor(buffer, minX, maxY, minZ, red, green, blue, alpha);
- }else
+ } else
{
maxY = box.getMaxY();
tempMaxY = DataPointUtil.getHeight(data);
@@ -262,8 +272,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
addPosAndColor(buffer, maxX, maxY, maxZ, red, green, blue, alpha);
addPosAndColor(buffer, maxX, minY, maxZ, red, green, blue, alpha);
addPosAndColor(buffer, maxX, minY, minZ, red, green, blue, alpha);
- }
- else
+ } else
{
maxY = box.getMaxY();
tempMaxY = DataPointUtil.getHeight(data);
@@ -308,8 +317,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
addPosAndColor(buffer, maxX, maxY, maxZ, red, green, blue, alpha);
addPosAndColor(buffer, minX, maxY, maxZ, red, green, blue, alpha);
addPosAndColor(buffer, minX, minY, maxZ, red, green, blue, alpha);
- }
- else
+ } else
{
maxY = box.getMaxY();
tempMaxY = DataPointUtil.getHeight(data);
@@ -354,8 +362,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
addPosAndColor(buffer, minX, maxY, minZ, red, green, blue, alpha);
addPosAndColor(buffer, maxX, maxY, minZ, red, green, blue, alpha);
addPosAndColor(buffer, maxX, minY, minZ, red, green, blue, alpha);
- }
- else
+ } else
{
maxY = box.getMaxY();
tempMaxY = DataPointUtil.getHeight(data);
diff --git a/src/main/java/com/seibel/lod/util/DataPointUtil.java b/src/main/java/com/seibel/lod/util/DataPointUtil.java
index 04f38227b..33aab8e5c 100644
--- a/src/main/java/com/seibel/lod/util/DataPointUtil.java
+++ b/src/main/java/com/seibel/lod/util/DataPointUtil.java
@@ -1,10 +1,6 @@
package com.seibel.lod.util;
import com.seibel.lod.enums.DistanceGenerationMode;
-import org.lwjgl.system.CallbackI;
-
-import java.lang.reflect.Array;
-import java.util.Arrays;
public class DataPointUtil
{
@@ -133,12 +129,12 @@ public class DataPointUtil
return (int) (dataPoint >>> COLOR_SHIFT);
}
- public static int getLightColor(long dataPoint)
+ public static int getLightColor(long dataPoint, int amp)
{
int lightBlock = getLightValue(dataPoint);
- int red = LodUtil.clamp(0, getRed(dataPoint) + lightBlock * 8, 255);
- int green = LodUtil.clamp(0, getGreen(dataPoint) + lightBlock * 8, 255);
- int blue = LodUtil.clamp(0, getBlue(dataPoint) + lightBlock * 4, 255);
+ int red = LodUtil.clamp(0, getRed(dataPoint) + lightBlock * amp, 255);
+ int green = LodUtil.clamp(0, getGreen(dataPoint) + lightBlock * amp, 255);
+ int blue = LodUtil.clamp(0, getBlue(dataPoint) + lightBlock * amp, 255);
return ColorUtil.rgbToInt(red, green, blue);
}
@@ -231,14 +227,16 @@ public class DataPointUtil
public static long[] mergeVerticalData(long[][] dataToMerge)
{
- boolean[] projection = new boolean[WORLD_HEIGHT + 1];
- int size = 0;
-
+ boolean[] projection = ThreadMapUtil.getProjection(WORLD_HEIGHT + 1);
+ int[][] heightAndDepth = ThreadMapUtil.getHeightAndDepth(WORLD_HEIGHT + 1);
+ long[] singleDataToMerge = ThreadMapUtil.getSingleAddDataToMerge(dataToMerge.length);
int genMode = DistanceGenerationMode.SERVER.complexity;
boolean allEmpty = true;
boolean allVoid = true;
long singleData;
+ for(int k=0; k < projection.length; k++)
+ projection[k] = false;
int depth = 0;
int height = 0;
//We collect the indexes of the data, ordered by the depth
@@ -278,7 +276,6 @@ public class DataPointUtil
int count = 0;
int i = 0;
- int[][] heightAndDepth = new int[projection.length][2];
while (i < projection.length)
{
while (i < projection.length && !projection[i])
@@ -303,7 +300,9 @@ public class DataPointUtil
{
depth = heightAndDepth[j][0];
height = heightAndDepth[j][1];
- long[] singleDataToMerge = new long[dataToMerge.length];
+ for(int k = 0; k < dataToMerge.length; k++){
+ singleDataToMerge[k] = 0;
+ }
for (int index = 0; index < dataToMerge.length; index++)
{
for (int dataIndex = 0; dataIndex < dataToMerge[index].length; dataIndex++)
@@ -314,8 +313,10 @@ public class DataPointUtil
if ((depth <= getDepth(singleData) && getDepth(singleData) <= height)
|| (depth <= getHeight(singleData) && getHeight(singleData) <= height))
{
- singleDataToMerge[index] = singleData;
- break;
+ if(getHeight(singleData) > getHeight(singleDataToMerge[index]))
+ {
+ singleDataToMerge[index] = singleData;
+ }
}
}
}
@@ -326,96 +327,6 @@ public class DataPointUtil
return dataPoint;
}
- /*
- public static long[] mergeVerticalData(long[][] dataToMerge)
- {
- int[][] dataCollector = new int[256][2];
- long[] singleDataToCollect = new long[256];
- int size = 0;
-
- int tempGenMode = DistanceGenerationMode.SERVER.complexity;
- boolean allEmpty = true;
- boolean allVoid = true;
- long singleData;
-
- //We collect the indexes of the data, ordered by the depth
- for (int index = 0; index < dataToMerge.length; index++)
- {
- for (int dataIndex = 0; dataIndex < dataToMerge[index].length; dataIndex++)
- {
- singleData = dataToMerge[index][dataIndex];
- if (doesItExist(singleData))
- {
- tempGenMode = Math.min(tempGenMode, getGenerationMode(singleData));
- allEmpty = false;
- if (!isItVoid(singleData))
- {
- allVoid = false;
- int j = size;
- while (j >= 0 && (getDepth(dataToMerge[dataCollector[j][0]][dataCollector[j][1]]) > getDepth(singleData)))
- {
- dataCollector[j] = dataCollector[j - 1];
- j = j - 1;
- }
- dataCollector[j][0] = index;
- dataCollector[j][1] = dataIndex;
- size++;
- }
- }
-
- }
- }
-
-
- //We check if there is any data that's not empty or void
- if (allEmpty)
- {
- return new long[]{EMPTY_DATA};
- }
- if (allVoid)
- {
- return new long[]{createVoidDataPoint(tempGenMode)};
- }
-
- //We merge together all the data
- int minDepth;
- int maxHeight = Integer.MIN_VALUE;
- int tempDepth;
- int tempHeight;
- int index = 0;
- int dataCount = 0;
- long[] singleDataToMerge = new long[dataToMerge.length];
- long[] newData = new long[256];
- while (index < size)
- {
- dataCount++;
- singleData = dataToMerge[dataCollector[index][0]][dataCollector[index][1]];
- minDepth = getDepth(singleData);
- maxHeight = getHeight(singleData);
- index++;
- while (index < size)
- {
- if(dataCollector[index][1] >= dataToMerge[dataCollector[index][0]].length)
- singleData = EMPTY_DATA;
- else
- singleData = dataToMerge[dataCollector[index][0]][dataCollector[index][1]];
- tempDepth = getDepth(singleData);
- tempHeight = getHeight(singleData);
- if (maxHeight >= tempDepth)
- {
- singleDataToMerge[dataCollector[index][0]] = singleData;
- maxHeight = tempHeight;
- index++;
- } else
- {
- break;
- }
- }
- singleData = mergeSingleData(singleDataToMerge);
- newData[dataCount] = createDataPoint(maxHeight, minDepth, getColor(singleData), getLightValue(singleData), getGenerationMode(singleData));
- }
- return Arrays.copyOf(newData, dataCount);
- }*/
public static long[] compress(long[] data, byte detailLevel)
{
diff --git a/src/main/java/com/seibel/lod/util/LodUtil.java b/src/main/java/com/seibel/lod/util/LodUtil.java
index 26e8faaf9..915eb7bab 100644
--- a/src/main/java/com/seibel/lod/util/LodUtil.java
+++ b/src/main/java/com/seibel/lod/util/LodUtil.java
@@ -64,6 +64,9 @@ public class LodUtil
* issue #64 */
public static final int STONE_COLOR_INT = LodUtil.colorToInt(new Color(150, 150, 150));
public static final int NETHERRACK_COLOR_INT = LodUtil.colorToInt(new Color(95, 38, 38));
+ public static final int WARPED_NYLIUM_COLOR_INT = LodUtil.colorToInt(new Color(34, 94, 85));
+ public static final int CRIMSON_NYLIUM_COLOR_INT = LodUtil.colorToInt(new Color(126, 27, 27));
+
/**
* In order of nearest to farthest:
* Red, Orange, Yellow, Green, Cyan, Blue, Magenta, white, gray, black
@@ -334,9 +337,9 @@ public class LodUtil
{
for (int z = centerChunk.z - chunkRenderDist; z < centerChunk.z + chunkRenderDist; z++)
{
- /*if (!lodDim.doesDataExist(LodUtil.CHUNK_DETAIL_LEVEL, x, z))
+ if (!lodDim.doesDataExist(LodUtil.CHUNK_DETAIL_LEVEL, x, z))
continue;
-
+ /*
long[] dataVertical = lodDim.getData(LodUtil.CHUNK_DETAIL_LEVEL, x, z);
long data = dataVertical[dataVertical.length - 1];
diff --git a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java
index 6b9588bae..39ea8f798 100644
--- a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java
+++ b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java
@@ -1,7 +1,5 @@
package com.seibel.lod.util;
-import com.seibel.lod.objects.LevelContainer;
-
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -18,6 +16,11 @@ public class ThreadMapUtil
public static final ConcurrentMap threadVerticalIndexesMap = new ConcurrentHashMap();
+ public static final ConcurrentMap projectionMap = new ConcurrentHashMap();
+ public static final ConcurrentMap heightAndDepthMap = new ConcurrentHashMap();
+ public static final ConcurrentMap singleDataToMergeMap = new ConcurrentHashMap();
+
+
public static long[] getSingleAddDataArray(){
if(!threadSingleAddDataMap.containsKey(Thread.currentThread().getName()) || (threadSingleAddDataMap.get(Thread.currentThread().getName()) == null))
{
@@ -91,4 +94,30 @@ public class ThreadMapUtil
}
return threadVerticalIndexesMap.get(Thread.currentThread().getName());
}
+
+
+
+ public static boolean[] getProjection(int size){
+ if(!projectionMap.containsKey(Thread.currentThread().getName()) || (projectionMap.get(Thread.currentThread().getName()) == null) || (projectionMap.get(Thread.currentThread().getName()).length != size))
+ {
+ projectionMap.put(Thread.currentThread().getName(), new boolean[size]);
+ }
+ return projectionMap.get(Thread.currentThread().getName());
+ }
+
+ public static int[][] getHeightAndDepth(int size){
+ if(!heightAndDepthMap.containsKey(Thread.currentThread().getName()) || (heightAndDepthMap.get(Thread.currentThread().getName()) == null) || (heightAndDepthMap.get(Thread.currentThread().getName()).length != size))
+ {
+ heightAndDepthMap.put(Thread.currentThread().getName(), new int[size][2]);
+ }
+ return heightAndDepthMap.get(Thread.currentThread().getName());
+ }
+
+ public static long[] getSingleAddDataToMerge(int size){
+ if(!singleDataToMergeMap.containsKey(Thread.currentThread().getName()) || (singleDataToMergeMap.get(Thread.currentThread().getName()) == null) || (singleDataToMergeMap.get(Thread.currentThread().getName()).length != size))
+ {
+ singleDataToMergeMap.put(Thread.currentThread().getName(), new long[size]);
+ }
+ return singleDataToMergeMap.get(Thread.currentThread().getName());
+ }
}