Created
April 11, 2016 06:39
-
-
Save StillManic/03e9ba79b7cb44887b3463ec53e940ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean saveTemplateToFile(MinecraftServer server, ResourceLocation id) { | |
if (this.blocks == null || this.blocks.isEmpty()) return false; | |
File file = server.getFile("templates"); | |
if ((!file.exists() && !file.mkdirs()) || !file.isDirectory()) return false; | |
file = new File(file, id.getResourcePath()); | |
NBTTagCompound compound = new NBTTagCompound(); | |
OutputStream outputStream = null; | |
boolean success; | |
try { | |
FMLLog.info(file.getAbsolutePath()); | |
this.write(compound); | |
outputStream = new FileOutputStream(file); | |
CompressedStreamTools.writeCompressed(compound, outputStream); | |
return true; | |
} catch (Throwable throwable) { | |
success = false; | |
} finally { | |
IOUtils.closeQuietly(outputStream); | |
} | |
return success; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment