From 0ab0aeeec66a314102e89660f97f3210ad5087de Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 10 Dec 2022 22:07:54 -0600 Subject: [PATCH] rename EDistanceGenerationMode -> EDhApiDistantGeneratorMode This includes moving it into the API and renaming NONE -> PRE_EXISTING_ONLY --- .../EDhApiDistantGeneratorMode.java} | 97 ++++++++++--------- .../both/IDhApiWorldGenerationConfig.java | 4 +- .../override/AbstractDhApiWorldGenerator.java | 6 +- .../both/DhApiWorldGenerationConfig.java | 6 +- .../com/seibel/lod/core/config/Config.java | 26 +++-- .../datatype/transform/LodBuilderConfig.java | 33 ++++--- .../config/ILodConfigWrapperSingleton.java | 5 +- .../config/LodConfigWrapperSingleton.java | 9 +- 8 files changed, 98 insertions(+), 88 deletions(-) rename api/src/main/java/com/seibel/lod/api/enums/{config/EDistanceGenerationMode.java => worldGeneration/EDhApiDistantGeneratorMode.java} (59%) diff --git a/api/src/main/java/com/seibel/lod/api/enums/config/EDistanceGenerationMode.java b/api/src/main/java/com/seibel/lod/api/enums/worldGeneration/EDhApiDistantGeneratorMode.java similarity index 59% rename from api/src/main/java/com/seibel/lod/api/enums/config/EDistanceGenerationMode.java rename to api/src/main/java/com/seibel/lod/api/enums/worldGeneration/EDhApiDistantGeneratorMode.java index bf8bf9b63..b048ff8eb 100644 --- a/api/src/main/java/com/seibel/lod/api/enums/config/EDistanceGenerationMode.java +++ b/api/src/main/java/com/seibel/lod/api/enums/worldGeneration/EDhApiDistantGeneratorMode.java @@ -17,10 +17,10 @@ * along with this program. If not, see . */ -package com.seibel.lod.api.enums.config; +package com.seibel.lod.api.enums.worldGeneration; /** - * NONE
+ * PRE_EXISTING_ONLY
* BIOME_ONLY
* BIOME_ONLY_SIMULATE_HEIGHT
* SURFACE
@@ -31,17 +31,17 @@ package com.seibel.lod.api.enums.config; * * @author James Seibel * @author Leonardo Amato - * @version 2022-7-1 + * @version 2022-12-10 */ -public enum EDistanceGenerationMode +public enum EDhApiDistantGeneratorMode { // Reminder: // when adding items up the API minor version // when removing items up the API major version - /** Don't generate anything except already existing chunks */ - NONE((byte) 1), + /** Don't generate any new terrain, just generate LODs for already generated chunks. */ + PRE_EXISTING_ONLY((byte) 1), /** * Only generate the biomes and use biome @@ -85,53 +85,58 @@ public enum EDistanceGenerationMode */ FULL((byte) 6); - public static EDistanceGenerationMode RENDERABLE = EDistanceGenerationMode.BIOME_ONLY; - /** - * The higher the number the more complete the generation is. - */ + + public static final EDhApiDistantGeneratorMode RENDERABLE = EDhApiDistantGeneratorMode.BIOME_ONLY; + + /** The higher the number the more complete the generation is. */ public final byte complexity; - EDistanceGenerationMode(byte complexity) + + EDhApiDistantGeneratorMode(byte complexity) { this.complexity = complexity; } + + + + /** returns null if out of range */ + public static EDhApiDistantGeneratorMode previous(EDhApiDistantGeneratorMode mode) { - this.complexity = complexity; - } - - // Note: return null if out of range - public static EDistanceGenerationMode previous(EDistanceGenerationMode mode) { - switch (mode) { - case FULL: - return EDistanceGenerationMode.FEATURES; - case FEATURES: - return EDistanceGenerationMode.SURFACE; - case SURFACE: - return EDistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT; - case BIOME_ONLY_SIMULATE_HEIGHT: - return EDistanceGenerationMode.BIOME_ONLY; - case BIOME_ONLY: - return EDistanceGenerationMode.NONE; - case NONE: - default: - return null; + switch (mode) + { + case FULL: + return EDhApiDistantGeneratorMode.FEATURES; + case FEATURES: + return EDhApiDistantGeneratorMode.SURFACE; + case SURFACE: + return EDhApiDistantGeneratorMode.BIOME_ONLY_SIMULATE_HEIGHT; + case BIOME_ONLY_SIMULATE_HEIGHT: + return EDhApiDistantGeneratorMode.BIOME_ONLY; + case BIOME_ONLY: + return EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY; + case PRE_EXISTING_ONLY: + default: + return null; } } - // Note: return null if out of range - public static EDistanceGenerationMode next(EDistanceGenerationMode mode) { - switch (mode) { - case FEATURES: - return EDistanceGenerationMode.FULL; - case SURFACE: - return EDistanceGenerationMode.FEATURES; - case BIOME_ONLY_SIMULATE_HEIGHT: - return EDistanceGenerationMode.SURFACE; - case BIOME_ONLY: - return EDistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT; - case NONE: - return EDistanceGenerationMode.BIOME_ONLY; - case FULL: - default: - return null; + /** returns null if out of range */ + public static EDhApiDistantGeneratorMode next(EDhApiDistantGeneratorMode mode) + { + switch (mode) + { + case FEATURES: + return EDhApiDistantGeneratorMode.FULL; + case SURFACE: + return EDhApiDistantGeneratorMode.FEATURES; + case BIOME_ONLY_SIMULATE_HEIGHT: + return EDhApiDistantGeneratorMode.SURFACE; + case BIOME_ONLY: + return EDhApiDistantGeneratorMode.BIOME_ONLY_SIMULATE_HEIGHT; + case PRE_EXISTING_ONLY: + return EDhApiDistantGeneratorMode.BIOME_ONLY; + case FULL: + default: + return null; } } + } diff --git a/api/src/main/java/com/seibel/lod/api/interfaces/config/both/IDhApiWorldGenerationConfig.java b/api/src/main/java/com/seibel/lod/api/interfaces/config/both/IDhApiWorldGenerationConfig.java index c5c9fea4e..d50679f97 100644 --- a/api/src/main/java/com/seibel/lod/api/interfaces/config/both/IDhApiWorldGenerationConfig.java +++ b/api/src/main/java/com/seibel/lod/api/interfaces/config/both/IDhApiWorldGenerationConfig.java @@ -20,7 +20,7 @@ package com.seibel.lod.api.interfaces.config.both; import com.seibel.lod.api.enums.config.EBlocksToAvoid; -import com.seibel.lod.api.enums.config.EDistanceGenerationMode; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.lod.api.enums.config.EGenerationPriority; import com.seibel.lod.api.interfaces.config.IDhApiConfigValue; import com.seibel.lod.api.enums.config.ELightGenerationMode; @@ -44,7 +44,7 @@ public interface IDhApiWorldGenerationConfig extends IDhApiConfigGroup IDhApiConfigValue getEnableDistantWorldGeneration(); /** Defines to what level fake chunks will be generated. */ - IDhApiConfigValue getDistantGeneratorDetailLevel(); + IDhApiConfigValue getDistantGeneratorMode(); /** Defines how generated fake chunks will be lit. */ IDhApiConfigValue getLightingMode(); diff --git a/api/src/main/java/com/seibel/lod/api/interfaces/override/AbstractDhApiWorldGenerator.java b/api/src/main/java/com/seibel/lod/api/interfaces/override/AbstractDhApiWorldGenerator.java index 3db8c905b..9d84b0833 100644 --- a/api/src/main/java/com/seibel/lod/api/interfaces/override/AbstractDhApiWorldGenerator.java +++ b/api/src/main/java/com/seibel/lod/api/interfaces/override/AbstractDhApiWorldGenerator.java @@ -1,7 +1,7 @@ package com.seibel.lod.api.interfaces.override; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.lod.api.interfaces.world.IDhApiLevelWrapper; -import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.lod.api.enums.worldGeneration.EDhApiWorldGenThreadMode; import com.seibel.lod.api.interfaces.world.IDhApiChunkWrapper; @@ -19,9 +19,9 @@ public abstract class AbstractDhApiWorldGenerator implements IDhApiOverrideable return this.getThreadingMode(); } - public abstract IDhApiChunkWrapper generateChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiWorldGenerationStep maxStepToGenerate); + public abstract IDhApiChunkWrapper generateChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiDistantGeneratorMode maxStepToGenerate); - public final IDhApiChunkWrapper generateCoreChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiWorldGenerationStep maxStepToGenerate) + public final IDhApiChunkWrapper generateCoreChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiDistantGeneratorMode maxStepToGenerate) { // TODO probably need to change the return type return null; //generateChunk(chunkPosX, chunkPosZ, null, generationStepEnumConverter.convertToApiType(maxStepToGenerate)); diff --git a/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java b/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java index 29e1eade2..aff18f21f 100644 --- a/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java +++ b/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java @@ -24,7 +24,7 @@ import com.seibel.lod.api.interfaces.config.both.IDhApiWorldGenerationConfig; import com.seibel.lod.api.objects.config.DhApiConfigValue; import com.seibel.lod.core.config.Config.Client.WorldGenerator; import com.seibel.lod.api.enums.config.EBlocksToAvoid; -import com.seibel.lod.api.enums.config.EDistanceGenerationMode; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.lod.api.enums.config.EGenerationPriority; import com.seibel.lod.api.enums.config.ELightGenerationMode; @@ -49,8 +49,8 @@ public class DhApiWorldGenerationConfig implements IDhApiWorldGenerationConfig { return new DhApiConfigValue<>(WorldGenerator.enableDistantGeneration); } @Override - public IDhApiConfigValue getDistantGeneratorDetailLevel() - { return new DhApiConfigValue<>(WorldGenerator.distanceGenerationMode); } + public IDhApiConfigValue getDistantGeneratorMode() + { return new DhApiConfigValue<>(WorldGenerator.distantGeneratorMode); } @Override public IDhApiConfigValue getLightingMode() diff --git a/core/src/main/java/com/seibel/lod/core/config/Config.java b/core/src/main/java/com/seibel/lod/core/config/Config.java index c36dcafd3..4ddd411a3 100644 --- a/core/src/main/java/com/seibel/lod/core/config/Config.java +++ b/core/src/main/java/com/seibel/lod/core/config/Config.java @@ -22,11 +22,9 @@ package com.seibel.lod.core.config; import com.seibel.lod.api.enums.config.*; import com.seibel.lod.api.enums.rendering.*; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.lod.core.config.types.*; -import java.util.HashMap; -import java.util.Map; - /** * This handles any configuration the user has access to. @@ -492,8 +490,8 @@ public class Config + "Note that in server, distant generation is always off.") .build(); - public static ConfigEntry distanceGenerationMode = new ConfigEntry.Builder() - .set(EDistanceGenerationMode.FEATURES) + public static ConfigEntry distantGeneratorMode = new ConfigEntry.Builder() + .set(EDhApiDistantGeneratorMode.FEATURES) .comment("" + "How detailed should fake chunks be generated outside the vanilla render distance? \n" + "\n" @@ -501,36 +499,36 @@ public class Config + " one chunk in Minecraft 1.16.5 and may be inaccurate for different Minecraft versions. \n" + "They are included to give a rough estimate as to how the different options \n" + " may perform in comparison to each other. \n" - + "(Note that all modes will load in already existing chunks) \n" + + "(Note that all modes will load in pre-existing chunks) \n" + "\n" - + EDistanceGenerationMode.NONE + " \n" - + "Only run the Generator to load in already existing chunks. \n" + + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + " \n" + + "Only create LOD data for already generated chunks. \n" + "\n" - + EDistanceGenerationMode.BIOME_ONLY + " \n" + + EDhApiDistantGeneratorMode.BIOME_ONLY + " \n" + "Only generate the biomes and use the biome's \n" + " grass color, water color, or snow color. \n" + "Doesn't generate height, everything is shown at sea level. \n" + " - Fastest (2-5 ms) \n" + "\n" - + EDistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT + " \n" - + "Same as " + EDistanceGenerationMode.BIOME_ONLY + ", except instead \n" + + EDhApiDistantGeneratorMode.BIOME_ONLY_SIMULATE_HEIGHT + " \n" + + "Same as " + EDhApiDistantGeneratorMode.BIOME_ONLY + ", except instead \n" + " of always using sea level as the LOD height \n" + " different biome types (mountain, ocean, forest, etc.) \n" + " use predetermined heights to simulate having height data. \n" + " - Fastest (2-5 ms) \n" + "\n" - + EDistanceGenerationMode.SURFACE + " \n" + + EDhApiDistantGeneratorMode.SURFACE + " \n" + "Generate the world surface, \n" + " this does NOT include trees, \n" + " or structures. \n" + " - Faster (10-20 ms) \n" + "\n" - + EDistanceGenerationMode.FEATURES + " \n" + + EDhApiDistantGeneratorMode.FEATURES + " \n" + "Generate everything except structures. \n" + "WARNING: This may cause world generation bugs or instability! \n" + " - Fast (15-20 ms) \n" + "\n" - + EDistanceGenerationMode.FULL + " \n" + + EDhApiDistantGeneratorMode.FULL + " \n" + "Ask the local server to generate/load each chunk. \n" + "This will show player made structures, which can \n" + " be useful if you are adding the mod to a pre-existing world. \n" diff --git a/core/src/main/java/com/seibel/lod/core/datatype/transform/LodBuilderConfig.java b/core/src/main/java/com/seibel/lod/core/datatype/transform/LodBuilderConfig.java index e9278e5f9..80351a865 100644 --- a/core/src/main/java/com/seibel/lod/core/datatype/transform/LodBuilderConfig.java +++ b/core/src/main/java/com/seibel/lod/core/datatype/transform/LodBuilderConfig.java @@ -19,15 +19,16 @@ package com.seibel.lod.core.datatype.transform; -import com.seibel.lod.api.enums.config.EDistanceGenerationMode; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; /** * This is used to easily configure how LodChunks are generated. * Generally this will only be used if we want to generate a - * LodChunk using an incomplete Chunk, otherwise the defaults - * work best for a fully generated chunk (IE has correct surface blocks). + * LodChunk using incomplete data, otherwise the defaults + * should work best for a fully generated chunk (IE has correct surface blocks). + * * @author James Seibel - * @version 8-14-2021 + * @version 2022-12-10 */ public class LodBuilderConfig { @@ -37,9 +38,10 @@ public class LodBuilderConfig public boolean useBiomeColors; /** default: true */ public boolean useSolidBlocksInColorGen; - /** default: server */ - public EDistanceGenerationMode distanceGenerationMode; + /** default: false */ public boolean quickFillWithVoid; + public EDhApiDistantGeneratorMode distantGeneratorDetailLevel; + /** * default settings for a normal chunk
@@ -47,18 +49,21 @@ public class LodBuilderConfig * useBiomeColors = false
* useSolidBlocksInColorGen = true
*/ - public LodBuilderConfig(EDistanceGenerationMode newDistanceGenerationMode) + public LodBuilderConfig(EDhApiDistantGeneratorMode distantGeneratorDetailLevel) { - useHeightmap = false; - useBiomeColors = false; - useSolidBlocksInColorGen = true; - quickFillWithVoid = false; - distanceGenerationMode = newDistanceGenerationMode; + this.useHeightmap = false; + this.useBiomeColors = false; + this.useSolidBlocksInColorGen = true; + this.quickFillWithVoid = false; + this.distantGeneratorDetailLevel = distantGeneratorDetailLevel; } - public static LodBuilderConfig getFillVoidConfig() { - LodBuilderConfig config = new LodBuilderConfig(EDistanceGenerationMode.NONE); + /** Default settings used when generating LODs for pre-generated terrain. */ + public static LodBuilderConfig getFillVoidConfig() + { + LodBuilderConfig config = new LodBuilderConfig(EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY); config.quickFillWithVoid = true; return config; } + } \ No newline at end of file diff --git a/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java b/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java index 39c9d4a71..6604ae825 100644 --- a/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java +++ b/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/ILodConfigWrapperSingleton.java @@ -21,6 +21,7 @@ package com.seibel.lod.core.wrapperInterfaces.config; import com.seibel.lod.api.enums.config.*; import com.seibel.lod.api.enums.rendering.*; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.lod.core.config.Config; import com.seibel.lod.core.interfaces.dependencyInjection.IBindable; import com.seibel.lod.core.dependencyInjection.SingletonInjector; @@ -243,8 +244,8 @@ public interface ILodConfigWrapperSingleton extends IBindable boolean getEnableDistantGeneration(); void setEnableDistantGeneration(boolean newEnableDistantGeneration); - EDistanceGenerationMode getDistanceGenerationMode(); - void setDistanceGenerationMode(EDistanceGenerationMode newDistanceGenerationMode); + EDhApiDistantGeneratorMode getDistanceGenerationMode(); + void setDistanceGenerationMode(EDhApiDistantGeneratorMode newDistanceGenerationMode); ELightGenerationMode getLightGenerationMode(); void setLightGenerationMode(ELightGenerationMode newLightGenerationMode); diff --git a/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/LodConfigWrapperSingleton.java b/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/LodConfigWrapperSingleton.java index bf2325641..436ca9d42 100644 --- a/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/LodConfigWrapperSingleton.java +++ b/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/config/LodConfigWrapperSingleton.java @@ -2,6 +2,7 @@ package com.seibel.lod.core.wrapperInterfaces.config; import com.seibel.lod.api.enums.config.*; import com.seibel.lod.api.enums.rendering.*; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.lod.core.config.Config; /** @@ -541,14 +542,14 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton @Override - public EDistanceGenerationMode getDistanceGenerationMode() + public EDhApiDistantGeneratorMode getDistanceGenerationMode() { - return Config.Client.WorldGenerator.distanceGenerationMode.get(); + return Config.Client.WorldGenerator.distantGeneratorMode.get(); } @Override - public void setDistanceGenerationMode(EDistanceGenerationMode newDistanceGenerationMode) + public void setDistanceGenerationMode(EDhApiDistantGeneratorMode newDistanceGenerationMode) { - Config.Client.WorldGenerator.distanceGenerationMode.set(newDistanceGenerationMode); + Config.Client.WorldGenerator.distantGeneratorMode.set(newDistanceGenerationMode); } /*