Search in sources :

Example 1 with DoublePlant

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

the class MixinBiomeForest method buildPopulators.

@Override
public void buildPopulators(World world, SpongeBiomeGenerationSettings gensettings) {
    BiomeDecorator theBiomeDecorator = this.decorator;
    int base = -3;
    if (this.type == BiomeForest.Type.FLOWER) {
        base = -1;
    }
    DoublePlant plant = DoublePlant.builder().perChunk(VariableAmount.baseWithRandomAddition(base * 5, 5 * 5)).type(DoublePlantTypes.SYRINGA, 1).type(DoublePlantTypes.ROSE, 1).type(DoublePlantTypes.PAEONIA, 1).build();
    gensettings.getPopulators().add(plant);
    super.buildPopulators(world, gensettings);
    gensettings.getPopulators().removeAll(gensettings.getPopulators(Forest.class));
    if (this.type == BiomeForest.Type.ROOFED) {
        RoofedForestPopulator forest = new RoofedForestPopulator();
        gensettings.getPopulators().add(0, forest);
    } else {
        Forest.Builder forest = Forest.builder();
        forest.perChunk(VariableAmount.baseWithOptionalAddition(theBiomeDecorator.treesPerChunk, 1, 0.1));
        if (this.type == BiomeForest.Type.BIRCH) {
            forest.type(BiomeTreeTypes.BIRCH.getPopulatorObject(), 1);
        } else {
            forest.type(BiomeTreeTypes.OAK.getPopulatorObject(), 4);
            forest.type(BiomeTreeTypes.BIRCH.getPopulatorObject(), 1);
        }
        gensettings.getPopulators().add(0, forest.build());
    }
    if (this.type == BiomeForest.Type.FLOWER) {
        gensettings.getPopulators().removeAll(gensettings.getPopulators(Flower.class));
        Flower flower = Flower.builder().perChunk(theBiomeDecorator.flowersPerChunk * 64).supplier(new FlowerForestSupplier()).build();
        gensettings.getPopulators().add(flower);
    }
}
Also used : RoofedForestPopulator(org.spongepowered.common.world.gen.populators.RoofedForestPopulator) Flower(org.spongepowered.api.world.gen.populator.Flower) FlowerForestSupplier(org.spongepowered.common.world.gen.populators.FlowerForestSupplier) Forest(org.spongepowered.api.world.gen.populator.Forest) BiomeForest(net.minecraft.world.biome.BiomeForest) BiomeDecorator(net.minecraft.world.biome.BiomeDecorator) DoublePlant(org.spongepowered.api.world.gen.populator.DoublePlant)

Example 2 with DoublePlant

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

the class MixinBiomeSavanna method buildPopulators.

@Override
public void buildPopulators(World world, SpongeBiomeGenerationSettings gensettings) {
    DoublePlant grass = DoublePlant.builder().type(DoublePlantTypes.GRASS, 1).perChunk(7 * 5).build();
    gensettings.getPopulators().add(grass);
    super.buildPopulators(world, gensettings);
    BiomeDecorator theBiomeDecorator = this.decorator;
    gensettings.getPopulators().removeAll(gensettings.getPopulators(Forest.class));
    Forest.Builder forest = Forest.builder();
    forest.perChunk(VariableAmount.baseWithOptionalAddition(theBiomeDecorator.treesPerChunk, 1, 0.1));
    forest.type(BiomeTreeTypes.OAK.getPopulatorObject(), 1);
    forest.type(BiomeTreeTypes.SAVANNA.getPopulatorObject(), 4);
    gensettings.getPopulators().add(0, forest.build());
}
Also used : Forest(org.spongepowered.api.world.gen.populator.Forest) BiomeDecorator(net.minecraft.world.biome.BiomeDecorator) DoublePlant(org.spongepowered.api.world.gen.populator.DoublePlant)

Example 3 with DoublePlant

use of org.spongepowered.api.world.gen.populator.DoublePlant 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 4 with DoublePlant

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

the class DoublePlantBuilder method build.

@Override
public DoublePlant build() throws IllegalStateException {
    if (this.types.isEmpty()) {
        throw new IllegalStateException("Builder is missing required weighted plant types.");
    }
    WorldGenDoublePlant wgen = new WorldGenDoublePlant();
    // Set a default just in case the weighted table is ever empty
    wgen.setPlantType(EnumPlantType.GRASS);
    DoublePlant populator = (DoublePlant) wgen;
    populator.getPossibleTypes().addAll(this.types);
    populator.setPlantsPerChunk(this.count);
    populator.setSupplierOverride(this.override);
    return populator;
}
Also used : WorldGenDoublePlant(net.minecraft.world.gen.feature.WorldGenDoublePlant) WorldGenDoublePlant(net.minecraft.world.gen.feature.WorldGenDoublePlant) DoublePlant(org.spongepowered.api.world.gen.populator.DoublePlant)

Aggregations

DoublePlant (org.spongepowered.api.world.gen.populator.DoublePlant)4 BiomeDecorator (net.minecraft.world.biome.BiomeDecorator)3 Forest (org.spongepowered.api.world.gen.populator.Forest)3 BiomeForest (net.minecraft.world.biome.BiomeForest)1 WorldGenDoublePlant (net.minecraft.world.gen.feature.WorldGenDoublePlant)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 BlockBlob (org.spongepowered.api.world.gen.populator.BlockBlob)1 Flower (org.spongepowered.api.world.gen.populator.Flower)1 Shrub (org.spongepowered.api.world.gen.populator.Shrub)1 FlowerForestSupplier (org.spongepowered.common.world.gen.populators.FlowerForestSupplier)1 RoofedForestPopulator (org.spongepowered.common.world.gen.populators.RoofedForestPopulator)1