From 0f73559404cab4eadbe4bddfb9b4902847d3dcb6 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Thu, 16 Jan 2014 09:37:29 +1100 Subject: [PATCH] Amongst other config file tweaks, made all per chunk values added by BOP configurable as booleans --- .../java/biomesoplenty/BiomesOPlenty.java | 4 +- .../configuration/BOPConfiguration.java | 2 + .../configuration/BOPConfigurationMain.java | 8 --- .../configuration/BOPConfigurationMisc.java | 1 + .../BOPConfigurationTerrainGen.java | 29 +--------- .../BOPConfigurationWorldFeatures.java | 55 +++++++++++++++++++ .../common/world/WorldChunkManagerBOP.java | 2 +- .../generation/WorldGenFieldAssociation.java | 1 + 8 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/configuration/BOPConfigurationWorldFeatures.java diff --git a/src/main/java/biomesoplenty/BiomesOPlenty.java b/src/main/java/biomesoplenty/BiomesOPlenty.java index 3985eff95..774d400e3 100644 --- a/src/main/java/biomesoplenty/BiomesOPlenty.java +++ b/src/main/java/biomesoplenty/BiomesOPlenty.java @@ -2,6 +2,7 @@ package biomesoplenty; import net.minecraft.creativetab.CreativeTabs; import biomesoplenty.common.configuration.BOPConfiguration; +import biomesoplenty.common.configuration.BOPConfigurationWorldFeatures; import biomesoplenty.common.core.BOPArmor; import biomesoplenty.common.core.BOPBiomes; import biomesoplenty.common.core.BOPBlocks; @@ -39,7 +40,7 @@ public class BiomesOPlenty @EventHandler public void preInit(FMLPreInitializationEvent event) - { + { configPath = event.getModConfigurationDirectory() + "/biomesoplenty/"; BOPConfiguration.init(configPath); @@ -54,6 +55,7 @@ public class BiomesOPlenty BOPCrafting.init(); BOPBiomes.init(); WorldGenFieldAssociation.init(); + BOPConfigurationWorldFeatures.init(BOPConfiguration.worldFeaturesConfigFile); ForcedBOPWorldGenerators.init(); ForcedDecorators.init(); BOPEntities.init(); diff --git a/src/main/java/biomesoplenty/common/configuration/BOPConfiguration.java b/src/main/java/biomesoplenty/common/configuration/BOPConfiguration.java index b690a57a9..60d385d4d 100644 --- a/src/main/java/biomesoplenty/common/configuration/BOPConfiguration.java +++ b/src/main/java/biomesoplenty/common/configuration/BOPConfiguration.java @@ -5,6 +5,7 @@ import java.io.File; public class BOPConfiguration { public static File mainConfigFile; + public static File worldFeaturesConfigFile; public static File biomeGenConfigFile; public static File terrainGenConfigFile; public static File idConfigFile; @@ -13,6 +14,7 @@ public class BOPConfiguration public static void init(String configpath) { mainConfigFile = new File(configpath + "main.cfg"); + worldFeaturesConfigFile = new File(configpath + "worldfeatures.cfg"); biomeGenConfigFile = new File(configpath + "biomegen.cfg"); terrainGenConfigFile = new File(configpath + "terraingen.cfg"); idConfigFile = new File(configpath + "ids.cfg"); diff --git a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMain.java b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMain.java index 73ab124a1..7c57a154f 100644 --- a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMain.java +++ b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMain.java @@ -14,11 +14,7 @@ public class BOPConfigurationMain { public static Configuration config; - // Configuration variables - public static boolean realisticTrees; - public static Property seenVersion; - public static Property seenWorldTypeMsg; public static void init(File configFile) { @@ -28,11 +24,7 @@ public class BOPConfigurationMain { config.load(); - //realisticTrees = config.get("Biome Settings", "Realistic Trees", true).getBoolean(true); - realisticTrees = false; - seenVersion = config.get("Vars", "Seen Version", "null"); - seenWorldTypeMsg = config.get("Vars", "Seen WorldType Msg", false); FMLCommonHandler.instance().getFMLLogger().log(Level.INFO, "[BiomesOPlenty] Generated Main Config!"); } diff --git a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java index 89ab39aaa..af53f981b 100644 --- a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java +++ b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java @@ -55,6 +55,7 @@ public class BOPConfigurationMisc skyColors = config.get("Hard-Coded Colors", "Enable Sky Colors", true).getBoolean(false); spawnSearchRadius = config.get("Spawn Settings", "Spawn Location Search Radius", 1024, "Must be 256 or higher").getInt(); + if (spawnSearchRadius < 256) spawnSearchRadius = 256; onlySpawnOnBeaches = config.get("Spawn Settings", "Only Spawn On Beaches", true).getBoolean(true); promisedLandSkyColor = config.get("Hard-Coded Colors", "Promised Land Sky Color", 5883101, null).getInt(); diff --git a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationTerrainGen.java b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationTerrainGen.java index acd0849a7..33781beeb 100644 --- a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationTerrainGen.java +++ b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationTerrainGen.java @@ -14,19 +14,9 @@ public class BOPConfigurationTerrainGen public static Configuration config; public static int biomeSize; - public static boolean addToDefault; + //public static boolean addToDefault; public static boolean vanillaEnhanced; public static boolean netherOverride; - public static boolean stoneFormationGen; - public static boolean pumpkinGen; - public static boolean poisonIvyGen; - public static boolean thornGen; - public static boolean springWaterGen; - public static boolean poisonWaterGen; - public static boolean quicksandGen; - public static boolean exposedStone; - public static boolean witherWartGen; - public static boolean burningBlossomGen; public static int villageDistance; public static int landmassPercentage; @@ -126,25 +116,12 @@ public class BOPConfigurationTerrainGen config.load(); biomeSize = config.get("Biomes O\' Plenty World Type Settings", "Biome Size", 4, "Default World Type has 4. Large Biomes World Type has 6.").getInt(4); - addToDefault = config.get("Biome Settings", "Add Biomes To Default World", false).getBoolean(true); + //addToDefault = config.get("Biome Settings", "Add Biomes To Default World", false).getBoolean(true); vanillaEnhanced = config.get("Biome Settings", "Enhanced Vanilla Biomes", true).getBoolean(false); netherOverride = config.get("Dimension Settings", "Enable Nether Override", true).getBoolean(true); - pumpkinGen = config.get("Decoration Settings", "Generate Pumpkins Without Faces", true).getBoolean(true); - stoneFormationGen = config.get("Decoration Settings", "Generate Stone Formations", true, "Stalagmites, stalactites, etc.").getBoolean(true); - poisonIvyGen = config.get("Decoration Settings", "Generate Poison Ivy", true).getBoolean(true); - thornGen = config.get("Decoration Settings", "Generate Thorns", true).getBoolean(true); - springWaterGen = config.get("Decoration Settings", "Generate Hot Springs", true).getBoolean(true); - poisonWaterGen = config.get("Decoration Settings", "Generate Poison Pools", true).getBoolean(true); - quicksandGen = config.get("Decoration Settings", "Generate Quicksand", true).getBoolean(true); - witherWartGen = config.get("Decoration Settings", "Generate Wither Wart", true).getBoolean(true); - burningBlossomGen = config.get("Decoration Settings", "Generate Burning Blossoms", true).getBoolean(true); - exposedStone = config.get("Decoration Settings", "Generate Sections Of Exposed Stone", true).getBoolean(true); villageDistance = config.get("Biomes O\' Plenty World Type Settings", "Distance between villages", 32, "In Vanilla it is set to 32").getInt(); - if (villageDistance < 8) - { - villageDistance = 8; - } + if (villageDistance < 8) villageDistance = 8; landmassPercentage = config.get("Biomes O\' Plenty World Type Settings", "Landmass Percentage", 10, "In Vanilla it is set to 10. Takes values from 0 to 100.").getInt(); diff --git a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationWorldFeatures.java b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationWorldFeatures.java new file mode 100644 index 000000000..c139d90e5 --- /dev/null +++ b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationWorldFeatures.java @@ -0,0 +1,55 @@ +package biomesoplenty.common.configuration; + +import java.io.File; +import java.util.ArrayList; +import java.util.Map.Entry; + +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.config.Configuration; + +import org.apache.logging.log4j.Level; + +import biomesoplenty.common.world.generation.WorldGenFieldAssociation; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; + +public class BOPConfigurationWorldFeatures +{ + public static Configuration config; + + public static void init(File configFile) + { + config = new Configuration(configFile); + + try + { + config.load(); + + for (Entry entry : WorldGenFieldAssociation.worldGeneratorMap.entrySet()) + { + String key = entry.getKey(); + + boolean featureEnabled = true; + + featureEnabled = config.get("World Features", key.replace("PerChunk", "Generation"), true).getBoolean(true); + + if (!featureEnabled) + { + WorldGenFieldAssociation.worldGeneratorMap.remove(key); + } + } + + FMLCommonHandler.instance().getFMLLogger().log(Level.INFO, "[BiomesOPlenty] Generated World Features Config!"); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, "Biomes O Plenty has had a problem loading its configuration", e); + } + finally + { + if (config.hasChanged()) { + config.save(); + } + } + } +} diff --git a/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java b/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java index 97fd7703e..0b5e6e9f6 100644 --- a/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java +++ b/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java @@ -18,7 +18,7 @@ public class WorldChunkManagerBOP extends WorldChunkManager @Override public ChunkPosition func_150795_a(int x, int z, int radius, List biomesToSpawnIn, Random random) { - int spawnSearchRadius = BOPConfigurationMisc.spawnSearchRadius >= 256 ? BOPConfigurationMisc.spawnSearchRadius : 256; + int spawnSearchRadius = BOPConfigurationMisc.spawnSearchRadius; return super.func_150795_a(x, z, spawnSearchRadius, biomesToSpawnIn, random); } diff --git a/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java b/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java index b2eebd03b..6fa7efd4a 100644 --- a/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java +++ b/src/main/java/biomesoplenty/common/world/generation/WorldGenFieldAssociation.java @@ -8,6 +8,7 @@ import net.minecraft.world.gen.feature.WorldGenLiquids; import net.minecraft.world.gen.feature.WorldGenMelon; import net.minecraft.world.gen.feature.WorldGenerator; import biomesoplenty.api.BOPBlockHelper; +import biomesoplenty.common.configuration.BOPConfigurationWorldFeatures; import biomesoplenty.common.world.features.WorldGenBOPDoubleFlora; import biomesoplenty.common.world.features.WorldGenBOPFlora; import biomesoplenty.common.world.features.WorldGenBOPTallGrass;