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);
}
}
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());
}
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());
}
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;
}
Aggregations