diff --git a/src/main/java/com/seibel/lod/core/api/external/ExternalApiShared.java b/src/main/java/com/seibel/lod/core/api/external/ExternalApiShared.java
index 39753c8a6..ba6dca001 100644
--- a/src/main/java/com/seibel/lod/core/api/external/ExternalApiShared.java
+++ b/src/main/java/com/seibel/lod/core/api/external/ExternalApiShared.java
@@ -1,24 +1,43 @@
package com.seibel.lod.core.api.external;
+import com.seibel.lod.core.config.types.ConfigEntry;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
/**
* This stores objects and variables that
- * are shared between the different Core external api classes.
+ * are shared between the different external api classes.
*
* The external api package is designed to hold any code that
- * interfaces between Distant Horizons and other mods or projects.
- * For example: if a weather mod wanted to disable LOD rendering during a blizzard
+ * interfaces between Distant Horizons and other mods or projects.
+ * For example: if a weather mod wanted to disable LOD rendering during a blizzard
* they would do that through a method in the external api.
*
*
* @author James Seibel
- * @version 2022-4-24
+ * @version 2022-5-28
*/
public class ExternalApiShared
{
- public static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
-
-
+ /**
+ * If the ConfigEntry doesn't allowApiOverride nothing happens.
+ *
+ * @param configEntry The ConfigEntry to set
+ * @param newValue the value to set the config too
+ * @param the type the config accepts
+ *
+ * @return true if the value was set, false otherwise
+ */
+ public static boolean attemptToSetApiValue(ConfigEntry configEntry, T newValue)
+ {
+ if (configEntry.allowApiOverride)
+ {
+ configEntry.set(newValue);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
}
diff --git a/src/main/java/com/seibel/lod/core/api/external/config/client/DhApiThreading.java b/src/main/java/com/seibel/lod/core/api/external/config/client/DhApiThreading.java
index fce7bfacd..2e906b075 100644
--- a/src/main/java/com/seibel/lod/core/api/external/config/client/DhApiThreading.java
+++ b/src/main/java/com/seibel/lod/core/api/external/config/client/DhApiThreading.java
@@ -1,40 +1,53 @@
package com.seibel.lod.core.api.external.config.client;
import com.seibel.lod.core.api.external.ExternalApiShared;
-import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
+import com.seibel.lod.core.config.Config.Client.Advanced.Threading;
+
/**
* General Threading settings.
*
* @author James Seibel
- * @version 2022-4-26
+ * @version 2022-5-28
*/
public class DhApiThreading
{
- private static final ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading threadSettings = ExternalApiShared.CONFIG.client().advanced().threading();
-
-
- /** Number of threads used to generate terrain outside the vanilla render distance. */
+ /**
+ * Returns the number of threads used to generate
+ * terrain outside the vanilla render distance.
+ */
public static int getNumberOfWorldGeneratorThreads_v1()
{
- return threadSettings._getWorldGenerationThreadPoolSize();
+ return Threading.getWorldGenerationThreadPoolSize();
+ }
+ /** @return true if the value was set, false otherwise. */
+ public static boolean setNumberOfWorldGeneratorThreads_v1(double newValue)
+ {
+ return ExternalApiShared.attemptToSetApiValue(Threading.numberOfWorldGenerationThreads, newValue);
}
/**
- * Returns a number between 0.0 and 1.0.
+ * Returns a number between 0.0 and 1.0, represents the expected time a world generator
+ * thread will be actively generating terrain as a percentage.
*
- * 0.0 = active 0% of the time
- * 0.5 = active 50% of the time
- * 1.0 = active 100% of the time
+ * 0.0 = active 0% of the time
+ * 0.5 = active 50% of the time
+ * 1.0 = active 100% of the time
*/
public static double getWorldGeneratorThreadActivePercentage_v1()
{
- return threadSettings._getWorldGenerationPartialRunTime();
+ return Threading.getWorldGenerationPartialRunTime();
}
- /** Number of threads used to rebuild geometry data. */
+
+ /** Returns the number of threads used to rebuild geometry data. */
public static int getNumberOfBufferBuilderThreads_v1()
{
- return threadSettings.getNumberOfBufferBuilderThreads();
+ return Threading.numberOfBufferBuilderThreads.get();
+ }
+ /** @return true if the value was set, false otherwise. */
+ public static boolean setNumberOfBufferBuilderThreads_v1(int newValue)
+ {
+ return ExternalApiShared.attemptToSetApiValue(Threading.numberOfBufferBuilderThreads, newValue);
}
}
diff --git a/src/main/java/com/seibel/lod/core/api/external/config/client/graphics/DhApiGraphicsGeneral.java b/src/main/java/com/seibel/lod/core/api/external/config/client/graphics/DhApiGraphicsGeneral.java
index 370360518..8c4a324ef 100644
--- a/src/main/java/com/seibel/lod/core/api/external/config/client/graphics/DhApiGraphicsGeneral.java
+++ b/src/main/java/com/seibel/lod/core/api/external/config/client/graphics/DhApiGraphicsGeneral.java
@@ -1,28 +1,44 @@
package com.seibel.lod.core.api.external.config.client.graphics;
import com.seibel.lod.core.api.external.ExternalApiShared;
+import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.rendering.RendererType;
-import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
+import com.seibel.lod.core.config.Config.Client.Graphics.Quality;
+import com.seibel.lod.core.config.Config.Client.Advanced.Debugging;
/**
* General graphics settings.
*
* @author James Seibel
- * @version 2022-4-26
+ * @version 2022-5-28
*/
public class DhApiGraphicsGeneral
{
- private static final ILodConfigWrapperSingleton.IClient.IGraphics.IQuality qualitySettings = ExternalApiShared.CONFIG.client().graphics().quality();
-
-
+ /** Returns the current Disant Horizons render distance radius in chunks. */
public static int getLodChunkRenderDistance_v1()
{
- return qualitySettings.getLodChunkRenderDistance();
+ return Quality.lodChunkRenderDistance.get();
+ }
+ /** @return true if the value was set, false otherwise. */
+ public static boolean setLodChunkRenderDistance_v1(int newValue)
+ {
+ return ExternalApiShared.attemptToSetApiValue(Quality.lodChunkRenderDistance, newValue);
}
+ /**
+ * Returns true if rendering is currently enabled.
+ * Returns false when rendering is disabled or debug rendering is enabled.
+ */
public static boolean getRenderingEnabled_v1()
{
- return ExternalApiShared.CONFIG.client().advanced().debugging().getRendererType() == RendererType.DEFAULT;
+ return Config.Client.Advanced.Debugging.rendererType.get() == RendererType.DEFAULT;
}
+ /** @return true if the value was set, false otherwise. */
+ public static boolean setRenderingEnabled_v1(boolean enableRendering)
+ {
+ RendererType newValue = enableRendering ? RendererType.DEFAULT : RendererType.DISABLED;
+ return ExternalApiShared.attemptToSetApiValue(Debugging.rendererType, newValue);
+ }
+
}