Biome weights (For BoP biomes) are now configurable. Closes #240

This commit is contained in:
Adubbz 2014-05-15 06:19:30 +10:00
parent e17b112dbf
commit 931d59f923
4 changed files with 28 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import java.util.List;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.biome.BiomeGenBase;
import biomesoplenty.common.configuration.BOPConfigurationBiomeGen;
import biomesoplenty.common.configuration.BOPConfigurationBiomeWeights;
import biomesoplenty.common.configuration.BOPConfigurationIDs;
public class BOPBiomeManager
@ -23,7 +24,7 @@ public class BOPBiomeManager
if (biome != null)
{
BiomeEntry entry = new BiomeEntry(biome, weight);
BiomeEntry entry = new BiomeEntry(biome, getConfiguredWeight(biome, biomeType, weight));
if (BOPConfigurationBiomeGen.config.get(biomeType + " Biomes To Generate", biome.biomeName, true).getBoolean(false))
{
@ -76,6 +77,11 @@ public class BOPBiomeManager
return -1;
}
private static int getConfiguredWeight(BiomeGenBase biome, String biomeType, int weight)
{
return BOPConfigurationBiomeWeights.config.get(biomeType + " Biome Weights", biome.biomeName, weight).getInt(weight);
}
public class TemperatureType
{
public static final int HOT = 0;

View File

@ -7,6 +7,7 @@ public class BOPConfiguration
public static File mainConfigFile;
public static File worldFeaturesConfigFile;
public static File biomeGenConfigFile;
public static File biomeWeightsConfigFile;
public static File terrainGenConfigFile;
public static File villagesConfigFile;
public static File strongholdsConfigFile;
@ -18,6 +19,7 @@ public class BOPConfiguration
mainConfigFile = new File(configpath + "main.cfg");
worldFeaturesConfigFile = new File(configpath + "worldfeatures.cfg");
biomeGenConfigFile = new File(configpath + "biomegen.cfg");
biomeWeightsConfigFile = new File(configpath + "biomeweights.cfg");
terrainGenConfigFile = new File(configpath + "terraingen.cfg");
villagesConfigFile = new File(configpath + "structures/villages.cfg");
strongholdsConfigFile = new File(configpath + "structures/strongholds.cfg");
@ -26,6 +28,7 @@ public class BOPConfiguration
BOPConfigurationMain.init(mainConfigFile);
BOPConfigurationBiomeGen.init(biomeGenConfigFile);
BOPConfigurationBiomeWeights.init(biomeWeightsConfigFile);
BOPConfigurationTerrainGen.init(terrainGenConfigFile);
BOPConfigurationIDs.init(idConfigFile);
BOPConfigurationMisc.init(miscConfigFile);

View File

@ -0,0 +1,15 @@
package biomesoplenty.common.configuration;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
public class BOPConfigurationBiomeWeights
{
public static Configuration config;
public static void init(File configFile)
{
config = new Configuration(configFile);
}
}

View File

@ -91,6 +91,7 @@ import biomesoplenty.common.biomes.overworld.subbiomes.BiomeGenVolcano;
import biomesoplenty.common.biomes.overworld.techbiomes.BiomeGenDryRiver;
import biomesoplenty.common.biomes.overworld.techbiomes.BiomeGenLushRiver;
import biomesoplenty.common.configuration.BOPConfigurationBiomeGen;
import biomesoplenty.common.configuration.BOPConfigurationBiomeWeights;
import biomesoplenty.common.configuration.BOPConfigurationIDs;
import biomesoplenty.common.configuration.BOPConfigurationMisc;
import biomesoplenty.common.utils.BOPLogger;
@ -112,6 +113,7 @@ public class BOPBiomes
{
BOPConfigurationIDs.config.load();
BOPConfigurationBiomeGen.config.load();
BOPConfigurationBiomeWeights.config.load();
registerBiomes();
}
catch (Exception e)
@ -122,6 +124,7 @@ public class BOPBiomes
{
if (BOPConfigurationIDs.config.hasChanged()) BOPConfigurationIDs.config.save();
if (BOPConfigurationBiomeGen.config.hasChanged()) BOPConfigurationBiomeGen.config.save();
if (BOPConfigurationBiomeWeights.config.hasChanged()) BOPConfigurationBiomeWeights.config.save();
}
addBiomesToDictionary();