Search in sources :

Example 6 with IGenerator

use of biomesoplenty.api.generation.IGenerator in project BiomesOPlenty by Glitchfiend.

the class GeneratorWeighted method configure.

@Override
public void configure(IConfigObj conf) {
    this.amountPerChunk = conf.getFloat("amountPerChunk", this.amountPerChunk);
    IConfigObj confGenerators = conf.getObject("generators");
    if (confGenerators != null) {
        for (String name : confGenerators.getKeys()) {
            IConfigObj confCurrentGen = confGenerators.getObject(name);
            if (this.generators.containsKey(name)) {
                IGenerator generator = this.getGenerator(name);
                Integer weight = confCurrentGen.getInt("weight", this.weights.get(generator));
                if (weight.intValue() < 1) {
                    // remove this generator if the weight is zero (or negative)
                    this.removeGenerator(name);
                } else {
                    // adjust weight
                    this.weights.put(generator, weight);
                    // configure the existing generator
                    generator.configure(confCurrentGen);
                }
            } else {
                // there was previously no generator of this name - attempt to add it
                Integer weight = confCurrentGen.getInt("weight", null);
                IGenerator generator = GeneratorRegistry.createGenerator(confCurrentGen);
                if (weight != null && generator != null) {
                    this.add(name, weight, generator);
                }
            }
        }
    }
}
Also used : IGenerator(biomesoplenty.api.generation.IGenerator) IConfigObj(biomesoplenty.api.config.IConfigObj)

Aggregations

IGenerator (biomesoplenty.api.generation.IGenerator)6 IExtendedBiome (biomesoplenty.api.biome.IExtendedBiome)2 IConfigObj (biomesoplenty.api.config.IConfigObj)2 GeneratorStage (biomesoplenty.api.generation.GeneratorStage)2 IGenerationManager (biomesoplenty.api.generation.IGenerationManager)2 BOPClimates (biomesoplenty.api.enums.BOPClimates)1 WeightedBiomeEntry (biomesoplenty.api.enums.BOPClimates.WeightedBiomeEntry)1 IGeneratorBuilder (biomesoplenty.api.generation.IGenerator.IGeneratorBuilder)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 Biome (net.minecraft.world.biome.Biome)1