use of org.pepsoft.worldpainter.layers.exporters.ExporterSettings in project WorldPainter by Captain-Chaos.
the class WorldFactory method createDefaultWorldWithoutTiles.
public static World2 createDefaultWorldWithoutTiles(final Configuration config, final long seed) {
final HeightMapTileFactory tileFactory;
if (config.isHilly()) {
tileFactory = TileFactoryFactory.createNoiseTileFactory(seed, config.getSurface(), config.getDefaultMaxHeight(), config.getLevel(), config.getWaterLevel(), config.isLava(), config.isBeaches(), config.getDefaultRange(), config.getDefaultScale());
} else {
tileFactory = TileFactoryFactory.createFlatTileFactory(seed, config.getSurface(), config.getDefaultMaxHeight(), config.getLevel(), config.getWaterLevel(), config.isLava(), config.isBeaches());
}
final Dimension defaults = config.getDefaultTerrainAndLayerSettings();
if ((defaults.getTileFactory() instanceof HeightMapTileFactory) && ((((HeightMapTileFactory) defaults.getTileFactory()).getTheme() instanceof SimpleTheme) && ((SimpleTheme) ((HeightMapTileFactory) defaults.getTileFactory()).getTheme()).getTerrainRanges() != null)) {
HeightMapTileFactory defaultTileFactory = (HeightMapTileFactory) defaults.getTileFactory();
SimpleTheme defaultTheme = (SimpleTheme) defaultTileFactory.getTheme();
SimpleTheme theme = (SimpleTheme) tileFactory.getTheme();
theme.setTerrainRanges(new TreeMap<>(defaultTheme.getTerrainRanges()));
theme.setRandomise(defaultTheme.isRandomise());
}
final World2 world = new World2(config.getDefaultPlatform(), World2.DEFAULT_OCEAN_SEED, tileFactory, tileFactory.getMaxHeight());
world.addHistoryEntry(HistoryEntry.WORLD_CREATED);
final ResourceBundle strings = ResourceBundle.getBundle("org.pepsoft.worldpainter.resources.strings");
world.setName(strings.getString("generated.world"));
// Export settings
world.setCreateGoodiesChest(config.isDefaultCreateGoodiesChest());
Generator generator = config.getDefaultGenerator();
if ((world.getMaxHeight() == DEFAULT_MAX_HEIGHT_1) && (generator == Generator.LARGE_BIOMES)) {
generator = Generator.DEFAULT;
} else if ((world.getMaxHeight() == DEFAULT_MAX_HEIGHT_2) && (generator == Generator.DEFAULT)) {
generator = Generator.LARGE_BIOMES;
}
world.setGenerator(generator);
if (generator == Generator.FLAT) {
world.setGeneratorOptions(config.getDefaultGeneratorOptions());
}
world.setMapFeatures(config.isDefaultMapFeatures());
world.setGameType(config.getDefaultGameType());
world.setAllowCheats(config.isDefaultAllowCheats());
final Dimension dim0 = world.getDimension(0);
dim0.setEventsInhibited(true);
try {
dim0.setBorder(defaults.getBorder());
dim0.setBorderSize(defaults.getBorderSize());
dim0.setBedrockWall(defaults.isBedrockWall());
dim0.setBorderLevel(defaults.getBorderLevel());
dim0.setSubsurfaceMaterial(defaults.getSubsurfaceMaterial());
dim0.setPopulate(defaults.isPopulate());
for (Map.Entry<Layer, ExporterSettings> entry : defaults.getAllLayerSettings().entrySet()) {
dim0.setLayerSettings(entry.getKey(), entry.getValue().clone());
}
dim0.setGridEnabled(config.isDefaultGridEnabled());
dim0.setGridSize(config.getDefaultGridSize());
dim0.setContoursEnabled(config.isDefaultContoursEnabled());
dim0.setContourSeparation(config.getDefaultContourSeparation());
dim0.setTopLayerMinDepth(defaults.getTopLayerMinDepth());
dim0.setTopLayerVariation(defaults.getTopLayerVariation());
dim0.setBottomless(defaults.isBottomless());
dim0.setCoverSteepTerrain(defaults.isCoverSteepTerrain());
} finally {
dim0.setEventsInhibited(false);
}
world.setDirty(false);
return world;
}
use of org.pepsoft.worldpainter.layers.exporters.ExporterSettings in project WorldPainter by Captain-Chaos.
the class HeightMapImporter method importToNewWorld.
/**
* Create a new WorldPainter world from the configured height map and import
* settings.
*
* @param progressReceiver The progress receiver to report progress to and
* check for cancellation with.
* @return A new WorldPainter world based on the specified height map.
* @throws org.pepsoft.util.ProgressReceiver.OperationCancelled If and when
* the specified progress received throws it (when the user cancels the
* operation).
*/
public World2 importToNewWorld(ProgressReceiver progressReceiver) throws ProgressReceiver.OperationCancelled {
Rectangle extent = heightMap.getExtent();
logger.info("Importing world from height map {} (size: {}x{})", name, extent.width, extent.height);
final boolean highRes = (imageHighLevel >= maxHeight) && (worldHighLevel < maxHeight);
final World2 world = new World2((maxHeight == DEFAULT_MAX_HEIGHT_2) ? JAVA_ANVIL : JAVA_MCREGION, World2.DEFAULT_OCEAN_SEED, tileFactory, maxHeight);
world.addHistoryEntry(HistoryEntry.WORLD_IMPORTED_FROM_HEIGHT_MAP, imageFile);
int p = name.lastIndexOf('.');
if (p != -1) {
name = name.substring(0, p);
}
world.setName(name);
final Dimension dimension = world.getDimension(0);
// Export settings
final Configuration config = Configuration.getInstance();
final boolean minecraft11Only = dimension.getMaxHeight() != DEFAULT_MAX_HEIGHT_2;
world.setCreateGoodiesChest(config.isDefaultCreateGoodiesChest());
Generator generator = config.getDefaultGenerator();
if (minecraft11Only && (generator == Generator.LARGE_BIOMES)) {
generator = Generator.DEFAULT;
} else if ((!minecraft11Only) && (generator == Generator.DEFAULT)) {
generator = Generator.LARGE_BIOMES;
}
world.setGenerator(generator);
if (generator == Generator.FLAT) {
world.setGeneratorOptions(config.getDefaultGeneratorOptions());
}
world.setMapFeatures(config.isDefaultMapFeatures());
world.setGameType(config.getDefaultGameType());
world.setAllowCheats(config.isDefaultAllowCheats());
// Turn off smooth snow, except for high res imports
if (!highRes) {
FrostExporter.FrostSettings frostSettings = new FrostExporter.FrostSettings();
frostSettings.setMode(FrostExporter.FrostSettings.MODE_FLAT);
dimension.setLayerSettings(Frost.INSTANCE, frostSettings);
}
importToDimension(dimension, true, progressReceiver);
Dimension defaults = config.getDefaultTerrainAndLayerSettings();
dimension.setBorder(defaults.getBorder());
dimension.setBorderSize(defaults.getBorderSize());
dimension.setBorderLevel(worldWaterLevel);
dimension.setBedrockWall(defaults.isBedrockWall());
dimension.setSubsurfaceMaterial(defaults.getSubsurfaceMaterial());
dimension.setPopulate(defaults.isPopulate());
dimension.setTopLayerMinDepth(defaults.getTopLayerMinDepth());
dimension.setTopLayerVariation(defaults.getTopLayerVariation());
dimension.setBottomless(defaults.isBottomless());
for (Map.Entry<Layer, ExporterSettings> entry : defaults.getAllLayerSettings().entrySet()) {
dimension.setLayerSettings(entry.getKey(), entry.getValue().clone());
}
dimension.setGridEnabled(config.isDefaultGridEnabled());
dimension.setGridSize(config.getDefaultGridSize());
dimension.setContoursEnabled(config.isDefaultContoursEnabled());
dimension.setContourSeparation(config.getDefaultContourSeparation());
world.setSpawnPoint(new Point(extent.x + extent.width / 2, extent.y + extent.height / 2));
dimension.setLastViewPosition(world.getSpawnPoint());
world.setDirty(false);
return world;
}
use of org.pepsoft.worldpainter.layers.exporters.ExporterSettings in project WorldPainter by Captain-Chaos.
the class RecoverWorld method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
int defaultMaxHeight = Integer.parseInt(args[1]);
// Load or initialise configuration
Configuration config;
try {
// This will migrate the configuration directory if necessary
config = Configuration.load();
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
if (config == null) {
if (!logger.isDebugEnabled()) {
// If debug logging is on, the Configuration constructor will
// already log this
logger.info("Creating new configuration");
}
config = new Configuration();
}
Configuration.setInstance(config);
logger.info("Installation ID: " + config.getUuid());
// Load and install trusted WorldPainter root certificate
X509Certificate trustedCert = null;
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
trustedCert = (X509Certificate) certificateFactory.generateCertificate(RecoverWorld.class.getResourceAsStream("/wproot.pem"));
} catch (CertificateException e) {
logger.error("Certificate exception while loading trusted root certificate", e);
}
// Load the plugins
if (trustedCert != null) {
PluginManager.loadPlugins(new File(Configuration.getConfigDir(), "plugins"), trustedCert.getPublicKey());
} else {
logger.error("Trusted root certificate not available; not loading plugins");
}
WPPluginManager.initialise(config.getUuid());
// Read as much data as possible. Use a trick via InstanceKeeper to get
// hold of the objects as they are created during deserialisation, even
// if the readObject() method throws an exception and never returns an
// instance
final List<World2> worlds = new ArrayList<>();
final Map<Dimension, List<Tile>> tiles = new HashMap<>();
@SuppressWarnings("unchecked") final List<Tile>[] tileListHolder = new List[1];
InstanceKeeper.setInstantiationListener(World2.class, worlds::add);
InstanceKeeper.setInstantiationListener(Dimension.class, dimension -> {
List<Tile> tileList = new ArrayList<>();
tiles.put(dimension, tileList);
tileListHolder[0] = tileList;
});
InstanceKeeper.setInstantiationListener(Tile.class, tile -> tileListHolder[0].add(tile));
File file = new File(args[0]);
try {
try (WPCustomObjectInputStream wrappedIn = new WPCustomObjectInputStream(new GZIPInputStream(new FileInputStream(file)), PluginManager.getPluginClassLoader(), AbstractObject.class)) {
Map<String, Object> metadata = null;
World2 world;
Object object = wrappedIn.readObject();
if (object instanceof Map) {
metadata = (Map<String, Object>) object;
object = wrappedIn.readObject();
}
if (object instanceof World2) {
world = (World2) object;
if (metadata != null) {
world.setMetadata(metadata);
}
} else if (object instanceof World) {
throw new RuntimeException("Old worlds (pre-0.2) not supported");
} else {
throw new RuntimeException("Object of unexpected type " + object.getClass() + " encountered");
}
}
} catch (IOException e) {
System.err.println("Warning: I/O error while reading world; world most likely corrupted! (Type: " + e.getClass().getSimpleName() + ", message: " + e.getMessage() + ")");
} catch (ClassNotFoundException e) {
System.err.println("Warning: class not found while reading world; world most likely corrupted! (Type: " + e.getClass().getSimpleName() + ", message: " + e.getMessage() + ")");
}
// Reconstitute as much of the data as possible
System.out.println(worlds.size() + " worlds read");
System.out.println(tiles.size() + " dimensions read");
World2 newWorld = null;
for (Map.Entry<Dimension, List<Tile>> entry : tiles.entrySet()) {
Dimension dimension = entry.getKey();
List<Tile> tileList = entry.getValue();
System.out.println(tileList.size() + " tiles read for dimension " + dimension.getName());
int maxHeight;
if (dimension.getMaxHeight() != 0) {
maxHeight = dimension.getMaxHeight();
} else {
maxHeight = defaultMaxHeight;
}
if (newWorld == null) {
if (worlds.size() > 0) {
World2 world = worlds.get(0);
if (world.getPlatform() != null) {
newWorld = new World2(world.getPlatform(), maxHeight);
} else if (maxHeight == DEFAULT_MAX_HEIGHT_2) {
newWorld = new World2(JAVA_ANVIL, maxHeight);
} else {
newWorld = new World2(JAVA_MCREGION, maxHeight);
}
if (world.getName() != null) {
newWorld.setName(worlds.get(0).getName() + " (recovered)");
}
newWorld.setCreateGoodiesChest(world.isCreateGoodiesChest());
try {
for (int i = 0; i < Terrain.CUSTOM_TERRAIN_COUNT; i++) {
newWorld.setMixedMaterial(i, world.getMixedMaterial(i));
}
} catch (NullPointerException e) {
System.err.println("Custom material settings lost");
}
newWorld.setGameType(world.getGameType());
if (world.getGenerator() != null) {
newWorld.setGenerator(world.getGenerator());
} else {
System.err.println("Landscape generator setting lost");
}
newWorld.setImportedFrom(world.getImportedFrom());
newWorld.setMapFeatures(world.isMapFeatures());
if (world.getSpawnPoint() != null) {
newWorld.setSpawnPoint(world.getSpawnPoint());
} else {
System.err.println("Spawn point setting lost; resetting to 0,0");
}
if (world.getUpIs() != null) {
newWorld.setUpIs(world.getUpIs());
} else {
System.err.println("North direction setting lost; resetting to north is up");
}
} else {
System.err.println("No world recovered; all world settings lost");
if (maxHeight == DEFAULT_MAX_HEIGHT_2) {
newWorld = new World2(JAVA_ANVIL, maxHeight);
} else {
newWorld = new World2(JAVA_MCREGION, maxHeight);
}
}
newWorld.addHistoryEntry(HistoryEntry.WORLD_RECOVERED);
if (newWorld.getName() == null) {
String worldName = file.getName();
if (worldName.toLowerCase().endsWith(".world")) {
worldName = worldName.substring(0, worldName.length() - 6);
}
newWorld.setName(worldName + " (recovered)");
}
}
TileFactory tileFactory = dimension.getTileFactory();
if (tileFactory == null) {
System.err.println("Dimension " + dimension.getName() + " tile factory lost; creating default tile factory");
tileFactory = TileFactoryFactory.createNoiseTileFactory(dimension.getSeed(), Terrain.GRASS, maxHeight, 58, 62, false, true, 20, 1.0);
}
Dimension newDimension = new Dimension(dimension.getMinecraftSeed(), tileFactory, dimension.getDim(), maxHeight);
try {
for (Map.Entry<Layer, ExporterSettings> settingsEntry : dimension.getAllLayerSettings().entrySet()) {
if (settingsEntry.getValue() != null) {
newDimension.setLayerSettings(settingsEntry.getKey(), settingsEntry.getValue());
} else {
System.err.println("Layer settings for layer " + settingsEntry.getKey().getName() + " lost for dimension " + dimension.getName());
}
}
} catch (NullPointerException e) {
System.err.println("Layer settings lost for dimension " + dimension.getName());
}
newDimension.setBedrockWall(dimension.isBedrockWall());
if ((dimension.getBorderLevel() > 0) && (dimension.getBorderSize() > 0)) {
newDimension.setBorder(dimension.getBorder());
newDimension.setBorderLevel(dimension.getBorderLevel());
newDimension.setBorderSize(dimension.getBorderSize());
} else {
System.err.println("Border settings lost for dimension " + dimension.getName());
}
if (dimension.getContourSeparation() > 0) {
newDimension.setContoursEnabled(dimension.isContoursEnabled());
newDimension.setContourSeparation(dimension.getContourSeparation());
} else {
System.err.println("Contour settings lost for dimension " + dimension.getName());
}
newDimension.setDarkLevel(dimension.isDarkLevel());
if (dimension.getGridSize() > 0) {
newDimension.setGridEnabled(dimension.isGridEnabled());
newDimension.setGridSize(dimension.getGridSize());
} else {
System.err.println("Grid settings lost for dimension " + dimension.getName());
}
newDimension.setMinecraftSeed(dimension.getMinecraftSeed());
newDimension.setOverlay(dimension.getOverlay());
newDimension.setOverlayEnabled(dimension.isOverlayEnabled());
newDimension.setOverlayOffsetX(dimension.getOverlayOffsetX());
newDimension.setOverlayOffsetY(dimension.getOverlayOffsetY());
newDimension.setOverlayScale(dimension.getOverlayScale());
newDimension.setOverlayTransparency(dimension.getOverlayTransparency());
newDimension.setPopulate(dimension.isPopulate());
if (dimension.getSubsurfaceMaterial() != null) {
newDimension.setSubsurfaceMaterial(dimension.getSubsurfaceMaterial());
} else {
System.err.println("Sub surface material lost for dimension " + dimension.getName() + "; resetting to STONE_MIX");
newDimension.setSubsurfaceMaterial(Terrain.STONE_MIX);
}
newWorld.addDimension(newDimension);
for (Tile tile : tileList) {
tile.repair(maxHeight, System.err);
newDimension.addTile(tile);
}
}
// Write to a new file
String filename = file.getName();
if (filename.toLowerCase().endsWith(".world")) {
filename = filename.substring(0, filename.length() - 6);
}
filename = filename + ".recovered.world";
WorldIO worldIO = new WorldIO(newWorld);
File outFile = new File(file.getParentFile(), filename);
try (OutputStream out = new FileOutputStream(outFile)) {
worldIO.save(out);
}
System.out.println("Recovered world written to " + outFile);
}
use of org.pepsoft.worldpainter.layers.exporters.ExporterSettings in project WorldPainter by Captain-Chaos.
the class EditLayerDialog method updatePreview.
private void updatePreview() {
// chance is remote
if (!editor.isCommitAvailable()) {
return;
}
final ExporterSettings settings = editor.getSettings();
synchronized (PREVIEW_STATE_LOCK) {
switch(previewRenderState) {
case IDLE:
// Not rendering anything yet
new Thread("Preview Creator for " + editor.getLayer().getName()) {
@Override
public void run() {
renderLoop: do {
synchronized (PREVIEW_RENDERER_LOCK) {
previewCreator.setLayer(settings.getLayer());
previewCreator.setSettings(settings);
final MinecraftWorldObject preview = previewCreator.renderPreview();
SwingUtilities.invokeLater(() -> dynMapPreviewer1.setObject(preview, app.getDimension()));
}
synchronized (PREVIEW_STATE_LOCK) {
switch(previewRenderState) {
case SECOND_RENDER_SCHEDULED:
previewRenderState = PreviewRenderState.RENDERING;
// Loop again
break;
case RENDERING:
previewRenderState = PreviewRenderState.IDLE;
// Fall through to break loop
default:
// Break loop
break renderLoop;
}
}
} while (true);
}
}.start();
previewRenderState = PreviewRenderState.RENDERING;
break;
case RENDERING:
// A preview is already being rendered; set the state such
// that when it is finished another render will immediately
// be started
previewRenderState = PreviewRenderState.SECOND_RENDER_SCHEDULED;
break;
case SECOND_RENDER_SCHEDULED:
// do
break;
}
}
}
use of org.pepsoft.worldpainter.layers.exporters.ExporterSettings in project WorldPainter by Captain-Chaos.
the class NewWorldDialog method getSelectedDimension.
public Dimension getSelectedDimension(final ProgressReceiver progressReceiver) throws ProgressReceiver.OperationCancelled {
long minecraftSeed;
try {
minecraftSeed = Long.parseLong(fieldSeed.getText());
} catch (NumberFormatException e) {
minecraftSeed = fieldSeed.getText().hashCode();
}
if (radioButtonCustomSeed.isSelected()) {
worldpainterSeed = minecraftSeed;
}
int waterHeight = (Integer) spinnerWaterLevel.getValue();
final TileFactory tileFactory = createTileFactory(worldpainterSeed);
int maxHeight = (Integer) comboBoxMaxHeight.getSelectedItem();
final Dimension dimension = new Dimension(minecraftSeed, tileFactory, dim, maxHeight);
dimension.setEventsInhibited(true);
try {
ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
final AtomicBoolean cancelled = new AtomicBoolean();
if (tiles != null) {
logger.info("Creating new dimension with " + tiles.size() + " preselected tiles");
final int[] tileCount = new int[1];
final int totalTiles = tiles.size();
for (final Point tileCoords : tiles) {
executorService.execute(() -> {
if (cancelled.get()) {
// Operation cancelled by user
return;
}
Tile tile = tileFactory.createTile(tileCoords.x, tileCoords.y);
dimension.addTile(tile);
if (progressReceiver != null) {
synchronized (tileCount) {
tileCount[0]++;
try {
progressReceiver.setProgress((float) tileCount[0] / totalTiles);
} catch (ProgressReceiver.OperationCancelled e) {
cancelled.set(true);
}
}
}
});
}
} else if (checkBoxCircular.isSelected()) {
final int radius = (Integer) spinnerWidth.getValue() / 2;
int diameter = radius * 2;
logger.info("Creating new circular dimension with diameter " + diameter + " blocks");
int tileRadius = (radius + 127) / 128;
final int[] tileCount = new int[1];
final int approximateTotalTiles = (int) Math.ceil(Math.PI * tileRadius * tileRadius);
for (int x = -tileRadius; x < tileRadius; x++) {
for (int y = -tileRadius; y < tileRadius; y++) {
if (org.pepsoft.worldpainter.util.MathUtils.getSmallestDistanceFromOrigin(x, y) < radius) {
// At least one corner is inside the circle; include
// the tile. Note that this is always correct in
// this case only because the centre of the circle
// is always at a tile intersection so the circle
// can never "bulge" into a tile without any of the
// the tile's corners being inside the circle
final int tileX = x, tileY = y;
executorService.execute(() -> {
if (cancelled.get()) {
// Operation cancelled by user
return;
}
Tile tile = tileFactory.createTile(tileX, tileY);
dimension.addTile(tile);
if (org.pepsoft.worldpainter.util.MathUtils.getLargestDistanceFromOrigin(tileX, tileY) >= radius) {
// the edge
for (int xx = 0; xx < TILE_SIZE; xx++) {
for (int yy = 0; yy < TILE_SIZE; yy++) {
float distance = MathUtils.getDistance(tileX * TILE_SIZE + xx + 0.5f, tileY * TILE_SIZE + yy + 0.5f);
if (distance > radius) {
tile.setBitLayerValue(org.pepsoft.worldpainter.layers.Void.INSTANCE, xx, yy, true);
}
}
}
}
if (progressReceiver != null) {
synchronized (tileCount) {
tileCount[0]++;
try {
// System.out.println("Progress: " + tileCount[0] + " of " + approximateTotalTiles + " (" + ((float) tileCount[0] / approximateTotalTiles) + ")");
progressReceiver.setProgress(Math.min((float) tileCount[0] / approximateTotalTiles, 1.0f));
} catch (ProgressReceiver.OperationCancelled e) {
cancelled.set(true);
}
}
}
});
}
}
}
// Assume the user will want an endless void border by default;
// override the preferences
dimension.setBorder(Border.ENDLESS_VOID);
} else {
int width = ((Integer) spinnerWidth.getValue()) / 128;
int height = ((Integer) spinnerLength.getValue()) / 128;
logger.info("Creating new dimension of size " + width + "x" + height + " for a total of " + width * height + " tiles");
final int[] tileCount = new int[1];
final int totalTiles = width * height;
int startX = -width / 2;
int startY = -height / 2;
for (int x = startX; x < startX + width; x++) {
for (int y = startY; y < startY + height; y++) {
final int tileX = x, tileY = y;
executorService.execute(() -> {
if (cancelled.get()) {
// Operation cancelled by user
return;
}
Tile tile = tileFactory.createTile(tileX, tileY);
dimension.addTile(tile);
if (progressReceiver != null) {
synchronized (tileCount) {
tileCount[0]++;
try {
progressReceiver.setProgress((float) tileCount[0] / totalTiles);
} catch (ProgressReceiver.OperationCancelled e) {
cancelled.set(true);
}
}
}
});
}
}
}
// Wait for all tiles to be created
executorService.shutdown();
try {
executorService.awaitTermination(1, TimeUnit.DAYS);
} catch (InterruptedException e) {
throw new RuntimeException("Thread interrupted", e);
}
if (cancelled.get()) {
// The operation was cancelled by the user
return null;
}
if (dim == DIM_NORMAL_CEILING) {
ResourcesExporter.ResourcesExporterSettings resourcesSettings = new ResourcesExporter.ResourcesExporterSettings(maxHeight);
// Invert min and max levels:
int maxZ = maxHeight - 1;
for (int blockType : resourcesSettings.getBlockTypes()) {
int low = resourcesSettings.getMinLevel(blockType);
int high = resourcesSettings.getMaxLevel(blockType);
resourcesSettings.setMinLevel(blockType, maxZ - high);
resourcesSettings.setMaxLevel(blockType, maxZ - low);
}
// Remove lava and water:
resourcesSettings.setChance(BLK_WATER, 0);
resourcesSettings.setChance(BLK_LAVA, 0);
dimension.setLayerSettings(Resources.INSTANCE, resourcesSettings);
} else if (dim == DIM_NETHER) {
dimension.setSubsurfaceMaterial(NETHERLIKE);
CavernsSettings cavernsSettings = new CavernsSettings();
cavernsSettings.setCavernsEverywhereLevel(16);
cavernsSettings.setSurfaceBreaking(true);
cavernsSettings.setFloodWithLava(true);
cavernsSettings.setWaterLevel(16);
dimension.setLayerSettings(Caverns.INSTANCE, cavernsSettings);
} else if (dim == DIM_NETHER_CEILING) {
dimension.setSubsurfaceMaterial(NETHERLIKE);
} else if ((dim == DIM_END) || (dim == DIM_END_CEILING)) {
dimension.setSubsurfaceMaterial(END_STONE);
}
Configuration config = Configuration.getInstance();
Dimension defaults = config.getDefaultTerrainAndLayerSettings();
if (dim == DIM_NORMAL) {
if (!checkBoxCircular.isSelected()) {
dimension.setBorder(defaults.getBorder());
dimension.setBorderSize(defaults.getBorderSize());
}
dimension.setBedrockWall(defaults.isBedrockWall());
dimension.setSubsurfaceMaterial(defaults.getSubsurfaceMaterial());
dimension.setPopulate(defaults.isPopulate());
dimension.setTopLayerMinDepth(defaults.getTopLayerMinDepth());
dimension.setTopLayerVariation(defaults.getTopLayerVariation());
dimension.setBottomless(defaults.isBottomless());
for (Map.Entry<Layer, ExporterSettings> entry : defaults.getAllLayerSettings().entrySet()) {
dimension.setLayerSettings(entry.getKey(), entry.getValue().clone());
}
}
dimension.setBorderLevel(waterHeight);
dimension.setCoverSteepTerrain(defaults.isCoverSteepTerrain());
dimension.setGridEnabled(config.isDefaultGridEnabled());
dimension.setGridSize(config.getDefaultGridSize());
dimension.setContoursEnabled(config.isDefaultContoursEnabled());
dimension.setContourSeparation(config.getDefaultContourSeparation());
} finally {
dimension.setEventsInhibited(false);
}
dimension.setDirty(false);
return dimension;
}
Aggregations