From 835beb607ddb8ae673f91cb693c3dc1d394490bb Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 9 Mar 2022 23:06:34 -0600 Subject: [PATCH 1/3] Close #207 (re-add brightness/contrast configs) --- .../java/com/seibel/lod/common/Config.java | 12 +++++++++- .../config/LodConfigWrapperSingleton.java | 24 +++++++++++++++++++ core | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index f3a3804d8..03b862f27 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -160,11 +160,21 @@ public class Config public static String _vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DESC; @ConfigAnnotations.Entry public static VanillaOverdraw vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DEFAULT; - + @ConfigAnnotations.FileComment public static String _useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DESC; @ConfigAnnotations.Entry public static boolean useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DESC; + @ConfigAnnotations.Entry + public static double brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DESC; + @ConfigAnnotations.Entry + public static double saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DEFAULT; /* @ConfigAnnotations.FileComment diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 789c7e686..e14915705 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -305,6 +305,30 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.useExtendedNearClipPlane").value = newUseExtendedNearClipPlane; ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.useExtendedNearClipPlane"); } + + @Override + public double getBrightnessMultiplier() + { + return Config.Client.Graphics.AdvancedGraphics.brightnessMultiplier; + } + @Override + public void setBrightnessMultiplier(double newBrightnessMultiplier) + { + ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.brightnessMultiplier").value = newBrightnessMultiplier; + ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.brightnessMultiplier"); + } + + @Override + public double getSaturationMultiplier() + { + return Config.Client.Graphics.AdvancedGraphics.saturationMultiplier; + } + @Override + public void setSaturationMultiplier(double newSaturationMultiplier) + { + ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.saturationMultiplier").value = newSaturationMultiplier; + ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.saturationMultiplier"); + } } } diff --git a/core b/core index c9cabd8a3..bca2b6180 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c9cabd8a321a63cbd971bfae41b54d224feb43c2 +Subproject commit bca2b61800b613b630def131e9c9f85f9736493d From b6a893085583e75da860950af22e57e23e7c498b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 18 Mar 2022 23:57:32 -0500 Subject: [PATCH 2/3] Add a config for the MultiDimension Similarity --- .../java/com/seibel/lod/common/Config.java | 9 ++++++++- .../config/LodConfigWrapperSingleton.java | 18 +++++++++++++++--- core | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index 03b862f27..b92a9c324 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -223,11 +223,18 @@ public class Config } - public static class Multiplayer { + public static class Multiplayer + { @ConfigAnnotations.FileComment public static String _serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DESC; @ConfigAnnotations.Entry public static ServerFolderNameMode serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DESC; + @ConfigAnnotations.Entry + public static double multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DEFAULT; + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index e14915705..756c11a9b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -3,7 +3,6 @@ package com.seibel.lod.common.wrappers.config; import com.seibel.lod.core.enums.config.*; import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.common.Config; /** @@ -432,8 +431,21 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.multiplayer.serverFolderNameMode").value = newServerFolderNameMode; ConfigGui.editSingleOption.saveOption("client.multiplayer.serverFolderNameMode"); } - - + + @Override + public double getMultiDimensionRequiredSimilarity() + { + return Config.Client.Multiplayer.multiDimensionRequiredSimilarity; + } + + @Override + public void setMultiDimensionRequiredSimilarity(double newMultiDimensionMinimumSimilarityPercent) + { + ConfigGui.editSingleOption.getEntry("client.multiplayer.multiDimensionMinimumSimilarityPercent").value = newMultiDimensionMinimumSimilarityPercent; + ConfigGui.editSingleOption.saveOption("client.multiplayer.multiDimensionMinimumSimilarityPercent"); + } + + } diff --git a/core b/core index bca2b6180..9fa7fa843 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit bca2b61800b613b630def131e9c9f85f9736493d +Subproject commit 9fa7fa843d442f199e74cb5c38cc2ef227c53950 From 6c7e1900a3f55941351b0b42316e6e84c265bbe3 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 19 Mar 2022 11:20:44 -0500 Subject: [PATCH 3/3] Merge in fog changes --- .../java/com/seibel/lod/common/Config.java | 193 ++++++-- .../common/wrappers/chunk/ChunkWrapper.java | 251 +++++----- .../config/LodConfigWrapperSingleton.java | 349 ++++++++++---- .../minecraft/MinecraftRenderWrapper.java | 438 +++++++++--------- .../common/wrappers/world/WorldWrapper.java | 66 +-- core | 2 +- 6 files changed, 810 insertions(+), 489 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index b92a9c324..d53063855 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -25,14 +25,18 @@ import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.*; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog.IHeightFog; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator; + /** * This handles any configuration the user has access to. * @author coolGi2007 * @version 12-12-2021 */ + public class Config //public class Config extends TinyConfig { @@ -50,12 +54,12 @@ public class Config // |-> Threads // |-> Buffers // |-> Debugging - + // Since the original config system uses forge stuff, that means we have to rewrite the whole config system - + @ConfigAnnotations.ScreenEntry public static Client client; - + @ConfigAnnotations.FileComment public static String _optionsButton = ILodConfigWrapperSingleton.IClient.OPTIONS_BUTTON_DESC; // I know this option should be in Client @@ -63,91 +67,184 @@ public class Config // Tough it is in client in the wrapper singleton @ConfigAnnotations.Entry public static boolean optionsButton = true; - + public static class Client { @ConfigAnnotations.ScreenEntry public static Graphics graphics; - + @ConfigAnnotations.ScreenEntry public static WorldGenerator worldGenerator; - + @ConfigAnnotations.ScreenEntry public static Multiplayer multiplayer; - + @ConfigAnnotations.ScreenEntry public static Advanced advanced; - - + + public static class Graphics { @ConfigAnnotations.ScreenEntry public static Quality quality; - + @ConfigAnnotations.ScreenEntry public static FogQuality fogQuality; - + @ConfigAnnotations.ScreenEntry public static AdvancedGraphics advancedGraphics; - - + + public static class Quality { @ConfigAnnotations.FileComment public static String _drawResolution = IQuality.DRAW_RESOLUTION_DESC; @ConfigAnnotations.Entry public static HorizontalResolution drawResolution = IQuality.DRAW_RESOLUTION_DEFAULT; - + @ConfigAnnotations.FileComment public static String _lodChunkRenderDistance = IQuality.LOD_CHUNK_RENDER_DISTANCE_DESC; @ConfigAnnotations.Entry(minValue = 16, maxValue = 2048) public static int lodChunkRenderDistance = IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX.defaultValue; - + @ConfigAnnotations.FileComment public static String _verticalQuality = IQuality.VERTICAL_QUALITY_DESC; @ConfigAnnotations.Entry public static VerticalQuality verticalQuality = IQuality.VERTICAL_QUALITY_DEFAULT; - + @ConfigAnnotations.FileComment public static String _horizontalScale = IQuality.HORIZONTAL_SCALE_DESC; @ConfigAnnotations.Entry(minValue = 2, maxValue = 32) public static int horizontalScale = IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.defaultValue; - + @ConfigAnnotations.FileComment public static String _horizontalQuality = IQuality.HORIZONTAL_SCALE_DESC; @ConfigAnnotations.Entry public static HorizontalQuality horizontalQuality = IQuality.HORIZONTAL_QUALITY_DEFAULT; - + @ConfigAnnotations.FileComment public static String _dropoffQuality = IQuality.DROPOFF_QUALITY_DESC; @ConfigAnnotations.Entry public static DropoffQuality dropoffQuality = IQuality.DROPOFF_QUALITY_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_DESC; + @ConfigAnnotations.Entry(minValue = 0, maxValue = 7) + public static int lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_MIN_DEFAULT_MAX.defaultValue; } - - + + public static class FogQuality { @ConfigAnnotations.FileComment public static String _fogDistance = IFogQuality.FOG_DISTANCE_DESC; @ConfigAnnotations.Entry public static FogDistance fogDistance = IFogQuality.FOG_DISTANCE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _fogDrawMode = IFogQuality.FOG_DRAW_MODE_DESC; @ConfigAnnotations.Entry public static FogDrawMode fogDrawMode = IFogQuality.FOG_DRAW_MODE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _fogColorMode = IFogQuality.FOG_COLOR_MODE_DESC; @ConfigAnnotations.Entry public static FogColorMode fogColorMode = IFogQuality.FOG_COLOR_MODE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DESC; @ConfigAnnotations.Entry public static boolean disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DEFAULT; + + @ConfigAnnotations.ScreenEntry + public static AdvancedFog advancedFog; + + public static class AdvancedFog { + static final double SQRT2 = 1.4142135623730951; + + @ConfigAnnotations.FileComment + public static String _farFogStart = IAdvancedFog.FAR_FOG_START_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double farFogStart = IAdvancedFog.FAR_FOG_START_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogEnd = IAdvancedFog.FAR_FOG_END_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double farFogEnd = IAdvancedFog.FAR_FOG_END_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogMin = IAdvancedFog.FAR_FOG_MIN_DESC; + @ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2) + public static double farFogMin = IAdvancedFog.FAR_FOG_MIN_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogMax = IAdvancedFog.FAR_FOG_MAX_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0) + public static double farFogMax = IAdvancedFog.FAR_FOG_MAX_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogType = IAdvancedFog.FAR_FOG_TYPE_DESC; + @ConfigAnnotations.Entry + public static FogSetting.FogType farFogType = IAdvancedFog.FAR_FOG_TYPE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_DESC; + @ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0) + public static double farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.ScreenEntry + public static HeightFog heightFog; + + public static class HeightFog { + + @ConfigAnnotations.FileComment + public static String _heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DESC; + @ConfigAnnotations.Entry + public static HeightFogMixMode heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DEFAULT; + @ConfigAnnotations.FileComment + public static String _heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DESC; + @ConfigAnnotations.Entry + public static HeightFogMode heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_DESC; + @ConfigAnnotations.Entry(minValue = -4096.0, maxValue = 4096.0) + public static double heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogStart = IHeightFog.HEIGHT_FOG_START_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double heightFogStart = IHeightFog.HEIGHT_FOG_START_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogEnd = IHeightFog.HEIGHT_FOG_END_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double heightFogEnd = IHeightFog.HEIGHT_FOG_END_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogMin = IHeightFog.HEIGHT_FOG_MIN_DESC; + @ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2) + public static double heightFogMin = IHeightFog.HEIGHT_FOG_MIN_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogMax = IHeightFog.HEIGHT_FOG_MAX_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0) + public static double heightFogMax = IHeightFog.HEIGHT_FOG_MAX_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DESC; + @ConfigAnnotations.Entry + public static FogSetting.FogType heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_DESC; + @ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0) + public static double heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; + + } + } } - + public static class AdvancedGraphics { @@ -155,7 +252,7 @@ public class Config public static String _disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DESC; @ConfigAnnotations.Entry public static boolean disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DEFAULT; - + @ConfigAnnotations.FileComment public static String _vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DESC; @ConfigAnnotations.Entry @@ -170,12 +267,12 @@ public class Config public static String _brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DESC; @ConfigAnnotations.Entry public static double brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DEFAULT; - + @ConfigAnnotations.FileComment public static String _saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DESC; @ConfigAnnotations.Entry public static double saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DEFAULT; - + /* @ConfigAnnotations.FileComment public static String _backsideCullingRange = IAdvancedGraphics.VANILLA_CULLING_RANGE_DESC; @@ -184,16 +281,16 @@ public class Config */ } } - - + + public static class WorldGenerator { @ConfigAnnotations.FileComment public static String _enableDistantGeneration = IWorldGenerator.ENABLE_DISTANT_GENERATION_DESC; @ConfigAnnotations.Entry public static boolean enableDistantGeneration = IWorldGenerator.ENABLE_DISTANT_GENERATION_DEFAULT; - -// @ConfigAnnotations.FileComment + + // @ConfigAnnotations.FileComment // public static String _distanceGenerationMode = IWorldGenerator.getDistanceGenerationModeDesc(); @ConfigAnnotations.Entry public static DistanceGenerationMode distanceGenerationMode = IWorldGenerator.DISTANCE_GENERATION_MODE_DEFAULT; @@ -221,8 +318,8 @@ public class Config @ConfigAnnotations.Entry public static BlocksToAvoid blocksToAvoid = IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT; } - - + + public static class Multiplayer { @ConfigAnnotations.FileComment @@ -236,65 +333,65 @@ public class Config public static double multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DEFAULT; } - - + + public static class Advanced { @ConfigAnnotations.ScreenEntry public static Threading threading; - + @ConfigAnnotations.ScreenEntry public static Debugging debugging; - + @ConfigAnnotations.ScreenEntry public static Buffers buffers; - - + + public static class Threading { @ConfigAnnotations.FileComment public static String _numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DESC; @ConfigAnnotations.Entry(minValue = 1, maxValue = 50) public static int numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue; - + @ConfigAnnotations.FileComment public static String _numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_DESC; @ConfigAnnotations.Entry(minValue = 1, maxValue = 50) public static int numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX.defaultValue; } - - + + public static class Debugging { @ConfigAnnotations.FileComment public static String _drawLods = IDebugging.DRAW_LODS_DESC; @ConfigAnnotations.Entry public static boolean drawLods = IDebugging.DRAW_LODS_DEFAULT; - + @ConfigAnnotations.FileComment public static String _debugMode = IDebugging.DEBUG_MODE_DESC; @ConfigAnnotations.Entry public static DebugMode debugMode = IDebugging.DEBUG_MODE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _enableDebugKeybindings = IDebugging.DEBUG_KEYBINDINGS_ENABLED_DESC; @ConfigAnnotations.Entry public static boolean enableDebugKeybindings = IDebugging.DEBUG_KEYBINDINGS_ENABLED_DEFAULT; } - - + + public static class Buffers { @ConfigAnnotations.FileComment public static String _gpuUploadMethod = IBuffers.GPU_UPLOAD_METHOD_DESC; @ConfigAnnotations.Entry public static GpuUploadMethod gpuUploadMethod = IBuffers.GPU_UPLOAD_METHOD_DEFAULT; - + @ConfigAnnotations.FileComment public static String _gpuUploadPerMegabyteInMilliseconds = IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DESC; @ConfigAnnotations.Entry(minValue = 0, maxValue = 50) public static int gpuUploadPerMegabyteInMilliseconds = IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DEFAULT.defaultValue; - + @ConfigAnnotations.FileComment public static String _rebuildTimes = IBuffers.REBUILD_TIMES_DESC; @ConfigAnnotations.Entry diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java index 2cd61bd18..0448c8524 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java @@ -1,5 +1,6 @@ package com.seibel.lod.common.wrappers.chunk; +import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.util.LevelPosUtil; import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; @@ -31,21 +32,21 @@ import net.minecraft.world.level.levelgen.Heightmap; */ public class ChunkWrapper implements IChunkWrapper { - private final ChunkAccess chunk; - private final LevelReader lightSource; - - - public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource) - { - this.chunk = chunk; - this.lightSource = lightSource; - } - - @Override - public int getHeight(){ - return chunk.getHeight(); - } - + private final ChunkAccess chunk; + private final LevelReader lightSource; + + + public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource) + { + this.chunk = chunk; + this.lightSource = lightSource; + } + + @Override + public int getHeight(){ + return chunk.getHeight(); + } + @Override public int getMinBuildHeight() { @@ -56,113 +57,129 @@ public class ChunkWrapper implements IChunkWrapper { return chunk.getMaxBuildHeight(); } - - @Override - public int getHeightMapValue(int xRel, int zRel) - { - return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel); - } - - @Override - public IBiomeWrapper getBiome(int x, int y, int z) - { - return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( - QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value()); - } - - @Override - public BlockDetailWrapper getBlockDetail(int x, int y, int z) { - BlockPos pos = new BlockPos(x,y,z); - BlockState blockState = chunk.getBlockState(pos); - BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); - return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; - } - - public ChunkAccess getChunk() { - return chunk; - } - - @Override - public int getChunkPosX(){ - return chunk.getPos().x; - } - - @Override - public int getChunkPosZ(){ - return chunk.getPos().z; - } - - @Override - public int getRegionPosX(){ - return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL); - } - - @Override - public int getRegionPosZ(){ - return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL); - } - - @Override - public int getMaxY(int x, int z) { - return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16)); - } - - @Override - public int getMaxX(){ - return chunk.getPos().getMaxBlockX(); - } - @Override - public int getMaxZ(){ - return chunk.getPos().getMaxBlockZ(); - } - @Override - public int getMinX(){ - return chunk.getPos().getMinBlockX(); - } - @Override - public int getMinZ() { - return chunk.getPos().getMinBlockZ(); - } - - @Override - public long getLongChunkPos() { - return chunk.getPos().toLong(); - } - - @Override - public boolean isLightCorrect(){ - //return true; - if (chunk instanceof LevelChunk) { - return ((LevelChunk) chunk).isClientLightReady(); - } - return chunk.isLightCorrect(); - } - - public boolean isWaterLogged(int x, int y, int z) - { - BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); - - //This type of block is always in water - return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock)) - && (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)); - } - - @Override - public int getEmittedBrightness(int x, int y, int z) - { - return chunk.getLightEmission(new BlockPos(x,y,z)); - } - + + @Override + public int getHeightMapValue(int xRel, int zRel) + { + return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel); + } + + @Override + public IBiomeWrapper getBiome(int x, int y, int z) + { + return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( + QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value()); + } + + @Override + public BlockDetailWrapper getBlockDetail(int x, int y, int z) { + BlockPos pos = new BlockPos(x,y,z); + BlockState blockState = chunk.getBlockState(pos); + BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; + } + + @Override + public BlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir) { + int fy = y+dir.getNormal().y; + if (fy < getMinBuildHeight() || fy > getMaxBuildHeight()) return null; + BlockPos pos = new BlockPos(x+dir.getNormal().x,fy,z+dir.getNormal().z); + BlockState blockState; + if (blockPosInsideChunk(x,y,z)) + blockState = chunk.getBlockState(pos); + else { + blockState = lightSource.getBlockState(pos); + } + if (blockState == null || blockState.isAir()) return null; + BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; + } + + public ChunkAccess getChunk() { + return chunk; + } + + @Override + public int getChunkPosX(){ + return chunk.getPos().x; + } + + @Override + public int getChunkPosZ(){ + return chunk.getPos().z; + } + + @Override + public int getRegionPosX(){ + return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL); + } + + @Override + public int getRegionPosZ(){ + return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL); + } + + @Override + public int getMaxY(int x, int z) { + return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16)); + } + + @Override + public int getMaxX(){ + return chunk.getPos().getMaxBlockX(); + } + @Override + public int getMaxZ(){ + return chunk.getPos().getMaxBlockZ(); + } + @Override + public int getMinX(){ + return chunk.getPos().getMinBlockX(); + } + @Override + public int getMinZ() { + return chunk.getPos().getMinBlockZ(); + } + + @Override + public long getLongChunkPos() { + return chunk.getPos().toLong(); + } + + @Override + public boolean isLightCorrect(){ + //return true; + if (chunk instanceof LevelChunk) { + return ((LevelChunk) chunk).isClientLightReady(); + } + return chunk.isLightCorrect(); + } + + public boolean isWaterLogged(int x, int y, int z) + { + BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); + + //This type of block is always in water + return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock)) + && (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)); + } + + @Override + public int getEmittedBrightness(int x, int y, int z) + { + return chunk.getLightEmission(new BlockPos(x,y,z)); + } + @Override public int getBlockLight(int x, int y, int z) { if (lightSource == null) return -1; - return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); + return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); } - + @Override public int getSkyLight(int x, int y, int z) { if (lightSource == null) return -1; - return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); + return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); } @Override @@ -176,10 +193,10 @@ public class ChunkWrapper implements IChunkWrapper } return true; } - + public LevelReader getColorResolver() { return lightSource; } - + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 756c11a9b..9c8f15889 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -15,47 +15,47 @@ import com.seibel.lod.common.Config; public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton { public static final LodConfigWrapperSingleton INSTANCE = new LodConfigWrapperSingleton(); - - + + private static final Client client = new Client(); @Override public IClient client() { return client; } - + public static class Client implements IClient { public final IGraphics graphics; public final IWorldGenerator worldGenerator; public final IMultiplayer multiplayer; public final IAdvanced advanced; - - + + @Override public IGraphics graphics() { return graphics; } - + @Override public IWorldGenerator worldGenerator() { return worldGenerator; } - + @Override public IMultiplayer multiplayer() { return multiplayer; } - + @Override public IAdvanced advanced() { return advanced; } - - + + @Override public boolean getOptionsButton() { @@ -67,8 +67,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("optionsButton").value = newOptionsButton; ConfigGui.editSingleOption.saveOption("optionsButton"); } - - + + //================// // Client Configs // //================// @@ -79,8 +79,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton multiplayer = new Multiplayer(); advanced = new Advanced(); } - - + + //==================// // Graphics Configs // //==================// @@ -89,36 +89,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton public final IQuality quality; public final IFogQuality fogQuality; public final IAdvancedGraphics advancedGraphics; - - - + + + @Override public IQuality quality() { return quality; } - + @Override public IFogQuality fogQuality() { return fogQuality; } - + @Override public IAdvancedGraphics advancedGraphics() { return advancedGraphics; } - - + + Graphics() { quality = new Quality(); fogQuality = new FogQuality(); advancedGraphics = new AdvancedGraphics(); } - - + + public static class Quality implements IQuality { @Override @@ -132,8 +132,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.drawResolution").value = newHorizontalResolution; ConfigGui.editSingleOption.saveOption("client.graphics.quality.drawResolution"); } - - + + @Override public int getLodChunkRenderDistance() { @@ -145,8 +145,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodChunkRenderDistance").value = newLodChunkRenderDistance; ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodChunkRenderDistance"); } - - + + @Override public VerticalQuality getVerticalQuality() { @@ -158,8 +158,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.verticalQuality").value = newVerticalQuality; ConfigGui.editSingleOption.saveOption("client.graphics.quality.verticalQuality"); } - - + + @Override public int getHorizontalScale() { @@ -171,8 +171,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalScale").value = newHorizontalScale; ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalScale"); } - - + + @Override public HorizontalQuality getHorizontalQuality() { @@ -194,11 +194,29 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.dropoffQuality").value = newDropoffQuality; ConfigGui.editSingleOption.saveOption("client.graphics.quality.dropoffQuality"); } + + @Override + public int getLodBiomeBlending() { + return Config.Client.Graphics.Quality.lodBiomeBlending; + } + + @Override + public void setLodBiomeBlending(int newLodBiomeBlending) { + ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodBiomeBlending").value = newLodBiomeBlending; + ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodBiomeBlending"); + } } - - + + public static class FogQuality implements IFogQuality { + public final IAdvancedFog advancedFog; + + FogQuality() + { + advancedFog = new AdvancedFog(); + } + @Override public FogDistance getFogDistance() { @@ -210,36 +228,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDistance").value = newFogDistance; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDistance"); } - - + + @Override public FogDrawMode getFogDrawMode() { return Config.Client.Graphics.FogQuality.fogDrawMode; } - + @Override public void setFogDrawMode(FogDrawMode setFogDrawMode) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDrawMode").value = setFogDrawMode; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDrawMode"); } - - + + @Override public FogColorMode getFogColorMode() { return Config.Client.Graphics.FogQuality.fogColorMode; } - + @Override public void setFogColorMode(FogColorMode newFogColorMode) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogColorMode").value = newFogColorMode; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogColorMode"); } - - + + @Override public boolean getDisableVanillaFog() { @@ -251,9 +269,170 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.disableVanillaFog").value = newDisableVanillaFog; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.disableVanillaFog"); } + + @Override + public IAdvancedFog advancedFog() { + return advancedFog; + } + + public static class AdvancedFog implements IAdvancedFog { + public final IHeightFog heightFog; + + public AdvancedFog() { + heightFog = new HeightFog(); + } + + @Override + public double getFarFogStart() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogStart; + } + @Override + public double getFarFogEnd() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogEnd; + } + @Override + public double getFarFogMin() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMin; + } + @Override + public double getFarFogMax() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax; + } + @Override + public FogSetting.FogType getFarFogType() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogType; + } + @Override + public double getFarFogDensity() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogDensity; + } + + @Override + public void setFarFogStart(double newFarFogStart) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogStart").value = newFarFogStart; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogStart"); + } + @Override + public void setFarFogEnd(double newFarFogEnd) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogEnd").value = newFarFogEnd; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogEnd"); + } + @Override + public void setFarFogMin(double newFarFogMin) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMin").value = newFarFogMin; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMin"); + } + @Override + public void setFarFogMax(double newFarFogMax) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMax").value = newFarFogMax; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMax"); + } + @Override + public void setFarFogType(FogSetting.FogType newFarFogType) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogType").value = newFarFogType; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogType"); + } + @Override + public void setFarFogDensity(double newFarFogDensity) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogDensity").value = newFarFogDensity; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogDensity"); + } + + @Override + public IHeightFog heightFog() { + return heightFog; + } + + public static class HeightFog implements IHeightFog { + + @Override + public HeightFogMixMode getHeightFogMixMode() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMixMode; + } + @Override + public HeightFogMode getHeightFogMode() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMode; + } + @Override + public double getHeightFogHeight() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogHeight; + } + @Override + public double getHeightFogStart() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogStart; + } + @Override + public double getHeightFogEnd() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogEnd; + } + @Override + public double getHeightFogMin() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMin; + } + @Override + public double getHeightFogMax() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMax; + } + @Override + public FogSetting.FogType getHeightFogType() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogType; + } + @Override + public double getHeightFogDensity() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogDensity; + } + + @Override + public void setHeightFogMixMode(HeightFogMixMode newHeightFogMixMode) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode").value = newHeightFogMixMode; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode"); + } + @Override + public void setHeightFogMode(HeightFogMode newHeightFogMode) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode").value = newHeightFogMode; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode"); + } + @Override + public void setHeightFogHeight(double newHeightFogHeight) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight").value = newHeightFogHeight; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight"); + } + @Override + public void setHeightFogStart(double newHeightFogStart) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart").value = newHeightFogStart; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart"); + } + @Override + public void setHeightFogEnd(double newHeightFogEnd) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd").value = newHeightFogEnd; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd"); + } + @Override + public void setHeightFogMin(double newHeightFogMin) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin").value = newHeightFogMin; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin"); + } + @Override + public void setHeightFogMax(double newHeightFogMax) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax").value = newHeightFogMax; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax"); + } + @Override + public void setHeightFogType(FogSetting.FogType newHeightFogType) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogType").value = newHeightFogType; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogType"); + } + @Override + public void setHeightFogDensity(double newHeightFogDensity) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity").value = newHeightFogDensity; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity"); + } + } + } + } - - + + public static class AdvancedGraphics implements IAdvancedGraphics { @Override @@ -267,8 +446,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.disableDirectionalCulling").value = newDisableDirectionalCulling; ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.disableDirectionalCulling"); } - - + + @Override public VanillaOverdraw getVanillaOverdraw() { @@ -330,10 +509,10 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton } } } - - - - + + + + //========================// // WorldGenerator Configs // //========================// @@ -350,8 +529,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.worldGenerator.generationPriority").value = newGenerationPriority; ConfigGui.editSingleOption.saveOption("client.worldGenerator.generationPriority"); } - - + + @Override public DistanceGenerationMode getDistanceGenerationMode() { @@ -376,8 +555,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.worldGenerator.allowUnstableFeatureGeneration").value = newAllowUnstableFeatureGeneration; ConfigGui.editSingleOption.saveOption("client.worldGenerator.allowUnstableFeatureGeneration"); }*/ - - + + @Override public BlocksToAvoid getBlocksToAvoid() { @@ -412,9 +591,9 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.worldGenerator.lightGenerationMode"); } } - - - + + + //=====================// // Multiplayer Configs // //=====================// @@ -447,9 +626,9 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton } - - - + + + //============================// // AdvancedModOptions Configs // //============================// @@ -458,36 +637,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton public final IThreading threading; public final IDebugging debugging; public final IBuffers buffers; - - + + @Override public IThreading threading() { return threading; } - - + + @Override public IDebugging debugging() { return debugging; } - - + + @Override public IBuffers buffers() { return buffers; } - - + + public Advanced() { threading = new Threading(); debugging = new Debugging(); buffers = new Buffers(); } - + public static class Threading implements IThreading { @Override @@ -501,8 +680,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.threading.numberOfWorldGenerationThreads").value = newNumberOfWorldGenerationThreads; ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfWorldGenerationThreads"); } - - + + @Override public int getNumberOfBufferBuilderThreads() { @@ -515,10 +694,10 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfBufferBuilderThreads"); } } - - - - + + + + //===============// // Debug Options // //===============// @@ -535,8 +714,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value = newDrawLods; ConfigGui.editSingleOption.saveOption("client.advanced.debugging.drawLods"); } - - + + @Override public DebugMode getDebugMode() { @@ -548,8 +727,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugMode").value = newDebugMode; ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugMode"); } - - + + @Override public boolean getDebugKeybindingsEnabled() { @@ -562,11 +741,11 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.advanced.debugging.enableDebugKeybindings"); } } - - + + public static class Buffers implements IBuffers { - + @Override public GpuUploadMethod getGpuUploadMethod() { @@ -578,8 +757,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadMethod").value = newDisableVanillaFog; ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadMethod"); } - - + + @Override public int getGpuUploadPerMegabyteInMilliseconds() { @@ -590,8 +769,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds").value = newMilliseconds; ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds"); } - - + + @Override public BufferRebuildTimes getRebuildTimes() { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java index e54ad7d93..f8f92d279 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.stream.Collectors; +import com.mojang.blaze3d.pipeline.RenderTarget; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; import com.seibel.lod.common.wrappers.misc.LightMapWrapper; @@ -24,7 +25,6 @@ import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; import com.seibel.lod.common.wrappers.McObjectConverter; @@ -54,103 +54,123 @@ import net.minecraft.world.phys.Vec3; */ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { - public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper(); - - private static final Minecraft MC = Minecraft.getInstance(); - private static final GameRenderer GAME_RENDERER = MC.gameRenderer; - private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE; - - @Override - public Vec3f getLookAtVector() - { - Camera camera = GAME_RENDERER.getMainCamera(); - Vector3f cameraDir = camera.getLookVector(); - return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z()); - } - - @Override - public AbstractBlockPosWrapper getCameraBlockPosition() - { - Camera camera = GAME_RENDERER.getMainCamera(); - BlockPos blockPos = camera.getBlockPosition(); - return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - } - - @Override - public boolean playerHasBlindnessEffect() - { - return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null; - } - - @Override - public Vec3d getCameraExactPosition() - { - Camera camera = GAME_RENDERER.getMainCamera(); - Vec3 projectedView = camera.getPosition(); - - return new Vec3d(projectedView.x, projectedView.y, projectedView.z); - } - - @Override - public Mat4f getDefaultProjectionMatrix(float partialTicks) - { - return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true))); - } - - @Override - public double getGamma() - { - return MC.options.gamma; - } - - @Override - public Color getFogColor(float partialTicks) { - FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks)); - float[] colorValues = RenderSystem.getShaderFogColor(); - return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]); - } - // getSpecialFogColor() is the same as getFogColor() - - @Override - public Color getSkyColor() { - if (MC.level.dimensionType().hasSkyLight()) { - Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime()); - return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); - } else - return new Color(0, 0, 0); - } - - @Override - public double getFov(float partialTicks) - { - return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true); - } - - /** Measured in chunks */ - @Override - public int getRenderDistance() - { - return MC.options.renderDistance; - } - - @Override - public int getScreenWidth() - { - return MC.getWindow().getWidth(); - } - @Override - public int getScreenHeight() - { - return MC.getWindow().getHeight(); - } - - /** - * This method returns the ChunkPos of all chunks that Minecraft - * is going to render this frame.

- *

- */ - - public boolean usingBackupGetVanillaRenderedChunks = false; + public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper(); + + private static final Minecraft MC = Minecraft.getInstance(); + private static final GameRenderer GAME_RENDERER = MC.gameRenderer; + private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE; + + @Override + public Vec3f getLookAtVector() + { + Camera camera = GAME_RENDERER.getMainCamera(); + Vector3f cameraDir = camera.getLookVector(); + return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z()); + } + + @Override + public AbstractBlockPosWrapper getCameraBlockPosition() + { + Camera camera = GAME_RENDERER.getMainCamera(); + BlockPos blockPos = camera.getBlockPosition(); + return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + } + + @Override + public boolean playerHasBlindnessEffect() + { + return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null; + } + + @Override + public Vec3d getCameraExactPosition() + { + Camera camera = GAME_RENDERER.getMainCamera(); + Vec3 projectedView = camera.getPosition(); + + return new Vec3d(projectedView.x, projectedView.y, projectedView.z); + } + + @Override + public Mat4f getDefaultProjectionMatrix(float partialTicks) + { + return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true))); + } + + @Override + public double getGamma() + { + return MC.options.gamma; + } + + @Override + public Color getFogColor(float partialTicks) { + FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks)); + float[] colorValues = RenderSystem.getShaderFogColor(); + return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]); + } + // getSpecialFogColor() is the same as getFogColor() + + @Override + public Color getSkyColor() { + if (MC.level.dimensionType().hasSkyLight()) { + Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime()); + return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); + } else + return new Color(0, 0, 0); + } + + @Override + public double getFov(float partialTicks) + { + return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true); + } + + /** Measured in chunks */ + @Override + public int getRenderDistance() + { + return MC.options.getEffectiveRenderDistance(); + } + + @Override + public int getScreenWidth() + { + return MC.getWindow().getWidth(); + } + @Override + public int getScreenHeight() + { + return MC.getWindow().getHeight(); + } + + private RenderTarget getRenderTarget() { + RenderTarget r = null; //MC.levelRenderer.getCloudsTarget(); + return r!=null ? r : MC.getMainRenderTarget(); + } + + @Override + public int getTargetFrameBuffer() { + return getRenderTarget().frameBufferId; + } + + @Override + public int getTargetFrameBufferViewportWidth() { + return getRenderTarget().viewWidth; + } + + @Override + public int getTargetFrameBufferViewportHeight() { + return getRenderTarget().viewHeight; + } + + /** + * This method returns the ChunkPos of all chunks that Minecraft + * is going to render this frame.

+ *

+ */ + + public boolean usingBackupGetVanillaRenderedChunks = true; @Override public HashSet getVanillaRenderedChunks() { @@ -169,51 +189,51 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper } if (!usingBackupGetVanillaRenderedChunks) { try { - LevelRenderer levelRenderer = MC.levelRenderer; - LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; - return (chunks.stream().map((chunk) -> { - AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); - return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), - Math.floorDiv((int) chunkBoundingBox.minZ, 16)); - }).collect(Collectors.toCollection(HashSet::new))); + LevelRenderer levelRenderer = MC.levelRenderer; + LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; + return (chunks.stream().map((chunk) -> { + AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); + return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), + Math.floorDiv((int) chunkBoundingBox.minZ, 16)); + }).collect(Collectors.toCollection(HashSet::new))); } catch (LinkageError e) { try { - MinecraftClientWrapper.INSTANCE.sendChatMessage( + MinecraftClientWrapper.INSTANCE.sendChatMessage( "\u00A7e\u00A7l\u00A7uWARNING: Distant Horizons: getVanillaRenderedChunks method failed." - + " Using Backup Method."); - MinecraftClientWrapper.INSTANCE.sendChatMessage( + + " Using Backup Method."); + MinecraftClientWrapper.INSTANCE.sendChatMessage( "\u00A7eOverdraw prevention will be worse than normal."); } catch (Exception e2) {} - ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e); + ApiShared.LOGGER.error("getVanillaRenderedChunks Error: ", e); usingBackupGetVanillaRenderedChunks = true; } } return getMaximumRenderedChunks(); } - - @Override - public int[] getLightmapPixels() - { - LightTexture tex = GAME_RENDERER.lightTexture(); - tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug - NativeImage lightMapPixels = tex.lightPixels; - LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels); - - - int lightMapHeight = getLightmapTextureHeight(); - int lightMapWidth = getLightmapTextureWidth(); - - int[] pixels = new int[lightMapWidth * lightMapHeight]; - for (int u = 0; u < lightMapWidth; u++) - { - for (int v = 0; v < lightMapWidth; v++) - { - // this could probably be kept as a int, but - // it is easier to test and see the colors when debugging this way. - // When creating a new release this should be changed to the int version. - Color c = LodUtil.intToColor(lightMap.getLightValue(u, v)); - - // these should both create a totally white image + + @Override + public int[] getLightmapPixels() + { + LightTexture tex = GAME_RENDERER.lightTexture(); + tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug + NativeImage lightMapPixels = tex.lightPixels; + LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels); + + + int lightMapHeight = getLightmapTextureHeight(); + int lightMapWidth = getLightmapTextureWidth(); + + int[] pixels = new int[lightMapWidth * lightMapHeight]; + for (int u = 0; u < lightMapWidth; u++) + { + for (int v = 0; v < lightMapWidth; v++) + { + // this could probably be kept as a int, but + // it is easier to test and see the colors when debugging this way. + // When creating a new release this should be changed to the int version. + Color c = LodUtil.intToColor(lightMap.getLightValue(u, v)); + + // these should both create a totally white image // int col = // Integer.MAX_VALUE; // int col = @@ -221,82 +241,82 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper // (0b11111111 << 8) + // green // (0b11111111 << 16) + // blue // (0b11111111 << 24); // blue - - int col = - ((c.getRed() & 0xFF) << 16) | // blue - ((c.getGreen() & 0xFF) << 8) | // green - ((c.getBlue() & 0xFF)) | // red - ((c.getAlpha() & 0xFF) << 24); // alpha - - // 2D array stored in a 1D array. - // Thank you Tim from College ;) - pixels[u * lightMapWidth + v] = col; - } - } - - return pixels; - } - - - @Override - public int getLightmapTextureHeight() - { - int height = -1; - - LightTexture lightTexture = GAME_RENDERER.lightTexture(); - if (lightTexture != null) - { - NativeImage tex = lightTexture.lightPixels; - if (tex != null) - { - height = tex.getHeight(); - } - } - - return height; - } - - @Override - public int getLightmapTextureWidth() - { - int width = -1; - - LightTexture lightTexture = GAME_RENDERER.lightTexture(); - if (lightTexture != null) - { - NativeImage tex = lightTexture.lightPixels; - if (tex != null) - { - width = tex.getWidth(); - } - } - - return width; - } - - - @Override - public int getLightmapGLFormat() { - int glFormat = -1; - - LightTexture lightTexture = GAME_RENDERER.lightTexture(); - if (lightTexture != null) { - NativeImage tex = lightTexture.lightPixels; - if (tex != null) { - glFormat = tex.format().glFormat(); - } - } - - return glFormat; - } - - @Override - public boolean isFogStateSpecial() { - Entity entity = GAME_RENDERER.getMainCamera().getEntity(); - boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS); - return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind; - } - + + int col = + ((c.getRed() & 0xFF) << 16) | // blue + ((c.getGreen() & 0xFF) << 8) | // green + ((c.getBlue() & 0xFF)) | // red + ((c.getAlpha() & 0xFF) << 24); // alpha + + // 2D array stored in a 1D array. + // Thank you Tim from College ;) + pixels[u * lightMapWidth + v] = col; + } + } + + return pixels; + } + + + @Override + public int getLightmapTextureHeight() + { + int height = -1; + + LightTexture lightTexture = GAME_RENDERER.lightTexture(); + if (lightTexture != null) + { + NativeImage tex = lightTexture.lightPixels; + if (tex != null) + { + height = tex.getHeight(); + } + } + + return height; + } + + @Override + public int getLightmapTextureWidth() + { + int width = -1; + + LightTexture lightTexture = GAME_RENDERER.lightTexture(); + if (lightTexture != null) + { + NativeImage tex = lightTexture.lightPixels; + if (tex != null) + { + width = tex.getWidth(); + } + } + + return width; + } + + + @Override + public int getLightmapGLFormat() { + int glFormat = -1; + + LightTexture lightTexture = GAME_RENDERER.lightTexture(); + if (lightTexture != null) { + NativeImage tex = lightTexture.lightPixels; + if (tex != null) { + glFormat = tex.format().glFormat(); + } + } + + return glFormat; + } + + @Override + public boolean isFogStateSpecial() { + Entity entity = GAME_RENDERER.getMainCamera().getEntity(); + boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS); + return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind; + } + @Override public boolean tryDisableVanillaFog() { return true; // Handled via MixinFogRenderer in both forge and fabric diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java index c944503af..56f3b570b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java @@ -36,6 +36,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkSource; import net.minecraft.world.level.chunk.ChunkStatus; import org.jetbrains.annotations.Nullable; @@ -50,12 +51,12 @@ public class WorldWrapper implements IWorldWrapper private static final ConcurrentMap worldWrapperMap = new ConcurrentHashMap<>(); private final LevelAccessor world; public final WorldType worldType; - - + + public WorldWrapper(LevelAccessor newWorld) { world = newWorld; - + if (world.getClass() == ServerLevel.class) worldType = WorldType.ServerWorld; else if (world.getClass() == ClientLevel.class) @@ -63,8 +64,8 @@ public class WorldWrapper implements IWorldWrapper else worldType = WorldType.Unknown; } - - + + @Nullable public static WorldWrapper getWorldWrapper(LevelAccessor world) { @@ -72,68 +73,68 @@ public class WorldWrapper implements IWorldWrapper //first we check if the biome has already been wrapped if(worldWrapperMap.containsKey(world) && worldWrapperMap.get(world) != null) return worldWrapperMap.get(world); - - + + //if it hasn't been created yet, we create it and save it in the map WorldWrapper worldWrapper = new WorldWrapper(world); worldWrapperMap.put(world, worldWrapper); - + //we return the newly created wrapper return worldWrapper; } - + public static void clearMap() { worldWrapperMap.clear(); } - + @Override public WorldType getWorldType() { return worldType; } - + @Override public DimensionTypeWrapper getDimensionType() { return DimensionTypeWrapper.getDimensionTypeWrapper(world.dimensionType()); } - + @Override public int getBlockLight(int x, int y, int z) { return world.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); } - + @Override public int getSkyLight(int x, int y, int z) { return world.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); } - + public LevelAccessor getWorld() { return world; } - + @Override public boolean hasCeiling() { return world.dimensionType().hasCeiling(); } - + @Override public boolean hasSkyLight() { return world.dimensionType().hasSkyLight(); } - + @Override public int getHeight() { return world.getHeight(); } - + @Override public short getMinHeight() { @@ -146,21 +147,21 @@ public class WorldWrapper implements IWorldWrapper { if (worldType != WorldType.ServerWorld) throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds."); - + ServerChunkCache chunkSource = ((ServerLevel) world).getChunkSource(); return chunkSource.getDataStorage().dataFolder; } - - + + /** @throws UnsupportedOperationException if the WorldWrapper isn't for a ServerWorld */ public ServerLevel getServerWorld() throws UnsupportedOperationException { if (worldType != WorldType.ServerWorld) throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds."); - + return (ServerLevel) world; } - + @Override public int getSeaLevel() { @@ -169,11 +170,18 @@ public class WorldWrapper implements IWorldWrapper } @Override - public IChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) { - ChunkAccess chunk = world.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false); - if (chunk == null) return null; - return new ChunkWrapper(chunk, world); + public IChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) { + ChunkAccess chunk = world.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false); + if (chunk == null) return null; + return new ChunkWrapper(chunk, world); } - - + + @Override + public boolean hasChunkLoaded(int chunkX, int chunkZ) { + // world.hasChunk(chunkX, chunkZ); THIS DOES NOT WORK FOR CLIENT LEVEL CAUSE MOJANG ALWAYS RETURN TRUE FOR THAT! + ChunkSource source = world.getChunkSource(); + return source.hasChunk(chunkX, chunkZ); + } + + } diff --git a/core b/core index 9fa7fa843..df73d1d27 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 9fa7fa843d442f199e74cb5c38cc2ef227c53950 +Subproject commit df73d1d275ca5c3ff5b940123f719208ae214454