Search in sources :

Example 1 with GroundCoverLayer

use of org.spongepowered.api.world.biome.GroundCoverLayer in project SpongeCommon by SpongePowered.

the class MixinBiome method buildPopulators.

@Override
public void buildPopulators(World world, SpongeBiomeGenerationSettings gensettings) {
    BiomeDecorator theBiomeDecorator = this.decorator;
    gensettings.getGroundCoverLayers().add(new GroundCoverLayer((BlockState) this.topBlock, SeededVariableAmount.fixed(1)));
    gensettings.getGroundCoverLayers().add(new GroundCoverLayer((BlockState) this.fillerBlock, WorldGenConstants.GROUND_COVER_DEPTH));
    String s = world.getWorldInfo().getGeneratorOptions();
    ChunkGeneratorSettings settings = ChunkGeneratorSettings.Factory.jsonToFactory(s).build();
    Ore dirt = Ore.builder().ore((BlockState) Blocks.DIRT.getDefaultState()).size(settings.dirtSize).perChunk(settings.dirtCount).height(VariableAmount.baseWithRandomAddition(settings.dirtMinHeight, settings.dirtMaxHeight - settings.dirtMinHeight)).build();
    gensettings.getPopulators().add(dirt);
    Ore gravel = Ore.builder().ore((BlockState) Blocks.GRAVEL.getDefaultState()).size(settings.gravelSize).perChunk(settings.gravelCount).height(VariableAmount.baseWithRandomAddition(settings.gravelMinHeight, settings.gravelMaxHeight - settings.gravelMinHeight)).build();
    gensettings.getPopulators().add(gravel);
    Ore diorite = Ore.builder().ore((BlockState) Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE)).size(settings.dioriteSize).perChunk(settings.dioriteCount).height(VariableAmount.baseWithRandomAddition(settings.dioriteMinHeight, settings.dioriteMaxHeight - settings.dioriteMinHeight)).build();
    gensettings.getPopulators().add(diorite);
    Ore granite = Ore.builder().ore((BlockState) Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE)).size(settings.graniteSize).perChunk(settings.graniteCount).height(VariableAmount.baseWithRandomAddition(settings.graniteMinHeight, settings.graniteMaxHeight - settings.graniteMinHeight)).build();
    gensettings.getPopulators().add(granite);
    Ore andesite = Ore.builder().ore((BlockState) Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE)).size(settings.andesiteSize).perChunk(settings.andesiteCount).height(VariableAmount.baseWithRandomAddition(settings.andesiteMinHeight, settings.andesiteMaxHeight - settings.andesiteMinHeight)).build();
    gensettings.getPopulators().add(andesite);
    Ore coal = Ore.builder().ore((BlockState) Blocks.COAL_ORE.getDefaultState()).size(settings.coalSize).perChunk(settings.coalCount).height(VariableAmount.baseWithRandomAddition(settings.coalMinHeight, settings.coalMaxHeight - settings.coalMinHeight)).build();
    gensettings.getPopulators().add(coal);
    Ore iron = Ore.builder().ore((BlockState) Blocks.IRON_ORE.getDefaultState()).size(settings.ironSize).perChunk(settings.ironCount).height(VariableAmount.baseWithRandomAddition(settings.ironMinHeight, settings.ironMaxHeight - settings.ironMinHeight)).build();
    gensettings.getPopulators().add(iron);
    Ore gold = Ore.builder().ore((BlockState) Blocks.GOLD_ORE.getDefaultState()).size(settings.goldSize).perChunk(settings.goldCount).height(VariableAmount.baseWithRandomAddition(settings.goldMinHeight, settings.goldMaxHeight - settings.goldMinHeight)).build();
    gensettings.getPopulators().add(gold);
    Ore redstone = Ore.builder().ore((BlockState) Blocks.REDSTONE_ORE.getDefaultState()).size(settings.redstoneSize).perChunk(settings.redstoneCount).height(VariableAmount.baseWithRandomAddition(settings.redstoneMinHeight, settings.redstoneMaxHeight - settings.redstoneMinHeight)).build();
    gensettings.getPopulators().add(redstone);
    Ore diamond = Ore.builder().ore((BlockState) Blocks.DIAMOND_ORE.getDefaultState()).size(settings.diamondSize).perChunk(settings.diamondCount).height(VariableAmount.baseWithRandomAddition(settings.diamondMinHeight, settings.diamondMaxHeight - settings.diamondMinHeight)).build();
    gensettings.getPopulators().add(diamond);
    Ore lapis = Ore.builder().ore((BlockState) Blocks.LAPIS_ORE.getDefaultState()).size(settings.lapisSize).perChunk(settings.lapisCount).height(VariableAmount.baseWithVariance(settings.lapisCenterHeight, settings.lapisSpread)).build();
    gensettings.getPopulators().add(lapis);
    if (theBiomeDecorator.sandPatchesPerChunk > 0) {
        SeaFloor sand = SeaFloor.builder().block((BlockState) Blocks.SAND.getDefaultState()).radius(VariableAmount.baseWithRandomAddition(2, 5)).depth(2).perChunk(theBiomeDecorator.sandPatchesPerChunk).replace(WorldGenConstants.DIRT_OR_GRASS).build();
        gensettings.getPopulators().add(sand);
    }
    if (theBiomeDecorator.clayPerChunk > 0) {
        SeaFloor clay = SeaFloor.builder().block((BlockState) Blocks.CLAY.getDefaultState()).radius(VariableAmount.baseWithRandomAddition(2, 2)).depth(1).perChunk(theBiomeDecorator.clayPerChunk).replace(WorldGenConstants.DIRT).build();
        gensettings.getPopulators().add(clay);
    }
    if (theBiomeDecorator.gravelPatchesPerChunk > 0) {
        SeaFloor gravelSeaFloor = SeaFloor.builder().block((BlockState) Blocks.GRAVEL.getDefaultState()).radius(VariableAmount.baseWithRandomAddition(2, 4)).depth(2).perChunk(theBiomeDecorator.gravelPatchesPerChunk).replace(WorldGenConstants.DIRT_OR_GRASS).build();
        gensettings.getPopulators().add(gravelSeaFloor);
    }
    Forest forest = Forest.builder().type(BiomeTreeTypes.OAK.getPopulatorObject(), 9).type(BiomeTreeTypes.OAK.getLargePopulatorObject().get(), 1).perChunk(VariableAmount.baseWithOptionalAddition(theBiomeDecorator.treesPerChunk, 1, 0.1)).build();
    gensettings.getPopulators().add(forest);
    if (theBiomeDecorator.bigMushroomsPerChunk > 0) {
        BigMushroom mushroom = BigMushroom.builder().mushroomsPerChunk(theBiomeDecorator.bigMushroomsPerChunk).type(MushroomTypes.BROWN.getPopulatorObject(), 1).type(MushroomTypes.RED.getPopulatorObject(), 1).build();
        gensettings.getPopulators().add(mushroom);
    }
    if (theBiomeDecorator.flowersPerChunk > 0) {
        Flower flower = Flower.builder().perChunk(theBiomeDecorator.flowersPerChunk * 64).type(PlantTypes.DANDELION, 2).type(PlantTypes.POPPY, 1).build();
        gensettings.getPopulators().add(flower);
    }
    if (theBiomeDecorator.grassPerChunk > 0) {
        Shrub grass = Shrub.builder().perChunk(theBiomeDecorator.grassPerChunk * 128).type(ShrubTypes.TALL_GRASS, 1).build();
        gensettings.getPopulators().add(grass);
    }
    if (theBiomeDecorator.deadBushPerChunk > 0) {
        DeadBush deadBush = DeadBush.builder().perChunk(theBiomeDecorator.deadBushPerChunk).build();
        gensettings.getPopulators().add(deadBush);
    }
    if (theBiomeDecorator.waterlilyPerChunk > 0) {
        WaterLily waterLily = WaterLily.builder().perChunk(theBiomeDecorator.waterlilyPerChunk * 10).build();
        gensettings.getPopulators().add(waterLily);
    }
    ChanceTable<MushroomType> types = new ChanceTable<MushroomType>();
    types.add(new WeightedObject<>(MushroomTypes.BROWN, 2));
    types.add(new WeightedObject<>(MushroomTypes.RED, 1));
    types.add(new EmptyObject<>(5));
    Mushroom smallMushroom = Mushroom.builder().types(types).mushroomsPerChunk(theBiomeDecorator.mushroomsPerChunk + 1).build();
    gensettings.getPopulators().add(smallMushroom);
    Reed reed = Reed.builder().perChunk(theBiomeDecorator.reedsPerChunk + 10).reedHeight(VariableAmount.baseWithRandomAddition(2, VariableAmount.baseWithRandomAddition(1, 3))).build();
    gensettings.getPopulators().add(reed);
    Pumpkin pumpkin = Pumpkin.builder().perChunk(64).chance(1 / 32d).build();
    gensettings.getPopulators().add(pumpkin);
    if (theBiomeDecorator.cactiPerChunk > 0) {
        Cactus cactus = Cactus.builder().cactiPerChunk(VariableAmount.baseWithOptionalAddition(0, VariableAmount.baseWithRandomAddition(1, VariableAmount.baseWithOptionalAddition(2, 3, 0.5)), 0.8)).build();
        gensettings.getPopulators().add(cactus);
    }
    if (theBiomeDecorator.generateFalls) {
        RandomBlock water = RandomBlock.builder().block((BlockState) Blocks.FLOWING_WATER.getDefaultState()).height(VariableAmount.baseWithRandomAddition(0, VariableAmount.baseWithRandomAddition(8, 248))).perChunk(50).placementTarget(WorldGenConstants.CAVE_LIQUIDS).build();
        gensettings.getPopulators().add(water);
        RandomBlock lava = RandomBlock.builder().block((BlockState) Blocks.FLOWING_LAVA.getDefaultState()).height(VariableAmount.baseWithRandomAddition(0, VariableAmount.baseWithRandomAddition(8, VariableAmount.baseWithRandomAddition(8, 240)))).perChunk(20).placementTarget(WorldGenConstants.CAVE_LIQUIDS).build();
        gensettings.getPopulators().add(lava);
    }
}
Also used : DeadBush(org.spongepowered.api.world.gen.populator.DeadBush) Flower(org.spongepowered.api.world.gen.populator.Flower) Ore(org.spongepowered.api.world.gen.populator.Ore) BigMushroom(org.spongepowered.api.world.gen.populator.BigMushroom) Pumpkin(org.spongepowered.api.world.gen.populator.Pumpkin) Mushroom(org.spongepowered.api.world.gen.populator.Mushroom) BigMushroom(org.spongepowered.api.world.gen.populator.BigMushroom) Shrub(org.spongepowered.api.world.gen.populator.Shrub) GroundCoverLayer(org.spongepowered.api.world.biome.GroundCoverLayer) WaterLily(org.spongepowered.api.world.gen.populator.WaterLily) BiomeDecorator(net.minecraft.world.biome.BiomeDecorator) WrappedBiomeDecorator(org.spongepowered.common.world.gen.populators.WrappedBiomeDecorator) RandomBlock(org.spongepowered.api.world.gen.populator.RandomBlock) BlockState(org.spongepowered.api.block.BlockState) IBlockState(net.minecraft.block.state.IBlockState) Reed(org.spongepowered.api.world.gen.populator.Reed) ChanceTable(org.spongepowered.api.util.weighted.ChanceTable) SeaFloor(org.spongepowered.api.world.gen.populator.SeaFloor) Cactus(org.spongepowered.api.world.gen.populator.Cactus) MushroomType(org.spongepowered.api.world.gen.type.MushroomType) Forest(org.spongepowered.api.world.gen.populator.Forest) ChunkGeneratorSettings(net.minecraft.world.gen.ChunkGeneratorSettings)

Example 2 with GroundCoverLayer

use of org.spongepowered.api.world.biome.GroundCoverLayer 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 3 with GroundCoverLayer

use of org.spongepowered.api.world.biome.GroundCoverLayer in project SpongeCommon by SpongePowered.

the class SpongeBiomeGenerationSettingsBuilder method groundCover.

@Override
public Builder groundCover(Iterable<GroundCoverLayer> coverLayers) {
    checkNotNull(coverLayers, "coverLayers");
    this.groundCover.clear();
    for (GroundCoverLayer layer : coverLayers) {
        this.groundCover.add(checkNotNull(layer, "layer"));
    }
    return this;
}
Also used : GroundCoverLayer(org.spongepowered.api.world.biome.GroundCoverLayer)

Example 4 with GroundCoverLayer

use of org.spongepowered.api.world.biome.GroundCoverLayer in project SpongeCommon by SpongePowered.

the class SpongeChunkGenerator method generateBiomeTerrain.

public void generateBiomeTerrain(World worldIn, Random rand, ChunkPrimer chunk, int x, int z, double stoneNoise, List<GroundCoverLayer> groundcover) {
    if (groundcover.isEmpty()) {
        return;
    }
    int seaLevel = worldIn.getSeaLevel();
    IBlockState currentPlacement = null;
    int layerProgress = -1;
    int relativeX = x & 15;
    int relativeZ = z & 15;
    int layerDepth = 0;
    for (int currentY = 255; currentY >= 0; --currentY) {
        IBlockState nextBlock = chunk.getBlockState(relativeX, currentY, relativeZ);
        if (nextBlock.getMaterial() == Material.AIR) {
            layerProgress = -1;
        } else if (nextBlock.getBlock() == Blocks.STONE) {
            if (layerProgress == -1) {
                if (groundcover.isEmpty()) {
                    layerProgress = 0;
                    continue;
                }
                layerDepth = 0;
                GroundCoverLayer layer = groundcover.get(layerDepth);
                currentPlacement = (IBlockState) layer.getBlockState().apply(stoneNoise);
                layerProgress = layer.getDepth().getFlooredAmount(rand, stoneNoise);
                if (layerProgress <= 0) {
                    continue;
                }
                if (currentY >= seaLevel - 1) {
                    chunk.setBlockState(relativeX, currentY, relativeZ, currentPlacement);
                    ++layerDepth;
                    if (layerDepth < groundcover.size()) {
                        layer = groundcover.get(layerDepth);
                        layerProgress = layer.getDepth().getFlooredAmount(rand, stoneNoise);
                        currentPlacement = (IBlockState) layer.getBlockState().apply(stoneNoise);
                    }
                } else if (currentY < seaLevel - 7 - layerProgress) {
                    layerProgress = 0;
                    chunk.setBlockState(relativeX, currentY, relativeZ, Blocks.GRAVEL.getDefaultState());
                } else {
                    ++layerDepth;
                    if (layerDepth < groundcover.size()) {
                        layer = groundcover.get(layerDepth);
                        layerProgress = layer.getDepth().getFlooredAmount(rand, stoneNoise);
                        currentPlacement = (IBlockState) layer.getBlockState().apply(stoneNoise);
                        chunk.setBlockState(relativeX, currentY, relativeZ, currentPlacement);
                    }
                }
            } else if (layerProgress > 0) {
                --layerProgress;
                chunk.setBlockState(relativeX, currentY, relativeZ, currentPlacement);
                if (layerProgress == 0) {
                    ++layerDepth;
                    if (layerDepth < groundcover.size()) {
                        GroundCoverLayer layer = groundcover.get(layerDepth);
                        layerProgress = layer.getDepth().getFlooredAmount(rand, stoneNoise);
                        currentPlacement = (IBlockState) layer.getBlockState().apply(stoneNoise);
                    }
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) GroundCoverLayer(org.spongepowered.api.world.biome.GroundCoverLayer)

Example 5 with GroundCoverLayer

use of org.spongepowered.api.world.biome.GroundCoverLayer in project LanternServer by LanternPowered.

the class LanternBiomeGenerationSettingsBuilder method groundCover.

@Override
public Builder groundCover(GroundCoverLayer... coverLayers) {
    checkNotNull(coverLayers, "coverLayers");
    this.groundCover.clear();
    for (GroundCoverLayer layer : coverLayers) {
        this.groundCover.add(checkNotNull(layer, "layer"));
    }
    return this;
}
Also used : GroundCoverLayer(org.spongepowered.api.world.biome.GroundCoverLayer)

Aggregations

GroundCoverLayer (org.spongepowered.api.world.biome.GroundCoverLayer)8 IBlockState (net.minecraft.block.state.IBlockState)3 BiomeDecorator (net.minecraft.world.biome.BiomeDecorator)3 BlockState (org.spongepowered.api.block.BlockState)3 Forest (org.spongepowered.api.world.gen.populator.Forest)3 Ore (org.spongepowered.api.world.gen.populator.Ore)2 RandomBlock (org.spongepowered.api.world.gen.populator.RandomBlock)2 Shrub (org.spongepowered.api.world.gen.populator.Shrub)2 BlockSilverfish (net.minecraft.block.BlockSilverfish)1 Blocks (net.minecraft.init.Blocks)1 World (net.minecraft.world.World)1 BiomeHills (net.minecraft.world.biome.BiomeHills)1 ChunkGeneratorSettings (net.minecraft.world.gen.ChunkGeneratorSettings)1 ShrubType (org.spongepowered.api.data.type.ShrubType)1 ChanceTable (org.spongepowered.api.util.weighted.ChanceTable)1 SeededVariableAmount (org.spongepowered.api.util.weighted.SeededVariableAmount)1 VariableAmount (org.spongepowered.api.util.weighted.VariableAmount)1 WeightedObject (org.spongepowered.api.util.weighted.WeightedObject)1 BigMushroom (org.spongepowered.api.world.gen.populator.BigMushroom)1 BlockBlob (org.spongepowered.api.world.gen.populator.BlockBlob)1