Search in sources :

Example 1 with BiomeEntry

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;
}
Also used : BiomeEntry(com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase.BiomeEntry) Biome(net.minecraft.world.biome.Biome) IBlockState(net.minecraft.block.state.IBlockState) SpeciesSelection(com.ferreusveritas.dynamictrees.api.worldgen.BiomePropertySelectors.SpeciesSelection) BlockPos(net.minecraft.util.math.BlockPos) Species(com.ferreusveritas.dynamictrees.trees.Species)

Aggregations

SpeciesSelection (com.ferreusveritas.dynamictrees.api.worldgen.BiomePropertySelectors.SpeciesSelection)1 Species (com.ferreusveritas.dynamictrees.trees.Species)1 BiomeEntry (com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase.BiomeEntry)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1 Biome (net.minecraft.world.biome.Biome)1