From a9bfc3fbe196cfb2ec11e3e2489b1c43b1686b56 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 29 Jan 2026 07:48:10 -0600 Subject: [PATCH] Clean up more TODOs --- .../core/api/internal/ClientApi.java | 25 +++--- .../distanthorizons/core/config/Config.java | 16 ++-- .../core/config/file/ConfigFileHandler.java | 4 +- .../core/config/types/ConfigEntry.java | 85 +++++++++++++++---- .../core/level/AbstractDhLevel.java | 2 +- .../renderer/generic/CloudRenderHandler.java | 22 ++++- .../wrapperInterfaces/IWrapperFactory.java | 2 +- .../assets/distanthorizons/lang/en_us.json | 2 +- 8 files changed, 114 insertions(+), 44 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java index e266460cb..6943e3a7a 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java @@ -73,8 +73,6 @@ public class ClientApi { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public static boolean prefLoggerEnabled = false; - public static final ClientApi INSTANCE = new ClientApi(); public static final TestRenderer TEST_RENDERER = new TestRenderer(); @@ -185,13 +183,12 @@ public class ClientApi MC_CLIENT.sendChatMessage("DH may behave strangely or have missing functionality."); MC_CLIENT.sendChatMessage("In order to use pre-generated LODs, put your DH database(s) in:"); MC_CLIENT.sendChatMessage(MinecraftTextFormat.GRAY +".Minecraft" + File.separator + ClientOnlySaveStructure.SERVER_DATA_FOLDER_NAME + File.separator + ClientOnlySaveStructure.REPLAY_SERVER_FOLDER_NAME + File.separator + "DIMENSION_NAME"+ MinecraftTextFormat.CLEAR_FORMATTING); - MC_CLIENT.sendChatMessage("This can be disabled in DH's config under Advanced -> Logging."); + MC_CLIENT.sendChatMessage("This message can be disabled in DH's config under Advanced -> Logging."); MC_CLIENT.sendChatMessage(""); } } - // firing after clientLevelLoadEvent - // TODO if level has prepped to load it should fire level load event + DhClientWorld world = new DhClientWorld(); SharedApi.setDhWorld(world); @@ -693,20 +690,20 @@ public class ClientApi } - if (glfwKey == GLFW.GLFW_KEY_F8) - { - Config.Client.Advanced.Debugging.debugRendering.set(EDhApiDebugRendering.next(Config.Client.Advanced.Debugging.debugRendering.get())); - MC_CLIENT.sendChatMessage("F8: Set debug mode to " + Config.Client.Advanced.Debugging.debugRendering.get()); - } - else if (glfwKey == GLFW.GLFW_KEY_F6) + if (glfwKey == GLFW.GLFW_KEY_F6) { Config.Client.Advanced.Debugging.rendererMode.set(EDhApiRendererMode.next(Config.Client.Advanced.Debugging.rendererMode.get())); MC_CLIENT.sendChatMessage("F6: Set rendering to " + Config.Client.Advanced.Debugging.rendererMode.get()); } - else if (glfwKey == GLFW.GLFW_KEY_P) + else if (glfwKey == GLFW.GLFW_KEY_F7) { - prefLoggerEnabled = !prefLoggerEnabled; - MC_CLIENT.sendChatMessage("P: Debug Pref Logger is " + (prefLoggerEnabled ? "enabled" : "disabled")); + Config.Client.Advanced.Debugging.lodOnlyMode.set(!Config.Client.Advanced.Debugging.lodOnlyMode.get()); + MC_CLIENT.sendChatMessage("F7: Set LOD only mode to " + Config.Client.Advanced.Debugging.lodOnlyMode.get()); + } + else if (glfwKey == GLFW.GLFW_KEY_F8) + { + Config.Client.Advanced.Debugging.debugRendering.set(EDhApiDebugRendering.next(Config.Client.Advanced.Debugging.debugRendering.get())); + MC_CLIENT.sendChatMessage("F8: Set debug mode to " + Config.Client.Advanced.Debugging.debugRendering.get()); } } 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 40574a06d..e62f37b6c 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 @@ -699,7 +699,7 @@ public class Config + "How intense should the noise should be?") .build(); - public static ConfigEntry noiseDropoff = new ConfigEntry.Builder() // TODO: Make this a float (the ClassicConfigGUI doesn't support floats) + public static ConfigEntry noiseDropoff = new ConfigEntry.Builder() .setMinDefaultMax(0, 1024, null) .comment("" + "Defines how far should the noise texture render before it fades away. (in blocks) \n" @@ -979,13 +979,15 @@ public class Config + "") .build(); - // TODO add LOD-only mode to this public static ConfigEntry enableDebugKeybindings = new ConfigEntry.Builder() - .set(false) - .comment("" - + "If true the F8 key can be used to cycle through the different debug modes. \n" - + "and the F6 key can be used to enable and disable LOD rendering.") - .build(); + .set(false) + .comment("" + + "If true several keys can be used to toggle debug states. \n" + + "F6 - enable/disable LOD rendering \n" + + "F7 - enable/disable LOD only rendering \n" + + "F8 - cycle through the different debug rendering modes \n" + + "") + .build(); public static ConfigEntry enableWhiteWorld = new ConfigEntry.Builder() .set(false) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandler.java index 28b64ce79..a43578cd8 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandler.java @@ -241,8 +241,8 @@ public class ConfigFileHandler } else if (entry.getTrueValue() == null) { - // TODO when can this happen? - throw new IllegalArgumentException("BlockBiomeWrapperPair [" + entry.getNameAndCategory() + "] is null, this may be a problem with [" + ModInfo.NAME + "]. Please contact the authors."); + // shouldn't happen, but just in case + throw new IllegalArgumentException("ConfigEntry [" + entry.getNameAndCategory() + "] is null, how did this happen?"); } workConfig.set(entry.getNameAndCategory(), ConfigTypeConverters.attemptToConvertToString(entry.getType(), entry.getTrueValue())); 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 979bdafaa..719b23940 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 @@ -60,6 +60,7 @@ public class ConfigEntry extends AbstractConfigBase //=============// // constructor // //=============// + //region private ConfigEntry( EConfigEntryAppearance appearance, @@ -78,11 +79,14 @@ public class ConfigEntry extends AbstractConfigBase this.listenerList = listenerList; } + //endregion + //==========================// // property getters/setters // //==========================// + //region /** the string used when entering the config into the command line or chat */ public String getChatCommandName() { return this.chatCommandName; } @@ -100,16 +104,22 @@ public class ConfigEntry extends AbstractConfigBase public T getMax() { return this.max; } public void setMax(T newMax) { this.max = newMax; } + //endregion + //===============// // value setters // //===============// + //region public void setApiValue(T newApiValue) { this.apiValue = newApiValue; - this.listenerList.forEach(IConfigListener::onConfigValueSet); + synchronized (this.listenerList) + { + this.listenerList.forEach(IConfigListener::onConfigValueSet); + } } public boolean apiIsOverriding() @@ -129,7 +139,11 @@ public class ConfigEntry extends AbstractConfigBase public void setWithoutSaving(T newValue) { super.set(newValue); - this.listenerList.forEach(IConfigListener::onConfigValueSet); + + synchronized (this.listenerList) + { + this.listenerList.forEach(IConfigListener::onConfigValueSet); + } } @Override public void set(T newValue) @@ -141,19 +155,30 @@ public class ConfigEntry extends AbstractConfigBase public void uiSetWithoutSaving(T newValue) { this.setWithoutSaving(newValue); - this.listenerList.forEach(IConfigListener::onUiModify); + + synchronized (this.listenerList) + { + this.listenerList.forEach(IConfigListener::onUiModify); + } } public void uiSet(T newValue) { this.set(newValue); - this.listenerList.forEach(IConfigListener::onUiModify); + + synchronized (this.listenerList) + { + this.listenerList.forEach(IConfigListener::onUiModify); + } } + //endregion + //===============// // value getters // //===============// + //region @Override public T get() @@ -174,11 +199,14 @@ public class ConfigEntry extends AbstractConfigBase @Nullable public T getApiValue() { return this.apiValue; } + //endregion + //===========// // listeners // //===========// + //region /** Fired whenever the config value changes to a new value. */ public void addValueChangeListener(Consumer onValueChangeFunc) @@ -187,26 +215,38 @@ public class ConfigEntry extends AbstractConfigBase this.addListener(changeListener); } /** Fired whenever the config value is updated, including when the value doesn't change (IE when the UI changes state or the config is reloaded). */ - public void addListener(IConfigListener newListener) { this.listenerList.add(newListener); } - - //public void removeValueChangeListener(Consumer onValueChangeFunc) { } // not currently implemented - public void removeListener(IConfigListener oldListener) { this.listenerList.remove(oldListener); } - - public void clearListeners() { this.listenerList.clear(); } - public ArrayList getListeners() { return this.listenerList; } - /** Replaces the listener list */ - public void setListeners(ArrayList newListeners) + public void addListener(IConfigListener newListener) { - this.listenerList.clear(); - this.listenerList.addAll(newListeners); + synchronized (this.listenerList) + { + this.listenerList.add(newListener); + } } - public void setListeners(IConfigListener... newListeners) { this.listenerList.addAll(Arrays.asList(newListeners)); } + + public void removeListener(IConfigListener oldListener) + { + synchronized (this.listenerList) + { + this.listenerList.remove(oldListener); + } + } + + public void clearListeners() + { + synchronized (this.listenerList) + { + this.listenerList.clear(); + } + } + + //endregion //====================// // min/max validation // //====================// + //region /** Checks if this config's current value is valid */ public EConfigValidity getValidity() { return this.getValidity(this.value, this.min, this.max); } @@ -257,22 +297,28 @@ public class ConfigEntry extends AbstractConfigBase } } + //endregion + //===============// // file handling // //===============// + //region /** This should normally not be called since set() automatically calls this */ public void save() { ConfigHandler.INSTANCE.configFileHandler.saveEntry(this); } /** This should normally not be called except for special circumstances */ public void load() { ConfigHandler.INSTANCE.configFileHandler.loadEntry(this); } + //endregion + //================// // base overrides // //================// + //region public boolean equals(AbstractConfigBase obj) { @@ -294,11 +340,14 @@ public class ConfigEntry extends AbstractConfigBase } } + //endregion + //=========// // builder // //=========// + //region public static class Builder extends AbstractConfigBase.Builder> { @@ -397,4 +446,8 @@ public class ConfigEntry extends AbstractConfigBase } + //endregion + + + } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java index 7d26e4295..d013b3596 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java @@ -289,7 +289,7 @@ public abstract class AbstractDhLevel implements IDhLevel int minBlockX, int maxBlockX, int minBlockZ, int maxBlockZ, List activeBeamList - ) // TODO min/max block pos instead + ) { if (this.beaconBeamRepo == null) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/generic/CloudRenderHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/generic/CloudRenderHandler.java index 9d8357770..9be182890 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/generic/CloudRenderHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/generic/CloudRenderHandler.java @@ -87,6 +87,7 @@ public class CloudRenderHandler //=============// // constructor // //=============// + //region public CloudRenderHandler(IDhClientLevel level, GenericObjectRenderer renderer) { @@ -269,6 +270,15 @@ public class CloudRenderHandler } } + //endregion + + + + //===========// + // rendering // + //===========// + //region + private void preRender(DhApiRenderParam renderParam, CloudParams cloudParams) { IDhApiRenderableBoxGroup boxGroup = this.boxGroupByOffset[cloudParams.instanceOffsetX+CLOUD_INSTANCE_RADIUS_COUNT][cloudParams.instanceOffsetZ+CLOUD_INSTANCE_RADIUS_COUNT]; @@ -399,8 +409,7 @@ public class CloudRenderHandler boxGroup.setOriginBlockPos(new DhApiVec3d(newMinPosX, newMinPosY, newMinPosZ)); } - - private synchronized boolean shouldCloudBeCulled( + private boolean shouldCloudBeCulled( float minPosX, float minPosY, float minPosZ, CloudParams cloudParams) { @@ -484,12 +493,14 @@ public class CloudRenderHandler return allOutsideRenderDistance || allBehindCamera; } + //endregion //==================// // texture handling // //==================// + //region private static boolean[][] getCloudsFromTexture() throws FileNotFoundException, IOException { @@ -523,11 +534,14 @@ public class CloudRenderHandler return whitePixels; } + //endregion + //================// // helper classes // //================// + //region private static class CloudParams { @@ -565,4 +579,8 @@ public class CloudRenderHandler } + //endregion + + + } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java index 2d31eefc6..0dc34bec8 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java @@ -42,7 +42,7 @@ public interface IWrapperFactory extends IDhApiWrapperFactory, IBindable IBatchGeneratorEnvironmentWrapper createBatchGenerator(IDhLevel targetLevel); IBiomeWrapper deserializeBiomeWrapper(String str, ILevelWrapper levelWrapper) throws IOException; - IBiomeWrapper getPlainsBiomeWrapper(ILevelWrapper levelWrapper); // TODO it would be nice to remove the level wrapper if possible to put this in line with getAirBlockStateWrapper() but it isn't necessary + IBiomeWrapper getPlainsBiomeWrapper(ILevelWrapper levelWrapper); default IBiomeWrapper deserializeBiomeWrapperOrGetDefault(String str, ILevelWrapper levelWrapper) { IBiomeWrapper biome; diff --git a/core/src/main/resources/assets/distanthorizons/lang/en_us.json b/core/src/main/resources/assets/distanthorizons/lang/en_us.json index fff0c0752..9abd00c3c 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -463,7 +463,7 @@ "distanthorizons.config.client.advanced.debugging.enableDebugKeybindings": "Enable debug keybindings", "distanthorizons.config.client.advanced.debugging.enableDebugKeybindings.@tooltip": - "§6True:§r debug keybindings can be used to change the Debug mode in game.", + "If true several keys can be used to toggle debug states. \nF6 - enable/disable LOD rendering \nF7 - enable/disable LOD only rendering \nF8 - cycle through the different debug rendering modes", "distanthorizons.config.client.advanced.debugging.enableWhiteWorld": "Enable white world", "distanthorizons.config.client.advanced.debugging.enableWhiteWorld.@tooltip":