diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiDebuggingConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiDebuggingConfig.java index 925dfc3da..37ecb7d55 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiDebuggingConfig.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiDebuggingConfig.java @@ -33,19 +33,19 @@ public class DhApiDebuggingConfig implements IDhApiDebuggingConfig - public IDhApiConfigValue debugRendering() + @Override public IDhApiConfigValue debugRendering() { return new DhApiConfigValue(Config.Client.Advanced.Debugging.debugRendering); } - public IDhApiConfigValue debugKeybindings() + @Override public IDhApiConfigValue debugKeybindings() { return new DhApiConfigValue(Config.Client.Advanced.Debugging.enableDebugKeybindings); } - public IDhApiConfigValue renderWireframe() + @Override public IDhApiConfigValue renderWireframe() { return new DhApiConfigValue(Config.Client.Advanced.Debugging.renderWireframe); } - public IDhApiConfigValue lodOnlyMode() + @Override public IDhApiConfigValue lodOnlyMode() { return new DhApiConfigValue(Config.Client.Advanced.Debugging.lodOnlyMode); } - public IDhApiConfigValue debugWireframeRendering() + @Override public IDhApiConfigValue debugWireframeRendering() { return new DhApiConfigValue(Config.Client.Advanced.Debugging.DebugWireframe.enableRendering); } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiMultiplayerConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiMultiplayerConfig.java index 1c16671d0..f1f1b2167 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiMultiplayerConfig.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiMultiplayerConfig.java @@ -33,10 +33,10 @@ public class DhApiMultiplayerConfig implements IDhApiMultiplayerConfig - public IDhApiConfigValue folderSavingMode() + @Override public IDhApiConfigValue folderSavingMode() { return new DhApiConfigValue(Config.Client.Advanced.Multiplayer.serverFolderNameMode); } - public IDhApiConfigValue multiverseSimilarityRequirement() + @Override public IDhApiConfigValue multiverseSimilarityRequirement() { return new DhApiConfigValue(Config.Client.Advanced.Multiplayer.multiverseSimilarityRequiredPercent); } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index b517223d7..006e3b7a5 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -61,61 +61,236 @@ public class Config { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); - public static ConfigCategory client = new ConfigCategory.Builder().set(Client.class).build(); - - - - public static class Client + private static Config GLOBAL_INSTANCE; + public static void initializeGlobalConfig() { - public static ConfigEntry quickEnableRendering = new ConfigEntry.Builder() - .set(true) - .comment("" - + "If true, Distant Horizons will render LODs beyond the vanilla render distance." - + "") - .setAppearance(EConfigEntryAppearance.ONLY_IN_GUI) + if (GLOBAL_INSTANCE != null) + { + throw new IllegalStateException("Cannot reinitialize the Config"); + } + GLOBAL_INSTANCE = new Config(); + } + public static Config getGlobalConfig() { return GLOBAL_INSTANCE; } + + public final QuickSettings quickSettings = new QuickSettings(); + public final Graphics graphics = new Graphics(); + + public class QuickSettings + { + public final ConfigEntry enableRendering = new ConfigEntry.Builder() + .computed( + () -> Config.this.debugging.rendererMode.get() != EDhApiRendererMode.DISABLED, + enableRendering -> Config.this.debugging.rendererMode.set(enableRendering + ? EDhApiRendererMode.DEFAULT + : EDhApiRendererMode.DISABLED + ) + ) .build(); - public static ConfigLinkedEntry quickLodChunkRenderDistance = new ConfigLinkedEntry(Advanced.Graphics.Quality.lodChunkRenderDistanceRadius); - - public static ConfigEntry qualityPresetSetting = new ConfigEntry.Builder() - .set(EDhApiQualityPreset.MEDIUM) // the default value is set via the listener when accessed - .comment("" - + "Changing this setting will modify a number of different settings that will change the \n" - + "visual fidelity of the rendered LODs.\n" - + "\n" - + "Higher settings will improve the graphical quality while increasing GPU and memory use.\n" - + "") - .setAppearance(EConfigEntryAppearance.ONLY_IN_GUI) - .addListener(RenderQualityPresetConfigEventHandler.INSTANCE) + public final ConfigEntry lodChunkRenderDistanceRadius = new ConfigEntry.Builder() + .linkedTo(() -> Config.this.graphics.quality.lodChunkRenderDistanceRadius) .build(); - public static ConfigEntry threadPresetSetting = new ConfigEntry.Builder() + public final ConfigEntry qualityPreset = new ConfigEntry.Builder() + .preset( + new ConfigEntry.PresetBuilder<>(EDhApiQualityPreset.CUSTOM) + .addConfigEntry(() -> Config.this.graphics.quality.maxHorizontalResolution, map -> { + map.put(EDhApiQualityPreset.MINIMUM, EDhApiMaxHorizontalResolution.TWO_BLOCKS); + map.put(EDhApiQualityPreset.LOW, EDhApiMaxHorizontalResolution.BLOCK); + map.put(EDhApiQualityPreset.MEDIUM, EDhApiMaxHorizontalResolution.BLOCK); + map.put(EDhApiQualityPreset.HIGH, EDhApiMaxHorizontalResolution.BLOCK); + map.put(EDhApiQualityPreset.EXTREME, EDhApiMaxHorizontalResolution.BLOCK); + }) + .addConfigEntry(() -> Config.this.graphics.quality.verticalQuality, map -> { + map.put(EDhApiQualityPreset.MINIMUM, EDhApiVerticalQuality.HEIGHT_MAP); + map.put(EDhApiQualityPreset.LOW, EDhApiVerticalQuality.LOW); + map.put(EDhApiQualityPreset.MEDIUM, EDhApiVerticalQuality.MEDIUM); + map.put(EDhApiQualityPreset.HIGH, EDhApiVerticalQuality.HIGH); + map.put(EDhApiQualityPreset.EXTREME, EDhApiVerticalQuality.EXTREME); + }) + .addConfigEntry(() -> Config.this.graphics.quality.horizontalQuality, map -> { + map.put(EDhApiQualityPreset.MINIMUM, EDhApiHorizontalQuality.LOWEST); + map.put(EDhApiQualityPreset.LOW, EDhApiHorizontalQuality.LOW); + map.put(EDhApiQualityPreset.MEDIUM, EDhApiHorizontalQuality.MEDIUM); + map.put(EDhApiQualityPreset.HIGH, EDhApiHorizontalQuality.HIGH); + map.put(EDhApiQualityPreset.EXTREME, EDhApiHorizontalQuality.EXTREME); + }) + .addConfigEntry(() -> Config.this.graphics.quality.transparency, map -> { + map.put(EDhApiQualityPreset.MINIMUM, EDhApiTransparency.DISABLED); + map.put(EDhApiQualityPreset.LOW, EDhApiTransparency.DISABLED); // should be fake if/when fake is fixed + map.put(EDhApiQualityPreset.MEDIUM, EDhApiTransparency.COMPLETE); + map.put(EDhApiQualityPreset.HIGH, EDhApiTransparency.COMPLETE); + map.put(EDhApiQualityPreset.EXTREME, EDhApiTransparency.COMPLETE); + }) + .addConfigEntry(() -> Config.this.graphics.quality.ssao.enabled, map -> { + map.put(EDhApiQualityPreset.MINIMUM, false); + map.put(EDhApiQualityPreset.LOW, false); + map.put(EDhApiQualityPreset.MEDIUM, true); + map.put(EDhApiQualityPreset.HIGH, true); + map.put(EDhApiQualityPreset.EXTREME, true); + }) + ) + .build(); + + public final ConfigEntry threadPreset = new ConfigEntry.Builder() .set(EDhApiThreadPreset.LOW_IMPACT) // the default value is set via the listener when accessed - .comment("" - + "Changing this setting will modify a number of different settings that will change \n" - + "the load that Distant Horizons is allowed to put on your CPU. \n" - + "\n" - + "Higher options will improve LOD generation and loading speed, \n" - + "but will increase CPU load and may introduce stuttering.\n" - + "\n" - + "Note: on CPUs with 4 cores or less these settings will be less effective \n" - + " and some settings will give similar results. \n" - + "") .setAppearance(EConfigEntryAppearance.ONLY_IN_GUI) .addListener(ThreadPresetConfigEventHandler.INSTANCE) .build(); - public static ConfigLinkedEntry quickEnableWorldGenerator = new ConfigLinkedEntry(Advanced.WorldGenerator.enableDistantGeneration); + public final ConfigLinkedEntry quickEnableWorldGenerator = new ConfigLinkedEntry(_Client.Advanced.WorldGenerator.enableDistantGeneration); - public static ConfigLinkedEntry quickLodCloudRendering = new ConfigLinkedEntry(Advanced.Graphics.GenericRendering.enableCloudRendering); + public final ConfigLinkedEntry quickLodCloudRendering = new ConfigLinkedEntry(_Client.Advanced.Graphics.GenericRendering.enableCloudRendering); - public static ConfigEntry optionsButton = new ConfigEntry.Builder() + public final ConfigEntry showOptionsButton = new ConfigEntry.Builder() .set(true) .setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) .comment("" + "Should Distant Horizon's config button appear in the options screen next to fov slider?") .build(); + } + + + public static class Graphics + { + public final Quality quality = new Quality(); + + public static class Quality + { + public ConfigEntry lodChunkRenderDistanceRadius = new ConfigEntry.Builder() + .setServersideShortName("renderDistanceRadius") + .setMinDefaultMax(32, 128, 4096) + .comment("" + + "The radius of the mod's render distance. (measured in chunks)\n" + + "On server changes the distance players will receive real-time updates for, if enabled." + + "\n" + + "Note for servers:\n" + + "This setting does not prevent players from generating farther out.\n" + + "If you want to limit performance impact, change rate limits\n" + + "and thread count/runtime ratio settings instead.\n" + + "It also does not affect the visuals on clients.") + .setPerformance(EConfigEntryPerformance.HIGH) + .setSide(EConfigEntryRelevantSide.BOTH) + .build(); + + public ConfigEntry maxHorizontalResolution = new ConfigEntry.Builder() + .set(EDhApiMaxHorizontalResolution.BLOCK) + .comment("" + + "What is the maximum detail LODs should be drawn at? \n" + + "Higher settings will increase memory and GPU usage. \n" + + "\n" + + EDhApiMaxHorizontalResolution.CHUNK + ": render 1 LOD for each Chunk. \n" + + EDhApiMaxHorizontalResolution.HALF_CHUNK + ": render 4 LODs for each Chunk. \n" + + EDhApiMaxHorizontalResolution.FOUR_BLOCKS + ": render 16 LODs for each Chunk. \n" + + EDhApiMaxHorizontalResolution.TWO_BLOCKS + ": render 64 LODs for each Chunk. \n" + + EDhApiMaxHorizontalResolution.BLOCK + ": render 256 LODs for each Chunk (width of one block). \n" + + "\n" + + "Lowest Quality: " + EDhApiMaxHorizontalResolution.CHUNK + "\n" + + "Highest Quality: " + EDhApiMaxHorizontalResolution.BLOCK) + .setPerformance(EConfigEntryPerformance.MEDIUM) + .build(); + + public ConfigEntry verticalQuality = new ConfigEntry.Builder() + .set(EDhApiVerticalQuality.MEDIUM) + .comment("" + + "This indicates how well LODs will represent \n" + + "overhangs, caves, floating islands, etc. \n" + + "Higher options will make the world more accurate, but" + + "will increase memory and GPU usage. \n" + + "\n" + + "Lowest Quality: " + EDhApiVerticalQuality.HEIGHT_MAP + "\n" + + "Highest Quality: " + EDhApiVerticalQuality.EXTREME) + .setPerformance(EConfigEntryPerformance.VERY_HIGH) + .addListener(ReloadLodsConfigEventHandler.INSTANCE) + .build(); + + public ConfigEntry horizontalQuality = new ConfigEntry.Builder() + .set(EDhApiHorizontalQuality.MEDIUM) + .comment("" + + "This indicates how quickly LODs decrease in quality the further away they are. \n" + + "Higher settings will render higher quality fake chunks farther away, \n" + + "but will increase memory and GPU usage.") + .setPerformance(EConfigEntryPerformance.MEDIUM) + .build(); + + public ConfigEntry transparency = new ConfigEntry.Builder() + .set(EDhApiTransparency.COMPLETE) + .comment("" + + "How should LOD transparency be handled. \n" + + "\n" + + EDhApiTransparency.COMPLETE + ": LODs will render transparent. \n" + + EDhApiTransparency.FAKE + ": LODs will be opaque, but shaded to match the blocks underneath. \n" + + EDhApiTransparency.DISABLED + ": LODs will be opaque. \n" + + "") + .setPerformance(EConfigEntryPerformance.MEDIUM) + .addListener(ReloadLodsConfigEventHandler.INSTANCE) + .build(); + + + public ConfigEntry blocksToIgnore = new ConfigEntry.Builder() + .set(EDhApiBlocksToAvoid.NON_COLLIDING) + .comment("" + + "What blocks shouldn't be rendered as LODs? \n" + + "\n" + + EDhApiBlocksToAvoid.NONE + ": Represent all blocks in the LODs \n" + + EDhApiBlocksToAvoid.NON_COLLIDING + ": Only represent solid blocks in the LODs (tall grass, torches, etc. won't count for a LOD's height) \n" + + "") + .setPerformance(EConfigEntryPerformance.NONE) + .addListener(ReloadLodsConfigEventHandler.INSTANCE) + .build(); + + public ConfigEntry tintWithAvoidedBlocks = new ConfigEntry.Builder() + .set(true) + .comment("" + + "Should the blocks underneath avoided blocks gain the color of the avoided block? \n" + + "\n" + + "True: a red flower will tint the grass below it red. \n" + + "False: skipped blocks will not change color of surface below them. " + + "") + .setPerformance(EConfigEntryPerformance.NONE) + .addListener(ReloadLodsConfigEventHandler.INSTANCE) + .build(); + + // TODO fixme + //public static ConfigEntry lodBiomeBlending = new ConfigEntry.Builder() + // .setMinDefaultMax(0,1,7) + // .comment("" + // + "This is the same as vanilla Biome Blending settings for Lod area. \n" + // + " Note that anything other than '0' will greatly effect Lod building time \n" + // + " and increase triangle count. The cost on chunk generation speed is also \n" + // + " quite large if set too high.\n" + // + "\n" + // + " '0' equals to Vanilla Biome Blending of '1x1' or 'OFF', \n" + // + " '1' equals to Vanilla Biome Blending of '3x3', \n" + // + " '2' equals to Vanilla Biome Blending of '5x5'...") + // .build(); + + } + + } + + public final Debugging debugging = new Debugging(); + + public static class Debugging + { + public ConfigEntry rendererMode = new ConfigEntry.Builder() + .set(EDhApiRendererMode.DEFAULT) + .comment("" + + "What renderer is active? \n" + + "\n" + + EDhApiRendererMode.DEFAULT + ": Default lod renderer \n" + + EDhApiRendererMode.DEBUG + ": Debug testing renderer \n" + + EDhApiRendererMode.DISABLED + ": Disable rendering") + .build(); + + } + + + public static class _Client + { + + public static ConfigCategory advanced = new ConfigCategory.Builder().set(Advanced.class).build(); @@ -146,112 +321,6 @@ public class Config public static class Quality { - public static ConfigEntry maxHorizontalResolution = new ConfigEntry.Builder() - .set(EDhApiMaxHorizontalResolution.BLOCK) - .comment("" - + "What is the maximum detail LODs should be drawn at? \n" - + "Higher settings will increase memory and GPU usage. \n" - + "\n" - + EDhApiMaxHorizontalResolution.CHUNK + ": render 1 LOD for each Chunk. \n" - + EDhApiMaxHorizontalResolution.HALF_CHUNK + ": render 4 LODs for each Chunk. \n" - + EDhApiMaxHorizontalResolution.FOUR_BLOCKS + ": render 16 LODs for each Chunk. \n" - + EDhApiMaxHorizontalResolution.TWO_BLOCKS + ": render 64 LODs for each Chunk. \n" - + EDhApiMaxHorizontalResolution.BLOCK + ": render 256 LODs for each Chunk (width of one block). \n" - + "\n" - + "Lowest Quality: " + EDhApiMaxHorizontalResolution.CHUNK + "\n" - + "Highest Quality: " + EDhApiMaxHorizontalResolution.BLOCK) - .setPerformance(EConfigEntryPerformance.MEDIUM) - .build(); - - public static ConfigEntry lodChunkRenderDistanceRadius = new ConfigEntry.Builder() - .setServersideShortName("renderDistanceRadius") - .setMinDefaultMax(32, 128, 4096) - .comment("" + - "The radius of the mod's render distance. (measured in chunks)\n" + - "On server changes the distance players will receive real-time updates for, if enabled." + - "\n" + - "Note for servers:\n" + - "This setting does not prevent players from generating farther out.\n" + - "If you want to limit performance impact, change rate limits\n" + - "and thread count/runtime ratio settings instead.\n" + - "It also does not affect the visuals on clients.") - .setPerformance(EConfigEntryPerformance.HIGH) - .setSide(EConfigEntryRelevantSide.BOTH) - .build(); - - public static ConfigEntry verticalQuality = new ConfigEntry.Builder() - .set(EDhApiVerticalQuality.MEDIUM) - .comment("" - + "This indicates how well LODs will represent \n" - + "overhangs, caves, floating islands, etc. \n" - + "Higher options will make the world more accurate, but" - + "will increase memory and GPU usage. \n" - + "\n" - + "Lowest Quality: " + EDhApiVerticalQuality.HEIGHT_MAP + "\n" - + "Highest Quality: " + EDhApiVerticalQuality.EXTREME) - .setPerformance(EConfigEntryPerformance.VERY_HIGH) - .addListener(ReloadLodsConfigEventHandler.INSTANCE) - .build(); - - public static ConfigEntry horizontalQuality = new ConfigEntry.Builder() - .set(EDhApiHorizontalQuality.MEDIUM) - .comment("" - + "This indicates how quickly LODs decrease in quality the further away they are. \n" - + "Higher settings will render higher quality fake chunks farther away, \n" - + "but will increase memory and GPU usage.") - .setPerformance(EConfigEntryPerformance.MEDIUM) - .build(); - - public static ConfigEntry transparency = new ConfigEntry.Builder() - .set(EDhApiTransparency.COMPLETE) - .comment("" - + "How should LOD transparency be handled. \n" - + "\n" - + EDhApiTransparency.COMPLETE + ": LODs will render transparent. \n" - + EDhApiTransparency.FAKE + ": LODs will be opaque, but shaded to match the blocks underneath. \n" - + EDhApiTransparency.DISABLED + ": LODs will be opaque. \n" - + "") - .setPerformance(EConfigEntryPerformance.MEDIUM) - .addListener(ReloadLodsConfigEventHandler.INSTANCE) - .build(); - - public static ConfigEntry blocksToIgnore = new ConfigEntry.Builder() - .set(EDhApiBlocksToAvoid.NON_COLLIDING) - .comment("" - + "What blocks shouldn't be rendered as LODs? \n" - + "\n" - + EDhApiBlocksToAvoid.NONE + ": Represent all blocks in the LODs \n" - + EDhApiBlocksToAvoid.NON_COLLIDING + ": Only represent solid blocks in the LODs (tall grass, torches, etc. won't count for a LOD's height) \n" - + "") - .setPerformance(EConfigEntryPerformance.NONE) - .addListener(ReloadLodsConfigEventHandler.INSTANCE) - .build(); - - public static ConfigEntry tintWithAvoidedBlocks = new ConfigEntry.Builder() - .set(true) - .comment("" - + "Should the blocks underneath avoided blocks gain the color of the avoided block? \n" - + "\n" - + "True: a red flower will tint the grass below it red. \n" - + "False: skipped blocks will not change color of surface below them. " - + "") - .setPerformance(EConfigEntryPerformance.NONE) - .addListener(ReloadLodsConfigEventHandler.INSTANCE) - .build(); - - // TODO fixme -// public static ConfigEntry lodBiomeBlending = new ConfigEntry.Builder() -// .setMinDefaultMax(0,1,7) -// .comment("" -// + "This is the same as vanilla Biome Blending settings for Lod area. \n" -// + " Note that anything other than '0' will greatly effect Lod building time \n" -// + " and increase triangle count. The cost on chunk generation speed is also \n" -// + " quite large if set too high.\n" -// + "\n" -// + " '0' equals to Vanilla Biome Blending of '1x1' or 'OFF', \n" -// + " '1' equals to Vanilla Biome Blending of '3x3', \n" -// + " '2' equals to Vanilla Biome Blending of '5x5'...") -// .build(); } public static class Fog diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/IConfigProvider.java b/core/src/main/java/com/seibel/distanthorizons/core/config/IConfigProvider.java new file mode 100644 index 000000000..e02f3816f --- /dev/null +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/IConfigProvider.java @@ -0,0 +1,6 @@ +package com.seibel.distanthorizons.core.config; + +public interface IConfigProvider +{ + +} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/RenderCacheConfigEventHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/RenderCacheConfigEventHandler.java index 24b613e9b..eccd5a3e8 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/RenderCacheConfigEventHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/RenderCacheConfigEventHandler.java @@ -102,7 +102,7 @@ public class RenderCacheConfigEventHandler // create a new timer task TimerTask timerTask = new TimerTask() { - public void run() + @Override public void run() { DhApi.Delayed.renderProxy.clearRenderDataCache(); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/ResetConfigEventHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/ResetConfigEventHandler.java index 05b14eca9..99c248563 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/ResetConfigEventHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/ResetConfigEventHandler.java @@ -32,7 +32,7 @@ public class ResetConfigEventHandler /** private since we only ever need one handler at a time */ private ResetConfigEventHandler() { - this.configChangeListener = new ConfigChangeListener<>(Config.Client.ResetConfirmation.resetAllSettings, (resetSettings) -> { doStuff(resetSettings); }); + this.configChangeListener = new ConfigChangeListener<>(Config.Client.ResetConfirmation.resetAllSettings, (resetSettings) -> { this.doStuff(resetSettings); }); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java index fa4269dad..4d4716984 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java @@ -20,6 +20,10 @@ package com.seibel.distanthorizons.core.config.types; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.Table; import com.seibel.distanthorizons.core.config.NumberUtil; import com.seibel.distanthorizons.core.config.listeners.ConfigChangeListener; import com.seibel.distanthorizons.core.config.listeners.IConfigListener; @@ -28,9 +32,11 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryPerformanc import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryRelevantSide; import com.seibel.distanthorizons.coreapi.interfaces.config.IConfigEntry; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.*; import java.util.function.Consumer; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Use for making the config variables @@ -135,9 +141,9 @@ public class ConfigEntry extends AbstractConfigType> implem @Override public T get() { - if (allowApiOverride && apiValue != null) + if (this.allowApiOverride && this.apiValue != null) { - return apiValue; + return this.apiValue; } return super.get(); @@ -186,8 +192,14 @@ public class ConfigEntry extends AbstractConfigType> implem public void clampWithinRange(T min, T max) { byte validness = this.isValid(min, max); - if (validness == -1) this.value = (T) NumberUtil.getMinimum(this.value.getClass()); - if (validness == 1) this.value = (T) NumberUtil.getMaximum(this.value.getClass()); + if (validness == -1) + { + this.value = (T) NumberUtil.getMinimum(this.value.getClass()); + } + if (validness == 1) + { + this.value = (T) NumberUtil.getMaximum(this.value.getClass()); + } } // TODO is this for command line use? @@ -204,7 +216,7 @@ public class ConfigEntry extends AbstractConfigType> implem public EConfigEntryRelevantSide getRelevantSide() { return this.relevantSide; } /** Fired whenever the config value changes to a new value. */ - public void addValueChangeListener(Consumer onValueChangeFunc) + @Override public void addValueChangeListener(Consumer onValueChangeFunc) { ConfigChangeListener changeListener = new ConfigChangeListener<>(this, onValueChangeFunc); this.addListener(changeListener); @@ -235,7 +247,7 @@ public class ConfigEntry extends AbstractConfigType> implem *

-1 == number too low */ @Override - public byte isValid() { return isValid(this.value, this.min, this.max); } + public byte isValid() { return this.isValid(this.value, this.min, this.max); } /** * Checks if a new value is valid * @@ -307,88 +319,136 @@ public class ConfigEntry extends AbstractConfigType> implem } /** This should normally not be called since set() automatically calls this */ - public void save() { configBase.configFileINSTANCE.saveEntry(this); } + public void save() { this.configBase.configFileINSTANCE.saveEntry(this); } /** This should normally not be called except for special circumstances */ - public void load() { configBase.configFileINSTANCE.loadEntry(this); } + public void load() { this.configBase.configFileINSTANCE.loadEntry(this); } @Override - public boolean equals(IConfigEntry obj) { return obj.getClass() == ConfigEntry.class && equals((ConfigEntry) obj); } + public boolean equals(IConfigEntry obj) { return obj.getClass() == ConfigEntry.class && this.equals((ConfigEntry) obj); } /** Is the value of this equal to another */ public boolean equals(ConfigEntry obj) { // Can all of this just be "return this.value.equals(obj.value)"? if (Number.class.isAssignableFrom(this.value.getClass())) + { return this.value == obj.value; + } else + { return this.value.equals(obj.value); + } } - - public static class Builder extends AbstractConfigType.Builder> + public static class Builder extends AbstractConfigType.Builder> { private String tmpComment = null; - private T tmpMin = null; - private T tmpMax = null; + private TValue tmpMin = null; + private TValue tmpMax = null; protected String tmpServersideShortName = null; private boolean tmpUseApiOverwrite = true; private EConfigEntryPerformance tmpPerformance = EConfigEntryPerformance.DONT_SHOW; private EConfigEntryRelevantSide tmpRelevantSide = EConfigEntryRelevantSide.CLIENT; protected ArrayList tmpIConfigListener = new ArrayList<>(); - public Builder comment(String newComment) + private Supplier computedValueGetter; + private Consumer computedValueSetter; + private boolean preventAutoApplyUntilExit; + + public Builder comment(String newComment) { this.tmpComment = newComment; return this; } + public Builder computed(Supplier computedValueGetter, Consumer computedValueSetter) + { + this.computedValueGetter = computedValueGetter; + this.computedValueSetter = computedValueSetter; + this.setAppearance(EConfigEntryAppearance.ONLY_IN_GUI); + return this; + } + + public Builder linkedTo(DeferredAccessor otherConfigAccessor) + { + return this.computed( + otherConfigAccessor::get, + otherConfigAccessor::set + ); + } + + public Builder preset(PresetBuilder presetBuilder) + { + return this.computed( + () -> { + List values = presetBuilder.presetValues.entrySet().stream() + .map(entry -> entry.getValue().inverse().get(entry.getKey().get())) + .distinct().limit(2) + .collect(Collectors.toList()); + + if (values.size() != 1) + { + return presetBuilder.customStateValue; + } + + return values.get(0); + }, + value -> { + for (Map.Entry, BiMap> entry : presetBuilder.presetValues.entrySet()) + { + entry.getKey().set(entry.getValue().get(value)); + } + } + ); + } + /** Allows most values to be set by 1 setter */ - public Builder setMinDefaultMax(T newMin, T newDefault, T newMax) + public Builder setMinDefaultMax(TValue newMin, TValue newDefault, TValue newMax) { this.set(newDefault); this.setMinMax(newMin, newMax); return this; } - public Builder setMinMax(T newMin, T newMax) + public Builder setMinMax(TValue newMin, TValue newMax) { this.tmpMin = newMin; this.tmpMax = newMax; return this; } - public Builder setMin(T newMin) + public Builder setMin(TValue newMin) { this.tmpMin = newMin; return this; } - public Builder setMax(T newMax) + public Builder setMax(TValue newMax) { this.tmpMax = newMax; return this; } - public Builder setServersideShortName(String name) + public Builder setServersideShortName(String name) { this.tmpServersideShortName = name; return this; } - public Builder setUseApiOverwrite(boolean newUseApiOverwrite) + public Builder setUseApiOverwrite(boolean newUseApiOverwrite) { this.tmpUseApiOverwrite = newUseApiOverwrite; return this; } - public Builder setPerformance(EConfigEntryPerformance newPerformance) + public Builder setPerformance(EConfigEntryPerformance newPerformance) { this.tmpPerformance = newPerformance; return this; } - public Builder setSide(EConfigEntryRelevantSide relevantSide) + public Builder setSide(EConfigEntryRelevantSide relevantSide) { this.tmpRelevantSide = relevantSide; return this; @@ -396,25 +456,25 @@ public class ConfigEntry extends AbstractConfigType> implem - public Builder replaceListeners(ArrayList newConfigListener) + public Builder replaceListeners(ArrayList newConfigListener) { this.tmpIConfigListener = newConfigListener; return this; } - public Builder addListeners(IConfigListener... newConfigListener) + public Builder addListeners(IConfigListener... newConfigListener) { this.tmpIConfigListener.addAll(Arrays.asList(newConfigListener)); return this; } - public Builder addListener(IConfigListener newConfigListener) + public Builder addListener(IConfigListener newConfigListener) { this.tmpIConfigListener.add(newConfigListener); return this; } - public Builder clearListeners() + public Builder clearListeners() { this.tmpIConfigListener.clear(); return this; @@ -422,7 +482,7 @@ public class ConfigEntry extends AbstractConfigType> implem - public ConfigEntry build() + public ConfigEntry build() { return new ConfigEntry<>( this.tmpAppearance, @@ -433,4 +493,46 @@ public class ConfigEntry extends AbstractConfigType> implem } + /** + * Wraps deferred accesses to a ConfigEntry.
+ * It replaces the direct uses of ConfigEntry in places where Java runtime should not attempt + * to dereference path to said entry, until initialization is done. + */ + @FunctionalInterface + public interface DeferredAccessor + { + ConfigEntry getEntry(); + + default T get() { return this.getEntry().get(); } + default void set(T value) { this.getEntry().set(value); } + + } + + public static class PresetBuilder + { + public final TValue customStateValue; + public final Map, BiMap> presetValues = new HashMap<>(); + + public PresetBuilder(TValue customStateValue) + { + this.customStateValue = customStateValue; + } + + @SuppressWarnings("unchecked") + public PresetBuilder addConfigEntry( + DeferredAccessor controlledEntrySupplier, + Consumer> presetValueInitializer + ) + { + presetValueInitializer.accept( + (Map) this.presetValues.computeIfAbsent( + (DeferredAccessor) controlledEntrySupplier, + ignored -> HashBiMap.create() + ) + ); + return this; + } + + } + } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigLinkedEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigLinkedEntry.java deleted file mode 100644 index 5483f7769..000000000 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigLinkedEntry.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of the Distant Horizons mod - * licensed under the GNU LGPL v3 License. - * - * Copyright (C) 2020-2023 James Seibel - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.seibel.distanthorizons.core.config.types; - -import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance; - -/** - * Creates a UI element that copies everything from another element. - * This only effects the UI - * - * @author coolGi - */ -@Deprecated // FIXME doesn't work with localization -public class ConfigLinkedEntry extends AbstractConfigType, ConfigLinkedEntry> -{ - public ConfigLinkedEntry(AbstractConfigType value) - { - super(EConfigEntryAppearance.ONLY_IN_GUI, value); - } - - /** Appearance shouldn't be changed */ - @Override - public void setAppearance(EConfigEntryAppearance newAppearance) { } - - /** Value shouldn't be changed after creation */ - @Override - public void set(AbstractConfigType newValue) { } - - - public static class Builder extends AbstractConfigType.Builder, Builder> - { - /** Appearance shouldn't be changed */ - @Override - public Builder setAppearance(EConfigEntryAppearance newAppearance) - { - return this; - } - - public ConfigLinkedEntry build() - { - return new ConfigLinkedEntry(this.tmpValue); - } - - } - -} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/BufferQuad.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/BufferQuad.java index 8392c25c3..5affe1c5f 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/BufferQuad.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/BufferQuad.java @@ -67,9 +67,13 @@ public final class BufferQuad EDhDirection direction) { if (widthEastWest == 0 || widthNorthSouthOrUpDown == 0) + { throw new IllegalArgumentException("Size 0 quad!"); + } if (widthEastWest < 0 || widthNorthSouthOrUpDown < 0) + { throw new IllegalArgumentException("Negative sized quad!"); + } this.x = x; this.y = y; @@ -95,7 +99,9 @@ public final class BufferQuad public int compare(BufferQuad quad, BufferMergeDirectionEnum compareDirection) { if (this.direction != quad.direction) + { throw new IllegalArgumentException("The other quad is not in the same direction: " + quad.direction + " vs " + this.direction); + } if (compareDirection == BufferMergeDirectionEnum.EastWest) { @@ -150,11 +156,15 @@ public final class BufferQuad public boolean tryMerge(BufferQuad quad, BufferMergeDirectionEnum mergeDirection) { if (quad.hasError || this.hasError) + { return false; + } // only merge quads that are in the same direction if (this.direction != quad.direction) + { return false; + } // make sure these quads share the same perpendicular axis if ((mergeDirection == BufferMergeDirectionEnum.EastWest && this.y != quad.y) || diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodQuadBuilder.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodQuadBuilder.java index 89cbcfec3..870d09316 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodQuadBuilder.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/bufferBuilding/LodQuadBuilder.java @@ -191,14 +191,14 @@ public class LodQuadBuilder public void addQuadDown(short x, short y, short z, short width, short wz, int color, byte irisBlockMaterialId, byte skylight, byte blocklight) { BufferQuad quad = new BufferQuad(x, y, z, width, wz, color, irisBlockMaterialId, skylight, blocklight, EDhDirection.DOWN); - ArrayList qs = (doTransparency && ColorUtil.getAlpha(color) < 255) - ? transparentQuads[EDhDirection.DOWN.ordinal()] : opaqueQuads[EDhDirection.DOWN.ordinal()]; + ArrayList qs = (this.doTransparency && ColorUtil.getAlpha(color) < 255) + ? this.transparentQuads[EDhDirection.DOWN.ordinal()] : this.opaqueQuads[EDhDirection.DOWN.ordinal()]; if (!qs.isEmpty() && (qs.get(qs.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.EastWest) || qs.get(qs.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.NorthSouthOrUpDown)) ) { - premergeCount++; + this.premergeCount++; return; } qs.add(quad); @@ -251,7 +251,9 @@ public class LodQuadBuilder private static long mergeQuadsInternal(ArrayList[] list, int directionIndex, BufferMergeDirectionEnum mergeDirection) { if (list[directionIndex].size() <= 1) + { return 0; + } list[directionIndex].sort((objOne, objTwo) -> objOne.compare(objTwo, mergeDirection)); @@ -423,9 +425,18 @@ public class LodQuadBuilder // 0b01 = positive offset // 0b11 = negative offset // format is: 0b00zzyyxx - if (mx != 0) mirco |= mx > 0 ? 0b01 : 0b11; - if (my != 0) mirco |= my > 0 ? 0b0100 : 0b1100; - if (mz != 0) mirco |= mz > 0 ? 0b010000 : 0b110000; + if (mx != 0) + { + mirco |= mx > 0 ? 0b01 : 0b11; + } + if (my != 0) + { + mirco |= my > 0 ? 0b0100 : 0b1100; + } + if (mz != 0) + { + mirco |= mz > 0 ? 0b010000 : 0b110000; + } meta |= mirco << 8; bb.putShort(meta); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java index 67e90d450..e3520f201 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java @@ -523,8 +523,8 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb // getters / setters // //===================// - public int getWaitingTaskCount() { return this.waitingTasks.size(); } - public int getInProgressTaskCount() { return this.inProgressGenTasksByLodPos.size(); } + @Override public int getWaitingTaskCount() { return this.waitingTasks.size(); } + @Override public int getInProgressTaskCount() { return this.inProgressGenTasksByLodPos.size(); } @Override public byte lowestDataDetail() { return this.lowestDataDetail; } @@ -536,7 +536,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb @Override public void setEstimatedTotalTaskCount(int newEstimate) { this.estimatedTotalTaskCount = newEstimate; } - public void addDebugMenuStringsToList(List messageList) { } + @Override public void addDebugMenuStringsToList(List messageList) { } @@ -544,7 +544,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb // shutdown // //==========// - public CompletableFuture startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning) + @Override public CompletableFuture startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning) { LOGGER.info("Closing world gen queue"); this.queueingThread.shutdownNow(); @@ -671,13 +671,17 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb { index = 4 * X * X - X - Y; if (X < Y) + { index = index - 2 * (X - Y); + } } else { index = 4 * Y * Y - X - Y; if (X < Y) + { index = index + 2 * (X - Y); + } } return index; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java b/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java index b0ecd9151..423dca3e7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java @@ -126,9 +126,9 @@ public class ClientLevelModule implements Closeable, AbstractDataSourceHandler.I boolean isBuffersDirty = false; EDhApiDebugRendering newDebugRendering = Config.Client.Advanced.Debugging.debugRendering.get(); - if (newDebugRendering != lastDebugRendering) + if (newDebugRendering != this.lastDebugRendering) { - lastDebugRendering = newDebugRendering; + this.lastDebugRendering = newDebugRendering; isBuffersDirty = true; } if (isBuffersDirty) @@ -225,7 +225,7 @@ public class ClientLevelModule implements Closeable, AbstractDataSourceHandler.I } } - public void close() + @Override public void close() { // shutdown the renderer ClientRenderState ClientRenderState = this.ClientRenderStateRef.get(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/fog/LodFogConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/render/fog/LodFogConfig.java index 8e0873b93..95a8283eb 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/fog/LodFogConfig.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/fog/LodFogConfig.java @@ -76,19 +76,19 @@ public class LodFogConfig private LodFogConfig(EDhApiFogDrawMode fogDrawMode) { // TODO: Move these out of here - earthCurveRatio = Config.Client.Advanced.Graphics.AdvancedGraphics.earthCurveRatio.get(); + this.earthCurveRatio = Config.Client.Advanced.Graphics.AdvancedGraphics.earthCurveRatio.get(); - noiseEnable = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseEnabled.get(); - noiseSteps = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseSteps.get(); - noiseIntensity = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseIntensity.get().floatValue(); - noiseDropoff = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff.get(); + this.noiseEnable = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseEnabled.get(); + this.noiseSteps = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseSteps.get(); + this.noiseIntensity = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseIntensity.get().floatValue(); + this.noiseDropoff = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff.get(); if (fogDrawMode != EDhApiFogDrawMode.FOG_DISABLED) { // fog should be drawn - farFogSetting = new FogSettings( + this.farFogSetting = new FogSettings( Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogStart.get(), Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogEnd.get(), Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogMin.get(), @@ -97,20 +97,20 @@ public class LodFogConfig Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogFalloff.get() ); - heightFogMixMode = Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMixMode.get(); - if (heightFogMixMode == EDhApiHeightFogMixMode.IGNORE_HEIGHT || heightFogMixMode == EDhApiHeightFogMixMode.BASIC) + this.heightFogMixMode = Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMixMode.get(); + if (this.heightFogMixMode == EDhApiHeightFogMixMode.IGNORE_HEIGHT || this.heightFogMixMode == EDhApiHeightFogMixMode.BASIC) { // basic fog mixing - heightFogSetting = null; - heightFogMode = null; - heightFogHeight = 0.f; + this.heightFogSetting = null; + this.heightFogMode = null; + this.heightFogHeight = 0.f; } else { // advanced fog mixing - heightFogSetting = new FogSettings( + this.heightFogSetting = new FogSettings( Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogDensity.get(), Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogEnd.get(), Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMin.get(), @@ -119,15 +119,15 @@ public class LodFogConfig Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogFalloff.get() ); - heightFogMode = Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMode.get(); + this.heightFogMode = Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMode.get(); - if (heightFogMode.basedOnCamera) + if (this.heightFogMode.basedOnCamera) { - heightFogHeight = 0.f; + this.heightFogHeight = 0.f; } else { - heightFogHeight = Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogBaseHeight.get().floatValue(); + this.heightFogHeight = Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogBaseHeight.get().floatValue(); } } } @@ -135,11 +135,11 @@ public class LodFogConfig { // fog disabled - farFogSetting = null; - heightFogMixMode = null; - heightFogMode = null; - heightFogSetting = null; - heightFogHeight = 0.f; + this.farFogSetting = null; + this.heightFogMixMode = null; + this.heightFogMode = null; + this.heightFogSetting = null; + this.heightFogHeight = 0.f; } } @@ -177,7 +177,7 @@ public class LodFogConfig "} \n"); - if (farFogSetting == null) + if (this.farFogSetting == null) { str.append("\n" + "float getFarFogThickness(float dist) { return 0.0; } \n" + @@ -195,7 +195,7 @@ public class LodFogConfig str.append("" + "float getFarFogThickness(float dist) \n" + "{ \n" + - getFarFogMethod(farFogSetting.fogType) + "\n" + + getFarFogMethod(this.farFogSetting.fogType) + "\n" + "} \n"); @@ -203,7 +203,7 @@ public class LodFogConfig str.append("" + "float getHeightFogThickness(float dist) \n" + "{ \n" + - (heightFogSetting != null ? getHeightFogMethod(heightFogSetting.fogType) : " return 0.0;") + "\n" + + (this.heightFogSetting != null ? getHeightFogMethod(this.heightFogSetting.fogType) : " return 0.0;") + "\n" + "} \n"); @@ -211,7 +211,7 @@ public class LodFogConfig str.append("" + "float calculateHeightFogDepth(float vertical, float realY) \n" + "{ \n" + - (heightFogSetting != null ? getHeightDepthMethod(heightFogMode, heightFogHeight) : " return 0.0;") + "\n" + + (this.heightFogSetting != null ? getHeightDepthMethod(this.heightFogMode, this.heightFogHeight) : " return 0.0;") + "\n" + "} \n"); @@ -219,7 +219,7 @@ public class LodFogConfig str.append("" + "float calculateFarFogDepth(float horizontal, float dist, float uNearFogStart) \n" + "{ \n" + - " return " + (heightFogMixMode == EDhApiHeightFogMixMode.BASIC ? + " return " + (this.heightFogMixMode == EDhApiHeightFogMixMode.BASIC ? "(dist - uNearFogStart)/(1.0 - uNearFogStart);" : "(horizontal - uNearFogStart)/(1.0 - uNearFogStart);") + "} \n"); @@ -228,7 +228,7 @@ public class LodFogConfig str.append("" + "float mixFogThickness(float near, float far, float height) \n" + "{ \n" + - getMixFogLine(heightFogMixMode) + "\n" + + getMixFogLine(this.heightFogMixMode) + "\n" + "} \n"); } } @@ -398,23 +398,27 @@ public class LodFogConfig public boolean equals(Object o) { if (this == o) + { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || this.getClass() != o.getClass()) + { return false; + } LodFogConfig that = (LodFogConfig) o; - return Float.compare(that.heightFogHeight, heightFogHeight) == 0 && - Objects.equals(farFogSetting, that.farFogSetting) && - Objects.equals(heightFogSetting, that.heightFogSetting) && heightFogMixMode == that.heightFogMixMode && - heightFogMode == that.heightFogMode + return Float.compare(that.heightFogHeight, this.heightFogHeight) == 0 && + Objects.equals(this.farFogSetting, that.farFogSetting) && + Objects.equals(this.heightFogSetting, that.heightFogSetting) && this.heightFogMixMode == that.heightFogMixMode && + this.heightFogMode == that.heightFogMode // TODO: Move these out of here - && earthCurveRatio == that.earthCurveRatio - && noiseEnable == that.noiseEnable && noiseSteps == that.noiseSteps && noiseIntensity == that.noiseIntensity && noiseDropoff == that.noiseDropoff; + && this.earthCurveRatio == that.earthCurveRatio + && this.noiseEnable == that.noiseEnable && this.noiseSteps == that.noiseSteps && this.noiseIntensity == that.noiseIntensity && this.noiseDropoff == that.noiseDropoff; } @Override public int hashCode() { - return Objects.hash(farFogSetting, heightFogSetting, heightFogMixMode, heightFogMode, heightFogHeight, earthCurveRatio, noiseEnable, noiseSteps, noiseIntensity, noiseDropoff); + return Objects.hash(this.farFogSetting, this.heightFogSetting, this.heightFogMixMode, this.heightFogMode, this.heightFogHeight, this.earthCurveRatio, this.noiseEnable, this.noiseSteps, this.noiseIntensity, this.noiseDropoff); } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java index 058b6b63e..0c7de85e6 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/DhTerrainShaderProgram.java @@ -130,8 +130,12 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade throw e; } - if (this.uEarthRadius != -1) this.setUniform(this.uEarthRadius, + if (this.uEarthRadius != -1) + { + this.setUniform(this.uEarthRadius, /*6371KM*/ 6371000.0f / Config.Client.Advanced.Graphics.AdvancedGraphics.earthCurveRatio.get()); + } + // Noise Uniforms @@ -185,7 +189,10 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade // setUniform(skyLightUniform, skyLight); this.setUniform(this.uLightMap, 0); // TODO this should probably be passed in - if (this.uWorldYOffset != -1) this.setUniform(this.uWorldYOffset, (float) renderParameters.worldYOffset); + if (this.uWorldYOffset != -1) + { + this.setUniform(this.uWorldYOffset, (float) renderParameters.worldYOffset); + } // Debug this.setUniform(this.uWhiteWorld, Config.Client.Advanced.Debugging.enableWhiteWorld.get()); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java index 694f2ad35..032751685 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java @@ -845,15 +845,23 @@ public class LodRenderer } if (this.quadIBO != null) + { this.quadIBO.destroyAsync(); + } // Delete framebuffer, color texture, and depth texture if (this.framebuffer != null && !this.usingMcFrameBuffer) + { this.framebuffer.destroy(); + } if (this.nullableColorTexture != null) + { this.nullableColorTexture.destroy(); + } if (this.depthTexture != null) + { this.depthTexture.destroy(); + } EVENT_LOGGER.info("Renderer Cleanup Complete"); }); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/FogShader.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/FogShader.java index f35eafc94..cc0b3e78d 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/FogShader.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/FogShader.java @@ -115,14 +115,32 @@ public class FogShader extends AbstractShaderRenderer int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH; // Fog - if (this.uFullFogMode != -1) this.shader.setUniform(this.uFullFogMode, MC_RENDER.isFogStateSpecial() ? 1 : 0); - if (this.uFogColor != -1) this.shader.setUniform(this.uFogColor, MC_RENDER.isFogStateSpecial() ? this.getSpecialFogColor(partialTicks) : this.getFogColor(partialTicks)); + if (this.uFullFogMode != -1) + { + this.shader.setUniform(this.uFullFogMode, MC_RENDER.isFogStateSpecial() ? 1 : 0); + } + if (this.uFogColor != -1) + { + this.shader.setUniform(this.uFogColor, MC_RENDER.isFogStateSpecial() ? this.getSpecialFogColor(partialTicks) : this.getFogColor(partialTicks)); + } float nearFogStart = (VERSION_CONSTANTS.isVanillaRenderedChunkSquare() ? (float) Math.sqrt(2.0) : 1.0f) / lodDrawDistance; - if (this.uNearFogStart != -1) this.shader.setUniform(this.uNearFogStart, nearFogStart); - if (this.uNearFogLength != -1) this.shader.setUniform(this.uNearFogLength, 0.0f); - if (this.uFogScale != -1) this.shader.setUniform(this.uFogScale, 1.f / lodDrawDistance); - if (this.uFogVerticalScale != -1) this.shader.setUniform(this.uFogVerticalScale, 1.f / MC.getWrappedClientLevel().getMaxHeight()); + if (this.uNearFogStart != -1) + { + this.shader.setUniform(this.uNearFogStart, nearFogStart); + } + if (this.uNearFogLength != -1) + { + this.shader.setUniform(this.uNearFogLength, 0.0f); + } + if (this.uFogScale != -1) + { + this.shader.setUniform(this.uFogScale, 1.f / lodDrawDistance); + } + if (this.uFogVerticalScale != -1) + { + this.shader.setUniform(this.uFogVerticalScale, 1.f / MC.getWrappedClientLevel().getMaxHeight()); + } } private Color getFogColor(float partialTicks) {