Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Robijnvogel/ea0b13db92e0c22384b357a5b0d87927 to your computer and use it in GitHub Desktop.
Save Robijnvogel/ea0b13db92e0c22384b357a5b0d87927 to your computer and use it in GitHub Desktop.
public void saveSchematic(Schematic schematic, String name) {
NBTTagCompound schematicNBT = Schematic.saveToNBT(schematic);
File saveFolder = new File(DDConfig.configurationFolder, "/Schematics/Saved");
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
File saveFile = new File(saveFolder.getAbsolutePath() + "/" + name + ".schem");
try {
saveFile.createNewFile();
GZIPOutputStream schematicZipStream = new GZIPOutputStream(new FileOutputStream(saveFile));
CompressedStreamTools.write(schematicNBT, new DataOutputStream(schematicZipStream));
saveFile.createNewFile();
} catch (IOException ex) {
Logger.getLogger(SchematicHandler.class.getName()).log(Level.SEVERE, null, ex);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment