diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java index 15d3a1c9f..a15344653 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java @@ -85,11 +85,9 @@ public class CubicLodTemplate extends AbstractLodTemplate return; if (depth == height) - { // if the top and bottom points are at the same height // render this LOD as 1 block thick height++; - } // offset the AABB by its x/z position in the world since // it uses doubles to specify its location, unlike the model view matrix diff --git a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java index 718df8af2..c1dcbd18e 100644 --- a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java @@ -44,7 +44,6 @@ import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.Heightmap; import net.minecraftforge.client.model.data.ModelDataMap; import java.awt.*; @@ -71,7 +70,6 @@ public class LodBuilder public static final Direction[] directions = new Direction[] { Direction.UP, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.DOWN }; public static final int CHUNK_DATA_WIDTH = LodUtil.CHUNK_WIDTH; public static final int CHUNK_SECTION_HEIGHT = CHUNK_DATA_WIDTH; - public static final Heightmap.Type DEFAULT_HEIGHTMAP = Heightmap.Type.WORLD_SURFACE_WG; public static final ConcurrentMap colorMap = new ConcurrentHashMap<>(); public static final ConcurrentMap tintColor = new ConcurrentHashMap<>(); public static final ConcurrentMap toTint = new ConcurrentHashMap<>(); @@ -112,7 +110,7 @@ public class LodBuilder public void generateLodNodeAsync(IChunk chunk, LodWorld lodWorld, IWorld world, DistanceGenerationMode generationMode) { - if (lodWorld == null || !lodWorld.getIsWorldLoaded()) + if (lodWorld == null || lodWorld.getIsWorldNotLoaded()) return; // don't try to create an LOD object @@ -235,9 +233,7 @@ public class LodBuilder lodDim.updateData(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, chunk.getPos().z); } - /** - * creates a vertical DataPoint - */ + /** creates a vertical DataPoint */ private long[] createVerticalDataToMerge(HorizontalResolution detail, IChunk chunk, LodBuilderConfig config, int startX, int startZ, int endX, int endZ) { // equivalent to 2^detailLevel @@ -359,9 +355,7 @@ public class LodBuilder return depth; } - /** - * Find the highest valid point from the Top - */ + /** Find the highest valid point from the Top */ private short determineHeightPointFrom(IChunk chunk, LodBuilderConfig config, int xRel, int zRel, int yAbs, BlockPos.Mutable blockPos) { short height = DEFAULT_HEIGHT; @@ -431,9 +425,7 @@ public class LodBuilder return colorInt; } - /** - * Gets the light value for the given block position - */ + /** Gets the light value for the given block position */ private int getLightValue(IChunk chunk, BlockPos.Mutable blockPos, boolean hasCeiling, boolean hasSkyLight, boolean topBlock) { int skyLight; diff --git a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java index 9c2f6eafd..45606b781 100644 --- a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java +++ b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java @@ -105,10 +105,8 @@ public class ReflectionHandler case 0: // optifine's "default" option, // it should never be called in this case - return FogQuality.FAST; - - - // normal options + + // normal options case 1: return FogQuality.FAST; case 2: diff --git a/src/main/java/com/seibel/lod/objects/LodWorld.java b/src/main/java/com/seibel/lod/objects/LodWorld.java index 6c38ef78c..1e3d2d26c 100644 --- a/src/main/java/com/seibel/lod/objects/LodWorld.java +++ b/src/main/java/com/seibel/lod/objects/LodWorld.java @@ -150,9 +150,9 @@ public class LodWorld } - public boolean getIsWorldLoaded() + public boolean getIsWorldNotLoaded() { - return isWorldLoaded; + return !isWorldLoaded; } public String getWorldName() diff --git a/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java b/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java index bfbf30bf2..16b21fc4e 100644 --- a/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java +++ b/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java @@ -60,14 +60,10 @@ public class PosToRenderContainer public boolean contains(byte detailLevel, int posX, int posZ) { if (LevelPosUtil.getRegion(detailLevel, posX) == regionPosX && LevelPosUtil.getRegion(detailLevel, posZ) == regionPosZ) - { return (population[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posX, minDetail))] [LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posZ, minDetail))] == (detailLevel + 1)); - } else - { return false; - } } public void clear(byte minDetail, int regionPosX, int regionPosZ) diff --git a/src/main/java/com/seibel/lod/proxy/ClientProxy.java b/src/main/java/com/seibel/lod/proxy/ClientProxy.java index 463fd9baf..fc1e4dee2 100644 --- a/src/main/java/com/seibel/lod/proxy/ClientProxy.java +++ b/src/main/java/com/seibel/lod/proxy/ClientProxy.java @@ -110,7 +110,7 @@ public class ClientProxy firstFrameSetup(); - if (mc == null || mc.getPlayer() == null || !lodWorld.getIsWorldLoaded()) + if (mc == null || mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded()) return; LodDimension lodDim = lodWorld.getLodDimension(mc.getCurrentDimension()); @@ -195,7 +195,7 @@ public class ClientProxy @SubscribeEvent public void serverTickEvent(TickEvent.ServerTickEvent event) { - if (mc == null || mc.getPlayer() == null || !lodWorld.getIsWorldLoaded()) + if (mc == null || mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded()) return; LodDimension lodDim = lodWorld.getLodDimension(mc.getPlayer().level.dimensionType()); diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index abcf8978d..2954fd6f4 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -722,10 +722,6 @@ public class LodRenderer switch (LodConfig.CLIENT.graphics.fogDistance.get()) { case NEAR_AND_FAR: - fogSettings.near.distance = FogDistance.NEAR; - fogSettings.far.distance = FogDistance.NEAR; - break; - case NEAR: fogSettings.near.distance = FogDistance.NEAR; fogSettings.far.distance = FogDistance.NEAR; @@ -739,14 +735,10 @@ public class LodRenderer break; case OFF: - fogSettings.near.quality = FogQuality.OFF; fogSettings.far.quality = FogQuality.OFF; break; - } - - return fogSettings; } diff --git a/src/main/java/com/seibel/lod/util/LevelPosUtil.java b/src/main/java/com/seibel/lod/util/LevelPosUtil.java index 4f67c36d1..142c9c6f9 100644 --- a/src/main/java/com/seibel/lod/util/LevelPosUtil.java +++ b/src/main/java/com/seibel/lod/util/LevelPosUtil.java @@ -164,9 +164,7 @@ public class LevelPosUtil boolean inXArea = playerPosX >= startPosX && playerPosX <= endPosX; boolean inZArea = playerPosZ >= startPosZ && playerPosZ <= endPosZ; if (inXArea && inZArea) - { return 0; - } else if (inXArea) { return Math.min( diff --git a/src/main/java/com/seibel/lod/util/LodUtil.java b/src/main/java/com/seibel/lod/util/LodUtil.java index 955d63e6a..9781c5f5f 100644 --- a/src/main/java/com/seibel/lod/util/LodUtil.java +++ b/src/main/java/com/seibel/lod/util/LodUtil.java @@ -80,29 +80,22 @@ public class LodUtil public static final Color[] DEBUG_DETAIL_LEVEL_COLORS = new Color[] { Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.WHITE, Color.GRAY, Color.BLACK }; - /** - * 512 blocks wide - */ - public static final byte REGION_DETAIL_LEVEL = 9; - /** - * 16 blocks wide - */ - public static final byte CHUNK_DETAIL_LEVEL = 4; - /** - * 1 block wide - */ - public static final byte BLOCK_DETAIL_LEVEL = 0; - - public static final byte DETAIL_OPTIONS = 10; + /** 512 blocks wide */ + public static final byte REGION_DETAIL_LEVEL = DETAIL_OPTIONS - 1; + /** 16 blocks wide */ + public static final byte CHUNK_DETAIL_LEVEL = 4; + /** 1 block wide */ + public static final byte BLOCK_DETAIL_LEVEL = 0; + public static final short MAX_VERTICAL_DATA = 4; /** * measured in Blocks
- * detail level 9 + * detail level max - 1 */ - public static final short REGION_WIDTH = 512; + public static final short REGION_WIDTH = 1 << REGION_DETAIL_LEVEL; /** * measured in Blocks
* detail level 4 @@ -115,10 +108,8 @@ public class LodUtil public static final short BLOCK_WIDTH = 1; - /** - * number of chunks wide - */ - public static final int REGION_WIDTH_IN_CHUNKS = 32; + /** number of chunks wide */ + public static final int REGION_WIDTH_IN_CHUNKS = REGION_WIDTH / CHUNK_WIDTH; /** @@ -194,9 +185,7 @@ public class LodUtil return returnWorld; } - /** - * Convert a 2D absolute position into a quad tree relative position. - */ + /** Convert a 2D absolute position into a quad tree relative position. */ public static RegionPos convertGenericPosToRegionPos(int x, int z, int detailLevel) { int relativePosX = Math.floorDiv(x, (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel)); @@ -205,9 +194,7 @@ public class LodUtil return new RegionPos(relativePosX, relativePosZ); } - /** - * Convert a 2D absolute position into a quad tree relative position. - */ + /** Convert a 2D absolute position into a quad tree relative position. */ public static int convertLevelPos(int pos, int currentDetailLevel, int targetDetailLevel) { return Math.floorDiv(pos, (int) Math.pow(2, targetDetailLevel - currentDetailLevel)); @@ -289,9 +276,7 @@ public class LodUtil } } - /** - * returns the server name, IP and game version. - */ + /** returns the server name, IP and game version. */ public static String getServerId() { ServerData server = mc.getCurrentServer(); @@ -304,9 +289,7 @@ public class LodUtil } - /** - * Convert a BlockColors int into a Color object. - */ + /** Convert a BlockColors int into a Color object */ public static Color intToColor(int num) { int filter = 0b11111111; @@ -318,9 +301,7 @@ public class LodUtil return new Color(red, green, blue); } - /** - * Convert a Color into a BlockColors object. - */ + /** Convert a Color into a BlockColors object. */ public static int colorToInt(Color color) { return color.getRGB(); diff --git a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java index ab8516c2d..b8e389990 100644 --- a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java +++ b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java @@ -9,6 +9,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import static com.seibel.lod.util.LodUtil.DETAIL_OPTIONS; + /** * Holds data used by specific threads so * the data doesn't have to be recreated every @@ -163,8 +165,8 @@ public class ThreadMapUtil { if (!verticalUpdate.containsKey(Thread.currentThread().getName()) || (verticalUpdate.get(Thread.currentThread().getName()) == null)) { - long[][] array = new long[10][]; - for (int i = 1; i < 10; i++) + long[][] array = new long[DETAIL_OPTIONS][]; + for (int i = 1; i < DETAIL_OPTIONS; i++) array[i] = new long[DetailDistanceUtil.getMaxVerticalData(i - 1) * 4]; verticalUpdate.put(Thread.currentThread().getName(), array); }