use of biomesoplenty.api.generation.IGenerator in project BiomeTweaker by superckl.
the class BOPIntegrationModule method addBiomeInfo.
@Override
public void addBiomeInfo(Biome biome, final JsonObject obj) {
final IExtendedBiome eBiome = BOPIntegrationModule.getExtendedBiome(biome);
biome = eBiome.getBaseBiome();
final IGenerationManager gManager = eBiome.getGenerationManager();
final JsonObject genNames = new JsonObject();
for (final GeneratorStage stage : GeneratorStage.values()) {
final Collection<IGenerator> gens = gManager.getGeneratorsForStage(stage);
if (gens.isEmpty())
continue;
final JsonArray subArray = new JsonArray();
final Iterator<IGenerator> it = gens.iterator();
while (it.hasNext()) {
final JsonObject subSubObj = new JsonObject();
final IGenerator gen = it.next();
subSubObj.addProperty("ID", gen.getIdentifier());
subSubObj.addProperty("Name", gen.getName());
subArray.add(subSubObj);
}
genNames.add(stage.name() + " Generators", subArray);
}
obj.add("BOP Generators", genNames);
obj.addProperty("BOP Owner", eBiome.getBiomeOwner().name());
final Gson gson = new Gson();
obj.add("BOP Weight Map", gson.toJsonTree(eBiome.getWeightMap()));
try {
final JsonObject weights = new JsonObject();
for (final BOPClimates climate : BOPClimates.values()) {
final List<WeightedBiomeEntry> entries = WarningHelper.uncheckedCast(BOPBiomeProperties.LAND_BIOMES.get(climate));
final JsonArray subArray = new JsonArray();
for (final WeightedBiomeEntry entry : entries) if (Biome.getIdForBiome(entry.biome) == Biome.getIdForBiome(biome))
subArray.add(new JsonPrimitive(entry.weight));
if (subArray.size() > 0)
weights.add(climate.name(), subArray);
}
obj.add("BOP Climate Weights", weights);
if (ModBiomes.islandBiomesMap.containsKey(Biome.getIdForBiome(biome)))
obj.add("BOP Island Weight", new JsonPrimitive(ModBiomes.islandBiomesMap.get(Biome.getIdForBiome(biome))));
else
obj.add("BOP Island Weight", new JsonPrimitive(0));
} catch (final Exception e) {
LogHelper.error("Failed to retrieve all BOP biome info!");
e.printStackTrace();
}
}
use of biomesoplenty.api.generation.IGenerator in project BiomesOPlenty by Glitchfiend.
the class GenerationManager method configure.
public void configure(IConfigObj generatorsObj) {
Iterator<String> genKeysItr = generators.keySet().iterator();
// iterate over all registered generators
while (genKeysItr.hasNext()) {
String name = genKeysItr.next();
IConfigObj currentObj = generatorsObj.getObject(name);
// there was previously no generator of this name - attempt to add it
if (generatorsObj.has(name)) {
IGenerator generator = GeneratorRegistry.createGenerator(currentObj);
if (generator != null) {
this.generators.put(name, generator);
}
}
// always attempt to do this so defaults are generated
if (currentObj.getBool("enable", true)) {
this.generators.get(name).configure(currentObj);
} else {
// remove this generator
genKeysItr.remove();
}
}
}
use of biomesoplenty.api.generation.IGenerator in project BiomesOPlenty by Glitchfiend.
the class DecorateBiomeEventHandler method runGeneratorStage.
private static boolean runGeneratorStage(World world, Random random, BlockPos pos, GeneratorStage stage) {
Biome biome = world.getBiome(pos.add(16, 0, 16));
IExtendedBiome extendedBiome = BOPBiomes.REG_INSTANCE.getExtendedBiome(biome);
if (extendedBiome != null) {
IGenerationManager generationManager = extendedBiome.getGenerationManager();
for (IGenerator generator : generationManager.getGeneratorsForStage(stage)) {
generator.scatter(world, random, pos);
}
}
return true;
}
use of biomesoplenty.api.generation.IGenerator in project BiomesOPlenty by Glitchfiend.
the class GeneratorWeighted method removeGenerator.
public void removeGenerator(String name) {
IGenerator generator = this.generators.get(name);
if (generator != null) {
this.generators.remove(name);
this.weights.remove(generator);
}
}
use of biomesoplenty.api.generation.IGenerator in project BiomesOPlenty by Glitchfiend.
the class GeneratorRegistry method createGenerator.
public static IGenerator createGenerator(IConfigObj conf) {
GeneratorStage stage = conf.getEnum("stage", GeneratorStage.class);
String identifier = conf.getString("type");
if (stage == null || identifier == null) {
return null;
}
IGenerator.IGeneratorBuilder builder = getGeneratorBuilder(identifier);
if (builder == null) {
conf.addMessage("No generator is registered with type name " + identifier);
return null;
}
IGenerator generator = builder.create();
generator.setStage(stage);
generator.configure(conf);
return generator;
}
Aggregations