diff --git a/src/main/java/biomesoplenty/client/handler/GuiEventHandler.java b/src/main/java/biomesoplenty/client/handler/GuiEventHandler.java new file mode 100644 index 000000000..3061a8dc4 --- /dev/null +++ b/src/main/java/biomesoplenty/client/handler/GuiEventHandler.java @@ -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(); + } + } +} diff --git a/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java b/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java index bdf17ad32..e6d946862 100644 --- a/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java +++ b/src/main/java/biomesoplenty/client/util/GenLayerVisualizer.java @@ -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 landAreaFactory = BOPLayerUtil.createInitialLandAndSeaFactory(contextFactory); - IAreaFactory climateFactory = BOPLayerUtil.createClimateFactory(contextFactory, new BOPWorldSettings()); + IAreaFactory climateFactory = BOPLayerUtil.createClimateFactory(contextFactory, new BOPOverworldGenSettings()); IAreaFactory biomeAreaFactory = BOPLayerUtil.createBiomeFactory(landAreaFactory, climateFactory, contextFactory); //IAreaFactory biomeAreaFactory = BOPLayerUtil.createAreaFactories(WorldType.DEFAULT, settings, contextFactory).get(0); diff --git a/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java b/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java index 952624237..1f0b88568 100644 --- a/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java +++ b/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java @@ -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) diff --git a/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java b/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java index 69968d0f1..bef79cd5d 100644 --- a/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java +++ b/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java b/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java index 024814820..a9a09b890 100644 --- a/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java +++ b/src/main/java/biomesoplenty/common/world/BOPLayerUtil.java @@ -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 > IAreaFactory createClimateFactory(LongFunction contextFactory, BOPWorldSettings settings) + public static > IAreaFactory createClimateFactory(LongFunction contextFactory, BOPOverworldGenSettings settings) { IAreaFactory 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 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 > ImmutableList> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction contextFactory) + public static > ImmutableList> createAreaFactories(WorldType worldType, BOPOverworldGenSettings settings, LongFunction 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 climateFactory = createClimateFactory(contextFactory, new BOPWorldSettings()); + IAreaFactory 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> factoryList = createAreaFactories(worldType, settings, (seedModifier) -> { diff --git a/src/main/java/biomesoplenty/common/world/BOPWorldSettings.java b/src/main/java/biomesoplenty/common/world/BOPOverworldGenSettings.java similarity index 54% rename from src/main/java/biomesoplenty/common/world/BOPWorldSettings.java rename to src/main/java/biomesoplenty/common/world/BOPOverworldGenSettings.java index 5ec56e489..c240102f2 100644 --- a/src/main/java/biomesoplenty/common/world/BOPWorldSettings.java +++ b/src/main/java/biomesoplenty/common/world/BOPOverworldGenSettings.java @@ -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(); + } } diff --git a/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java b/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java index 3a9fbace9..5dfff1902 100644 --- a/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java +++ b/src/main/java/biomesoplenty/common/world/ChunkGeneratorOverworldBOP.java @@ -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); } diff --git a/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java b/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java index e17d1ff54..fdae17ba1 100644 --- a/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java +++ b/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java @@ -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) { diff --git a/src/main/java/biomesoplenty/init/ModConfig.java b/src/main/java/biomesoplenty/init/ModConfig.java index 89f91e43e..0c111189a 100644 --- a/src/main/java/biomesoplenty/init/ModConfig.java +++ b/src/main/java/biomesoplenty/init/ModConfig.java @@ -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 biomeSize; + public static final ForgeConfigSpec.EnumValue riverSize; + public static final ForgeConfigSpec.EnumValue temperatureVariationScheme; + public static final ForgeConfigSpec.EnumValue 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"); } diff --git a/src/main/java/biomesoplenty/init/ModVanillaCompat.java b/src/main/java/biomesoplenty/init/ModVanillaCompat.java index 25a54c89f..1c7139ce0 100644 --- a/src/main/java/biomesoplenty/init/ModVanillaCompat.java +++ b/src/main/java/biomesoplenty/init/ModVanillaCompat.java @@ -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); } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index ffd01b376..dfd6de4d8 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -13,6 +13,10 @@ public net.minecraft.block.PressurePlateBlock (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 *