From ec7e791e9f443755f8dfd07e28acc1470bdeab7b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 6 Jan 2026 07:09:08 -0600 Subject: [PATCH] Change EMinecraftColor -> MinecraftTextFormat No need for an enum when all the values are strings --- .../core/api/internal/ClientApi.java | 22 ++++----- .../ChunkUpdateQueueManager.java | 6 +-- .../core/enums/EMinecraftColor.java | 47 ------------------- .../core/enums/MinecraftTextFormat.java | 35 ++++++++++++++ .../core/logging/DhLogger.java | 18 +++---- .../client/ClientNetworkState.java | 6 +-- .../core/pooling/PhantomArrayListPool.java | 5 +- .../core/world/DhClientServerWorld.java | 4 +- .../core/world/DhClientWorld.java | 4 +- .../core/world/DhServerWorld.java | 4 +- 10 files changed, 68 insertions(+), 83 deletions(-) delete mode 100644 core/src/main/java/com/seibel/distanthorizons/core/enums/EMinecraftColor.java create mode 100644 core/src/main/java/com/seibel/distanthorizons/core/enums/MinecraftTextFormat.java 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 bdbd87193..5124e43db 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 @@ -24,7 +24,7 @@ import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode; import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass; import com.seibel.distanthorizons.api.methods.events.abstractEvents.*; import com.seibel.distanthorizons.core.api.internal.rendering.DhRenderState; -import com.seibel.distanthorizons.core.enums.EMinecraftColor; +import com.seibel.distanthorizons.core.enums.MinecraftTextFormat; import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.network.messages.MessageRegistry; @@ -153,10 +153,10 @@ public class ClientApi if (Config.Common.Logging.Warning.showReplayWarningOnStartup.get()) { - MC_CLIENT.sendChatMessage(EMinecraftColor.ORANGE + "Distant Horizons: Replay detected." + EMinecraftColor.CLEAR_FORMATTING); + MC_CLIENT.sendChatMessage(MinecraftTextFormat.ORANGE + "Distant Horizons: Replay detected." + MinecraftTextFormat.CLEAR_FORMATTING); 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(EMinecraftColor.GRAY +".Minecraft" + File.separator + ClientOnlySaveStructure.SERVER_DATA_FOLDER_NAME + File.separator + ClientOnlySaveStructure.REPLAY_SERVER_FOLDER_NAME + File.separator + "DIMENSION_NAME"+EMinecraftColor.CLEAR_FORMATTING); + 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(""); } @@ -508,10 +508,10 @@ public class ClientApi this.rendererDisabledBecauseOfExceptions = true; LOGGER.error("Unexpected Renderer error in render pass [" + renderPass + "]. Error: " + e.getMessage(), e); - MC_CLIENT.sendChatMessage(EMinecraftColor.DARK_RED + "" + EMinecraftColor.BOLD + "ERROR: Distant Horizons renderer has encountered an exception!" + EMinecraftColor.CLEAR_FORMATTING); - MC_CLIENT.sendChatMessage(EMinecraftColor.DARK_RED + "Renderer disabled to try preventing GL state corruption." + EMinecraftColor.CLEAR_FORMATTING); - MC_CLIENT.sendChatMessage(EMinecraftColor.DARK_RED + "Toggle DH rendering via the config UI to re-activate DH rendering." + EMinecraftColor.CLEAR_FORMATTING); - MC_CLIENT.sendChatMessage(EMinecraftColor.DARK_RED + "Error: " + EMinecraftColor.CLEAR_FORMATTING + e); + MC_CLIENT.sendChatMessage(MinecraftTextFormat.DARK_RED + "" + MinecraftTextFormat.BOLD + "ERROR: Distant Horizons renderer has encountered an exception!" + MinecraftTextFormat.CLEAR_FORMATTING); + MC_CLIENT.sendChatMessage(MinecraftTextFormat.DARK_RED + "Renderer disabled to try preventing GL state corruption." + MinecraftTextFormat.CLEAR_FORMATTING); + MC_CLIENT.sendChatMessage(MinecraftTextFormat.DARK_RED + "Toggle DH rendering via the config UI to re-activate DH rendering." + MinecraftTextFormat.CLEAR_FORMATTING); + MC_CLIENT.sendChatMessage(MinecraftTextFormat.DARK_RED + "Error: " + MinecraftTextFormat.CLEAR_FORMATTING + e); } @@ -656,7 +656,7 @@ public class ClientApi // remind the user that this is a development build String message = - EMinecraftColor.DARK_GREEN + "Distant Horizons: nightly/unstable build, version: [" + ModInfo.VERSION+"]." +EMinecraftColor.CLEAR_FORMATTING + "\n" + + MinecraftTextFormat.DARK_GREEN + "Distant Horizons: nightly/unstable build, version: [" + ModInfo.VERSION+"]." + MinecraftTextFormat.CLEAR_FORMATTING + "\n" + "Issues may occur with this version.\n" + "Here be dragons!\n"; MC_CLIENT.sendChatMessage(message); @@ -680,7 +680,7 @@ public class ClientApi { String message = // orange text - EMinecraftColor.ORANGE + "Distant Horizons: Low memory detected." + EMinecraftColor.CLEAR_FORMATTING + "\n" + + MinecraftTextFormat.ORANGE + "Distant Horizons: Low memory detected." + MinecraftTextFormat.CLEAR_FORMATTING + "\n" + "Stuttering or low FPS may occur. \n" + "Please increase Minecraft's available memory to 4 GB or more. \n" + "This warning can be disabled in DH's config under Advanced -> Logging. \n"; @@ -702,12 +702,12 @@ public class ClientApi this.lastStaticWarningMessageSentMsTime = System.currentTimeMillis(); String message = - EMinecraftColor.YELLOW + "Distant Horizons: High vanilla render distance detected." + EMinecraftColor.CLEAR_FORMATTING + "\n" + + MinecraftTextFormat.YELLOW + "Distant Horizons: High vanilla render distance detected." + MinecraftTextFormat.CLEAR_FORMATTING + "\n" + "Using a high vanilla render distance uses a lot of CPU power \n" + "and doesn't improve graphics much after about 12.\n" + "Lowing your vanilla render distance will give you better FPS\n" + "and reduce stuttering at a similar visual quality.\n" + - EMinecraftColor.GRAY + "A vanilla render distance of 8 is recommended." + EMinecraftColor.CLEAR_FORMATTING + "\n" + + MinecraftTextFormat.GRAY + "A vanilla render distance of 8 is recommended." + MinecraftTextFormat.CLEAR_FORMATTING + "\n" + "This message can be disabled in DH's config under Advanced -> Logging.\n"; MC_CLIENT.sendChatMessage(message); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/ChunkUpdateQueueManager.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/ChunkUpdateQueueManager.java index 6901b69c8..7f8dbf416 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/ChunkUpdateQueueManager.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/ChunkUpdateQueueManager.java @@ -1,13 +1,11 @@ package com.seibel.distanthorizons.core.api.internal.chunkUpdating; -import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.seibel.distanthorizons.core.api.internal.ClientApi; import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.enums.EMinecraftColor; +import com.seibel.distanthorizons.core.enums.MinecraftTextFormat; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; -import com.seibel.distanthorizons.core.multiplayer.client.SyncOnLoadRequestQueue; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.world.EWorldEnvironment; import com.seibel.distanthorizons.core.logging.DhLogger; @@ -120,7 +118,7 @@ public class ChunkUpdateQueueManager { lastOverloadedLogMessageMsTime = System.currentTimeMillis(); - String message = EMinecraftColor.ORANGE + "Distant Horizons overloaded, too many chunks queued for LOD processing. " + EMinecraftColor.CLEAR_FORMATTING + + String message = MinecraftTextFormat.ORANGE + "Distant Horizons overloaded, too many chunks queued for LOD processing. " + MinecraftTextFormat.CLEAR_FORMATTING + "\nThis may result in holes in your LODs. " + "\nFix: move through the world slower, decrease your vanilla render distance, slow down your world pre-generator (IE Chunky), or increase the Distant Horizons' CPU thread counts. " + "\nMax queue count [" + SharedApi.CHUNK_UPDATE_QUEUE_MANAGER.maxSize + "] ([" + SharedApi.MAX_UPDATING_CHUNK_COUNT_PER_THREAD_AND_PLAYER + "] per thread+players)."; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/enums/EMinecraftColor.java b/core/src/main/java/com/seibel/distanthorizons/core/enums/EMinecraftColor.java deleted file mode 100644 index 8e03f461d..000000000 --- a/core/src/main/java/com/seibel/distanthorizons/core/enums/EMinecraftColor.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.seibel.distanthorizons.core.enums; - -/** - * might be deprecated in the future? in that case we'll probably want a wrapper - * function to handle colors for new MC versions - *

- * source: https://minecraft.wiki/w/Formatting_codes - */ -public enum EMinecraftColor // TODO EMinecraftTextFormat -{ - BLACK("\u00A70"), - DARK_BLUE("\u00A71"), - DARK_GREEN("\u00A72"), - DARK_AQUA("\u00A73"), - DARK_RED("\u00A74"), - DARK_PURPLE("\u00A75"), - ORANGE("\u00A76"), - GRAY("\u00A77"), - DARK_GRAY("\u00A78"), - BLUE("\u00A79"), - GREEN("\u00A7a"), - AQUA("\u00A7b"), - RED("\u00A7c"), - LIGHT_PURPLE("\u00A7d"), - YELLOW("\u00A7e"), - WHITE("\u00A7f"), - - OBFUSCATED("\u00A7k"), - BOLD("\u00A7l"), - STRIKETHROUGH("\u00A7m"), - UNDERLINE("\u00A7n"), - ITALIC("\u00A7o"), - CLEAR_FORMATTING("\u00A7r"); - - public final String colorCode; - - EMinecraftColor(String colorCode) - { - this.colorCode = colorCode; - } - - - - @Override - public String toString() { return this.colorCode; } - -} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/enums/MinecraftTextFormat.java b/core/src/main/java/com/seibel/distanthorizons/core/enums/MinecraftTextFormat.java new file mode 100644 index 000000000..bbc7e1897 --- /dev/null +++ b/core/src/main/java/com/seibel/distanthorizons/core/enums/MinecraftTextFormat.java @@ -0,0 +1,35 @@ +package com.seibel.distanthorizons.core.enums; + +/** + * might be deprecated in the future? in that case we'll probably want a wrapper + * function to handle colors for new MC versions + *

+ * source: https://minecraft.wiki/w/Formatting_codes + */ +public class MinecraftTextFormat +{ + public static final String BLACK = "\u00A70"; + public static final String DARK_BLUE = "\u00A71"; + public static final String DARK_GREEN = "\u00A72"; + public static final String DARK_AQUA = "\u00A73"; + public static final String DARK_RED = "\u00A74"; + public static final String DARK_PURPLE = "\u00A75"; + public static final String ORANGE = "\u00A76"; + public static final String GRAY = "\u00A77"; + public static final String DARK_GRAY = "\u00A78"; + public static final String BLUE = "\u00A79"; + public static final String GREEN = "\u00A7a"; + public static final String AQUA = "\u00A7b"; + public static final String RED = "\u00A7c"; + public static final String LIGHT_PURPLE = "\u00A7d"; + public static final String YELLOW = "\u00A7e"; + public static final String WHITE = "\u00A7f"; + + public static final String OBFUSCATED = "\u00A7k"; + public static final String BOLD = "\u00A7l"; + public static final String STRIKETHROUGH = "\u00A7m"; + public static final String UNDERLINE = "\u00A7n"; + public static final String ITALIC = "\u00A7o"; + public static final String CLEAR_FORMATTING = "\u00A7r"; + +} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/logging/DhLogger.java b/core/src/main/java/com/seibel/distanthorizons/core/logging/DhLogger.java index 1840da3e3..d2dd4b729 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/logging/DhLogger.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/logging/DhLogger.java @@ -24,7 +24,7 @@ import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.config.listeners.IConfigListener; import com.seibel.distanthorizons.core.config.types.ConfigEntry; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; -import com.seibel.distanthorizons.core.enums.EMinecraftColor; +import com.seibel.distanthorizons.core.enums.MinecraftTextFormat; import com.seibel.distanthorizons.core.util.ThreadUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.coreapi.ModInfo; @@ -303,32 +303,32 @@ public class DhLogger implements IConfigListener String prefix = "[" + ModInfo.READABLE_NAME + "] "; if (logLevel == Level.ERROR) { - prefix += EMinecraftColor.DARK_RED; + prefix += MinecraftTextFormat.DARK_RED; } else if (logLevel == Level.WARN) { - prefix += EMinecraftColor.ORANGE; + prefix += MinecraftTextFormat.ORANGE; } else if (logLevel == Level.INFO) { - prefix += EMinecraftColor.AQUA; + prefix += MinecraftTextFormat.AQUA; } else if (logLevel == Level.DEBUG) { - prefix += EMinecraftColor.GREEN; + prefix += MinecraftTextFormat.GREEN; } else if (logLevel == Level.TRACE) { - prefix += EMinecraftColor.DARK_GRAY; + prefix += MinecraftTextFormat.DARK_GRAY; } else { - prefix += EMinecraftColor.WHITE; + prefix += MinecraftTextFormat.WHITE; } - prefix += EMinecraftColor.BOLD + "" + EMinecraftColor.WHITE; + prefix += MinecraftTextFormat.BOLD + "" + MinecraftTextFormat.WHITE; prefix += logLevel.name(); - prefix += EMinecraftColor.CLEAR_FORMATTING + " "; + prefix += MinecraftTextFormat.CLEAR_FORMATTING + " "; mc_client.sendChatMessage(prefix + message); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/ClientNetworkState.java b/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/ClientNetworkState.java index 89a5721a8..0a922fa9e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/ClientNetworkState.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/multiplayer/client/ClientNetworkState.java @@ -4,7 +4,7 @@ import com.seibel.distanthorizons.core.api.internal.ClientApi; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.config.listeners.ConfigChangeListener; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; -import com.seibel.distanthorizons.core.enums.EMinecraftColor; +import com.seibel.distanthorizons.core.enums.MinecraftTextFormat; import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.multiplayer.config.SessionConfig; @@ -100,11 +100,11 @@ public class ClientNetworkState implements Closeable if (ModInfo.PROTOCOL_VERSION < event.protocolVersion) { - ClientApi.INSTANCE.showChatMessageNextFrame(EMinecraftColor.ORANGE + "Distant Horizons: Your mod is outdated. Update to receive LODs on this server."); + ClientApi.INSTANCE.showChatMessageNextFrame(MinecraftTextFormat.ORANGE + "Distant Horizons: Your mod is outdated. Update to receive LODs on this server."); } else { - ClientApi.INSTANCE.showChatMessageNextFrame(EMinecraftColor.ORANGE + "Distant Horizons: The server's mod is outdated. Ask the server's owner to update."); + ClientApi.INSTANCE.showChatMessageNextFrame(MinecraftTextFormat.ORANGE + "Distant Horizons: The server's mod is outdated. Ask the server's owner to update."); } } }); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/pooling/PhantomArrayListPool.java b/core/src/main/java/com/seibel/distanthorizons/core/pooling/PhantomArrayListPool.java index 9b471eebd..466dbf1ca 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/pooling/PhantomArrayListPool.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/pooling/PhantomArrayListPool.java @@ -2,7 +2,7 @@ package com.seibel.distanthorizons.core.pooling; import com.seibel.distanthorizons.core.api.internal.ClientApi; import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.enums.EMinecraftColor; +import com.seibel.distanthorizons.core.enums.MinecraftTextFormat; import com.seibel.distanthorizons.core.logging.DhLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.f3.F3Screen; @@ -13,7 +13,6 @@ import com.seibel.distanthorizons.coreapi.util.StringUtil; import it.unimi.dsi.fastutil.bytes.ByteArrayList; import it.unimi.dsi.fastutil.longs.LongArrayList; import it.unimi.dsi.fastutil.shorts.ShortArrayList; -import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -179,7 +178,7 @@ public class PhantomArrayListPool { lowMemoryWarningLogged = true; - String message = EMinecraftColor.ORANGE + "Distant Horizons: Insufficient memory detected." + EMinecraftColor.CLEAR_FORMATTING + "\n" + + String message = MinecraftTextFormat.ORANGE + "Distant Horizons: Insufficient memory detected." + MinecraftTextFormat.CLEAR_FORMATTING + "\n" + "This may cause stuttering or crashing. \n" + "Potential causes: \n" + "1. your allocated memory isn't high enough \n" + diff --git a/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java b/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java index 70a4ce003..987b750b6 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientServerWorld.java @@ -20,7 +20,7 @@ package com.seibel.distanthorizons.core.world; import com.seibel.distanthorizons.core.api.internal.ClientApi; -import com.seibel.distanthorizons.core.enums.EMinecraftColor; +import com.seibel.distanthorizons.core.enums.MinecraftTextFormat; import com.seibel.distanthorizons.core.level.DhClientServerLevel; import com.seibel.distanthorizons.core.util.TimerUtil; import com.seibel.distanthorizons.core.util.LodUtil; @@ -83,7 +83,7 @@ public class DhClientServerWorld extends AbstractDhServerWorld LOGGER.fatal("Failed to load server level, error: ["+e.getMessage()+"].", e); ClientApi.INSTANCE.showChatMessageNextFrame( - EMinecraftColor.RED + "Distant Horizons: Server level loading failed." + EMinecraftColor.CLEAR_FORMATTING + "\n" + + MinecraftTextFormat.RED + "Distant Horizons: Server level loading failed." + MinecraftTextFormat.CLEAR_FORMATTING + "\n" + "Unable to load level ["+serverLevelWrapper.getDhIdentifier()+"], LODs may not appear. See log for more information."); return null;