genTexture(); worldGenerator = WorldGeneratorManager.createWorldGenerator(worldGenUri, subContext, environment); worldGenerator.setWorldSeed(seed.getText());
@Override public void set(String value) { selectedWorld = value; try { if (findWorldByName(selectedWorld).getWorldGenerator() == null) { worldGenerator = WorldGeneratorManager.createWorldGenerator(findWorldByName(selectedWorld).getWorldGeneratorInfo().getUri(), context, environment); findWorldByName(selectedWorld).setWorldGenerator(worldGenerator); } else { worldGenerator = findWorldByName(selectedWorld).getWorldGenerator(); } if (worldGenerator.getWorldSeed() == null) { worldGenerator.setWorldSeed(createSeed(selectedWorld)); } previewGen = new FacetLayerPreview(environment, worldGenerator); updatePreview(); } catch (UnresolvedWorldGeneratorException e) { e.printStackTrace(); } } });
/** * This method sets the world whose properties are to be changed. This function is called before the screen comes * to the forefront. * @param subContext the new environment created in {@link UniverseSetupScreen} * @param worldSelected the world whose configurations are to be changed. * @throws UnresolvedWorldGeneratorException */ public void setWorld(Context subContext, WorldSetupWrapper worldSelected) throws UnresolvedWorldGeneratorException { world = worldSelected; context = subContext; SimpleUri worldGenUri = worldSelected.getWorldGeneratorInfo().getUri(); environment = context.get(ModuleEnvironment.class); context.put(WorldGeneratorPluginLibrary.class, new TempWorldGeneratorPluginLibrary(environment, context)); if (world.getWorldGenerator() == null) { worldGenerator = WorldGeneratorManager.createWorldGenerator(worldGenUri, context, environment); world.setWorldGenerator(worldGenerator); } else { worldGenerator = world.getWorldGenerator(); } configureProperties(); }
/** * @param uri uri of the world generator to create. * @param context objects from this context will be injected into the * @return The instantiated world generator. */ public static WorldGenerator createGenerator(SimpleUri uri, Context context) throws UnresolvedWorldGeneratorException { ModuleManager moduleManager = context.get(ModuleManager.class); Module module = moduleManager.getEnvironment().get(uri.getModuleName()); if (module == null) { DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry()); ResolutionResult result = resolver.resolve(uri.getModuleName()); if (!result.isSuccess()) { if (moduleManager.getRegistry().getLatestModuleVersion(uri.getModuleName()) == null) { throw new UnresolvedWorldGeneratorException("Unable to resolve world generator '" + uri + "' - not found"); } else { throw new UnresolvedWorldGeneratorException("Unable to resolve world generator '" + uri + "' - unable to resolve module dependencies"); } } try (ModuleEnvironment environment = moduleManager.loadEnvironment(result.getModules(), false)) { return createWorldGenerator(uri, context, environment); } } else { return createWorldGenerator(uri, context, moduleManager.getEnvironment()); } }
@Override public void onOpened() { try { if (findWorldByName(selectedWorld).getWorldGenerator() == null) { worldGenerator = WorldGeneratorManager.createWorldGenerator(findWorldByName(selectedWorld).getWorldGeneratorInfo().getUri(), context, environment); findWorldByName(selectedWorld).setWorldGenerator(worldGenerator); } else { worldGenerator = findWorldByName(selectedWorld).getWorldGenerator(); } if (worldGenerator.getWorldSeed().isEmpty()) { worldGenerator.setWorldSeed(createSeed(selectedWorld)); } previewGen = new FacetLayerPreview(environment, worldGenerator); updatePreview(); } catch (UnresolvedWorldGeneratorException e) { e.printStackTrace(); } }
private void setWorldGenerators() { for (WorldSetupWrapper worldSetupWrapper : worldList) { if (worldSetupWrapper.getWorldGenerator() == null) { try { worldSetupWrapper.setWorldGenerator(WorldGeneratorManager.createWorldGenerator(findWorldByName(worldSetupWrapper.getWorldName().toString()).getWorldGeneratorInfo().getUri(), context, environment)); } catch (UnresolvedWorldGeneratorException e) { e.printStackTrace(); } } worldSetupWrapper.getWorldGenerator().setWorldSeed(createSeed(worldSetupWrapper.getWorldName().toString())); } }