Added various config options
This commit is contained in:
parent
e297832f5e
commit
ba648379a6
11 changed files with 157 additions and 31 deletions
|
@ -0,0 +1,39 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2014-2019, the Biomes O' Plenty Team
|
||||
*
|
||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||
*
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
******************************************************************************/
|
||||
package biomesoplenty.client.handler;
|
||||
|
||||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import biomesoplenty.init.ModBiomes;
|
||||
import biomesoplenty.init.ModConfig;
|
||||
import net.minecraft.client.gui.screen.CreateWorldScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class GuiEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onPreInitCreateWorld(GuiScreenEvent.InitGuiEvent.Pre event)
|
||||
{
|
||||
Screen screenGui = event.getGui();
|
||||
|
||||
if (ModConfig.ClientConfig.useWorldType.get() && screenGui instanceof CreateWorldScreen)
|
||||
{
|
||||
CreateWorldScreen createWorldGui = (CreateWorldScreen)screenGui;
|
||||
|
||||
// Do not change back when returning from the 'Customize' screen
|
||||
if (createWorldGui.levelTypeIndex == WorldType.NORMAL.getId())
|
||||
createWorldGui.levelTypeIndex = ModBiomes.worldType.getId();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
package biomesoplenty.client.util;
|
||||
|
||||
import biomesoplenty.common.world.BOPLayerUtil;
|
||||
import biomesoplenty.common.world.BOPWorldSettings;
|
||||
import biomesoplenty.common.world.BOPOverworldGenSettings;
|
||||
import biomesoplenty.common.world.layer.traits.IBOPContextExtended;
|
||||
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
|
||||
import biomesoplenty.init.ModBiomes;
|
||||
|
@ -168,7 +168,7 @@ public class GenLayerVisualizer
|
|||
};
|
||||
|
||||
IAreaFactory<LazyArea> landAreaFactory = BOPLayerUtil.createInitialLandAndSeaFactory(contextFactory);
|
||||
IAreaFactory<LazyArea> climateFactory = BOPLayerUtil.createClimateFactory(contextFactory, new BOPWorldSettings());
|
||||
IAreaFactory<LazyArea> climateFactory = BOPLayerUtil.createClimateFactory(contextFactory, new BOPOverworldGenSettings());
|
||||
IAreaFactory<LazyArea> biomeAreaFactory = BOPLayerUtil.createBiomeFactory(landAreaFactory, climateFactory, contextFactory);
|
||||
|
||||
//IAreaFactory<LazyArea> biomeAreaFactory = BOPLayerUtil.createAreaFactories(WorldType.DEFAULT, settings, contextFactory).get(0);
|
||||
|
|
|
@ -7,22 +7,18 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.common.util.biome;
|
||||
|
||||
import biomesoplenty.common.world.BOPWorldSettings;
|
||||
import biomesoplenty.common.world.BOPOverworldGenSettings;
|
||||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class BiomeUtil
|
||||
{
|
||||
public static int getBiomeSize(World world)
|
||||
{
|
||||
// TODO
|
||||
return BOPWorldSettings.BiomeSize.MEDIUM.getValue();
|
||||
return BOPOverworldGenSettings.BiomeSize.MEDIUM.getValue();
|
||||
}
|
||||
|
||||
public static BlockPos spiralOutwardsLookingForBiome(World world, Biome biomeToFind, double startX, double startZ)
|
||||
|
|
|
@ -39,7 +39,7 @@ public class BOPBiomeProvider extends OverworldBiomeProvider
|
|||
super(settingsProvider);
|
||||
this.possibleBiomes = Sets.newHashSet(super.possibleBiomes);
|
||||
this.possibleBiomes.addAll(BOPClimates.getOverworldBiomes());
|
||||
this.noiseBiomeLayer = BOPLayerUtil.createGenLayers(settingsProvider.getSeed(), settingsProvider.getGeneratorType(), settingsProvider.getGeneratorSettings())[0];
|
||||
this.noiseBiomeLayer = BOPLayerUtil.createGenLayers(settingsProvider.getSeed(), settingsProvider.getGeneratorType(), (BOPOverworldGenSettings)settingsProvider.getGeneratorSettings())[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ package biomesoplenty.common.world;
|
|||
|
||||
import biomesoplenty.common.world.layer.*;
|
||||
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
|
||||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.WorldType;
|
||||
|
@ -58,11 +59,11 @@ public class BOPLayerUtil
|
|||
}
|
||||
|
||||
// superimpose hot and cold regions an a land and sea layer
|
||||
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createClimateFactory(LongFunction<C> contextFactory, BOPWorldSettings settings)
|
||||
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createClimateFactory(LongFunction<C> contextFactory, BOPOverworldGenSettings settings)
|
||||
{
|
||||
IAreaFactory<T> temperatureFactory;
|
||||
|
||||
switch (settings.tempScheme)
|
||||
switch (settings.getTempScheme())
|
||||
{
|
||||
case LATITUDE: default:
|
||||
temperatureFactory = TemperatureLatitudeLayer.INSTANCE.run(contextFactory.apply(2L));
|
||||
|
@ -82,7 +83,7 @@ public class BOPLayerUtil
|
|||
}
|
||||
|
||||
IAreaFactory<T> rainfallFactory;
|
||||
switch(settings.rainScheme)
|
||||
switch(settings.getRainScheme())
|
||||
{
|
||||
case SMALL_ZONES:
|
||||
rainfallFactory = RainfallNoiseLayer.SMALL_ZONES.run(contextFactory.apply(7L));
|
||||
|
@ -110,7 +111,7 @@ public class BOPLayerUtil
|
|||
return biomeFactory;
|
||||
}
|
||||
|
||||
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> ImmutableList<IAreaFactory<T>> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction<C> contextFactory)
|
||||
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> ImmutableList<IAreaFactory<T>> createAreaFactories(WorldType worldType, BOPOverworldGenSettings settings, LongFunction<C> contextFactory)
|
||||
{
|
||||
// Create the initial land and sea layer. Is also responsible for adding deep oceans
|
||||
// and mushroom islands
|
||||
|
@ -130,7 +131,7 @@ public class BOPLayerUtil
|
|||
biomeSize = LayerUtil.getModdedBiomeSize(worldType, biomeSize);
|
||||
|
||||
// Create the climates
|
||||
IAreaFactory<T> climateFactory = createClimateFactory(contextFactory, new BOPWorldSettings());
|
||||
IAreaFactory<T> climateFactory = createClimateFactory(contextFactory, settings);
|
||||
|
||||
// Add islands and deep oceans
|
||||
landSeaFactory = AddMushroomIslandLayer.INSTANCE.run(contextFactory.apply(5L), landSeaFactory);
|
||||
|
@ -175,7 +176,7 @@ public class BOPLayerUtil
|
|||
return ImmutableList.of(biomesFactory, voroniZoomBiomesFactory, biomesFactory);
|
||||
}
|
||||
|
||||
public static Layer[] createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings)
|
||||
public static Layer[] createGenLayers(long seed, WorldType worldType, BOPOverworldGenSettings settings)
|
||||
{
|
||||
ImmutableList<IAreaFactory<LazyArea>> factoryList = createAreaFactories(worldType, settings, (seedModifier) ->
|
||||
{
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.common.world;
|
||||
|
||||
public class BOPWorldSettings
|
||||
import biomesoplenty.init.ModConfig;
|
||||
import net.minecraft.world.gen.OverworldGenSettings;
|
||||
|
||||
public class BOPOverworldGenSettings extends OverworldGenSettings
|
||||
{
|
||||
public enum LandMassScheme
|
||||
{
|
||||
|
@ -54,9 +57,46 @@ public class BOPWorldSettings
|
|||
}
|
||||
}
|
||||
|
||||
public LandMassScheme landScheme = LandMassScheme.VANILLA;
|
||||
public TemperatureVariationScheme tempScheme = TemperatureVariationScheme.MEDIUM_ZONES;
|
||||
public RainfallVariationScheme rainScheme = RainfallVariationScheme.MEDIUM_ZONES;
|
||||
public BiomeSize biomeSize = BiomeSize.MEDIUM;
|
||||
public float amplitude = 1.0F;
|
||||
public enum RiverSize
|
||||
{
|
||||
TINY (2),
|
||||
SMALL (3),
|
||||
MEDIUM (4),
|
||||
LARGE (5),
|
||||
HUGE (6);
|
||||
|
||||
private final int value;
|
||||
|
||||
RiverSize(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeSize()
|
||||
{
|
||||
return ModConfig.GenerationConfig.biomeSize.get().value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRiverSize()
|
||||
{
|
||||
return ModConfig.GenerationConfig.riverSize.get().value;
|
||||
}
|
||||
|
||||
public TemperatureVariationScheme getTempScheme()
|
||||
{
|
||||
return ModConfig.GenerationConfig.temperatureVariationScheme.get();
|
||||
}
|
||||
|
||||
public RainfallVariationScheme getRainScheme()
|
||||
{
|
||||
return ModConfig.GenerationConfig.rainfallVariationScheme.get();
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ import net.minecraft.world.gen.OverworldGenSettings;
|
|||
|
||||
public class ChunkGeneratorOverworldBOP extends OverworldChunkGenerator
|
||||
{
|
||||
public ChunkGeneratorOverworldBOP(IWorld world, BiomeProvider provider, OverworldGenSettings settings)
|
||||
public ChunkGeneratorOverworldBOP(IWorld world, BiomeProvider provider, BOPOverworldGenSettings settings)
|
||||
{
|
||||
super(world, provider, settings);
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ public class WorldTypeBOP extends WorldType
|
|||
{
|
||||
if (world.getDimension().getType() == DimensionType.OVERWORLD)
|
||||
{
|
||||
OverworldGenSettings overworldGenSettings = new OverworldGenSettings();
|
||||
BOPOverworldGenSettings genSettings = new BOPOverworldGenSettings();
|
||||
OverworldBiomeProviderSettings biomeProviderSettings = new OverworldBiomeProviderSettings(world.getLevelData());
|
||||
biomeProviderSettings.setGeneratorSettings(overworldGenSettings);
|
||||
biomeProviderSettings.setGeneratorSettings(genSettings);
|
||||
|
||||
return new ChunkGeneratorOverworldBOP(world, new BOPBiomeProvider(biomeProviderSettings), overworldGenSettings);
|
||||
return new ChunkGeneratorOverworldBOP(world, new BOPBiomeProvider(biomeProviderSettings), genSettings);
|
||||
}
|
||||
else if (world.getDimension().getType() == DimensionType.NETHER)
|
||||
{
|
||||
|
|
|
@ -7,11 +7,8 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.init;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.world.BOPOverworldGenSettings;
|
||||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
@ -21,8 +18,6 @@ import java.nio.file.FileAlreadyExistsException;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ModConfig
|
||||
{
|
||||
|
@ -44,6 +39,51 @@ public class ModConfig
|
|||
}
|
||||
}
|
||||
|
||||
public static class ClientConfig
|
||||
{
|
||||
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
public static final ForgeConfigSpec SPEC;
|
||||
|
||||
public static final ForgeConfigSpec.BooleanValue useWorldType;
|
||||
|
||||
static
|
||||
{
|
||||
BUILDER.comment("Client-related options.");
|
||||
BUILDER.push("gui");
|
||||
useWorldType = BUILDER.comment("Select the Biomes O' Plenty world type by default.").define("use_world_type", true);
|
||||
BUILDER.pop();
|
||||
|
||||
SPEC = BUILDER.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class GenerationConfig
|
||||
{
|
||||
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
public static final ForgeConfigSpec SPEC;
|
||||
|
||||
public static final ForgeConfigSpec.EnumValue<BOPOverworldGenSettings.BiomeSize> biomeSize;
|
||||
public static final ForgeConfigSpec.EnumValue<BOPOverworldGenSettings.RiverSize> riverSize;
|
||||
public static final ForgeConfigSpec.EnumValue<BOPOverworldGenSettings.TemperatureVariationScheme> temperatureVariationScheme;
|
||||
public static final ForgeConfigSpec.EnumValue<BOPOverworldGenSettings.RainfallVariationScheme> rainfallVariationScheme;
|
||||
public static final ForgeConfigSpec.BooleanValue enhanceVanillaBiomes;
|
||||
|
||||
static
|
||||
{
|
||||
BUILDER.comment("World generation related options.");
|
||||
BUILDER.push("overworld");
|
||||
biomeSize = BUILDER.comment("The size of generated biomes.").defineEnum("biome_size", BOPOverworldGenSettings.BiomeSize.MEDIUM);
|
||||
riverSize = BUILDER.comment("The size of generated rivers.").defineEnum("river_size", BOPOverworldGenSettings.RiverSize.MEDIUM);
|
||||
temperatureVariationScheme = BUILDER.comment("Type of temperature zones to use during biome placement.").defineEnum("temperature_variation_scheme", BOPOverworldGenSettings.TemperatureVariationScheme.MEDIUM_ZONES);
|
||||
rainfallVariationScheme = BUILDER.comment("Type of rainfall zones to use during biome placement.").defineEnum("rainfall_variation_scheme", BOPOverworldGenSettings.RainfallVariationScheme.MEDIUM_ZONES);
|
||||
enhanceVanillaBiomes = BUILDER.comment("Enhance vanilla biomes by adding additional decoration.").define("enhance_vanilla_biomes", true);
|
||||
BUILDER.pop();
|
||||
|
||||
SPEC = BUILDER.build();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setup()
|
||||
{
|
||||
Path configPath = FMLPaths.CONFIGDIR.get();
|
||||
|
@ -63,6 +103,8 @@ public class ModConfig
|
|||
BiomesOPlenty.logger.error("Failed to create biomesoplenty config directory", e);
|
||||
}
|
||||
|
||||
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, GenerationConfig.SPEC, "biomesoplenty/generation.toml");
|
||||
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.CLIENT, ClientConfig.SPEC, "biomesoplenty/client.toml");
|
||||
// The server specific config type seems to load too late. Use common instead.
|
||||
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, ServerConfig.SPEC, "biomesoplenty/server.toml");
|
||||
}
|
||||
|
|
|
@ -329,6 +329,10 @@ public class ModVanillaCompat
|
|||
|
||||
public static void addFeature(Biome biome, GenerationStage.Decoration decorationStage, ConfiguredFeature<?, ?> featureIn)
|
||||
{
|
||||
// Don't add features if it is disabled in the config
|
||||
if (!ModConfig.GenerationConfig.enhanceVanillaBiomes.get())
|
||||
return;
|
||||
|
||||
biome.addFeature(decorationStage, featureIn);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ public net.minecraft.block.PressurePlateBlock <init>(Lnet/minecraft/block/Pressu
|
|||
|
||||
public-f net.minecraft.item.AxeItem field_203176_a # BLOCK_STRIPPING_MAP
|
||||
|
||||
# Default to BOP world type
|
||||
public net.minecraft.client.gui.screen.CreateWorldScreen field_146331_K # levelTypeIndex
|
||||
|
||||
|
||||
# server.properties world type hackery
|
||||
public-f net.minecraft.server.dedicated.ServerProperties *
|
||||
public net.minecraft.server.dedicated.PropertyManager *
|
||||
|
|
Loading…
Reference in a new issue