use of com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase.BiomeEntry in project DynamicTrees by DynamicTreesTeam.
the class TreeGenerator method makeTree.
public EnumGeneratorResult makeTree(World world, BiomeDataBase biomeDataBase, PoissonDisc circle, IGroundFinder groundFinder, SafeChunkBounds safeBounds) {
// Move the circle into the "stage"
circle.add(8, 8);
BlockPos pos = new BlockPos(circle.x, 0, circle.z);
Biome biome = world.getBiome(pos);
BiomeEntry biomeEntry = biomeDataBase.getEntry(biome);
pos = groundFinder.findGround(biomeEntry, world, pos);
if (pos == BlockPos.ORIGIN) {
return EnumGeneratorResult.NOGROUND;
}
random.setXOR(pos);
IBlockState dirtState = world.getBlockState(pos);
EnumGeneratorResult result = EnumGeneratorResult.GENERATED;
SpeciesSelection speciesSelection = biomeEntry.getSpeciesSelector().getSpecies(pos, dirtState, random);
if (speciesSelection.isHandled()) {
Species species = speciesSelection.getSpecies();
if (species.isValid()) {
if (species.isAcceptableSoilForWorldgen(world, pos, dirtState)) {
if (biomeEntry.getChanceSelector().getChance(random, species, circle.radius) == EnumChance.OK) {
if (species.generate(world, pos, biome, random, circle.radius, safeBounds)) {
result = EnumGeneratorResult.GENERATED;
} else {
result = EnumGeneratorResult.FAILGENERATION;
}
} else {
result = EnumGeneratorResult.FAILCHANCE;
}
} else {
result = EnumGeneratorResult.FAILSOIL;
}
} else {
result = EnumGeneratorResult.NOTREE;
}
} else {
result = EnumGeneratorResult.UNHANDLEDBIOME;
}
// Display wool circles for testing the circle growing algorithm
if (ModConfigs.worldGenDebug) {
makeWoolCircle(world, circle, pos.getY(), result, safeBounds);
}
// Move the circle back to normal coords
circle.add(-8, -8);
return result;
}
Aggregations