Removed most cases of LodConfigWrapperSingleton

This commit is contained in:
coolGi
2022-06-11 22:27:15 +09:30
parent 33f999d139
commit fef487f698
24 changed files with 150 additions and 160 deletions
@@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.rendering.ERendererType;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
@@ -47,7 +48,6 @@ import com.seibel.lod.core.util.DetailDistanceUtil;
import com.seibel.lod.core.logging.SpamReducedLogger;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
@@ -75,7 +75,6 @@ public class ClientApi
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.get(IMinecraftRenderWrapper.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IWrapperFactory FACTORY = SingletonHandler.get(IWrapperFactory.class);
private static final EventApi EVENT_API = EventApi.INSTANCE;
@@ -174,8 +173,8 @@ public class ClientApi
ConfigBasedLogger.updateAll();
ConfigBasedSpamLogger.updateAll(doFlush);
if (InternalApiShared.previousVertQual != CONFIG.client().graphics().quality().getVerticalQuality()) {
InternalApiShared.previousVertQual = CONFIG.client().graphics().quality().getVerticalQuality();
if (InternalApiShared.previousVertQual != Config.Client.Graphics.Quality.verticalQuality.get()) {
InternalApiShared.previousVertQual = Config.Client.Graphics.Quality.verticalQuality.get();
EventApi.INSTANCE.worldUnloadEvent(MC.getWrappedServerWorld());
EventApi.INSTANCE.worldLoadEvent(MC.getWrappedClientWorld());
return;
@@ -264,7 +263,7 @@ public class ClientApi
if (CONFIG.client().advanced().debugging().getRendererType() == ERendererType.DEFAULT)
if (Config.Client.Advanced.Debugging.rendererType.get() == ERendererType.DEFAULT)
{
// Note to self:
// if "unspecified" shows up in the pie chart, it is
@@ -290,7 +289,7 @@ public class ClientApi
}
profiler.pop(); // end LOD
profiler.push("terrain"); // go back into "terrain"
} else if (CONFIG.client().advanced().debugging().getRendererType() == ERendererType.DEBUG) {
} else if (Config.Client.Advanced.Debugging.rendererType.get() == ERendererType.DEBUG) {
IProfilerWrapper profiler = MC.getProfiler();
profiler.pop(); // get out of "terrain"
profiler.push("LODTestRendering");
@@ -302,7 +301,7 @@ public class ClientApi
// these can't be set until after the buffers are built (in renderer.drawLODs)
// otherwise the buffers may be set to the wrong size, or not changed at all
InternalApiShared.previousChunkRenderDistance = MC_RENDER.getRenderDistance();
InternalApiShared.previousLodRenderDistance = CONFIG.client().graphics().quality().getLodChunkRenderDistance();
InternalApiShared.previousLodRenderDistance = Config.Client.Graphics.Quality.lodChunkRenderDistance.get();
}
catch (Exception e)
{
@@ -346,21 +345,21 @@ public class ClientApi
// Trigger once on key press, with CLIENT PLAYER.
public void keyPressedEvent(int glfwKey)
{
if (!CONFIG.client().advanced().debugging().getDebugKeybindingsEnabled())
if (!Config.Client.Advanced.Debugging.enableDebugKeybindings.get())
return;
if (glfwKey == GLFW.GLFW_KEY_F8)
{
CONFIG.client().advanced().debugging()
.setDebugMode(CONFIG.client().advanced().debugging().getDebugMode().getNext());
MC.sendChatMessage("F8: Set debug mode to " + CONFIG.client().advanced().debugging().getDebugMode());
Config.Client.Advanced.Debugging
.debugMode.set(Config.Client.Advanced.Debugging.debugMode.get().getNext());
MC.sendChatMessage("F8: Set debug mode to " + Config.Client.Advanced.Debugging.debugMode.get());
}
if (glfwKey == GLFW.GLFW_KEY_F6)
{
CONFIG.client().advanced().debugging()
.setRendererType(ERendererType.next(CONFIG.client().advanced().debugging().getRendererType()));
MC.sendChatMessage("F6: Set rendering to " + CONFIG.client().advanced().debugging().getRendererType());
Config.Client.Advanced.Debugging
.rendererType.set(ERendererType.next(Config.Client.Advanced.Debugging.rendererType.get()));
MC.sendChatMessage("F6: Set rendering to " + Config.Client.Advanced.Debugging.rendererType.get());
}
if (glfwKey == GLFW.GLFW_KEY_P)
@@ -21,6 +21,7 @@ package com.seibel.lod.core.api.internal;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.builders.worldGeneration.BatchGenerator;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.EWorldType;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.logging.DhLoggerBuilder;
@@ -33,7 +34,6 @@ import com.seibel.lod.core.util.DetailDistanceUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
@@ -56,7 +56,6 @@ public class EventApi
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IVersionConstants VERSION_CONSTANTS = SingletonHandler.get(IVersionConstants.class);
/**
@@ -91,7 +90,7 @@ public class EventApi
if (InternalApiShared.isShuttingDown)
return;
if (CONFIG.client().worldGenerator().getEnableDistantGeneration())
if (Config.Client.WorldGenerator.enableDistantGeneration.get())
{
if (lastWorldGenTickDelta <= 0) {
lastWorldGenTickDelta = 20; // 20 ticks is 1 second. We don't need to refresh world gen status every tick.
@@ -154,7 +153,7 @@ public class EventApi
// make sure the correct LODs are being rendered
// (if this isn't done the previous world's LODs may be drawn)
ClientApi.renderer.regenerateLODsNextFrame();
InternalApiShared.previousVertQual = CONFIG.client().graphics().quality().getVerticalQuality();
InternalApiShared.previousVertQual = Config.Client.Graphics.Quality.verticalQuality.get();
}
/** This is also called when the user disconnects from a server+ */
@@ -235,10 +234,10 @@ public class EventApi
// calculate how wide the dimension(s) should be in regions
int chunksWide;
if (MC.getWrappedClientWorld().getDimensionType().hasCeiling())
chunksWide = Math.min(CONFIG.client().graphics().quality().getLodChunkRenderDistance(),
chunksWide = Math.min(Config.Client.Graphics.Quality.lodChunkRenderDistance.get(),
LodUtil.CEILED_DIMENSION_MAX_RENDER_DISTANCE) * 2 + 1;
else
chunksWide = CONFIG.client().graphics().quality().getLodChunkRenderDistance() * 2 + 1;
chunksWide = Config.Client.Graphics.Quality.lodChunkRenderDistance.get() * 2 + 1;
int newWidth = (int) Math.ceil(chunksWide / (float) LodUtil.REGION_WIDTH_IN_CHUNKS);
// make sure we have an odd number of regions
@@ -23,6 +23,7 @@ import java.util.ConcurrentModificationException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.ELodDirection;
import com.seibel.lod.core.enums.config.EBlocksToAvoid;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
@@ -40,7 +41,6 @@ import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
@@ -59,10 +59,9 @@ public class LodBuilder
{
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final IWrapperFactory FACTORY = SingletonHandler.get(IWrapperFactory.class);
private static final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
public static final ConfigBasedLogger EVENT_LOGGER = new ConfigBasedLogger(LogManager.getLogger(LodBuilder.class),
() -> config.client().advanced().debugging().debugSwitch().getLogLodBuilderEvent());
() -> Config.Client.Advanced.Debugging.DebugSwitch.logLodBuilderEvent.get());
/** This cannot be final! Different world have different height, and in menu, this causes Null Exceptions*/
//public static final short MIN_WORLD_HEIGHT = MC.getWrappedClientWorld().getMinHeight();
@@ -337,7 +336,7 @@ public class LodBuilder
boolean topBlock = true;
if (y < chunk.getMinBuildHeight())
dataToMerge[0] = DataPointUtil.createVoidDataPoint(generation);
int maxConnectedLods = LodBuilder.config.client().graphics().quality().getVerticalQuality().maxVerticalData[0];
int maxConnectedLods = Config.Client.Graphics.Quality.verticalQuality.get().maxVerticalData[0];
while (y >= chunk.getMinBuildHeight()) {
int height = determineHeightPointFrom(chunk, config, x, y, z);
// If the lod is at the default height, it must be void data
@@ -394,7 +393,7 @@ public class LodBuilder
if (strictEdge)
{
IBlockDetailWrapper blockAbove = chunk.getBlockDetail(xAbs, yAbs + 1, zAbs);
if (blockAbove != null && config.client().worldGenerator().getTintWithAvoidedBlocks() && !blockAbove.shouldRender(config.client().worldGenerator().getBlocksToAvoid()))
if (blockAbove != null && Config.Client.WorldGenerator.tintWithAvoidedBlocks.get() && !blockAbove.shouldRender(Config.Client.WorldGenerator.blocksToAvoid.get()))
{ // The above block is skipped. Lets use its skipped color for current block
currentBlockDetail = blockAbove;
}
@@ -458,7 +457,7 @@ public class LodBuilder
colorInt = 0;
if (chunk.blockPosInsideChunk(x, y+1, z)) {
IBlockDetailWrapper blockAbove = chunk.getBlockDetail(x, y+1, z);
if (blockAbove != null && config.client().worldGenerator().getTintWithAvoidedBlocks() && !blockAbove.shouldRender(config.client().worldGenerator().getBlocksToAvoid()))
if (blockAbove != null && Config.Client.WorldGenerator.tintWithAvoidedBlocks.get() && !blockAbove.shouldRender(Config.Client.WorldGenerator.blocksToAvoid.get()))
{ // The above block is skipped. Lets use its skipped color for current block
colorInt = blockAbove.getAndResolveFaceColor(null, chunk, new DHBlockPos(x, y+1, z));
}
@@ -555,14 +554,14 @@ public class LodBuilder
/** Is the block at the given blockPos a valid LOD point? */
private boolean isLayerValidLodPoint(IBlockDetailWrapper blockDetail)
{
EBlocksToAvoid avoid = config.client().worldGenerator().getBlocksToAvoid();
EBlocksToAvoid avoid = Config.Client.WorldGenerator.blocksToAvoid.get();
return blockDetail != null && blockDetail.shouldRender(avoid);
}
/** Is the block at the given blockPos a valid LOD point? */
private boolean isLayerValidLodPoint(IChunkWrapper chunk, int x, int y, int z)
{
EBlocksToAvoid avoid = config.client().worldGenerator().getBlocksToAvoid();
EBlocksToAvoid avoid = Config.Client.WorldGenerator.blocksToAvoid.get();
IBlockDetailWrapper block = chunk.getBlockDetail(x, y, z);
return block != null && block.shouldRender(avoid);
}
@@ -24,6 +24,7 @@ import java.time.Duration;
import java.util.concurrent.*;
import java.util.concurrent.locks.ReentrantLock;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.logging.SpamReducedLogger;
@@ -35,7 +36,6 @@ import com.seibel.lod.core.render.LodRenderer;
import com.seibel.lod.core.render.objects.GLBuffer;
import com.seibel.lod.core.util.*;
import com.seibel.lod.core.util.gridList.MovableGridRingList;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import org.apache.logging.log4j.Logger;
@@ -69,8 +69,7 @@ public class LodBufferBuilderFactory {
}
}
}
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
@@ -82,7 +81,7 @@ public class LodBufferBuilderFactory {
/** The threads used to generate buffers. */
private static LodThreadFactory bufferBuilderThreadFactory = new LodThreadFactory("BufferBuilder",
Thread.NORM_PRIORITY - 2);
private static int previousBufferBuilderThreads = CONFIG.client().advanced().threading().getNumberOfBufferBuilderThreads();
private static int previousBufferBuilderThreads = Config.Client.Advanced.Threading.numberOfBufferBuilderThreads.get();
public static ExecutorService bufferBuilderThreads = Executors.newFixedThreadPool(previousBufferBuilderThreads, bufferBuilderThreadFactory);
/** The thread used to upload buffers. */
@@ -173,7 +172,7 @@ public class LodBufferBuilderFactory {
}
bufferBuilderThreads.shutdownNow();
bufferUploadThread.shutdownNow();
previousBufferBuilderThreads = CONFIG.client().advanced().threading().getNumberOfBufferBuilderThreads();
previousBufferBuilderThreads = Config.Client.Advanced.Threading.numberOfBufferBuilderThreads.get();
bufferBuilderThreadFactory = new LodThreadFactory("BufferBuilder", Thread.NORM_PRIORITY - 2);
bufferBuilderThreads = Executors.newFixedThreadPool(previousBufferBuilderThreads, bufferBuilderThreadFactory);
@@ -187,7 +186,7 @@ public class LodBufferBuilderFactory {
int playerZ, boolean fullRegen) {
//ArrayList<RenderRegion> regionsToCleanup = new ArrayList<RenderRegion>();
try {
if (previousBufferBuilderThreads != CONFIG.client().advanced().threading().getNumberOfBufferBuilderThreads())
if (previousBufferBuilderThreads != Config.Client.Advanced.Threading.numberOfBufferBuilderThreads.get())
resetThreadPools(false);
regionsListLock.lockInterruptibly();
if (ENABLE_EVENT_LOGGING)
@@ -195,10 +194,10 @@ public class LodBufferBuilderFactory {
lodDim, renderRegions==null ? "NULL" : renderRegions.toString());
long startTime = System.currentTimeMillis();
boolean doCaveCulling = CONFIG.client().graphics().advancedGraphics().getEnableCaveCulling();
boolean doCaveCulling = Config.Client.Graphics.AdvancedGraphics.enableCaveCulling.get();
doCaveCulling &= !lodDim.dimension.hasCeiling();
doCaveCulling &= lodDim.dimension.hasSkyLight();
doCaveCulling &= playerY > CONFIG.client().graphics().advancedGraphics().getCaveCullingHeight() + 5;
doCaveCulling &= playerY > Config.Client.Graphics.AdvancedGraphics.caveCullingHeight.get() + 5;
int playerSkylight = MC.getPlayerSkylight(); // if fail returns -1.
doCaveCulling &= playerSkylight > 7;
@@ -29,12 +29,10 @@ import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.enums.ELodDirection;
import com.seibel.lod.core.enums.ELodDirection.Axis;
import com.seibel.lod.core.enums.config.EGpuUploadMethod;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.render.LodRenderer;
import com.seibel.lod.core.render.objects.GLVertexBuffer;
import com.seibel.lod.core.util.ColorUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import static com.seibel.lod.core.render.LodRenderer.EVENT_LOGGER;
@@ -45,8 +43,6 @@ import static com.seibel.lod.core.render.LodRenderer.EVENT_LOGGER;
*/
public class LodQuadBuilder
{
static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
public final boolean skipQuadsWithZeroSkylight;
public final short skyLightCullingBelow;
@@ -20,6 +20,7 @@
package com.seibel.lod.core.builders.worldGeneration;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EGenerationPriority;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
@@ -29,7 +30,6 @@ import com.seibel.lod.core.objects.lod.LodDimension;
import com.seibel.lod.core.util.LevelPosUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper;
@@ -43,12 +43,11 @@ public class BatchGenerator
public static final boolean ENABLE_GENERATOR_STATS_LOGGING = false;
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IWrapperFactory FACTORY = SingletonHandler.get(IWrapperFactory.class);
public AbstractBatchGenerationEnvionmentWrapper generationGroup;
public LodDimension targetLodDim;
public static final int generationGroupSize = 4;
public static int previousThreadCount = CONFIG.client().advanced().threading()._getWorldGenerationThreadPoolSize();
public static int previousThreadCount = Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get()<1 ? 1 : (int) Math.ceil(Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get());
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
private int estimatedSampleNeeded = 128;
@@ -72,8 +71,8 @@ public class BatchGenerator
LOGGER.info("1.18 Experimental Chunk Generator reinitialized");
}
EDistanceGenerationMode mode = CONFIG.client().worldGenerator().getDistanceGenerationMode();
int newThreadCount = CONFIG.client().advanced().threading()._getWorldGenerationThreadPoolSize();
EDistanceGenerationMode mode = Config.Client.WorldGenerator.distanceGenerationMode.get();
int newThreadCount = Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get()<1 ? 1 : (int) Math.ceil(Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get());
if (newThreadCount != previousThreadCount) {
generationGroup.resizeThreadPool(newThreadCount);
previousThreadCount = newThreadCount;
@@ -81,7 +80,7 @@ public class BatchGenerator
if (estimatedPointsToQueue < newThreadCount)
estimatedPointsToQueue = newThreadCount;
EGenerationPriority priority = CONFIG.client().worldGenerator().getGenerationPriority();
EGenerationPriority priority = Config.Client.WorldGenerator.generationPriority.get();
if (priority == EGenerationPriority.AUTO)
priority = MC.hasSinglePlayerServer() ? EGenerationPriority.FAR_FIRST : EGenerationPriority.NEAR_FIRST;
@@ -106,7 +105,7 @@ public class BatchGenerator
// round the player's block position down to the nearest chunk BlockPos
int playerPosX = MC.getPlayerBlockPos().getX();
int playerPosZ = MC.getPlayerBlockPos().getZ();
double runTimeRatio = CONFIG.client().advanced().threading()._getWorldGenerationPartialRunTime();
double runTimeRatio = Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get()>1 ? 1.0 : Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get();
PosToGenerateContainer posToGenerate = lodDim.getPosToGenerate(estimatedSampleNeeded, playerPosX, playerPosZ,
priority, mode);
@@ -215,6 +215,7 @@ public class Config
public static class AdvancedFog {
// TODO: Make some of the option here floats rather than doubles (the ClassicConfigGUI dosnt support floats)
private static final Double FOG_RANGE_MIN = 0.0;
private static final Double FOG_RANGE_MAX = Math.sqrt(2.0);
@@ -421,7 +422,7 @@ public class Config
+ "This setting shouldn't affect performance.")
.build();
public static ConfigEntry<Double> brightnessMultiplier = new ConfigEntry.Builder<Double>()
public static ConfigEntry<Double> brightnessMultiplier = new ConfigEntry.Builder<Double>() // TODO: Make this a float (the ClassicConfigGUI dosnt support floats)
.set(1.0)
.comment(""
+ "How bright fake chunk colors are. \n"
@@ -431,7 +432,7 @@ public class Config
+ " 2 = near white")
.build();
public static ConfigEntry<Double> saturationMultiplier = new ConfigEntry.Builder<Double>()
public static ConfigEntry<Double> saturationMultiplier = new ConfigEntry.Builder<Double>() // TODO: Make this a float (the ClassicConfigGUI dosnt support floats)
.set(1.0)
.comment(""
+ "How saturated fake chunk colors are. \n"
@@ -160,9 +160,8 @@ public class ConfigFileHandling {
} catch (Exception e) {
System.out.println("Loading file failed because of this expectation:\n"+e);
try { // Now try remaking the file and loading it
Path configFilePath = ConfigPath.getParent();
if (!configFilePath.toFile().exists())
Files.createDirectory(configFilePath);
if (!ConfigPath.getParent().toFile().exists())
Files.createDirectory(ConfigPath.getParent());
else
Files.deleteIfExists(ConfigPath);
Files.createFile(ConfigPath);
@@ -33,9 +33,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.api.internal.ClientApi;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
@@ -65,9 +64,8 @@ import org.apache.logging.log4j.LogManager;
*/
public class LodDimensionFileHandler
{
private static final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
public static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(LodDimensionFileHandler.class),
() -> config.client().advanced().debugging().debugSwitch().getLogFileReadWriteEvent());
() -> Config.Client.Advanced.Debugging.DebugSwitch.logFileReadWriteEvent.get());
public static final boolean ENABLE_SAVE_THREAD_LOGGING = true;
public static final boolean ENABLE_SAVE_REGION_LOGGING = false;
@@ -22,6 +22,7 @@ package com.seibel.lod.core.handlers;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.seibel.lod.core.api.internal.InternalApiShared;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.handlers.dimensionFinder.PlayerData;
import com.seibel.lod.core.handlers.dimensionFinder.SubDimCompare;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
@@ -38,7 +39,6 @@ import com.seibel.lod.core.util.DataPointUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
@@ -60,10 +60,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class LodDimensionFinder
{
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IWrapperFactory FACTORY = SingletonHandler.get(IWrapperFactory.class);
public static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(LodDimensionFinder.class),
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogFileSubDimEvent());
() -> Config.Client.Advanced.Debugging.DebugSwitch.logFileSubDimEvent.get());
/** Increasing this will increase accuracy but increase calculation time */
private static final EVerticalQuality VERTICAL_QUALITY_TO_TEST_WITH = EVerticalQuality.LOW;
@@ -119,7 +118,7 @@ public class LodDimensionFinder
{
// attempt to get the file handler
File saveDir;
if (CONFIG.client().multiplayer().getMultiDimensionRequiredSimilarity() == 0)
if (Config.Client.Multiplayer.multiDimensionRequiredSimilarity.get() == 0)
{
// only allow 1 sub dimension per world
saveDir = getDefaultSubDimensionFolder(dimensionTypeWrapper);
@@ -19,8 +19,7 @@
package com.seibel.lod.core.handlers.dimensionFinder;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.config.Config;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -36,9 +35,6 @@ import java.io.File;
*/
public class SubDimCompare implements Comparable<SubDimCompare>
{
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
public int equalDataPoints = 0;
public int totalDataPoints = 0;
public int playerPosDist = 0;
@@ -79,7 +75,7 @@ public class SubDimCompare implements Comparable<SubDimCompare>
/** Returns true if this sub dimension is close enough to be considered a valid sub dimension */
public boolean isValidSubDim()
{
double minimumSimilarityRequired = CONFIG.client().multiplayer().getMultiDimensionRequiredSimilarity();
double minimumSimilarityRequired = Config.Client.Multiplayer.multiDimensionRequiredSimilarity.get();
return this.getPercentEqual() >= minimumSimilarityRequired || this.playerPosDist <= 3;
}
}
@@ -2,6 +2,7 @@ package com.seibel.lod.core.objects.a7;
import com.seibel.lod.core.api.internal.InternalApiShared;
import com.seibel.lod.core.api.internal.a7.ClientApi;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.objects.a7.data.DataFileHandler;
import com.seibel.lod.core.objects.a7.pos.DhBlockPos2D;
@@ -11,7 +12,6 @@ import com.seibel.lod.core.render.a7LodRenderer;
import com.seibel.lod.core.util.DetailDistanceUtil;
import com.seibel.lod.core.util.EventLoop;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
@@ -22,7 +22,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
public class DHLevel extends LodQuadTree implements Closeable {
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
public final File saveFolder; // Could be null, for no saving
public final DataFileHandler dataFileHandler; // Could be null, for no saving
@@ -36,7 +35,7 @@ public class DHLevel extends LodQuadTree implements Closeable {
public EventLoop eventLoop;
public DHLevel(DHWorld world, File saveFolder, IWorldWrapper level) {
super(CONFIG.client().graphics().quality().getLodChunkRenderDistance()*16,
super(Config.Client.Graphics.Quality.lodChunkRenderDistance.get()*16,
MC.getPlayerBlockPos().x,
MC.getPlayerBlockPos().z);
this.world = world;
@@ -1,11 +1,11 @@
package com.seibel.lod.core.objects.a7.io;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EServerFolderNameMode;
import com.seibel.lod.core.handlers.LodDimensionFinder;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.objects.ParsedIp;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import org.apache.logging.log4j.LogManager;
@@ -19,9 +19,8 @@ public class DHFolderHandler {
*/
public static final String INVALID_FILE_CHARACTERS_REGEX = "[\\\\/:*?\"<>|]";
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
public static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(LodDimensionFinder.class),
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogFileSubDimEvent());
() -> Config.Client.Advanced.Debugging.DebugSwitch.logFileSubDimEvent.get());
public static File getCurrentWorldFolder() {
File dimensionFolder;
@@ -80,7 +79,7 @@ public class DHFolderHandler {
// determine the format of the folder name
EServerFolderNameMode folderNameMode = CONFIG.client().multiplayer().getServerFolderNameMode();
EServerFolderNameMode folderNameMode = Config.Client.Multiplayer.serverFolderNameMode.get();
if (folderNameMode == EServerFolderNameMode.AUTO)
{
if (parsedIp.isLan())
@@ -3,6 +3,7 @@ package com.seibel.lod.core.objects.a7.io;
import com.seibel.lod.core.api.internal.InternalApiShared;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EVerticalQuality;
import com.seibel.lod.core.handlers.LodDimensionFileHandler;
@@ -20,7 +21,6 @@ import com.seibel.lod.core.objects.lod.LodRegion;
import com.seibel.lod.core.util.DataPointUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
import org.apache.logging.log4j.LogManager;
@@ -33,9 +33,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class LevelToFileMatcher {
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
public static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(LodDimensionFinder.class),
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogFileSubDimEvent());
() -> Config.Client.Advanced.Debugging.DebugSwitch.logFileSubDimEvent.get());
/** Increasing this will increase accuracy but increase calculation time */
private static final EVerticalQuality VERTICAL_QUALITY_TO_TEST_WITH = EVerticalQuality.LOW;
@@ -73,7 +72,7 @@ public class LevelToFileMatcher {
private void tick() {
// prevent multiple threads running at the same time
if (CONFIG.client().multiplayer().getMultiDimensionRequiredSimilarity() == 0 || MC.hasSinglePlayerServer()) {
if (Config.Client.Multiplayer.multiDimensionRequiredSimilarity.get() == 0 || MC.hasSinglePlayerServer()) {
File saveDir = getLevelFolderWithoutSimilarityMatching();
foundLevel = new DHLevel(dhWorld, saveDir, currentWorld);
} else {
@@ -20,6 +20,7 @@
package com.seibel.lod.core.objects.lod;
import com.seibel.lod.core.api.internal.ClientApi;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EDropoffQuality;
import com.seibel.lod.core.enums.config.EGenerationPriority;
@@ -33,7 +34,6 @@ import com.seibel.lod.core.objects.PosToGenerateContainer;
import com.seibel.lod.core.objects.DHRegionPos;
import com.seibel.lod.core.util.*;
import com.seibel.lod.core.util.gridList.MovableGridRingList;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
import org.apache.logging.log4j.Logger;
@@ -62,7 +62,6 @@ import java.util.concurrent.TimeUnit;
*/
public class LodDimension
{
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
@@ -337,10 +336,10 @@ public class LodDimension
}
isExpanding = true;
EVerticalQuality verticalQuality = CONFIG.client().graphics().quality().getVerticalQuality();
EDropoffQuality dropoffQuality = CONFIG.client().graphics().quality().getDropoffQuality();
EVerticalQuality verticalQuality = Config.Client.Graphics.Quality.verticalQuality.get();
EDropoffQuality dropoffQuality = Config.Client.Graphics.Quality.dropoffQuality.get();
if (dropoffQuality == EDropoffQuality.AUTO)
dropoffQuality = CONFIG.client().graphics().quality().getLodChunkRenderDistance() < 128 ?
dropoffQuality = Config.Client.Graphics.Quality.lodChunkRenderDistance.get() < 128 ?
EDropoffQuality.SMOOTH_DROPOFF : EDropoffQuality.PERFORMANCE_FOCUSED;
int dropoffSwitch = dropoffQuality.fastModeSwitch;
// don't run the expander multiple times
@@ -23,6 +23,7 @@ import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EDropoffQuality;
import com.seibel.lod.core.enums.config.EGenerationPriority;
@@ -34,6 +35,7 @@ import com.seibel.lod.core.util.DetailDistanceUtil;
import com.seibel.lod.core.util.LevelPosUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
/**
* This object holds all loaded LevelContainers acting as a quad tree for a
@@ -296,7 +298,7 @@ public class LodRegion {
}
public byte getRenderDetailLevelAt(int playerPosX, int playerPosZ, byte detailLevel, int offsetX, int offsetZ) {
EGenerationPriority generationPriority = CONFIG.client().worldGenerator().getResolvedGenerationPriority();
EGenerationPriority generationPriority = getResolvedGenerationPriority();
EDropoffQuality dropoffQuality = CONFIG.client().graphics().quality().getResolvedDropoffQuality();
double minDistance = LevelPosUtil.minDistance(LodUtil.REGION_DETAIL_LEVEL, regionPosX, regionPosZ,
@@ -321,13 +323,29 @@ public class LodRegion {
int playerPosZ)
{
// use FAR_FIRST on local worlds and NEAR_FIRST on servers
EGenerationPriority generationPriority = CONFIG.client().worldGenerator().getResolvedGenerationPriority();
EGenerationPriority generationPriority = getResolvedGenerationPriority();
EDropoffQuality dropoffQuality = CONFIG.client().graphics().quality().getResolvedDropoffQuality();
getPosToRender(posToRender, playerPosX, playerPosZ, generationPriority, dropoffQuality);
}
private EGenerationPriority getResolvedGenerationPriority() {
EGenerationPriority priority = Config.Client.WorldGenerator.generationPriority.get();
IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
if (priority == EGenerationPriority.AUTO)
priority = MC.hasSinglePlayerServer() ? EGenerationPriority.FAR_FIRST : EGenerationPriority.BALANCED;
return priority;
}
private EDropoffQuality getResolvedDropoffQuality() {
EDropoffQuality dropoffQuality = Config.Client.Graphics.Quality.dropoffQuality.get();
if (dropoffQuality == EDropoffQuality.AUTO)
dropoffQuality = Config.Client.Graphics.Quality.lodChunkRenderDistance.get() < 128 ?
EDropoffQuality.SMOOTH_DROPOFF : EDropoffQuality.PERFORMANCE_FOCUSED;
return dropoffQuality;
}
/**
* This method will fill the posToRender array with all levelPos that are
* render-able.
@@ -30,11 +30,11 @@ import com.seibel.lod.core.api.internal.ClientApi;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.CubicLodTemplate;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodQuadBuilder;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.ELodDirection;
import com.seibel.lod.core.enums.config.EGpuUploadMethod;
import com.seibel.lod.core.enums.rendering.EDebugMode;
import com.seibel.lod.core.enums.rendering.EGLProxyContext;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.objects.DHBlockPos;
import com.seibel.lod.core.objects.BoolType;
import com.seibel.lod.core.objects.LodDataView;
@@ -52,14 +52,11 @@ import com.seibel.lod.core.util.LevelPosUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.StatsMap;
import com.seibel.lod.core.util.gridList.PosArrayGridList;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import static com.seibel.lod.core.render.LodRenderer.EVENT_LOGGER;
public class RenderRegion implements AutoCloseable
{
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
/** stores if the region at the given x and z index needs to be regenerated */
// Use int because I need Tri state:
private final AtomicInteger needRegen = new AtomicInteger(2);
@@ -189,7 +186,7 @@ public class RenderRegion implements AutoCloseable
return CompletableFuture.supplyAsync(() -> {
try {
EVENT_LOGGER.trace("RenderRegion start QuadBuild @ {}", regionPos);
int skyLightCullingBelow = CONFIG.client().graphics().advancedGraphics().getCaveCullingHeight();
int skyLightCullingBelow = Config.Client.Graphics.AdvancedGraphics.caveCullingHeight.get();
// FIXME: Clamp also to the max world height.
skyLightCullingBelow = Math.max(skyLightCullingBelow, LodBuilder.MIN_WORLD_HEIGHT);
LodQuadBuilder builder = new LodQuadBuilder(doCaveCulling, skyLightCullingBelow);
@@ -257,7 +254,7 @@ public class RenderRegion implements AutoCloseable
byte minDetail = region.getMinDetailLevel();
// Variable initialization
EDebugMode debugMode = CONFIG.client().advanced().debugging().getDebugMode();
EDebugMode debugMode = Config.Client.Advanced.Debugging.debugMode.get();
// We ask the lod dimension which block we have to render given the player
// position
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import com.seibel.lod.core.api.internal.ClientApi;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodQuadBuilder;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.render.LodRenderer;
import com.seibel.lod.core.render.objects.GLVertexBuffer;
@@ -34,20 +35,17 @@ import org.lwjgl.opengl.GL32;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodBufferBuilderFactory;
import com.seibel.lod.core.enums.config.EGpuUploadMethod;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodQuadBuilder.BufferFiller;
import com.seibel.lod.core.render.GLProxy;
import com.seibel.lod.core.render.LodRenderProgram;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.StatsMap;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import static com.seibel.lod.core.render.GLProxy.GL_LOGGER;
public class SimpleRenderBuffer extends RenderBuffer
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final long MAX_BUFFER_UPLOAD_TIMEOUT_NANOSECONDS = 1_000_000;
GLVertexBuffer[] vbos;
@@ -123,8 +121,8 @@ public class SimpleRenderBuffer extends RenderBuffer
private void _uploadBuffersDirect(LodQuadBuilder builder, EGpuUploadMethod method) {
resize(builder.getCurrentNeededVertexBufferCount());
long remainingNS = 0;
long BPerNS = CONFIG.client().advanced().buffers().getGpuUploadPerMegabyteInMilliseconds();
long BPerNS = Config.Client.Advanced.Buffers.gpuUploadPerMegabyteInMilliseconds.get();
int i = 0;
Iterator<ByteBuffer> iter = builder.makeVertexBuffers();
while (iter.hasNext()) {
@@ -26,6 +26,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import org.apache.logging.log4j.LogManager;
@@ -44,7 +45,6 @@ import com.seibel.lod.core.enums.rendering.EGLProxyContext;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.util.GLMessage;
import com.seibel.lod.core.util.GLMessageOutputStream;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
/**
@@ -67,15 +67,14 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
public class GLProxy
{
public static final boolean OVERWIDE_VANILLA_GL_LOGGER = ModInfo.IS_DEV_BUILD;
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private ExecutorService workerThread = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat(GLProxy.class.getSimpleName() + "-Worker-Thread").build());
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
public static final ConfigBasedLogger GL_LOGGER = new ConfigBasedLogger(LogManager.getLogger(GLProxy.class),
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogRendererGLEvent());
() -> Config.Client.Advanced.Debugging.DebugSwitch.logRendererGLEvent.get());
private static GLProxy instance = null;
@@ -418,7 +417,7 @@ public class GLProxy
}
public EGpuUploadMethod getGpuUploadMethod() {
EGpuUploadMethod method = CONFIG.client().advanced().buffers().getGpuUploadMethod();
EGpuUploadMethod method = Config.Client.Advanced.Buffers.gpuUploadMethod.get();
if (!bufferStorageSupported && method == EGpuUploadMethod.BUFFER_STORAGE)
{
@@ -19,6 +19,7 @@
package com.seibel.lod.core.render;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.rendering.EFogDrawMode;
import com.seibel.lod.core.enums.rendering.EFogDistance;
import com.seibel.lod.core.enums.rendering.*;
@@ -72,7 +73,7 @@ public class LodFogConfig
/** sets all fog options from the config */
private LodFogConfig(EFogDrawMode fogDrawMode)
{
earthCurveRatio = CONFIG.client().graphics().advancedGraphics().getEarthCurveRatio(); //FIXME: Move this out of here
earthCurveRatio = Config.Client.Graphics.AdvancedGraphics.earthCurveRatio.get(); //FIXME: Move this out of here
if (fogDrawMode != EFogDrawMode.FOG_DISABLED)
{
@@ -24,6 +24,7 @@ import java.time.Duration;
import java.util.concurrent.TimeUnit;
import com.seibel.lod.core.api.internal.InternalApiShared;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
import com.seibel.lod.core.objects.DHBlockPos;
@@ -47,7 +48,6 @@ import com.seibel.lod.core.objects.math.Mat4f;
import com.seibel.lod.core.objects.math.Vec3d;
import com.seibel.lod.core.objects.math.Vec3f;
import com.seibel.lod.core.objects.opengl.RenderRegion;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
@@ -62,12 +62,11 @@ import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
*/
public class LodRenderer
{
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
public static final ConfigBasedLogger EVENT_LOGGER = new ConfigBasedLogger(LogManager.getLogger(LodRenderer.class),
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogRendererBufferEvent());
() -> Config.Client.Advanced.Debugging.DebugSwitch.logRendererBufferEvent.get());
public static ConfigBasedSpamLogger tickLogger = new ConfigBasedSpamLogger(LogManager.getLogger(LodRenderer.class),
() -> CONFIG.client().advanced().debugging().debugSwitch().getLogRendererBufferEvent(),1);
() -> Config.Client.Advanced.Debugging.DebugSwitch.logRendererBufferEvent.get(),1);
public static final boolean ENABLE_DRAW_LAG_SPIKE_LOGGING = false;
public static final boolean ENABLE_DUMP_GL_STATE = true;
public static final long DRAW_LAG_SPIKE_THRESHOLD_NS = TimeUnit.NANOSECONDS.convert(20, TimeUnit.MILLISECONDS);
@@ -184,7 +183,7 @@ public class LodRenderer
drawSaveGLState.end("drawSaveGLState");
GLProxy glProxy = GLProxy.getInstance();
if (canVanillaFogBeDisabled && CONFIG.client().graphics().fogQuality().getDisableVanillaFog())
if (canVanillaFogBeDisabled && Config.Client.Graphics.FogQuality.disableVanillaFog.get())
if (!MC_RENDER.tryDisableVanillaFog())
canVanillaFogBeDisabled = false;
@@ -248,10 +247,10 @@ public class LodRenderer
drawBindBuff.end("drawBindBuff");
// set the required open GL settings
LagSpikeCatcher drawSetPolygon = new LagSpikeCatcher();
if (CONFIG.client().advanced().debugging().getDebugMode() == EDebugMode.SHOW_DETAIL_WIREFRAME
|| CONFIG.client().advanced().debugging().getDebugMode() == EDebugMode.SHOW_GENMODE_WIREFRAME
|| CONFIG.client().advanced().debugging().getDebugMode() == EDebugMode.SHOW_WIREFRAME
|| CONFIG.client().advanced().debugging().getDebugMode() == EDebugMode.SHOW_OVERLAPPING_QUADS_WIREFRAME) {
if (Config.Client.Advanced.Debugging.debugMode.get() == EDebugMode.SHOW_DETAIL_WIREFRAME
|| Config.Client.Advanced.Debugging.debugMode.get() == EDebugMode.SHOW_GENMODE_WIREFRAME
|| Config.Client.Advanced.Debugging.debugMode.get() == EDebugMode.SHOW_WIREFRAME
|| Config.Client.Advanced.Debugging.debugMode.get() == EDebugMode.SHOW_OVERLAPPING_QUADS_WIREFRAME) {
GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_LINE);
//GL32.glDisable(GL32.GL_CULL_FACE);
}
@@ -301,9 +300,9 @@ public class LodRenderer
int farPlaneBlockDistance;
// required for setupFog and setupProjectionMatrix
if (MC.getWrappedClientWorld().getDimensionType().hasCeiling())
farPlaneBlockDistance = Math.min(CONFIG.client().graphics().quality().getLodChunkRenderDistance(), LodUtil.CEILED_DIMENSION_MAX_RENDER_DISTANCE) * LodUtil.CHUNK_WIDTH;
farPlaneBlockDistance = Math.min(Config.Client.Graphics.Quality.lodChunkRenderDistance.get(), LodUtil.CEILED_DIMENSION_MAX_RENDER_DISTANCE) * LodUtil.CHUNK_WIDTH;
else
farPlaneBlockDistance = CONFIG.client().graphics().quality().getLodChunkRenderDistance() * LodUtil.CHUNK_WIDTH;
farPlaneBlockDistance = Config.Client.Graphics.Quality.lodChunkRenderDistance.get() * LodUtil.CHUNK_WIDTH;
drawCalculateParams.end("drawCalculateParams");
Mat4f combinedMatrix = createCombinedMatrix(baseProjectionMatrix, baseModelViewMatrix,
@@ -337,7 +336,7 @@ public class LodRenderer
profiler.popPush("LOD draw");
LagSpikeCatcher draw = new LagSpikeCatcher();
boolean cullingDisabled = CONFIG.client().graphics().advancedGraphics().getDisableDirectionalCulling();
boolean cullingDisabled = Config.Client.Graphics.AdvancedGraphics.disableDirectionalCulling.get();
Vec3d cameraPos = MC_RENDER.getCameraExactPosition();
DHBlockPos cameraBlockPos = MC_RENDER.getCameraBlockPosition();
Vec3f cameraDir = MC_RENDER.getLookAtVector();
@@ -432,7 +431,7 @@ public class LodRenderer
{
Color fogColor;
if (CONFIG.client().graphics().fogQuality().getFogColorMode() == EFogColorMode.USE_SKY_COLOR)
if (Config.Client.Graphics.FogQuality.fogColorMode.get() == EFogColorMode.USE_SKY_COLOR)
fogColor = MC_RENDER.getSkyColor();
else
fogColor = MC_RENDER.getFogColor(partialTicks);
@@ -465,9 +464,9 @@ public class LodRenderer
Mat4f lodProj = projMat.copy();
float nearClipPlane;
if (CONFIG.client().advanced().getLodOnlyMode()) {
if (Config.Client.Advanced.lodOnlyMode.get()) {
nearClipPlane = 0.1f;
} else if (CONFIG.client().graphics().advancedGraphics().getUseExtendedNearClipPlane()) {
} else if (Config.Client.Graphics.AdvancedGraphics.useExtendedNearClipPlane.get()) {
nearClipPlane = Math.min((vanillaBlockRenderedDistance-16f),8f*16f);
} else {
nearClipPlane = 16f;
@@ -529,7 +528,7 @@ public class LodRenderer
// if the player is high enough, draw all LODs
IWorldWrapper world = MC.getWrappedClientWorld();
if (lastUpdatedPos.getY() > world.getHeight()-world.getMinHeight() ||
CONFIG.client().advanced().getLodOnlyMode()) {
Config.Client.Advanced.lodOnlyMode.get()) {
if (vanillaChunks != null) {
vanillaChunks = null;
return true;
@@ -564,25 +563,25 @@ public class LodRenderer
boolean tryFullGen = false;
// check if the view distance or config changed
if (InternalApiShared.previousLodRenderDistance != CONFIG.client().graphics().quality().getLodChunkRenderDistance()
if (InternalApiShared.previousLodRenderDistance != Config.Client.Graphics.Quality.lodChunkRenderDistance.get()
|| chunkRenderDistance != prevRenderDistance
|| prevFogDistance != CONFIG.client().graphics().fogQuality().getFogDistance())
|| prevFogDistance != Config.Client.Graphics.FogQuality.fogDistance.get())
{
DetailDistanceUtil.updateSettings(); // FIXME: This should NOT be here!
prevFogDistance = CONFIG.client().graphics().fogQuality().getFogDistance();
prevFogDistance = Config.Client.Graphics.FogQuality.fogDistance.get();
prevRenderDistance = chunkRenderDistance;
tryFullGen = true;
} else if (CONFIG.client().advanced().debugging().getDebugMode() != previousDebugMode)
} else if (Config.Client.Advanced.Debugging.debugMode.get() != previousDebugMode)
{ // did the user change the debug setting?
previousDebugMode = CONFIG.client().advanced().debugging().getDebugMode();
previousDebugMode = Config.Client.Advanced.Debugging.debugMode.get();
tryFullGen = true;
}
// check if the player has moved
if (newTime - prevPlayerPosTime > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveTimeout) {
if (newTime - prevPlayerPosTime > Config.Client.Advanced.Buffers.rebuildTimes.get().playerMoveTimeout) {
if (lastUpdatedPos == null
|| Math.abs(newPos.getX() - lastUpdatedPos.getX()) > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveDistance*16
|| Math.abs(newPos.getZ() - lastUpdatedPos.getZ()) > CONFIG.client().advanced().buffers().getRebuildTimes().playerMoveDistance*16)
|| Math.abs(newPos.getX() - lastUpdatedPos.getX()) > Config.Client.Advanced.Buffers.rebuildTimes.get().playerMoveDistance*16
|| Math.abs(newPos.getZ() - lastUpdatedPos.getZ()) > Config.Client.Advanced.Buffers.rebuildTimes.get().playerMoveDistance*16)
{
shouldUpdateChunks = true;
}
@@ -590,14 +589,14 @@ public class LodRenderer
}
// check if the vanilla rendered chunks changed
if (newTime - prevVanillaChunkTime > CONFIG.client().advanced().buffers().getRebuildTimes().renderedChunkTimeout)
if (newTime - prevVanillaChunkTime > Config.Client.Advanced.Buffers.rebuildTimes.get().renderedChunkTimeout)
{
shouldUpdateChunks = true;
prevVanillaChunkTime = newTime;
}
// check if there is any newly generated terrain to show
if (newTime - prevChunkTime > CONFIG.client().advanced().buffers().getRebuildTimes().chunkChangeTimeout)
if (newTime - prevChunkTime > Config.Client.Advanced.Buffers.rebuildTimes.get().chunkChangeTimeout)
{
tryPartialGen = true;
prevChunkTime = newTime;
@@ -19,9 +19,8 @@
package com.seibel.lod.core.util;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EHorizontalQuality;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
/**
*
@@ -30,22 +29,20 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
*/
public class DetailDistanceUtil
{
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static byte minDetail = CONFIG.client().graphics().quality().getDrawResolution().detailLevel;
private static byte minDetail = Config.Client.Graphics.Quality.drawResolution.get().detailLevel;
private static final byte maxDetail = LodUtil.DETAIL_OPTIONS;
private static final double minDistance = 0;
private static double distanceUnit = 16 * CONFIG.client().graphics().quality().getHorizontalScale();
private static double maxDistance = CONFIG.client().graphics().quality().getLodChunkRenderDistance() * 16 * 2;
private static double logBase = Math.log(CONFIG.client().graphics().quality().getHorizontalQuality().quadraticBase);
private static double distanceUnit = 16 * Config.Client.Graphics.Quality.horizontalScale.get();
private static double maxDistance = Config.Client.Graphics.Quality.lodChunkRenderDistance.get() * 16 * 2;
private static double logBase = Math.log(Config.Client.Graphics.Quality.horizontalQuality.get().quadraticBase);
public static void updateSettings()
{
distanceUnit = 16 * CONFIG.client().graphics().quality().getHorizontalScale();
minDetail = CONFIG.client().graphics().quality().getDrawResolution().detailLevel;
maxDistance = CONFIG.client().graphics().quality().getLodChunkRenderDistance() * 16 * 8;
logBase = Math.log(CONFIG.client().graphics().quality().getHorizontalQuality().quadraticBase);
distanceUnit = 16 * Config.Client.Graphics.Quality.horizontalScale.get();
minDetail = Config.Client.Graphics.Quality.drawResolution.get().detailLevel;
maxDistance = Config.Client.Graphics.Quality.lodChunkRenderDistance.get() * 16 * 8;
logBase = Math.log(Config.Client.Graphics.Quality.horizontalQuality.get().quadraticBase);
}
public static double baseDistanceFunction(int detail)
@@ -57,11 +54,11 @@ public class DetailDistanceUtil
detail-=minDetail;
if (CONFIG.client().graphics().quality().getHorizontalQuality() == EHorizontalQuality.LOWEST)
if (Config.Client.Graphics.Quality.horizontalQuality.get() == EHorizontalQuality.LOWEST)
return ((double)detail * distanceUnit);
else
{
double base = CONFIG.client().graphics().quality().getHorizontalQuality().quadraticBase;
double base = Config.Client.Graphics.Quality.horizontalQuality.get().quadraticBase;
return Math.pow(base, detail) * distanceUnit;
}
}
@@ -81,7 +78,7 @@ public class DetailDistanceUtil
int detail;
if (CONFIG.client().graphics().quality().getHorizontalQuality() == EHorizontalQuality.LOWEST)
if (Config.Client.Graphics.Quality.horizontalQuality.get() == EHorizontalQuality.LOWEST)
detail = (int) (distance/distanceUnit);
else
detail = (int) (Math.log(distance/distanceUnit) / logBase);
@@ -104,7 +101,7 @@ public class DetailDistanceUtil
public static int getMaxVerticalData(int detail)
{
return CONFIG.client().graphics().quality().getVerticalQuality().maxVerticalData[detail];
return Config.Client.Graphics.Quality.verticalQuality.get().maxVerticalData[detail];
}
}
@@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.EServerFolderNameMode;
import com.seibel.lod.core.enums.config.EVanillaOverdraw;
import com.seibel.lod.core.handlers.IReflectionHandler;
@@ -38,7 +39,6 @@ import com.seibel.lod.core.objects.opengl.LodVertexFormat;
import com.seibel.lod.core.util.gridList.EdgeDistanceBooleanGrid;
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
@@ -54,7 +54,6 @@ public class LodUtil
{
private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.get(IMinecraftRenderWrapper.class);
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IWrapperFactory FACTORY = SingletonHandler.get(IWrapperFactory.class);
private static final IReflectionHandler REFLECTION_HANDLER = SingletonHandler.get(IReflectionHandler.class);
private static final IVersionConstants VERSION_CONSTANTS = SingletonHandler.get(IVersionConstants.class);
@@ -261,7 +260,7 @@ public class LodUtil
// determine the format of the folder name
EServerFolderNameMode folderNameMode = CONFIG.client().multiplayer().getServerFolderNameMode();
EServerFolderNameMode folderNameMode = Config.Client.Multiplayer.serverFolderNameMode.get();
if (folderNameMode == EServerFolderNameMode.AUTO)
{
if (parsedIp.isLan())
@@ -350,11 +349,11 @@ public class LodUtil
public static int computeOverdrawOffset(LodDimension lodDim) {
int chunkRenderDist = MC_RENDER.getRenderDistance() + 1;
EVanillaOverdraw overdraw = CONFIG.client().graphics().advancedGraphics().getVanillaOverdraw();
EVanillaOverdraw overdraw = Config.Client.Graphics.AdvancedGraphics.vanillaOverdraw.get();
if (overdraw == EVanillaOverdraw.ALWAYS) return Integer.MAX_VALUE;
int offset;
if (overdraw == EVanillaOverdraw.NEVER) {
offset = CONFIG.client().graphics().advancedGraphics().getOverdrawOffset();
offset = Config.Client.Graphics.AdvancedGraphics.overdrawOffset.get();
} else {
if (chunkRenderDist < MINIMUM_RENDER_DISTANCE_FOR_FAR_OVERDRAW) {
offset = 1;
@@ -19,6 +19,8 @@
package com.seibel.lod.core.wrapperInterfaces.config;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.config.types.ConfigCategory;
import com.seibel.lod.core.enums.rendering.EFogDrawMode;
import com.seibel.lod.core.enums.rendering.EFogColorMode;
import com.seibel.lod.core.enums.rendering.EFogDistance;
@@ -80,9 +82,9 @@ public interface ILodConfigWrapperSingleton extends IBindable
EDropoffQuality getDropoffQuality();
void setDropoffQuality(EDropoffQuality newDropoffQuality);
default EDropoffQuality getResolvedDropoffQuality() {
EDropoffQuality dropoffQuality = getDropoffQuality();
EDropoffQuality dropoffQuality = Config.Client.Graphics.Quality.dropoffQuality.get();
if (dropoffQuality == EDropoffQuality.AUTO)
dropoffQuality = getLodChunkRenderDistance() < 128 ?
dropoffQuality = Config.Client.Graphics.Quality.lodChunkRenderDistance.get() < 128 ?
EDropoffQuality.SMOOTH_DROPOFF : EDropoffQuality.PERFORMANCE_FOCUSED;
return dropoffQuality;
}
@@ -158,12 +160,12 @@ public interface ILodConfigWrapperSingleton extends IBindable
default EFogSetting computeHeightFogSetting() {
return new EFogSetting(
getHeightFogStart(),
getHeightFogEnd(),
getHeightFogMin(),
getHeightFogMax(),
getHeightFogDensity(),
getHeightFogType()
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogDensity.get(),
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogEnd.get(),
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMin.get(),
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMax.get(),
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogDensity.get(),
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogType.get()
);
}
}
@@ -261,7 +263,7 @@ public interface ILodConfigWrapperSingleton extends IBindable
void setGenerationPriority(EGenerationPriority newGenerationPriority);
default EGenerationPriority getResolvedGenerationPriority() {
EGenerationPriority priority = getGenerationPriority();
EGenerationPriority priority = Config.Client.WorldGenerator.generationPriority.get();
IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
if (priority == EGenerationPriority.AUTO)
priority = MC.hasSinglePlayerServer() ? EGenerationPriority.FAR_FIRST : EGenerationPriority.BALANCED;
@@ -295,12 +297,12 @@ public interface ILodConfigWrapperSingleton extends IBindable
void setNumberOfWorldGenerationThreads(double newNumberOfWorldGenerationThreads);
default int _getWorldGenerationThreadPoolSize()
{
return getNumberOfWorldGenerationThreads()<1 ? 1 :
(int) Math.ceil(getNumberOfWorldGenerationThreads());
return Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get()<1 ? 1 :
(int) Math.ceil(Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get());
}
default double _getWorldGenerationPartialRunTime()
{
return getNumberOfWorldGenerationThreads()>1 ? 1.0 : getNumberOfWorldGenerationThreads();
return Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get()>1 ? 1.0 : Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get();
}
int getNumberOfBufferBuilderThreads();