Search in sources :

Example 11 with MixedMaterial

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;
}
Also used : JavaWorldExporter(org.pepsoft.worldpainter.exporting.JavaWorldExporter) ProgressReceiver(org.pepsoft.util.ProgressReceiver) IOException(java.io.IOException) File(java.io.File) MixedMaterial(org.pepsoft.worldpainter.MixedMaterial)

Example 12 with MixedMaterial

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;
}
Also used : MixedMaterial(org.pepsoft.worldpainter.MixedMaterial)

Example 13 with MixedMaterial

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();
}
Also used : Terrain(org.pepsoft.worldpainter.Terrain) MixedMaterial(org.pepsoft.worldpainter.MixedMaterial)

Aggregations

MixedMaterial (org.pepsoft.worldpainter.MixedMaterial)13 Terrain (org.pepsoft.worldpainter.Terrain)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Material (org.pepsoft.minecraft.Material)2 CustomLayer (org.pepsoft.worldpainter.layers.CustomLayer)2 Layer (org.pepsoft.worldpainter.layers.Layer)2 Point (java.awt.Point)1 FileInputStream (java.io.FileInputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Random (java.util.Random)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 JFrame (javax.swing.JFrame)1 TreePath (javax.swing.tree.TreePath)1 Point3i (javax.vecmath.Point3i)1 ProgressReceiver (org.pepsoft.util.ProgressReceiver)1 TiledImageViewer (org.pepsoft.util.swing.TiledImageViewer)1