Revamp the API to use API objects and enums

This commit is contained in:
James Seibel
2022-06-02 22:33:52 -05:00
parent 4d2e68e4e5
commit 83fac52334
22 changed files with 281 additions and 196 deletions
@@ -44,4 +44,5 @@ public class DhApiMain
{
return LodDimensionFileHandler.LOD_SAVE_FILE_VERSION;
}
}
@@ -1,9 +1,5 @@
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 external api classes. <br> <br>
@@ -15,29 +11,9 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
*
*
* @author James Seibel
* @version 2022-5-28
* @version 2022-6-2
*/
public class ExternalApiShared
{
/**
* If the ConfigEntry doesn't allowApiOverride nothing happens.
*
* @param configEntry The ConfigEntry to set
* @param newValue the value to set the config too
* @param <T> the type the config accepts
*
* @return true if the value was set, false otherwise
*/
public static <T> boolean attemptToSetApiValue(ConfigEntry<T> configEntry, T newValue)
{
if (configEntry.allowApiOverride)
{
configEntry.set(newValue);
return true;
}
else
{
return false;
}
}
}
@@ -17,26 +17,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.enums.rendering;
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* USE_DEFAULT_FOG_COLOR, <br>
* USE_SKY_COLOR, <br>
*
* @author James Seibel
* @version 11-27-2021
* @version 2022-6-2
*/
public enum FogColorMode
public enum DhApiFogColorMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** Fog uses Minecraft's fog color. */
USE_WORLD_FOG_COLOR,
/**
* Replicates the effect of the clear sky mod.
* Making the fog blend in with the sky better
* For it to look good you need one of the following mods:
* https://www.curseforge.com/minecraft/mc-mods/clear-skies
* https://www.curseforge.com/minecraft/mc-mods/clear-skies-forge-port
* For it to look good you need one of those mods
*/
USE_SKY_COLOR,
}
@@ -17,16 +17,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.enums.rendering;
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* NEAR, FAR, or NEAR_AND_FAR.
*
* @author James Seibel
* @version 11-26-2021
* @version 2022-6-2
*/
public enum FogDistance
public enum DhApiFogDistance
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NEAR,
FAR,
NEAR_AND_FAR
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.enums.rendering;
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* USE_OPTIFINE_FOG_SETTING, <br>
@@ -25,10 +25,14 @@ package com.seibel.lod.core.enums.rendering;
* FOG_DISABLED <br>
*
* @author James Seibel
* @version 11-27-2021
* @version 2022-6-2
*/
public enum FogDrawMode
public enum DhApiFogDrawMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* Use whatever Fog setting optifine is using.
* If optifine isn't installed this defaults to ALWAYS_DRAW_FOG.
@@ -36,5 +40,6 @@ public enum FogDrawMode
USE_OPTIFINE_SETTING,
FOG_ENABLED,
FOG_DISABLED
FOG_DISABLED;
}
@@ -17,27 +17,46 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.enums.rendering;
package com.seibel.lod.core.api.external.apiObjects.enums;
public enum RendererType {
/**
* Default
* Debug
* Disabled
*
* @version 2022-6-2
*/
public enum DhApiRendererType
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
DEFAULT,
DEBUG,
DISABLED,
;
public static RendererType next(RendererType type) {
switch (type) {
DISABLED;
/** Used by the config GUI to cycle through the available rendering options */
public static DhApiRendererType next(DhApiRendererType type)
{
switch (type)
{
case DEFAULT: return DEBUG;
case DEBUG: return DISABLED;
default: return DEFAULT;
}
}
public static RendererType previous(RendererType type) {
switch (type) {
/** Used by the config GUI to cycle through the available rendering options */
public static DhApiRendererType previous(DhApiRendererType type)
{
switch (type)
{
case DEFAULT: return DISABLED;
case DEBUG: return DEFAULT;
default: return DEBUG;
}
}
}
@@ -0,0 +1,75 @@
package com.seibel.lod.core.api.external.apiObjects.objects;
import com.seibel.lod.core.config.types.ConfigEntry;
/**
* A wrapper used to interface with Distant Horizon's Config.
*
* @param <T>
* @author James Seibel
* @version 2022-6-2
*/
public class DhApiConfig_v1<T>
{
private final ConfigEntry<T> configEntry;
/**
* This constructor should only be called internally. <br>
* There is no reason to create this object.
*/
public DhApiConfig_v1(ConfigEntry<T> newConfigEntry)
{
this.configEntry = newConfigEntry;
}
/**
* Returns the active value for this config. <br>
* Returns the True value if either the config cannot be overridden by
* the API or if it hasn't been set by the API.
*/
public T getValue() { return this.configEntry.get(); }
/**
* Returns the value held by this config. <br>
* This is the value stored in the config file.
*/
public T getTrueValue() { return this.configEntry.getTrueValue(); }
/**
* Returns the value of the config if it was set by the API.
* Returns null if the config wasn't set by the API.
*/
public T getApiValue() { return this.configEntry.getApiValue(); }
/**
* Sets the config's value. <br>
* If the newValue is set to null then the config
* will revert to using the True Value.<br>
* If the config cannot be set via the API this method will return false.
*
* @return true if the value was set, false otherwise.
*/
public boolean setValue(T newValue)
{
if (this.configEntry.allowApiOverride)
{
this.configEntry.setApiValue(newValue);
return true;
}
else
{
return false;
}
}
/** Returns true if this config can be set via the API, false otherwise. */
public boolean getCanBeOverrodeByApi() { return this.configEntry.allowApiOverride; }
/** Returns the default value for this config. */
public T getDefaultValue() { return this.configEntry.getDefaultValue(); }
/** Returns the max value for this config, null if there is no max. */
public T getMaxValue() { return this.configEntry.getMax(); }
/** Returns the min value for this config, null if there is no min. */
public T getMinValue() { return this.configEntry.getMin(); }
}
@@ -1,6 +1,6 @@
package com.seibel.lod.core.api.external.config.client;
import com.seibel.lod.core.api.external.ExternalApiShared;
import com.seibel.lod.core.api.external.apiObjects.objects.DhApiConfig_v1;
import com.seibel.lod.core.config.Config.Client.Advanced.Threading;
@@ -8,46 +8,29 @@ import com.seibel.lod.core.config.Config.Client.Advanced.Threading;
* General Threading settings.
*
* @author James Seibel
* @version 2022-5-28
* @version 2022-6-2
*/
public class DhApiThreading
{
/**
* Returns the number of threads used to generate
* terrain outside the vanilla render distance.
*/
public static int getNumberOfWorldGeneratorThreads_v1()
{
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, represents the expected time a world generator
* thread will be actively generating terrain as a percentage. <br> <br>
* Returns the config related to the world generator threads. <br>
* <br>
* If the number of threads is less than 1 it will be treated as a percentage
* representing how often a single thread will be actively generating terrain. <br> <br>
*
* 0.0 = active 0% of the time <br>
* 0.5 = active 50% of the time <br>
* 1.0 = active 100% of the time <br>
* 0.0 = 1 thread active 0% of the time <br>
* 0.5 = 1 thread active 50% of the time <br>
* 1.0 = 1 thread active 100% of the time <br>
* 1.5 = 2 threads active 100% of the time (partial values are rounded up) <br>
* 2.0 = 2 threads active 100% of the time <br>
*/
public static double getWorldGeneratorThreadActivePercentage_v1()
{
return Threading.getWorldGenerationPartialRunTime();
}
public static DhApiConfig_v1<Double> getWorldGeneratorThreadConfig_v1()
{ return new DhApiConfig_v1<>(Threading.numberOfWorldGenerationThreads); }
/** Returns the number of threads used to rebuild geometry data. */
public static int getNumberOfBufferBuilderThreads_v1()
{
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);
}
/** Returns the config related to the buffer (GPU Terrain data) builder threads. */
public static DhApiConfig_v1<Integer> getBufferBuilderThreadConfig_v1()
{ return new DhApiConfig_v1<>(Threading.numberOfBufferBuilderThreads); }
}
@@ -0,0 +1,35 @@
package com.seibel.lod.core.api.external.config.client.graphics;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogColorMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDistance;
import com.seibel.lod.core.api.external.apiObjects.objects.DhApiConfig_v1;
import com.seibel.lod.core.config.Config.Client.Graphics.FogQuality;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDrawMode;
/**
* Any graphics settings related to fog.
*
* @author James Seibel
* @version 2022-6-2
*/
public class DhApiGraphicsFog
{
/** Returns the config related to when fog is rendered. */
public static DhApiConfig_v1<DhApiFogDistance> getFogDistanceConfig_v1()
{ return new DhApiConfig_v1<>(FogQuality.fogDistance); }
/** Returns the config related to when fog is rendered. */
public static DhApiConfig_v1<DhApiFogDrawMode> getFogRenderConfig_v1()
{ return new DhApiConfig_v1<>(FogQuality.fogDrawMode); }
/** Returns the config related to the fog draw type. */
public static DhApiConfig_v1<DhApiFogColorMode> getFogColorConfig_v1()
{ return new DhApiConfig_v1<>(FogQuality.fogColorMode); }
/** Returns the config related to disabling vanilla fog. */
public static DhApiConfig_v1<Boolean> getDisableVanillaFogConfig_v1()
{ return new DhApiConfig_v1<>(FogQuality.disableVanillaFog); }
}
@@ -1,8 +1,8 @@
package com.seibel.lod.core.api.external.config.client.graphics;
import com.seibel.lod.core.api.external.ExternalApiShared;
import com.seibel.lod.core.api.external.apiObjects.objects.DhApiConfig_v1;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.rendering.RendererType;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiRendererType;
import com.seibel.lod.core.config.Config.Client.Graphics.Quality;
import com.seibel.lod.core.config.Config.Client.Advanced.Debugging;
@@ -10,35 +10,20 @@ import com.seibel.lod.core.config.Config.Client.Advanced.Debugging;
* General graphics settings.
*
* @author James Seibel
* @version 2022-5-28
* @version 2022-6-2
*/
public class DhApiGraphicsGeneral
{
/** Returns the current Disant Horizons render distance radius in chunks. */
public static int getLodChunkRenderDistance_v1()
{
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. <br>
* Returns false when rendering is disabled or debug rendering is enabled.
* Returns the config related to Distant Horizons render distance. <br>
* The distance is a radius in measured in chunks.
*/
public static boolean getRenderingEnabled_v1()
{
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);
}
public static DhApiConfig_v1<Integer> getDhChunkRenderDistanceConfig_v1()
{ return new DhApiConfig_v1<>(Quality.lodChunkRenderDistance); }
/** Returns the config related to how Distant Horizons is set to render. */
public static DhApiConfig_v1<DhApiRendererType> getRenderingTypeConfig_v1()
{ return new DhApiConfig_v1<>(Debugging.rendererType); }
}
@@ -24,7 +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.enums.rendering.RendererType;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiRendererType;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
import com.seibel.lod.core.objects.DHChunkPos;
@@ -264,7 +264,7 @@ public class ClientApi
if (CONFIG.client().advanced().debugging().getRendererType() == RendererType.DEFAULT)
if (CONFIG.client().advanced().debugging().getRendererType() == DhApiRendererType.DEFAULT)
{
// Note to self:
// if "unspecified" shows up in the pie chart, it is
@@ -290,7 +290,7 @@ public class ClientApi
}
profiler.pop(); // end LOD
profiler.push("terrain"); // go back into "terrain"
} else if (CONFIG.client().advanced().debugging().getRendererType() == RendererType.DEBUG) {
} else if (CONFIG.client().advanced().debugging().getRendererType() == DhApiRendererType.DEBUG) {
IProfilerWrapper profiler = MC.getProfiler();
profiler.pop(); // get out of "terrain"
profiler.push("LODTestRendering");
@@ -359,7 +359,7 @@ public class ClientApi
if (glfwKey == GLFW.GLFW_KEY_F6)
{
CONFIG.client().advanced().debugging()
.setRendererType(RendererType.next(CONFIG.client().advanced().debugging().getRendererType()));
.setRendererType(DhApiRendererType.next(CONFIG.client().advanced().debugging().getRendererType()));
MC.sendChatMessage("F6: Set rendering to " + CONFIG.client().advanced().debugging().getRendererType());
}
@@ -22,7 +22,7 @@ package com.seibel.lod.core.api.internal.a7;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.enums.rendering.RendererType;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiRendererType;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
@@ -211,7 +211,7 @@ public class ClientApi
level.asyncTick();
}
if (Config.Client.Advanced.Debugging.rendererType.get() == RendererType.DEFAULT) {
if (Config.Client.Advanced.Debugging.rendererType.get() == DhApiRendererType.DEFAULT) {
if (MC_RENDER.playerHasBlindnessEffect()) {
// if the player is blind, don't render LODs,
// and don't change minecraft's fog
@@ -237,7 +237,7 @@ public class ClientApi
}
}
profiler.pop(); // "Render-Lods"
} else if (Config.Client.Advanced.Debugging.rendererType.get() == RendererType.DEBUG) {
} else if (Config.Client.Advanced.Debugging.rendererType.get() == DhApiRendererType.DEBUG) {
profiler.push("Render-Test");
try {
ClientApi.testRenderer.render();
@@ -293,7 +293,7 @@ public class ClientApi
}
if (glfwKey == GLFW.GLFW_KEY_F6)
{
Config.Client.Advanced.Debugging.rendererType.set(RendererType.next(Config.Client.Advanced.Debugging.rendererType.get()));
Config.Client.Advanced.Debugging.rendererType.set(DhApiRendererType.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)
@@ -20,22 +20,15 @@
package com.seibel.lod.core.config;
import com.seibel.lod.core.config.*;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDrawMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogColorMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDistance;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiRendererType;
import com.seibel.lod.core.config.types.*;
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.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;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.*;
/**
* This handles any configuration the user has access to.
@@ -178,34 +171,34 @@ public class Config
public static class FogQuality
{
public static ConfigEntry<FogDistance> fogDistance = new ConfigEntry.Builder<FogDistance>()
.set(FogDistance.FAR)
public static ConfigEntry<DhApiFogDistance> fogDistance = new ConfigEntry.Builder<DhApiFogDistance>()
.set(DhApiFogDistance.FAR)
.comment(""
+ "At what distance should Fog be drawn on the fake chunks? \n"
+ "\n"
+ "This setting shouldn't affect performance.")
.build();
public static ConfigEntry<FogDrawMode> fogDrawMode = new ConfigEntry.Builder<FogDrawMode>()
.set(FogDrawMode.FOG_ENABLED)
public static ConfigEntry<DhApiFogDrawMode> fogDrawMode = new ConfigEntry.Builder<DhApiFogDrawMode>()
.set(DhApiFogDrawMode.FOG_ENABLED)
.comment(""
+ "When should fog be drawn? \n"
+ "\n"
+ FogDrawMode.USE_OPTIFINE_SETTING + ": Use whatever Fog setting Optifine is using.\n"
+ "If Optifine isn't installed this defaults to " + FogDrawMode.FOG_ENABLED + ". \n"
+ FogDrawMode.FOG_ENABLED + ": Never draw fog on the LODs \n"
+ FogDrawMode.FOG_DISABLED + ": Always draw fast fog on the LODs \n"
+ DhApiFogDrawMode.USE_OPTIFINE_SETTING + ": Use whatever Fog setting Optifine is using.\n"
+ "If Optifine isn't installed this defaults to " + DhApiFogDrawMode.FOG_ENABLED + ". \n"
+ DhApiFogDrawMode.FOG_ENABLED + ": Never draw fog on the LODs \n"
+ DhApiFogDrawMode.FOG_DISABLED + ": Always draw fast fog on the LODs \n"
+ "\n"
+ "Disabling fog will improve GPU performance.")
.build();
public static ConfigEntry<FogColorMode> fogColorMode = new ConfigEntry.Builder<FogColorMode>()
.set(FogColorMode.USE_WORLD_FOG_COLOR)
public static ConfigEntry<DhApiFogColorMode> fogColorMode = new ConfigEntry.Builder<DhApiFogColorMode>()
.set(DhApiFogColorMode.USE_WORLD_FOG_COLOR)
.comment(""
+ "What color should fog use? \n"
+ "\n"
+ FogColorMode.USE_WORLD_FOG_COLOR + ": Use the world's fog color. \n"
+ FogColorMode.USE_SKY_COLOR + ": Use the sky's color. \n"
+ DhApiFogColorMode.USE_WORLD_FOG_COLOR + ": Use the world's fog color. \n"
+ DhApiFogColorMode.USE_SKY_COLOR + ": Use the sky's color. \n"
+ "\n"
+ "This setting doesn't affect performance.")
.build();
@@ -737,14 +730,14 @@ public class Config
public static class Debugging
{
public static ConfigEntry<RendererType> rendererType = new ConfigEntry.Builder<RendererType>()
.set(RendererType.DEFAULT)
public static ConfigEntry<DhApiRendererType> rendererType = new ConfigEntry.Builder<DhApiRendererType>()
.set(DhApiRendererType.DEFAULT)
.comment(""
+ "What renderer is active? \n"
+ "\n"
+ RendererType.DEFAULT + ": Default lod renderer \n"
+ RendererType.DEBUG + ": Debug testing renderer \n"
+ RendererType.DISABLED + ": Disable rendering")
+ DhApiRendererType.DEFAULT + ": Default lod renderer \n"
+ DhApiRendererType.DEBUG + ": Debug testing renderer \n"
+ DhApiRendererType.DISABLED + ": Disable rendering")
.build();
public static ConfigEntry<DebugMode> debugMode = new ConfigEntry.Builder<DebugMode>()
@@ -115,14 +115,14 @@ public class ConfigFileHandling {
if (workConfig.contains(entry.getNameWCategory())) {
try {
if (entry.getType().isEnum()) {
entry.setWithoutSaving((T) ( workConfig.getEnum(entry.getNameWCategory(), (Class<? extends Enum>) entry.getType()) ));
entry.setWTSave((T) ( workConfig.getEnum(entry.getNameWCategory(), (Class<? extends Enum>) entry.getType()) ));
} else if (ConfigTypeConverters.convertObjects.containsKey(entry.getType())) {
entry.setWithoutSaving((T) ConfigTypeConverters.convertFromString(entry.getType(), workConfig.get(entry.getNameWCategory())));
entry.setWTSave((T) ConfigTypeConverters.convertFromString(entry.getType(), workConfig.get(entry.getNameWCategory())));
} else {
entry.setWithoutSaving((T) workConfig.get(entry.getNameWCategory()));
entry.setWTSave((T) workConfig.get(entry.getNameWCategory()));
if (entry.isValid() == 0) return;
else if (entry.isValid() == -1) entry.setWithoutSaving(entry.getMin());
else if (entry.isValid() == 1) entry.setWithoutSaving(entry.getMax());
else if (entry.isValid() == -1) entry.setWTSave(entry.getMin());
else if (entry.isValid() == 1) entry.setWTSave(entry.getMax());
}
} catch (Exception e) {
e.printStackTrace();
@@ -41,10 +41,14 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
public T getDefaultValue() {
return this.defaultValue;
}
public void setApiValue(T newApiValue) {
this.apiValue = newApiValue;
}
public T getApiValue() {
return this.apiValue;
}
@Override
public void set(T newValue) {
this.value = newValue;
@@ -61,7 +65,7 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
}
/** Sets the value without saving */
public void setWithoutSaving(T newValue) {
public void setWTSave(T newValue) {
this.value = newValue;
}
@@ -190,4 +194,5 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
return new ConfigEntry<T>(tmpAppearance, tmpValue, tmpComment, tmpMin, tmpMax, tmpUseApiOverwrite);
}
}
}
@@ -19,7 +19,7 @@
package com.seibel.lod.core.handlers;
import com.seibel.lod.core.enums.rendering.FogDrawMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDrawMode;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
/**
@@ -40,7 +40,7 @@ import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
public interface IReflectionHandler extends IBindable
{
/** @return Whether Optifine is set to render fog or not. */
FogDrawMode getFogDrawMode();
DhApiFogDrawMode getFogDrawMode();
/** @return if Vivecraft is present. Attempts to find the "VRRenderer" class. */
boolean vivecraftPresent();
@@ -27,7 +27,7 @@ import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import org.apache.logging.log4j.Logger;
import com.seibel.lod.core.enums.rendering.FogDrawMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDrawMode;
/**
* A singleton used to get variables from methods
@@ -109,14 +109,14 @@ public class ReflectionHandler implements IReflectionHandler
* @return the fog quality
*/
@Override
public FogDrawMode getFogDrawMode()
public DhApiFogDrawMode getFogDrawMode()
{
if (ofFogField == null)
{
// either optifine isn't installed,
// the variable name was changed, or
// the setup method wasn't called yet.
return FogDrawMode.FOG_ENABLED;
return DhApiFogDrawMode.FOG_ENABLED;
}
int returnNum = 0;
@@ -140,9 +140,9 @@ public class ReflectionHandler implements IReflectionHandler
// normal options
case 1: // fast
case 2: // fancy
return FogDrawMode.FOG_ENABLED;
return DhApiFogDrawMode.FOG_ENABLED;
case 3: // off
return FogDrawMode.FOG_DISABLED;
return DhApiFogDrawMode.FOG_DISABLED;
}
}
@@ -19,6 +19,8 @@
package com.seibel.lod.core.render;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDrawMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDistance;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.handlers.IReflectionHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
@@ -60,26 +62,26 @@ public class LodFogConfig
public static LodFogConfig generateFogConfig()
{
FogDrawMode fogMode = CONFIG.client().graphics().fogQuality().getFogDrawMode();
if (fogMode == FogDrawMode.USE_OPTIFINE_SETTING)
DhApiFogDrawMode fogMode = CONFIG.client().graphics().fogQuality().getFogDrawMode();
if (fogMode == DhApiFogDrawMode.USE_OPTIFINE_SETTING)
fogMode = REFLECTION_HANDLER.getFogDrawMode();
return new LodFogConfig(fogMode);
}
/** sets all fog options from the config */
private LodFogConfig(FogDrawMode fogDrawMode)
private LodFogConfig(DhApiFogDrawMode fogDrawMode)
{
earthCurveRatio = CONFIG.client().graphics().advancedGraphics().getEarthCurveRatio(); //FIXME: Move this out of here
if (fogDrawMode != FogDrawMode.FOG_DISABLED)
if (fogDrawMode != DhApiFogDrawMode.FOG_DISABLED)
{
ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality fogSettings = CONFIG.client().graphics().fogQuality();
FogDistance fogDistance = fogSettings.getFogDistance();
drawNearFog = (fogDistance == FogDistance.NEAR || fogDistance == FogDistance.NEAR_AND_FAR);
DhApiFogDistance fogDistance = fogSettings.getFogDistance();
drawNearFog = (fogDistance == DhApiFogDistance.NEAR || fogDistance == DhApiFogDistance.NEAR_AND_FAR);
if (fogDistance == FogDistance.FAR || fogDistance == FogDistance.NEAR_AND_FAR)
if (fogDistance == DhApiFogDistance.FAR || fogDistance == DhApiFogDistance.NEAR_AND_FAR)
{
// far fog should be drawn
@@ -39,8 +39,8 @@ import org.lwjgl.opengl.GL32;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodBufferBuilderFactory;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.enums.rendering.FogColorMode;
import com.seibel.lod.core.enums.rendering.FogDistance;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogColorMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDistance;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.objects.lod.LodDimension;
import com.seibel.lod.core.objects.math.Mat4f;
@@ -118,7 +118,7 @@ public class LodRenderer
/** This is used to determine if the LODs should be regenerated */
private FogDistance prevFogDistance = FogDistance.NEAR_AND_FAR;
private DhApiFogDistance prevFogDistance = DhApiFogDistance.NEAR_AND_FAR;
/**
* if this is true the LOD buffers should be regenerated,
@@ -432,7 +432,7 @@ public class LodRenderer
{
Color fogColor;
if (CONFIG.client().graphics().fogQuality().getFogColorMode() == FogColorMode.USE_SKY_COLOR)
if (CONFIG.client().graphics().fogQuality().getFogColorMode() == DhApiFogColorMode.USE_SKY_COLOR)
fogColor = MC_RENDER.getSkyColor();
else
fogColor = MC_RENDER.getFogColor(partialTicks);
@@ -20,36 +20,26 @@
package com.seibel.lod.core.render;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.api.internal.InternalApiShared;
import com.seibel.lod.core.builders.lodBuilding.bufferBuilding.LodBufferBuilderFactory;
import com.seibel.lod.core.config.types.ConfigEntry;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.enums.rendering.FogColorMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogColorMode;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.logging.ConfigBasedLogger;
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
import com.seibel.lod.core.objects.BoolType;
import com.seibel.lod.core.objects.DHBlockPos;
import com.seibel.lod.core.objects.Pos2D;
import com.seibel.lod.core.objects.a7.DHLevel;
import com.seibel.lod.core.objects.a7.render.RenderBufferHandler;
import com.seibel.lod.core.objects.lod.LodDimension;
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.render.objects.GLState;
import com.seibel.lod.core.render.objects.QuadElementBuffer;
import com.seibel.lod.core.util.DetailDistanceUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.gridList.EdgeDistanceBooleanGrid;
import com.seibel.lod.core.util.gridList.MovableGridRingList;
import com.seibel.lod.core.util.gridList.PosArrayGridList;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
import org.apache.logging.log4j.LogManager;
import org.lwjgl.opengl.GL32;
@@ -286,7 +276,7 @@ public class a7LodRenderer
{
Color fogColor;
if (Config.Client.Graphics.FogQuality.fogColorMode.get() == FogColorMode.USE_SKY_COLOR)
if (Config.Client.Graphics.FogQuality.fogColorMode.get() == DhApiFogColorMode.USE_SKY_COLOR)
fogColor = MC_RENDER.getSkyColor();
else
fogColor = MC_RENDER.getFogColor(partialTicks);
@@ -19,6 +19,10 @@
package com.seibel.lod.core.wrapperInterfaces.config;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDrawMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogColorMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDistance;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiRendererType;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
@@ -89,14 +93,14 @@ public interface ILodConfigWrapperSingleton extends IBindable
@Deprecated
interface IFogQuality
{
FogDistance getFogDistance();
void setFogDistance(FogDistance newFogDistance);
DhApiFogDistance getFogDistance();
void setFogDistance(DhApiFogDistance newFogDistance);
FogDrawMode getFogDrawMode();
void setFogDrawMode(FogDrawMode newFogDrawMode);
DhApiFogDrawMode getFogDrawMode();
void setFogDrawMode(DhApiFogDrawMode newFogDrawMode);
FogColorMode getFogColorMode();
void setFogColorMode(FogColorMode newFogColorMode);
DhApiFogColorMode getFogColorMode();
void setFogColorMode(DhApiFogColorMode newFogColorMode);
boolean getDisableVanillaFog();
void setDisableVanillaFog(boolean newDisableVanillaFog);
@@ -305,8 +309,8 @@ public interface ILodConfigWrapperSingleton extends IBindable
@Deprecated
interface IDebugging
{
RendererType getRendererType();
void setRendererType(RendererType newRendererType);
DhApiRendererType getRendererType();
void setRendererType(DhApiRendererType newRendererType);
DebugMode getDebugMode();
void setDebugMode(DebugMode newDebugMode);
@@ -1,5 +1,9 @@
package com.seibel.lod.core.wrapperInterfaces.config;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDrawMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogColorMode;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiFogDistance;
import com.seibel.lod.core.api.external.apiObjects.enums.DhApiRendererType;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
@@ -206,38 +210,38 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
}
@Override
public FogDistance getFogDistance()
public DhApiFogDistance getFogDistance()
{
return Config.Client.Graphics.FogQuality.fogDistance.get();
}
@Override
public void setFogDistance(FogDistance newFogDistance)
public void setFogDistance(DhApiFogDistance newFogDistance)
{
Config.Client.Graphics.FogQuality.fogDistance.set(newFogDistance);
}
@Override
public FogDrawMode getFogDrawMode()
public DhApiFogDrawMode getFogDrawMode()
{
return Config.Client.Graphics.FogQuality.fogDrawMode.get();
}
@Override
public void setFogDrawMode(FogDrawMode setFogDrawMode)
public void setFogDrawMode(DhApiFogDrawMode setFogDrawMode)
{
Config.Client.Graphics.FogQuality.fogDrawMode.set(setFogDrawMode);
}
@Override
public FogColorMode getFogColorMode()
public DhApiFogColorMode getFogColorMode()
{
return Config.Client.Graphics.FogQuality.fogColorMode.get();
}
@Override
public void setFogColorMode(FogColorMode newFogColorMode)
public void setFogColorMode(DhApiFogColorMode newFogColorMode)
{
Config.Client.Graphics.FogQuality.fogColorMode.set(newFogColorMode);
}
@@ -725,11 +729,11 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
* DISABLED
* */
@Override
public RendererType getRendererType() {
public DhApiRendererType getRendererType() {
return Config.Client.Advanced.Debugging.rendererType.get();
}
@Override
public void setRendererType(RendererType newRenderType) {
public void setRendererType(DhApiRendererType newRenderType) {
Config.Client.Advanced.Debugging.rendererType.set(newRenderType);
}