rename EDistanceGenerationMode -> EDhApiDistantGeneratorMode

This includes moving it into the API and renaming NONE -> PRE_EXISTING_ONLY
This commit is contained in:
James Seibel
2022-12-10 22:07:54 -06:00
parent bf698ad7b9
commit 0ab0aeeec6
8 changed files with 98 additions and 88 deletions
@@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.api.enums.config;
package com.seibel.lod.api.enums.worldGeneration;
/**
* NONE <br>
* PRE_EXISTING_ONLY <br>
* BIOME_ONLY <br>
* BIOME_ONLY_SIMULATE_HEIGHT <br>
* SURFACE <br>
@@ -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;
}
}
}
@@ -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<Boolean> getEnableDistantWorldGeneration();
/** Defines to what level fake chunks will be generated. */
IDhApiConfigValue<EDistanceGenerationMode> getDistantGeneratorDetailLevel();
IDhApiConfigValue<EDhApiDistantGeneratorMode> getDistantGeneratorMode();
/** Defines how generated fake chunks will be lit. */
IDhApiConfigValue<ELightGenerationMode> getLightingMode();
@@ -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));
@@ -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<EDistanceGenerationMode> getDistantGeneratorDetailLevel()
{ return new DhApiConfigValue<>(WorldGenerator.distanceGenerationMode); }
public IDhApiConfigValue<EDhApiDistantGeneratorMode> getDistantGeneratorMode()
{ return new DhApiConfigValue<>(WorldGenerator.distantGeneratorMode); }
@Override
public IDhApiConfigValue<ELightGenerationMode> getLightingMode()
@@ -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<EDistanceGenerationMode> distanceGenerationMode = new ConfigEntry.Builder<EDistanceGenerationMode>()
.set(EDistanceGenerationMode.FEATURES)
public static ConfigEntry<EDhApiDistantGeneratorMode> distantGeneratorMode = new ConfigEntry.Builder<EDhApiDistantGeneratorMode>()
.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"
@@ -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 <br>
@@ -47,18 +49,21 @@ public class LodBuilderConfig
* useBiomeColors = false <br>
* useSolidBlocksInColorGen = true <br>
*/
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;
}
}
@@ -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);
@@ -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);
}
/*