Search in sources :

Example 1 with SpongeWorldGenerator

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

the class MixinWorldServer method createWorldGenerator.

@Override
public SpongeWorldGenerator createWorldGenerator(String settings) {
    final WorldServer worldServer = (WorldServer) (Object) this;
    final WorldType worldType = worldServer.getWorldType();
    final IChunkGenerator chunkGenerator;
    final BiomeProvider biomeProvider;
    if (worldType instanceof SpongeWorldType) {
        chunkGenerator = ((SpongeWorldType) worldType).getChunkGenerator(worldServer, settings);
        biomeProvider = ((SpongeWorldType) worldType).getBiomeProvider(worldServer);
    } else {
        final IChunkGenerator currentGenerator = this.getChunkProvider().chunkGenerator;
        if (currentGenerator != null) {
            chunkGenerator = currentGenerator;
        } else {
            final WorldProvider worldProvider = worldServer.provider;
            ((IMixinWorldProvider) worldProvider).setGeneratorSettings(settings);
            chunkGenerator = worldProvider.createChunkGenerator();
        }
        biomeProvider = worldServer.provider.biomeProvider;
    }
    return new SpongeWorldGenerator(worldServer, (BiomeGenerator) biomeProvider, SpongeGenerationPopulator.of(worldServer, chunkGenerator));
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) IMixinWorldProvider(org.spongepowered.common.interfaces.world.IMixinWorldProvider) SpongeWorldType(org.spongepowered.common.world.type.SpongeWorldType) WorldType(net.minecraft.world.WorldType) IChunkGenerator(net.minecraft.world.gen.IChunkGenerator) IMixinWorldProvider(org.spongepowered.common.interfaces.world.IMixinWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) WorldServer(net.minecraft.world.WorldServer) IMixinWorldServer(org.spongepowered.common.interfaces.world.IMixinWorldServer) SpongeWorldGenerator(org.spongepowered.common.world.gen.SpongeWorldGenerator) SpongeWorldType(org.spongepowered.common.world.type.SpongeWorldType)

Example 2 with SpongeWorldGenerator

use of org.spongepowered.common.world.gen.SpongeWorldGenerator 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

IChunkGenerator (net.minecraft.world.gen.IChunkGenerator)2 SpongeWorldGenerator (org.spongepowered.common.world.gen.SpongeWorldGenerator)2 WorldProvider (net.minecraft.world.WorldProvider)1 WorldServer (net.minecraft.world.WorldServer)1 WorldType (net.minecraft.world.WorldType)1 BiomeProvider (net.minecraft.world.biome.BiomeProvider)1 ChunkProviderServer (net.minecraft.world.gen.ChunkProviderServer)1 DataContainer (org.spongepowered.api.data.DataContainer)1 WorldGeneratorModifier (org.spongepowered.api.world.gen.WorldGeneratorModifier)1 IMixinWorldProvider (org.spongepowered.common.interfaces.world.IMixinWorldProvider)1 IMixinWorldServer (org.spongepowered.common.interfaces.world.IMixinWorldServer)1 IMixinChunkProviderServer (org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer)1 IPopulatorProvider (org.spongepowered.common.interfaces.world.gen.IPopulatorProvider)1 SpongeWorldType (org.spongepowered.common.world.type.SpongeWorldType)1