Search in sources :

Example 1 with FilteredPopulator

use of org.spongepowered.common.world.gen.populators.FilteredPopulator in project SpongeCommon by SpongePowered.

the class MixinChunkGeneratorFlat method addPopulators.

@Override
public void addPopulators(WorldGenerator generator) {
    for (Object o : this.structureGenerators.values()) {
        if (o instanceof MapGenBase) {
            generator.getGenerationPopulators().add((GenerationPopulator) o);
            if (o instanceof MapGenStructure) {
                generator.getPopulators().add((Populator) o);
            }
        }
    }
    if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lake")) {
        Lake lake = Lake.builder().chance(1 / 4d).liquidType((BlockState) Blocks.WATER.getDefaultState()).height(VariableAmount.baseWithRandomAddition(0, 256)).build();
        FilteredPopulator filtered = new FilteredPopulator(lake);
        filtered.setRequiredFlags(WorldGenConstants.VILLAGE_FLAG);
        generator.getPopulators().add(lake);
    }
    if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lava_lake")) {
        Lake lake = Lake.builder().chance(1 / 8d).liquidType((BlockState) Blocks.WATER.getDefaultState()).height(VariableAmount.baseWithVariance(0, VariableAmount.baseWithRandomAddition(8, VariableAmount.baseWithOptionalAddition(55, 193, 0.1)))).build();
        FilteredPopulator filtered = new FilteredPopulator(lake);
        filtered.setRequiredFlags(WorldGenConstants.VILLAGE_FLAG);
        generator.getPopulators().add(filtered);
    }
    if (this.hasDungeons) {
        Dungeon dungeon = Dungeon.builder().attempts(8).build();
        generator.getPopulators().add(dungeon);
    }
    for (BiomeType type : Sponge.getRegistry().getAllOf(BiomeType.class)) {
        BiomeGenerationSettings settings = generator.getBiomeSettings(type);
        settings.getGroundCoverLayers().clear();
        if (!this.hasDecoration) {
            settings.getPopulators().clear();
            settings.getGenerationPopulators().clear();
        }
    }
}
Also used : BiomeType(org.spongepowered.api.world.biome.BiomeType) FilteredPopulator(org.spongepowered.common.world.gen.populators.FilteredPopulator) MapGenStructure(net.minecraft.world.gen.structure.MapGenStructure) Dungeon(org.spongepowered.api.world.gen.populator.Dungeon) BiomeGenerationSettings(org.spongepowered.api.world.biome.BiomeGenerationSettings) Lake(org.spongepowered.api.world.gen.populator.Lake) MapGenBase(net.minecraft.world.gen.MapGenBase)

Example 2 with FilteredPopulator

use of org.spongepowered.common.world.gen.populators.FilteredPopulator in project SpongeCommon by SpongePowered.

the class MixinChunkGeneratorOverworld method addPopulators.

@Override
public void addPopulators(WorldGenerator generator) {
    if (this.settings.useCaves) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.caveGenerator);
    }
    if (this.settings.useRavines) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.ravineGenerator);
    }
    if (this.settings.useMineShafts && this.mapFeaturesEnabled) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.mineshaftGenerator);
        generator.getPopulators().add((Populator) this.mineshaftGenerator);
    }
    if (this.settings.useVillages && this.mapFeaturesEnabled) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.villageGenerator);
        generator.getPopulators().add((Populator) this.villageGenerator);
    }
    if (this.settings.useStrongholds && this.mapFeaturesEnabled) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.strongholdGenerator);
        generator.getPopulators().add((Populator) this.strongholdGenerator);
    }
    if (this.settings.useTemples && this.mapFeaturesEnabled) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.scatteredFeatureGenerator);
        generator.getPopulators().add((Populator) this.scatteredFeatureGenerator);
    }
    if (this.settings.useMonuments && this.mapFeaturesEnabled) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.oceanMonumentGenerator);
        generator.getPopulators().add((Populator) this.oceanMonumentGenerator);
    }
    if (this.settings.useMansions && this.mapFeaturesEnabled) {
        generator.getGenerationPopulators().add((GenerationPopulator) this.woodlandMansionGenerator);
        generator.getPopulators().add((Populator) this.woodlandMansionGenerator);
    }
    if (this.settings.useWaterLakes) {
        Lake lake = Lake.builder().chance(1d / this.settings.waterLakeChance).liquidType((BlockState) Blocks.WATER.getDefaultState()).height(VariableAmount.baseWithRandomAddition(0, 256)).build();
        FilteredPopulator filtered = new FilteredPopulator(lake, (c) -> {
            Biome biomegenbase = this.world.getBiome(VecHelper.toBlockPos(c.getBlockMin()).add(16, 0, 16));
            return biomegenbase != Biomes.DESERT && biomegenbase != Biomes.DESERT_HILLS;
        });
        filtered.setRequiredFlags(WorldGenConstants.VILLAGE_FLAG);
        generator.getPopulators().add(filtered);
    }
    if (this.settings.useLavaLakes) {
        Lake lake = Lake.builder().chance(1d / this.settings.lavaLakeChance).liquidType((BlockState) Blocks.WATER.getDefaultState()).height(VariableAmount.baseWithVariance(0, VariableAmount.baseWithRandomAddition(8, VariableAmount.baseWithOptionalAddition(55, 193, 0.1)))).build();
        FilteredPopulator filtered = new FilteredPopulator(lake);
        filtered.setRequiredFlags(WorldGenConstants.VILLAGE_FLAG);
        generator.getPopulators().add(filtered);
    }
    if (this.settings.useDungeons) {
        Dungeon dungeon = Dungeon.builder().attempts(this.settings.dungeonChance).build();
        generator.getPopulators().add(dungeon);
    }
    generator.getPopulators().add(new AnimalPopulator());
    generator.getPopulators().add(new SnowPopulator());
}
Also used : FilteredPopulator(org.spongepowered.common.world.gen.populators.FilteredPopulator) Biome(net.minecraft.world.biome.Biome) Dungeon(org.spongepowered.api.world.gen.populator.Dungeon) SnowPopulator(org.spongepowered.common.world.gen.populators.SnowPopulator) Lake(org.spongepowered.api.world.gen.populator.Lake) AnimalPopulator(org.spongepowered.common.world.gen.populators.AnimalPopulator)

Aggregations

Dungeon (org.spongepowered.api.world.gen.populator.Dungeon)2 Lake (org.spongepowered.api.world.gen.populator.Lake)2 FilteredPopulator (org.spongepowered.common.world.gen.populators.FilteredPopulator)2 Biome (net.minecraft.world.biome.Biome)1 MapGenBase (net.minecraft.world.gen.MapGenBase)1 MapGenStructure (net.minecraft.world.gen.structure.MapGenStructure)1 BiomeGenerationSettings (org.spongepowered.api.world.biome.BiomeGenerationSettings)1 BiomeType (org.spongepowered.api.world.biome.BiomeType)1 AnimalPopulator (org.spongepowered.common.world.gen.populators.AnimalPopulator)1 SnowPopulator (org.spongepowered.common.world.gen.populators.SnowPopulator)1