use of com.sk89q.worldedit.extent.Extent in project FunnyGuilds by FunnyGuilds.
the class SchematicHelper method pasteSchematic.
public static boolean pasteSchematic(File schematicFile, Location location, boolean withAir) {
try {
Vector pasteLocation = new Vector(location.getX(), location.getY(), location.getZ());
World pasteWorld = new BukkitWorld(location.getWorld());
WorldData pasteWorldData = pasteWorld.getWorldData();
Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematicFile)).read(pasteWorldData);
Region pasteRegion = clipboard.getRegion();
Extent pasteExtent = WorldEdit.getInstance().getEditSessionFactory().getEditSession(pasteWorld, -1);
AffineTransform transform = new AffineTransform();
ForwardExtentCopy copy = new ForwardExtentCopy(pasteExtent, pasteRegion, clipboard.getOrigin(), pasteExtent, pasteLocation);
if (!transform.isIdentity()) {
copy.setTransform(transform);
}
if (!withAir) {
copy.setSourceMask(new ExistingBlockMask(clipboard));
}
Operations.completeLegacy(copy);
return true;
} catch (IOException | MaxChangedBlocksException e) {
FunnyLogger.exception(e);
return false;
}
}
Aggregations