From 2241492bc5d765866ed7fc16b8bbee18a358e64a Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sun, 19 Sep 2021 22:08:30 +0200 Subject: [PATCH] there is a thunderstorm i don't want to loose progress --- .../seibel/lod/builders/LodBufferBuilder.java | 2 ++ .../com/seibel/lod/builders/LodBuilder.java | 33 ++++++++++--------- .../lod/objects/VerticalLevelContainer.java | 2 ++ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java b/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java index 45d443d7f..8fb2b3a27 100644 --- a/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java +++ b/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java @@ -303,6 +303,7 @@ public class LodBufferBuilder adjData.get(direction)[0] = lodDim.getSingleData(detailLevel, xAdj, zAdj); } else { + adjData.replace(direction, new long[DetailDistanceUtil.getMaxVerticalData(lodDim.getMaxVerticalData(detailLevel,posX,posZ))]); for (int verticalIndex = 0; verticalIndex < lodDim.getMaxVerticalData(detailLevel, xAdj, zAdj); verticalIndex++) adjData.get(direction)[verticalIndex] = lodDim.getData(detailLevel, xAdj, zAdj, verticalIndex); } @@ -326,6 +327,7 @@ public class LodBufferBuilder adjData.get(direction)[0] = lodDim.getSingleData(detailLevel, xAdj, zAdj); } else { + adjData.replace(direction, new long[DetailDistanceUtil.getMaxVerticalData(lodDim.getMaxVerticalData(detailLevel,posX,posZ))]); for (int verticalIndex = 0; verticalIndex < lodDim.getMaxVerticalData(detailLevel, xAdj, zAdj); verticalIndex++) adjData.get(direction)[verticalIndex] = lodDim.getData(detailLevel, xAdj, zAdj, verticalIndex); } diff --git a/src/main/java/com/seibel/lod/builders/LodBuilder.java b/src/main/java/com/seibel/lod/builders/LodBuilder.java index 7fdf912b1..08e8f6a96 100644 --- a/src/main/java/com/seibel/lod/builders/LodBuilder.java +++ b/src/main/java/com/seibel/lod/builders/LodBuilder.java @@ -88,7 +88,7 @@ public class LodBuilder public static final ConcurrentMap colorMap = new ConcurrentHashMap<>(); public static final ConcurrentMap shapeMap = new ConcurrentHashMap<>(); - public static final ModelDataMap dataMap = new ModelDataMap.Builder().build() ; + public static final ModelDataMap dataMap = new ModelDataMap.Builder().build(); /** * If no blocks are found in the area in determineBottomPointForArea return this @@ -134,7 +134,7 @@ public class LodBuilder // get the textures for blocks if (mc.getClientWorld() == null) return; - + DimensionType dim = world.dimensionType(); LodDimension lodDim; @@ -245,7 +245,7 @@ public class LodBuilder if (data.length == 0 || data == null) data = new long[]{DataPointUtil.EMPTY_DATA}; lodDim.clear(detailLevel, posX, posZ); - for(int verticalIndex = 0; (verticalIndex < data.length) && (verticalIndex < lodDim.getMaxVerticalData(detailLevel,posX,posZ)); verticalIndex++) + for (int verticalIndex = 0; (verticalIndex < data.length) && (verticalIndex < lodDim.getMaxVerticalData(detailLevel, posX, posZ)); verticalIndex++) { lodDim.addData(detailLevel, posX, @@ -254,7 +254,13 @@ public class LodBuilder data[verticalIndex], false, isServer); + long dataTest = lodDim.getData(detailLevel, + posX, + posZ, + verticalIndex); + System.out.println(DataPointUtil.toString(dataTest)); } + break; } @@ -321,21 +327,20 @@ public class LodBuilder //If the lod is at default, then we set this as void data if (height == DEFAULT_HEIGHT) { - dataToMerge[index*verticalData + 0] = DataPointUtil.createVoidDataPoint(generation); + dataToMerge[index * verticalData + 0] = DataPointUtil.createVoidDataPoint(generation); break; } yAbs = height - 1; // We search light on above air block depth = determineBottomPointFrom(chunk, config, xRel, zRel, yAbs, blockPos); - if(hasCeiling && 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 + } else { color = generateLodColor(chunk, config, xRel, yAbs, zRel, blockPos); blockPos.set(xAbs, yAbs + 1, zAbs); @@ -344,7 +349,7 @@ public class LodBuilder blockPos.set(xAbs, yAbs + 1, zAbs); light = getLightValue(chunk, blockPos, hasCeiling && topBlock); lightBlock = light & 0b1111; - if(!hasCeiling && topBlock) + if (!hasCeiling && topBlock) lightSky = 15; //default max light else lightSky = (light >> 4) & 0b1111; @@ -612,7 +617,7 @@ public class LodBuilder blockLight = world.getBrightness(LightType.BLOCK, blockPos); skyLight = world.getBrightness(LightType.SKY, blockPos); - if(ceilingTopBlock) + if (ceilingTopBlock) blockPos.set(blockPos.getX(), blockPos.getY() + 1, blockPos.getZ()); else blockPos.set(blockPos.getX(), blockPos.getY() - 1, blockPos.getZ()); @@ -632,19 +637,17 @@ public class LodBuilder World world = mc.getClientWorld(); TextureAtlasSprite texture; - if(topTextureRequired) + if (topTextureRequired) { List quad = ((IForgeBakedModel) mc.getModelManager().getBlockModelShaper().getBlockModel(blockState)).getQuads(blockState, Direction.UP, new Random(0), dataMap); if (!quad.isEmpty()) { texture = quad.get(0).getSprite(); - } - else + } else { texture = mc.getModelManager().getBlockModelShaper().getTexture(blockState, world, blockPos); } - } - else + } else { texture = mc.getModelManager().getBlockModelShaper().getTexture(blockState, world, blockPos); } @@ -667,7 +670,7 @@ public class LodBuilder /*if (blockState.getBlock() instanceof LeavesBlock) color = 0; else*/ - continue; + continue; } else { color = texture.getPixelRGBA(k, i, j); diff --git a/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java b/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java index dd461acc9..3fc830779 100644 --- a/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java +++ b/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java @@ -69,6 +69,8 @@ public class VerticalLevelContainer implements LevelContainer } public boolean doesItExist(int posX, int posZ){ + posX = LevelPosUtil.getRegionModule(detailLevel, posX); + posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); return DataPointUtil.doesItExist(getSingleData(posX,posZ)); }