Search in sources :

Example 1 with BlockBlob

use of org.spongepowered.api.world.gen.populator.BlockBlob in project SpongeCommon by SpongePowered.

the class MixinBiomeTaiga method buildPopulators.

@Override
public void buildPopulators(World world, SpongeBiomeGenerationSettings gensettings) {
    if (this.type == BiomeTaiga.Type.MEGA || this.type == BiomeTaiga.Type.MEGA_SPRUCE) {
        BlockBlob blob = BlockBlob.builder().blobCount(VariableAmount.baseWithRandomAddition(0, 3)).block((BlockState) Blocks.MOSSY_COBBLESTONE.getDefaultState()).radius(VariableAmount.baseWithRandomAddition(0, 2)).build();
        gensettings.getPopulators().add(blob);
    }
    DoublePlant fern = DoublePlant.builder().type(DoublePlantTypes.FERN, 1).perChunk(7 * 5).build();
    gensettings.getPopulators().add(fern);
    super.buildPopulators(world, gensettings);
    if (this.type == BiomeTaiga.Type.MEGA || this.type == BiomeTaiga.Type.MEGA_SPRUCE) {
        gensettings.getGroundCoverLayers().clear();
        gensettings.getGroundCoverLayers().add(new GroundCoverLayer((Double seed) -> {
            if (seed > 1.75D) {
                return (BlockState) Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
            } else if (seed > -0.95D) {
                return (BlockState) Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL);
            }
            return (BlockState) Blocks.GRASS.getDefaultState();
        }, WorldGenConstants.GROUND_COVER_DEPTH));
        gensettings.getGroundCoverLayers().add(new GroundCoverLayer((BlockState) this.fillerBlock, WorldGenConstants.GROUND_COVER_DEPTH));
    }
    BiomeDecorator theBiomeDecorator = this.decorator;
    for (Iterator<Shrub> it = gensettings.getPopulators(Shrub.class).iterator(); it.hasNext(); ) {
        Shrub next = it.next();
        if (next.getTypes().size() == 1) {
            TableEntry<ShrubType> entry = next.getTypes().getEntries().get(0);
            if (entry instanceof WeightedObject && ((WeightedObject<ShrubType>) entry).get() == ShrubTypes.TALL_GRASS) {
                it.remove();
            }
        }
    }
    Shrub grass = Shrub.builder().perChunk(theBiomeDecorator.grassPerChunk * 128).type(ShrubTypes.FERN, 4).type(ShrubTypes.TALL_GRASS, 1).build();
    gensettings.getPopulators().add(grass);
    gensettings.getPopulators().removeAll(gensettings.getPopulators(Forest.class));
    Forest.Builder forest = Forest.builder();
    forest.perChunk(VariableAmount.baseWithOptionalAddition(theBiomeDecorator.treesPerChunk, 1, 0.1));
    if (this.type == BiomeTaiga.Type.MEGA || this.type == BiomeTaiga.Type.MEGA_SPRUCE) {
        if (this.type == BiomeTaiga.Type.MEGA) {
            forest.type(BiomeTreeTypes.POINTY_TAIGA.getLargePopulatorObject().get(), 1);
            forest.type(BiomeTreeTypes.TALL_TAIGA.getLargePopulatorObject().get(), 12);
        } else {
            forest.type(BiomeTreeTypes.TALL_TAIGA.getLargePopulatorObject().get(), 13);
        }
        forest.type(BiomeTreeTypes.POINTY_TAIGA.getPopulatorObject(), 26 / 3d);
        forest.type(BiomeTreeTypes.TALL_TAIGA.getPopulatorObject(), 52 / 3d);
    } else {
        forest.type(BiomeTreeTypes.POINTY_TAIGA.getPopulatorObject(), 1);
        forest.type(BiomeTreeTypes.TALL_TAIGA.getPopulatorObject(), 2);
    }
    gensettings.getPopulators().add(0, forest.build());
}
Also used : BlockBlob(org.spongepowered.api.world.gen.populator.BlockBlob) ShrubType(org.spongepowered.api.data.type.ShrubType) WeightedObject(org.spongepowered.api.util.weighted.WeightedObject) Shrub(org.spongepowered.api.world.gen.populator.Shrub) GroundCoverLayer(org.spongepowered.api.world.biome.GroundCoverLayer) BiomeDecorator(net.minecraft.world.biome.BiomeDecorator) BlockState(org.spongepowered.api.block.BlockState) Forest(org.spongepowered.api.world.gen.populator.Forest) DoublePlant(org.spongepowered.api.world.gen.populator.DoublePlant)

Example 2 with BlockBlob

use of org.spongepowered.api.world.gen.populator.BlockBlob in project SpongeCommon by SpongePowered.

the class BlockBlobBuilder method build.

@Override
public BlockBlob build() throws IllegalStateException {
    if (this.block == null) {
        throw new IllegalStateException("Builder is missing required BlockState argument.");
    }
    BlockBlob populator = (BlockBlob) new WorldGenBlockBlob((Block) this.block.getType(), 2);
    populator.setBlock(this.block);
    populator.setRadius(this.radius);
    populator.setCount(this.count);
    return populator;
}
Also used : WorldGenBlockBlob(net.minecraft.world.gen.feature.WorldGenBlockBlob) BlockBlob(org.spongepowered.api.world.gen.populator.BlockBlob) Block(net.minecraft.block.Block) WorldGenBlockBlob(net.minecraft.world.gen.feature.WorldGenBlockBlob)

Aggregations

BlockBlob (org.spongepowered.api.world.gen.populator.BlockBlob)2 Block (net.minecraft.block.Block)1 BiomeDecorator (net.minecraft.world.biome.BiomeDecorator)1 WorldGenBlockBlob (net.minecraft.world.gen.feature.WorldGenBlockBlob)1 BlockState (org.spongepowered.api.block.BlockState)1 ShrubType (org.spongepowered.api.data.type.ShrubType)1 WeightedObject (org.spongepowered.api.util.weighted.WeightedObject)1 GroundCoverLayer (org.spongepowered.api.world.biome.GroundCoverLayer)1 DoublePlant (org.spongepowered.api.world.gen.populator.DoublePlant)1 Forest (org.spongepowered.api.world.gen.populator.Forest)1 Shrub (org.spongepowered.api.world.gen.populator.Shrub)1