From 82065cd1ceb488a0b19dbe70d3f06c62cc1ecc91 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 18 Mar 2022 23:56:25 -0500 Subject: [PATCH] Add a config for the MultiDimension Similarity --- .../core/builders/lodBuilding/LodBuilder.java | 6 +++--- .../core/handlers/LodDimensionFileHelper.java | 17 +++++++---------- .../config/ILodConfigWrapperSingleton.java | 13 +++++++++++++ src/main/resources/assets/lod/lang/en_us.json | 6 +++++- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java index 8e6c241e3..37a41116f 100644 --- a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java @@ -135,9 +135,9 @@ public class LodBuilder catch (RuntimeException e) { ApiShared.LOGGER.error("LodBuilder Thread Uncaught Exception: ", e); - // // if the world changes while LODs are being generated - // // they will throw errors as they try to access things that no longer - // // exist. + // if the world changes while LODs are being generated + // they will throw errors as they try to access things that no longer + // exist. } finally { if (!retryNeeded) endCallback.run(); diff --git a/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHelper.java b/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHelper.java index 31cd1a13c..01ba44383 100644 --- a/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHelper.java +++ b/src/main/java/com/seibel/lod/core/handlers/LodDimensionFileHelper.java @@ -12,6 +12,7 @@ import com.seibel.lod.core.objects.lod.RegionPos; import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper; @@ -28,16 +29,11 @@ import java.util.UUID; public class LodDimensionFileHelper { private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class); + private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); /** Increasing this will increase accuracy but increase calculation time */ private static final VerticalQuality VERTICAL_QUALITY_TO_TEST_WITH = VerticalQuality.LOW; - /** - * The minimum percent of identical dataPoints to consider two chunks as the same.
- * 0.9 = 90% - */ - private static final double minimumSimilarityRequired = 0.9; - /** * Currently this method checks a single chunk (where the player is) @@ -129,6 +125,7 @@ public class LodDimensionFileHelper File mostSimilarWorldFolder = null; int mostEqualLines = 0; boolean oneDimensionIsValid = false; + double minimumSimilarityRequired = CONFIG.client().multiplayer().getMultiDimensionRequiredSimilarity(); for (File testDimFolder : dimensionFolder.listFiles()) { @@ -176,10 +173,7 @@ public class LodDimensionFileHelper } } } - -// String message = "test data [" + testDimFolder.getName().substring(0, 6) + "...] " + testChunkData[0][0][0] + " equal lines: " + equalLines + "/" + totalLineCount; -// MC.sendChatMessage(message); -// ApiShared.LOGGER.info(message); + // determine if this world is closer to the newly loaded world double percentEqual = (double) equalLines / (double) totalLineCount; @@ -188,6 +182,9 @@ public class LodDimensionFileHelper mostEqualLines = equalLines; mostSimilarWorldFolder = testDimFolder; } +// String message = "test data [" + testDimFolder.getName().substring(0, 6) + "...] " + testChunkData[0][0][0] + " equal lines: " + equalLines + "/" + totalLineCount + " = " + percentEqual; +// MC.sendChatMessage(message); +// ApiShared.LOGGER.info(message); } diff --git a/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java b/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java index 8510d2fa8..1588ae76e 100644 --- a/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java +++ b/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java @@ -354,6 +354,19 @@ public interface ILodConfigWrapperSingleton extends IBindable + "\n"; ServerFolderNameMode getServerFolderNameMode(); void setServerFolderNameMode(ServerFolderNameMode newServerFolderNameMode); + + double MULTI_DIMENSION_REQUIRED_SIMILARITY_DEFAULT = 0.8; + String MULTI_DIMENSION_REQUIRED_SIMILARITY_DESC = "" + + " When matching worlds of the same dimension type the \n" + + " chunks tested must be at least this percent the same \n" + + " in order to be considered the same world. \n" + + "\n" + + " 1 (100%) means the chunks must be identical. \n" + + " 0.5 (50%) means the chunks must be half the same. \n" + + " 0 (0%) means almost any world will match. \n" + + "\n"; + double getMultiDimensionRequiredSimilarity(); + void setMultiDimensionRequiredSimilarity(double newMultiDimensionMinimumSimilarityPercent); } diff --git a/src/main/resources/assets/lod/lang/en_us.json b/src/main/resources/assets/lod/lang/en_us.json index 230a0f91c..8d38a8e15 100644 --- a/src/main/resources/assets/lod/lang/en_us.json +++ b/src/main/resources/assets/lod/lang/en_us.json @@ -120,7 +120,11 @@ "DistantHorizons.config.client.multiplayer.serverFolderNameMode": "Server Folder Mode", "DistantHorizons.config.client.multiplayer.serverFolderNameMode.@tooltip": - "Determines the folder format for local multiplayer data.\n\n§6Auto:§r\nUses \"Name, IP\" for LAN worlds and \"Name, IP, Port\" for standard multiplayer.\n§6Name Only:§r\nUses the server browser name. Ex: \"Minecraft Server\"\n§6Name IP:§r\n\"Minecraft Server, IP 192.168.1.40\"\n§6Name, IP, Port:§r\n\"Minecraft Server, IP 192.168.1.40:25565\"\n§6Name, IP, Port, MC Version:§r\n\"Minecraft Server, IP 192.168.1.40:25565, GameVersion 1.18.1\"\n\n§c§lCaution:§r changing while connected to a multiplayer server may cause glitches.", + "Determines the folder format for local multiplayer data.\n\n§6Auto:§r\nUses \"Name, IP\" for LAN worlds and \"Name, IP, Port\" for standard multiplayer.\n§6Name Only:§r\nUses the server browser name. Ex: \"Minecraft Server\"\n§6Name IP:§r\n\"Minecraft Server, IP 192.168.1.40\"\n§6Name, IP, Port:§r\n\"Minecraft Server, IP 192.168.1.40:25565\"\n§6Name, IP, Port, MC Version:§r\n\"Minecraft Server, IP 192.168.1.40:25565, GameVersion 1.18.1\"\n\n§c§lCaution:§r changing while connected to a multiplayer server may cause glitches.", + "DistantHorizons.config.client.multiplayer.multiDimensionRequiredSimilarity": + "Multi Dimension Required Similarity", + "DistantHorizons.config.client.multiplayer.multiDimensionRequiredSimilarity.@tooltip": + "When matching worlds of the same dimension type the\nchunks tested must be at least this percent the same\nin order to be considered the same world.\n\n§61:§r the chunks must be identical.\n§60.5:§r the chunks must be half the same.\n§60:§r almost any world will match.", "DistantHorizons.config.client.advanced": "Advanced Options", "DistantHorizons.config.client.advanced.threading":