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));
}
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;
}
Aggregations