Search in sources :

Example 1 with IPopulatorProvider

use of org.spongepowered.common.interfaces.world.gen.IPopulatorProvider in project SpongeCommon by SpongePowered.

the class MixinWorldServer method updateWorldGenerator.

@Override
public void updateWorldGenerator() {
    // Get the default generator for the world type
    DataContainer generatorSettings = this.getProperties().getGeneratorSettings();
    SpongeWorldGenerator newGenerator = createWorldGenerator(generatorSettings);
    // by the base generation populator
    if (newGenerator.getBaseGenerationPopulator() instanceof IChunkGenerator) {
        // from a mod chunk provider extending a provider that we mixed into
        if (WorldGenConstants.isValid((IChunkGenerator) newGenerator.getBaseGenerationPopulator(), IPopulatorProvider.class)) {
            ((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
        }
    } else if (newGenerator.getBaseGenerationPopulator() instanceof IPopulatorProvider) {
        // If its not a chunk provider but is a populator provider then we call it as well
        ((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
    }
    for (WorldGeneratorModifier modifier : this.getProperties().getGeneratorModifiers()) {
        modifier.modifyWorldGenerator(this.getProperties(), generatorSettings, newGenerator);
    }
    this.spongegen = createChunkGenerator(newGenerator);
    this.spongegen.setGenerationPopulators(newGenerator.getGenerationPopulators());
    this.spongegen.setPopulators(newGenerator.getPopulators());
    this.spongegen.setBiomeOverrides(newGenerator.getBiomeSettings());
    ChunkProviderServer chunkProviderServer = this.getChunkProvider();
    chunkProviderServer.chunkGenerator = this.spongegen;
}
Also used : DataContainer(org.spongepowered.api.data.DataContainer) WorldGeneratorModifier(org.spongepowered.api.world.gen.WorldGeneratorModifier) IChunkGenerator(net.minecraft.world.gen.IChunkGenerator) IPopulatorProvider(org.spongepowered.common.interfaces.world.gen.IPopulatorProvider) IMixinChunkProviderServer(org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) SpongeWorldGenerator(org.spongepowered.common.world.gen.SpongeWorldGenerator)

Aggregations

ChunkProviderServer (net.minecraft.world.gen.ChunkProviderServer)1 IChunkGenerator (net.minecraft.world.gen.IChunkGenerator)1 DataContainer (org.spongepowered.api.data.DataContainer)1 WorldGeneratorModifier (org.spongepowered.api.world.gen.WorldGeneratorModifier)1 IMixinChunkProviderServer (org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer)1 IPopulatorProvider (org.spongepowered.common.interfaces.world.gen.IPopulatorProvider)1 SpongeWorldGenerator (org.spongepowered.common.world.gen.SpongeWorldGenerator)1