Search in sources :

Example 1 with MapGenStructure

use of net.minecraft.world.gen.structure.MapGenStructure 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)

Aggregations

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 Dungeon (org.spongepowered.api.world.gen.populator.Dungeon)1 Lake (org.spongepowered.api.world.gen.populator.Lake)1 FilteredPopulator (org.spongepowered.common.world.gen.populators.FilteredPopulator)1