Search in sources :

Example 6 with IConfigObj

use of biomesoplenty.api.config.IConfigObj 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

IConfigObj (biomesoplenty.api.config.IConfigObj)6 IGenerator (biomesoplenty.api.generation.IGenerator)2 File (java.io.File)2 BOPClimates (biomesoplenty.api.enums.BOPClimates)1 EnumCreatureType (net.minecraft.entity.EnumCreatureType)1 ResourceLocation (net.minecraft.util.ResourceLocation)1