From 7007e8bd9250979a95096c247657b17646881cc8 Mon Sep 17 00:00:00 2001 From: Cheeserolls Date: Sun, 24 May 2015 14:52:55 +0100 Subject: [PATCH] Allow biome weights to be configured, add config warning logging --- .../biomesoplenty/api/biome/BOPBiome.java | 24 +++++++++++++++++++ .../biomesoplenty/common/init/ModBiomes.java | 5 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/biomesoplenty/api/biome/BOPBiome.java b/src/main/java/biomesoplenty/api/biome/BOPBiome.java index 25ea7baa2..85109f5c1 100644 --- a/src/main/java/biomesoplenty/api/biome/BOPBiome.java +++ b/src/main/java/biomesoplenty/api/biome/BOPBiome.java @@ -17,6 +17,7 @@ import biomesoplenty.api.biome.generation.GenerationManager; import biomesoplenty.api.biome.generation.GeneratorStage; import biomesoplenty.api.biome.generation.IGenerator; import biomesoplenty.common.util.config.ConfigHelper; +import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; public class BOPBiome extends BiomeGenBase implements IExtendedBiome { @@ -37,8 +38,11 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome public void configure(ConfigHelper conf) { + + // Allow name to be overridden this.biomeName = conf.getString("biomeName",this.biomeName); + // Allow basic properties to be overridden this.topBlock = conf.getBlockState("topBlock", this.topBlock); this.fillerBlock = conf.getBlockState("fillerBlock", this.fillerBlock); this.minHeight = conf.getFloat("rootHeight", this.minHeight); @@ -46,6 +50,26 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome this.temperature = conf.getFloat("temperature", this.temperature); this.rainfall = conf.getFloat("rainfall", this.rainfall); this.waterColorMultiplier = conf.getInt("waterColorMultiplier", this.waterColorMultiplier); + + // Allow weights to be overridden + WrappedJsonObject confWeights = conf.getObject("weights"); + if (confWeights != null) + { + for (BiomeType type : BiomeType.values()) + { + Integer weight = confWeights.getInt(type.name().toLowerCase(), null); + if (weight == null) {continue;} + if (weight.intValue() == 0) + { + this.weightMap.remove(type); + } + else + { + this.weightMap.put(type, weight); + } + } + } + } diff --git a/src/main/java/biomesoplenty/common/init/ModBiomes.java b/src/main/java/biomesoplenty/common/init/ModBiomes.java index 1558ab690..bfc8a57f3 100644 --- a/src/main/java/biomesoplenty/common/init/ModBiomes.java +++ b/src/main/java/biomesoplenty/common/init/ModBiomes.java @@ -95,7 +95,10 @@ public class ModBiomes BOPCommand.biomeCount++; biome.biomeID = id; biome.setBiomeName(name); - biome.configure(conf); + // If there was a valid config file, then use it to configure the biome + if (!conf.isNull()) {biome.configure(conf);} + // log any warnings from parsing the config file + for (String msg : conf.messages) {BiomesOPlenty.logger.warn(idName+" config "+msg);} BiomeGenBase.getBiomeGenArray()[id] = biome;