Advertisement
Guest User

Untitled

a guest
Sep 30th, 2017
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1.     public void takeSnapShot(Resident resident) throws IOException {
  2.  
  3.         Vector loc1 = new Vector(chunk.getX()*16, 0, chunk.getZ()*16);
  4.         Vector loc2 = new Vector(chunk.getX()*16+15,256,chunk.getZ()*16+15);
  5.         Region region =  new CuboidRegion(loc1, loc2);
  6.  
  7.         File file = new File("plugins/WorldEdit/schematics", chunk.getX() + "_" + chunk.getZ() + ".schematic");
  8.  
  9.         SchematicHelper.saveSchematic(region,chunk.getWorld(),file);
  10.  
  11.  
  12.     }
  13.  
  14. public class SchematicHelper {
  15.  
  16.     public static void saveSchematic(Region region, org.bukkit.World world, File file) throws IOException {
  17.  
  18.         World weWorld = new BukkitWorld(world);
  19.         WorldData worldData = weWorld.getWorldData();
  20.  
  21.  
  22.         region.setWorld(weWorld);
  23.  
  24.         BlockArrayClipboard blockArrayClipboard = new BlockArrayClipboard(region);
  25.  
  26.         file.createNewFile();
  27.  
  28.  
  29.         System.out.println(region.getWorld().getName());
  30.         System.out.println(region.getMinimumPoint().toString() + " pos1");
  31.  
  32.         Closer closer = Closer.create();
  33.  
  34.         FileOutputStream fos = closer.register(new FileOutputStream(file));
  35.         BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
  36.         ClipboardWriter writer = closer.register(ClipboardFormat.SCHEMATIC.getWriter(bos));
  37.         writer.write(blockArrayClipboard, worldData);
  38.         closer.close();
  39.  
  40.     }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement