Incomplete instance based config

This commit is contained in:
s809
2024-09-20 19:47:31 +05:00
parent f7bf05b62f
commit 5b746a9534
16 changed files with 476 additions and 300 deletions
@@ -33,19 +33,19 @@ public class DhApiDebuggingConfig implements IDhApiDebuggingConfig
public IDhApiConfigValue<EDhApiDebugRendering> debugRendering()
@Override public IDhApiConfigValue<EDhApiDebugRendering> debugRendering()
{ return new DhApiConfigValue<EDhApiDebugRendering, EDhApiDebugRendering>(Config.Client.Advanced.Debugging.debugRendering); }
public IDhApiConfigValue<Boolean> debugKeybindings()
@Override public IDhApiConfigValue<Boolean> debugKeybindings()
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.enableDebugKeybindings); }
public IDhApiConfigValue<Boolean> renderWireframe()
@Override public IDhApiConfigValue<Boolean> renderWireframe()
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.renderWireframe); }
public IDhApiConfigValue<Boolean> lodOnlyMode()
@Override public IDhApiConfigValue<Boolean> lodOnlyMode()
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.lodOnlyMode); }
public IDhApiConfigValue<Boolean> debugWireframeRendering()
@Override public IDhApiConfigValue<Boolean> debugWireframeRendering()
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.DebugWireframe.enableRendering); }
}
@@ -33,10 +33,10 @@ public class DhApiMultiplayerConfig implements IDhApiMultiplayerConfig
public IDhApiConfigValue<EDhApiServerFolderNameMode> folderSavingMode()
@Override public IDhApiConfigValue<EDhApiServerFolderNameMode> folderSavingMode()
{ return new DhApiConfigValue<EDhApiServerFolderNameMode, EDhApiServerFolderNameMode>(Config.Client.Advanced.Multiplayer.serverFolderNameMode); }
public IDhApiConfigValue<Double> multiverseSimilarityRequirement()
@Override public IDhApiConfigValue<Double> multiverseSimilarityRequirement()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Multiplayer.multiverseSimilarityRequiredPercent); }
}
@@ -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<Boolean> quickEnableRendering = new ConfigEntry.Builder<Boolean>()
.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<Boolean> enableRendering = new ConfigEntry.Builder<Boolean>()
.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<EDhApiQualityPreset> qualityPresetSetting = new ConfigEntry.Builder<EDhApiQualityPreset>()
.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<Integer> lodChunkRenderDistanceRadius = new ConfigEntry.Builder<Integer>()
.linkedTo(() -> Config.this.graphics.quality.lodChunkRenderDistanceRadius)
.build();
public static ConfigEntry<EDhApiThreadPreset> threadPresetSetting = new ConfigEntry.Builder<EDhApiThreadPreset>()
public final ConfigEntry<EDhApiQualityPreset> qualityPreset = new ConfigEntry.Builder<EDhApiQualityPreset>()
.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<EDhApiThreadPreset> threadPreset = new ConfigEntry.Builder<EDhApiThreadPreset>()
.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<Boolean> optionsButton = new ConfigEntry.Builder<Boolean>()
public final ConfigEntry<Boolean> showOptionsButton = new ConfigEntry.Builder<Boolean>()
.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<Integer> lodChunkRenderDistanceRadius = new ConfigEntry.Builder<Integer>()
.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<EDhApiMaxHorizontalResolution> maxHorizontalResolution = new ConfigEntry.Builder<EDhApiMaxHorizontalResolution>()
.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<EDhApiVerticalQuality> verticalQuality = new ConfigEntry.Builder<EDhApiVerticalQuality>()
.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<EDhApiHorizontalQuality> horizontalQuality = new ConfigEntry.Builder<EDhApiHorizontalQuality>()
.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<EDhApiTransparency> transparency = new ConfigEntry.Builder<EDhApiTransparency>()
.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<EDhApiBlocksToAvoid> blocksToIgnore = new ConfigEntry.Builder<EDhApiBlocksToAvoid>()
.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<Boolean> tintWithAvoidedBlocks = new ConfigEntry.Builder<Boolean>()
.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<Integer> lodBiomeBlending = new ConfigEntry.Builder<Integer>()
// .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<EDhApiRendererMode> rendererMode = new ConfigEntry.Builder<EDhApiRendererMode>()
.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<EDhApiMaxHorizontalResolution> maxHorizontalResolution = new ConfigEntry.Builder<EDhApiMaxHorizontalResolution>()
.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<Integer> lodChunkRenderDistanceRadius = new ConfigEntry.Builder<Integer>()
.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<EDhApiVerticalQuality> verticalQuality = new ConfigEntry.Builder<EDhApiVerticalQuality>()
.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<EDhApiHorizontalQuality> horizontalQuality = new ConfigEntry.Builder<EDhApiHorizontalQuality>()
.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<EDhApiTransparency> transparency = new ConfigEntry.Builder<EDhApiTransparency>()
.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<EDhApiBlocksToAvoid> blocksToIgnore = new ConfigEntry.Builder<EDhApiBlocksToAvoid>()
.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<Boolean> tintWithAvoidedBlocks = new ConfigEntry.Builder<Boolean>()
.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<Integer> lodBiomeBlending = new ConfigEntry.Builder<Integer>()
// .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
@@ -0,0 +1,6 @@
package com.seibel.distanthorizons.core.config;
public interface IConfigProvider
{
}
@@ -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();
}
@@ -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); });
}
@@ -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<T> extends AbstractConfigType<T, ConfigEntry<T>> 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<T> extends AbstractConfigType<T, ConfigEntry<T>> 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<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
public EConfigEntryRelevantSide getRelevantSide() { return this.relevantSide; }
/** Fired whenever the config value changes to a new value. */
public void addValueChangeListener(Consumer<T> onValueChangeFunc)
@Override public void addValueChangeListener(Consumer<T> onValueChangeFunc)
{
ConfigChangeListener<T> changeListener = new ConfigChangeListener<>(this, onValueChangeFunc);
this.addListener(changeListener);
@@ -235,7 +247,7 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
* <p> -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<T> extends AbstractConfigType<T, ConfigEntry<T>> 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<T> extends AbstractConfigType.Builder<T, Builder<T>>
public static class Builder<TValue> extends AbstractConfigType.Builder<TValue, Builder<TValue>>
{
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<IConfigListener> tmpIConfigListener = new ArrayList<>();
public Builder<T> comment(String newComment)
private Supplier<TValue> computedValueGetter;
private Consumer<TValue> computedValueSetter;
private boolean preventAutoApplyUntilExit;
public Builder<TValue> comment(String newComment)
{
this.tmpComment = newComment;
return this;
}
public Builder<TValue> computed(Supplier<TValue> computedValueGetter, Consumer<TValue> computedValueSetter)
{
this.computedValueGetter = computedValueGetter;
this.computedValueSetter = computedValueSetter;
this.setAppearance(EConfigEntryAppearance.ONLY_IN_GUI);
return this;
}
public Builder<TValue> linkedTo(DeferredAccessor<TValue> otherConfigAccessor)
{
return this.computed(
otherConfigAccessor::get,
otherConfigAccessor::set
);
}
public Builder<TValue> preset(PresetBuilder<TValue> presetBuilder)
{
return this.computed(
() -> {
List<TValue> 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<DeferredAccessor<Object>, BiMap<TValue, Object>> entry : presetBuilder.presetValues.entrySet())
{
entry.getKey().set(entry.getValue().get(value));
}
}
);
}
/** Allows most values to be set by 1 setter */
public Builder<T> setMinDefaultMax(T newMin, T newDefault, T newMax)
public Builder<TValue> setMinDefaultMax(TValue newMin, TValue newDefault, TValue newMax)
{
this.set(newDefault);
this.setMinMax(newMin, newMax);
return this;
}
public Builder<T> setMinMax(T newMin, T newMax)
public Builder<TValue> setMinMax(TValue newMin, TValue newMax)
{
this.tmpMin = newMin;
this.tmpMax = newMax;
return this;
}
public Builder<T> setMin(T newMin)
public Builder<TValue> setMin(TValue newMin)
{
this.tmpMin = newMin;
return this;
}
public Builder<T> setMax(T newMax)
public Builder<TValue> setMax(TValue newMax)
{
this.tmpMax = newMax;
return this;
}
public Builder<T> setServersideShortName(String name)
public Builder<TValue> setServersideShortName(String name)
{
this.tmpServersideShortName = name;
return this;
}
public Builder<T> setUseApiOverwrite(boolean newUseApiOverwrite)
public Builder<TValue> setUseApiOverwrite(boolean newUseApiOverwrite)
{
this.tmpUseApiOverwrite = newUseApiOverwrite;
return this;
}
public Builder<T> setPerformance(EConfigEntryPerformance newPerformance)
public Builder<TValue> setPerformance(EConfigEntryPerformance newPerformance)
{
this.tmpPerformance = newPerformance;
return this;
}
public Builder<T> setSide(EConfigEntryRelevantSide relevantSide)
public Builder<TValue> setSide(EConfigEntryRelevantSide relevantSide)
{
this.tmpRelevantSide = relevantSide;
return this;
@@ -396,25 +456,25 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
public Builder<T> replaceListeners(ArrayList<IConfigListener> newConfigListener)
public Builder<TValue> replaceListeners(ArrayList<IConfigListener> newConfigListener)
{
this.tmpIConfigListener = newConfigListener;
return this;
}
public Builder<T> addListeners(IConfigListener... newConfigListener)
public Builder<TValue> addListeners(IConfigListener... newConfigListener)
{
this.tmpIConfigListener.addAll(Arrays.asList(newConfigListener));
return this;
}
public Builder<T> addListener(IConfigListener newConfigListener)
public Builder<TValue> addListener(IConfigListener newConfigListener)
{
this.tmpIConfigListener.add(newConfigListener);
return this;
}
public Builder<T> clearListeners()
public Builder<TValue> clearListeners()
{
this.tmpIConfigListener.clear();
return this;
@@ -422,7 +482,7 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
public ConfigEntry<T> build()
public ConfigEntry<TValue> build()
{
return new ConfigEntry<>(
this.tmpAppearance,
@@ -433,4 +493,46 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
}
/**
* Wraps deferred accesses to a ConfigEntry. <br>
* 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<T>
{
ConfigEntry<T> getEntry();
default T get() { return this.getEntry().get(); }
default void set(T value) { this.getEntry().set(value); }
}
public static class PresetBuilder<TValue>
{
public final TValue customStateValue;
public final Map<DeferredAccessor<Object>, BiMap<TValue, Object>> presetValues = new HashMap<>();
public PresetBuilder(TValue customStateValue)
{
this.customStateValue = customStateValue;
}
@SuppressWarnings("unchecked")
public <TControlledEntryValue> PresetBuilder<TValue> addConfigEntry(
DeferredAccessor<TControlledEntryValue> controlledEntrySupplier,
Consumer<Map<TValue, TControlledEntryValue>> presetValueInitializer
)
{
presetValueInitializer.accept(
(Map<TValue, TControlledEntryValue>) this.presetValues.computeIfAbsent(
(DeferredAccessor<Object>) controlledEntrySupplier,
ignored -> HashBiMap.create()
)
);
return this;
}
}
}
@@ -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 <https://www.gnu.org/licenses/>.
*/
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<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<AbstractConfigType<?, ?>, Builder>
{
/** Appearance shouldn't be changed */
@Override
public Builder setAppearance(EConfigEntryAppearance newAppearance)
{
return this;
}
public ConfigLinkedEntry build()
{
return new ConfigLinkedEntry(this.tmpValue);
}
}
}
@@ -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) ||
@@ -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<BufferQuad> qs = (doTransparency && ColorUtil.getAlpha(color) < 255)
? transparentQuads[EDhDirection.DOWN.ordinal()] : opaqueQuads[EDhDirection.DOWN.ordinal()];
ArrayList<BufferQuad> 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<BufferQuad>[] 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);
@@ -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<String> messageList) { }
@Override public void addDebugMenuStringsToList(List<String> messageList) { }
@@ -544,7 +544,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
// shutdown //
//==========//
public CompletableFuture<Void> startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning)
@Override public CompletableFuture<Void> startClosingAsync(boolean cancelCurrentGeneration, boolean alsoInterruptRunning)
{
LOGGER.info("Closing world gen queue");
this.queueingThread.shutdownNow();
@@ -671,14 +671,18 @@ 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;
}
@@ -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();
@@ -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);
}
}
@@ -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());
@@ -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");
});
@@ -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)
{