From 7d7d468b58626c9ca98461bf36e77dbac71886d6 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Mon, 25 Apr 2022 14:47:47 +0200 Subject: [PATCH] don't write all file if not requested --- .../kotlin/de/bixilon/pixlyzer/PixLyzer.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/de/bixilon/pixlyzer/PixLyzer.kt b/src/main/kotlin/de/bixilon/pixlyzer/PixLyzer.kt index 912b138..0c373f6 100644 --- a/src/main/kotlin/de/bixilon/pixlyzer/PixLyzer.kt +++ b/src/main/kotlin/de/bixilon/pixlyzer/PixLyzer.kt @@ -40,7 +40,7 @@ object PixLyzer { try { Class.forName("net.minecraft.DetectedVersion") - throw IllegalStateException("This branch only works with yarn mappings, not with mojangs!") + throw IllegalStateException("This branch only works with yarn mappings, not with mojangs!") } catch (exception: ClassNotFoundException) { } @@ -95,21 +95,16 @@ object PixLyzer { println("Done generating ${generator.name} in ${System.currentTimeMillis() - startTime}ms, generated ${generator.entries} entries.") } - - println("Writing all to file...") - - writData("${outputDirectory.absolutePath}/all", all) + println("Eventually writing all to file...") val tempFileOutputPath = System.getProperty("java.io.tmpdir") + "/" + UUID.randomUUID().toString() - val jsonHash = Util.saveHashFile(all.toJsonString().byteInputStream(), tempFileOutputPath, GZIPOutputStream(FileOutputStream(tempFileOutputPath)), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.gz") - - val mbfStream = ByteArrayOutputStream() - MBFBinaryWriter(mbfStream).writeMBF(MBFData(dataInfo = MBFDataInfo(compression = MBFCompressionTypes.ZSDT, preferVariableTypes = true, variableLengthPrefix = true, compressionLevel = 22), data = all)) - - val mbfHash = Util.saveHashFile(ByteArrayInputStream(mbfStream.toByteArray()), tempFileOutputPath, FileOutputStream(tempFileOutputPath), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.mbf") if (File(jsonAssetsIndex.absolutePath + ".json").exists()) { + writData("${outputDirectory.absolutePath}/all", all) + + val jsonHash = Util.saveHashFile(all.toJsonString().byteInputStream(), tempFileOutputPath, GZIPOutputStream(FileOutputStream(tempFileOutputPath)), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.gz") + val assetsIndexJson = Util.readJsonFile(jsonAssetsIndex.absolutePath + ".json") assetsIndexJson[versionId] = jsonHash @@ -120,6 +115,11 @@ object PixLyzer { } if (File(mbfAssetsIndex.absolutePath + ".json").exists()) { + val mbfStream = ByteArrayOutputStream() + MBFBinaryWriter(mbfStream).writeMBF(MBFData(dataInfo = MBFDataInfo(compression = MBFCompressionTypes.ZSDT, preferVariableTypes = true, variableLengthPrefix = true, compressionLevel = 22), data = all)) + + val mbfHash = Util.saveHashFile(ByteArrayInputStream(mbfStream.toByteArray()), tempFileOutputPath, FileOutputStream(tempFileOutputPath), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.mbf") + val assetsIndexData = Util.readJsonFile(mbfAssetsIndex.absolutePath + ".json")