Add the first draft of the DH Api

This commit is contained in:
James Seibel
2022-04-26 22:04:21 -05:00
parent 170042620a
commit 76ac0ad3ff
6 changed files with 129 additions and 4 deletions
@@ -29,7 +29,7 @@ package com.seibel.lod.core;
*
* @author James Seibel
* @author Ran
* @version 11-29-2021
* @version 2022-4-25
*/
public final class ModInfo
{
@@ -40,6 +40,11 @@ public final class ModInfo
public static final String NAME = "DistantHorizons";
/** Human readable version of NAME */
public static final String READABLE_NAME = "Distant Horizons";
public static final String API = "LodAPI";
public static final String VERSION = "1.7.0a-dev";
/** This version should only be updated when breaking changes are introduced to the DH API */
public static final int API_MAJOR_VERSION = 1;
/** This version should be updated whenever new methods are added to the DH API */
public static final int API_MINOR_VERSION = 1;
}
@@ -0,0 +1,47 @@
package com.seibel.lod.core.api.external;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.handlers.LodDimensionFileHandler;
/**
* This holds API methods related to version numbers and other unchanging endpoints.
* This shouldn't change between API versions.
*
* @author James Seibel
* @version 2022-4-26
*/
public class ApiMain
{
/** This version should only be updated when breaking changes are introduced to the DH API */
public static int getApiMajorVersion()
{
return ModInfo.API_MAJOR_VERSION;
}
/** This version should be updated whenever new methods are added to the DH API */
public static int getApiMinorVersion()
{
return ModInfo.API_MINOR_VERSION;
}
/** Returns the mod's version number in the format: Major.Minor.Patch */
public static String getModVersion()
{
return ModInfo.VERSION;
}
/** Returns true if the mod is a development version, false if it is a release version. */
public static boolean getIsDevVersion()
{
return #if DEV_BUILD true; #else false; #endif
}
/** Returns the network protocol version. */
public static int getNetworkProtocolVersion()
{
return ModInfo.PROTOCOL_VERSION;
}
/** Returns the LOD file version. */
public static int getLodFileFormatVersion()
{
return LodDimensionFileHandler.LOD_SAVE_FILE_VERSION;
}
}
@@ -1,5 +1,8 @@
package com.seibel.lod.core.api.external;
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. <br> <br>
@@ -15,5 +18,7 @@ package com.seibel.lod.core.api.external;
*/
public class ExternalApiShared
{
public static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
}
@@ -0,0 +1,40 @@
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;
/**
* General Threading settings.
*
* @author James Seibel
* @version 2022-4-26
*/
public class Threading
{
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. */
public static int getNumberOfWorldGeneratorThreads_v1()
{
return threadSettings._getWorldGenerationThreadPoolSize();
}
/**
* Returns a number between 0.0 and 1.0.
*
* 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();
}
/** Number of threads used to rebuild geometry data. */
public static int getNumberOfBufferBuilderThreads_v1()
{
return threadSettings.getNumberOfBufferBuilderThreads();
}
}
@@ -0,0 +1,28 @@
package com.seibel.lod.core.api.external.config.client.graphics;
import com.seibel.lod.core.api.external.ExternalApiShared;
import com.seibel.lod.core.enums.rendering.RendererType;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
/**
* General graphics settings.
*
* @author James Seibel
* @version 2022-4-26
*/
public class General
{
private static final ILodConfigWrapperSingleton.IClient.IGraphics.IQuality qualitySettings = ExternalApiShared.CONFIG.client().graphics().quality();
public static int getLodChunkRenderDistance_v1()
{
return qualitySettings.getLodChunkRenderDistance();
}
public static boolean getRenderingEnabled_v1()
{
return ExternalApiShared.CONFIG.client().advanced().debugging().getRendererType() == RendererType.DEFAULT;
}
}
@@ -99,7 +99,7 @@ public class ReflectionHandler implements IReflectionHandler
// we didn't find the field,
// either optifine isn't installed, or
// optifine changed the name of the variable
LOGGER.info(ReflectionHandler.class.getSimpleName() + ": unable to find the Optifine fog field. If Optifine isn't installed this can be ignored.");
LOGGER.info("Unable to find the Optifine fog field. If Optifine isn't installed this can be ignored.");
}