use of org.pepsoft.worldpainter.MixedMaterial in project WorldPainter by Captain-Chaos.
the class ExportWorldOp method go.
@Override
public Void go() throws ScriptException {
goCalled();
// not exported before)
if (world.getPlatform() == null) {
world.setPlatform((world.getMaxHeight() == DEFAULT_MAX_HEIGHT_2) ? DefaultPlugin.JAVA_ANVIL : DefaultPlugin.JAVA_MCREGION);
}
// Load any custom materials defined in the world
for (int i = 0; i < Terrain.CUSTOM_TERRAIN_COUNT; i++) {
MixedMaterial material = world.getMixedMaterial(i);
Terrain.setCustomMaterial(i, material);
}
// Select and create (if necessary) the backups directory
File baseDir = new File(directory);
if (!baseDir.isDirectory()) {
throw new ScriptException("Directory " + directory + " does not exist or is not a directory");
}
File worldDir = new File(baseDir, FileUtils.sanitiseName(world.getName()));
JavaWorldExporter exporter = new JavaWorldExporter(world);
try {
File backupDir = exporter.selectBackupDir(worldDir);
// Export the world
exporter.export(baseDir, world.getName(), backupDir, null);
} catch (ProgressReceiver.OperationCancelled e) {
// Can never happen since we don't pass a progress receiver in
throw new InternalError();
} catch (IOException e) {
throw new ScriptException("I/O error while exporting world", e);
}
return null;
}
use of org.pepsoft.worldpainter.MixedMaterial in project WorldPainter by Captain-Chaos.
the class MergeWorldOp method go.
// TODO
@Override
public Void go() throws ScriptException {
goCalled();
// not exported before)
if (world.getPlatform() == null) {
world.setPlatform((world.getMaxHeight() == DEFAULT_MAX_HEIGHT_2) ? DefaultPlugin.JAVA_ANVIL : DefaultPlugin.JAVA_MCREGION);
}
// Load any custom materials defined in the world
for (int i = 0; i < Terrain.CUSTOM_TERRAIN_COUNT; i++) {
MixedMaterial material = world.getMixedMaterial(i);
Terrain.setCustomMaterial(i, material);
}
return null;
}
use of org.pepsoft.worldpainter.MixedMaterial in project WorldPainter by Captain-Chaos.
the class UndergroundPocketsDialog method ok.
@Override
protected void ok() {
String name = fieldName.getText();
MixedMaterial material = radioButtonCustomMaterial.isSelected() ? mixedMaterialChooser.getMaterial() : null;
if (material != null) {
// Make sure the material is registered, in case it's new
material = MixedMaterialManager.getInstance().register(material);
}
Terrain terrain = radioButtonTerrain.isSelected() ? (Terrain) comboBoxTerrain.getSelectedItem() : null;
int occurrence = (Integer) spinnerOccurrence.getValue();
int scale = (Integer) spinnerScale.getValue();
int minLevel = (Integer) spinnerMinLevel.getValue();
int maxLevel = (Integer) spinnerMaxLevel.getValue();
if (layer == null) {
layer = new UndergroundPocketsLayer(name, material, terrain, occurrence, minLevel, maxLevel, scale, selectedColour);
} else {
layer.setName(name);
layer.setColour(selectedColour);
layer.setMaterial(material);
layer.setTerrain(terrain);
layer.setFrequency(occurrence);
layer.setMinLevel(minLevel);
layer.setMaxLevel(maxLevel);
layer.setScale(scale);
}
super.ok();
}
Aggregations