Search in sources :

Example 1 with BuiltInClipboardFormat

use of com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat in project Histeria by zelytra.

the class LuckyBlock method WEgenerate.

private void WEgenerate(World world, String fileName, double locX, double locY, double locZ) {
    // Load the file selected
    InputStream is = Histeria.getInstance().getResource("luckyBlock/" + fileName + ".schem");
    BuiltInClipboardFormat format = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
    Clipboard clipboard = null;
    try (ClipboardReader reader = format.getReader(is)) {
        clipboard = reader.read();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1)) {
        Operation operation = new ClipboardHolder(clipboard).createPaste(editSession).to(BlockVector3.at(locX, locY, locZ)).ignoreAirBlocks(true).build();
        Operations.complete(operation);
    } catch (WorldEditException e) {
        e.printStackTrace();
    }
}
Also used : ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) InputStream(java.io.InputStream) BuiltInClipboardFormat(com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) IOException(java.io.IOException) EditSession(com.sk89q.worldedit.EditSession) Operation(com.sk89q.worldedit.function.operation.Operation) ClipboardReader(com.sk89q.worldedit.extent.clipboard.io.ClipboardReader) WorldEditException(com.sk89q.worldedit.WorldEditException)

Aggregations

EditSession (com.sk89q.worldedit.EditSession)1 WorldEditException (com.sk89q.worldedit.WorldEditException)1 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)1 BuiltInClipboardFormat (com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat)1 ClipboardReader (com.sk89q.worldedit.extent.clipboard.io.ClipboardReader)1 Operation (com.sk89q.worldedit.function.operation.Operation)1 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1