}
private GameManifest createGameManifest() {
GameManifest gameManifest = new GameManifest();
Config config = CoreRegistry.get(Config.class);
ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
for (Name moduleName : config.getDefaultModSelection().listModules()) {
Module module = moduleManager.getRegistry().getLatestModuleVersion(moduleName);
if (module != null) {
gameManifest.addModule(module.getId(), module.getVersion());
}
}
WorldGenerationConfig worldGenConfig = config.getWorldGeneration();
// If no valid default world generator set then try to find one - no option to pick one manually in headless
if (!worldGenConfig.getDefaultGenerator().isValid()) {
// find the first gameplay module that is available, it should have a preferred world gen
for (Name moduleName : config.getDefaultModSelection().listModules()) {
Module module = moduleManager.getRegistry().getLatestModuleVersion(moduleName);
if (moduleManager.isGameplayModule(module)) {
String defaultWorldGenerator = module.getMetadata().getExtension(ModuleManager.DEFAULT_WORLD_GENERATOR_EXT, String.class);
worldGenConfig.setDefaultGenerator(new SimpleUri(defaultWorldGenerator));
break;