Add World generator API config

This commit is contained in:
James Seibel
2022-07-01 22:02:57 -05:00
parent 1855e27d29
commit d92b1f1032
9 changed files with 348 additions and 20 deletions
@@ -0,0 +1,53 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* NONE, <br>
* NON_FULL, <br>
* NO_COLLISION, <br>
* BOTH, <br>
*
* @author Leonardo Amato
* @version 2022-7-1
*/
public enum EDhApiBlocksToAvoid
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NONE(false, false),
NON_FULL(true, false),
NO_COLLISION(false, true),
BOTH(true, true);
public final boolean nonFull;
public final boolean noCollision;
EDhApiBlocksToAvoid(boolean nonFull, boolean noCollision)
{
this.nonFull = nonFull;
this.noCollision = noCollision;
}
}
@@ -0,0 +1,88 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* NONE <br>
* BIOME_ONLY <br>
* BIOME_ONLY_SIMULATE_HEIGHT <br>
* SURFACE <br>
* FEATURES <br>
* FULL <br><br>
*
* In order of fastest to slowest.
*
* @author James Seibel
* @author Leonardo Amato
* @version 2022-7-1
*/
public enum EDhApiDistanceGenerationMode
{
// 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,
/**
* Only generate the biomes and use biome
* grass/foliage color, water color, or ice color
* to generate the color. <br>
* Doesn't generate height, everything is shown at sea level. <br>
* Multithreaded - Fastest (2-5 ms)
*/
BIOME_ONLY,
/**
* Same as BIOME_ONLY, except instead
* of always using sea level as the LOD height
* different biome types (mountain, ocean, forest, etc.)
* use predetermined heights to simulate having height data.
*/
BIOME_ONLY_SIMULATE_HEIGHT,
/**
* Generate the world surface,
* this does NOT include caves, trees,
* or structures. <br>
* Multithreaded - Faster (10-20 ms)
*/
SURFACE,
/**
* Generate including structures.
* NOTE: This may cause world generation bugs or instability,
* since some features can cause concurrentModification exceptions. <br>
* Multithreaded - Fast (15-20 ms)
*/
FEATURES,
/**
* Ask the server to generate/load each chunk.
* This is the most compatible, but causes server/simulation lag.
* This will also show player made structures if you
* are adding the mod on a pre-existing world. <br>
* Single-threaded - Slow (15-50 ms, with spikes up to 200 ms)
*/
FULL;
}
@@ -0,0 +1,47 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* AUTO <br>
* Near_First <br>
* Far_First <br> <br>
*
* Determines which LODs should have priority when generating
* outside the normal view distance.
*
* @author Leonardo Amato
* @version 12-1-2021
*/
public enum EDhApiGenerationPriority
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** NEAR_FIRST when connected to servers and BALANCED when on single player */
AUTO,
NEAR_FIRST,
BALANCED,
FAR_FIRST
}
@@ -0,0 +1,40 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* FAST, <br>
* RANCY,
*
* @author Leetom
* @version 2022-7-1
*/
public enum EDhApiLightGenerationMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** Fake light values using a height map */
FAST,
/** Run the lighting engine though the chunk to generate proper light values */
FANCY
}
@@ -0,0 +1,77 @@
package com.seibel.lod.core.api.external.config.client;
import com.seibel.lod.core.api.external.apiObjects.enums.*;
import com.seibel.lod.core.api.external.apiObjects.wrapperInterfaces.IDhApiConfig;
import com.seibel.lod.core.api.implementation.objects.GenericEnumConverter;
import com.seibel.lod.core.api.implementation.wrappers.DhApiConfig;
import com.seibel.lod.core.config.Config.Client.Advanced.Debugging;
import com.seibel.lod.core.config.Config.Client.WorldGenerator;
import com.seibel.lod.core.enums.config.EBlocksToAvoid;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EGenerationPriority;
import com.seibel.lod.core.enums.config.ELightGenerationMode;
import com.seibel.lod.core.enums.rendering.ERendererType;
/**
* General graphics settings.
*
* @author James Seibel
* @version 2022-6-13
*/
public class DhApiWorldGeneration
{
/**
* Returns the config related to whether Distant Horizons
* will attempt to generate fake chunks outside Minecraft's
* vanilla render distance.
*/
public static IDhApiConfig<Boolean> getEnableDistantWorldGenerationConfig()
{ return new DhApiConfig<>(WorldGenerator.enableDistantGeneration); }
/**
* Returns the config related to how Distant Horizons' distant world
* generator will generate chunks.
*/
public static IDhApiConfig<EDhApiDistanceGenerationMode> getDistantGeneratorModeConfig()
{ return new DhApiConfig<>(WorldGenerator.distanceGenerationMode, new GenericEnumConverter<>(EDistanceGenerationMode.class, EDhApiDistanceGenerationMode.class)); }
/**
* Returns the config related to how Distant Horizons' distant world
* generator will light the chunks it generates.
*/
public static IDhApiConfig<EDhApiLightGenerationMode> getLightingModeConfig()
{ return new DhApiConfig<>(WorldGenerator.lightGenerationMode, new GenericEnumConverter<>(ELightGenerationMode.class, EDhApiLightGenerationMode.class)); }
/**
* Returns the config related to the order Distant Horizons' distant world
* generator will generate chunks.
*/
public static IDhApiConfig<EDhApiLightGenerationMode> getGenerationPriorityConfig()
{ return new DhApiConfig<>(WorldGenerator.generationPriority, new GenericEnumConverter<>(EGenerationPriority.class, EDhApiLightGenerationMode.class)); }
/**
* Returns the config related to what blocks Distant Horizons' distant world
* generator will ignore when generating LODs.
*
* @deprecated this method won't be needed once we transition to an ID based save system <br>
* (vs the color based system we have currently)
*/
@Deprecated
public static IDhApiConfig<EDhApiBlocksToAvoid> getBlocksToAvoidConfig()
{ return new DhApiConfig<>(WorldGenerator.blocksToAvoid, new GenericEnumConverter<>(EBlocksToAvoid.class, EDhApiBlocksToAvoid.class)); }
/**
* Returns the config related to whether Distant Horizons' distant world
* generator will color the blocks below an avoided block. <Br>
* (IE: if flowers are avoided should they color the grass below them?)
*
* @deprecated this method won't be needed once we transition to an ID based save system <br>
* (vs the color based system we have currently)
*/
@Deprecated
public static IDhApiConfig<Boolean> getTintWithAvoidedBlocksConfig()
{ return new DhApiConfig<>(WorldGenerator.tintWithAvoidedBlocks); }
}
@@ -20,14 +20,20 @@
package com.seibel.lod.core.enums.config;
/**
* heightmap <br>
* multi_lod <br>
*
* NONE, <br>
* NON_FULL, <br>
* NO_COLLISION, <br>
* BOTH, <br>
*
* @author Leonardo Amato
* @version 11-16-2021
* @version 2022-7-1
*/
public enum EBlocksToAvoid
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NONE(false, false),
NON_FULL(true, false),
@@ -25,26 +25,29 @@ package com.seibel.lod.core.enums.config;
* BIOME_ONLY_SIMULATE_HEIGHT <br>
* SURFACE <br>
* FEATURES <br>
* SERVER <br><br>
* <p>
* FULL <br><br>
*
* In order of fastest to slowest.
*
* @author James Seibel
* @author Leonardo Amato
* @version 8-7-2021
* @version 2022-7-1
*/
public enum EDistanceGenerationMode
{
/**
* Don't generate anything except just load in already existing chunks
*/
// 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),
/**
* Only generate the biomes and use biome
* grass/foliage color, water color, or ice color
* to generate the color.
* Doesn't generate height, everything is shown at sea level.
* to generate the color. <br>
* Doesn't generate height, everything is shown at sea level. <br>
* Multithreaded - Fastest (2-5 ms)
*/
BIOME_ONLY((byte) 2),
@@ -60,15 +63,15 @@ public enum EDistanceGenerationMode
/**
* Generate the world surface,
* this does NOT include caves, trees,
* or structures.
* or structures. <br>
* Multithreaded - Faster (10-20 ms)
*/
SURFACE((byte) 4),
/**
* Generate everything except structures.
* Generate including structures.
* NOTE: This may cause world generation bugs or instability,
* since some features cause concurrentModification exceptions.
* since some features can cause concurrentModification exceptions. <br>
* Multithreaded - Fast (15-20 ms)
*/
FEATURES((byte) 5),
@@ -77,7 +80,7 @@ public enum EDistanceGenerationMode
* Ask the server to generate/load each chunk.
* This is the most compatible, but causes server/simulation lag.
* This will also show player made structures if you
* are adding the mod on a pre-existing world.
* are adding the mod on a pre-existing world. <br>
* Single-threaded - Slow (15-50 ms, with spikes up to 200 ms)
*/
FULL((byte) 6);
@@ -22,8 +22,8 @@ package com.seibel.lod.core.enums.config;
/**
* AUTO <br>
* Near_First <br>
* Far_First <br>
* <br>
* Far_First <br> <br>
*
* Determines which LODs should have priority when generating
* outside the normal view distance.
*
@@ -32,6 +32,10 @@ package com.seibel.lod.core.enums.config;
*/
public enum EGenerationPriority
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** NEAR_FIRST when connected to servers and BALANCED when on single player */
AUTO,
@@ -19,12 +19,22 @@
package com.seibel.lod.core.enums.config;
/**
* FAST, <br>
* RANCY,
*
* @author Leetom
* @version 2022-7-1
*/
public enum ELightGenerationMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
// Fake in light values based on height maps
/** Fake light values using a height map */
FAST,
// Run the light engine though the chunk to generate proper light values
/** Run the lighting engine though the chunk to generate proper light values */
FANCY
}