use of com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase in project DynamicTrees by DynamicTreesTeam.
the class WorldGenRegistry method populateDataBase.
public static void populateDataBase() {
if (WorldGenRegistry.isWorldGenEnabled()) {
BiomeDataBaseJsonCapabilityRegistryEvent capabilityEvent = new BiomeDataBaseJsonCapabilityRegistryEvent();
// Register the main Json capabilities
BiomeDataBasePopulatorJson.registerJsonCapabilities(capabilityEvent);
// Send out an event asking for Json Capabilities to be registered
MinecraftForge.EVENT_BUS.post(capabilityEvent);
// Prep the databases by clearing them out
TreeGenerator.getTreeGenerator().clearAllBiomeDataBases();
BiomeDataBase database = TreeGenerator.getTreeGenerator().getDefaultBiomeDataBase();
// This collects all available populators and returns an aggregate populator for the lot
IBiomeDataBasePopulator biomePopulator = collectDataBasePopulators();
// This is where the main population occurs
biomePopulator.populate(database);
// Send out an event after the database has been populated
MinecraftForge.EVENT_BUS.post(new PopulateDataBaseEvent(database, biomePopulator));
// Populate custom dimensions if available
loadMultiDimensionalPopulator(biomePopulator);
// Blacklist certain dimensions according to the base config
ModConfigs.dimensionBlacklist.forEach(d -> TreeGenerator.getTreeGenerator().BlackListDimension(d));
// Cleanup all of the unused static objects
BiomeDataBasePopulatorJson.cleanup();
}
}
use of com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase in project DynamicTrees by DynamicTreesTeam.
the class JsonBiomePropertyApplierDensity method apply.
@Override
public void apply(BiomeDataBase dbase, JsonElement element, Biome biome) {
if (element.isJsonObject()) {
JsonObject object = element.getAsJsonObject();
Operation operation = readMethod(object);
dbase.setDensitySelector(biome, readDensitySelector(object, biome), operation);
} else if (element.isJsonArray()) {
dbase.setDensitySelector(biome, createScaleDensitySelector(element.getAsJsonArray()), Operation.REPLACE);
} else if (element.isJsonPrimitive()) {
JsonPrimitive prim = element.getAsJsonPrimitive();
if (prim.isNumber()) {
float value = prim.getAsFloat();
dbase.setDensitySelector(biome, (rnd, n) -> value, Operation.REPLACE);
} else if (prim.isString()) {
String simple = prim.getAsString();
if ("standard".equals(simple)) {
final double treeDensity = MathHelper.clamp(biome.decorator.treesPerChunk / 10.0f, 0.0f, 1.0f);
dbase.setDensitySelector(biome, (rnd, n) -> n * treeDensity, Operation.REPLACE);
}
}
}
}
Aggregations