From 2e86ccb558cb017d9bd8ec5e3a7e41aa2c609510 Mon Sep 17 00:00:00 2001 From: NoobSex <61795895+SpartanB312@users.noreply.github.com> Date: Tue, 9 Jul 2024 00:42:11 +0800 Subject: [PATCH] Fixed class dump for missing dependencies --- .../main/kotlin/net/spartanb312/grunt/config/Configs.kt | 2 +- .../spartanb312/grunt/process/resource/ResourceCache.kt | 8 +++++--- .../transformers/redirect/InvokeDynamicTransformer.kt | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/grunt-main/src/main/kotlin/net/spartanb312/grunt/config/Configs.kt b/grunt-main/src/main/kotlin/net/spartanb312/grunt/config/Configs.kt index 2679074..7887567 100644 --- a/grunt-main/src/main/kotlin/net/spartanb312/grunt/config/Configs.kt +++ b/grunt-main/src/main/kotlin/net/spartanb312/grunt/config/Configs.kt @@ -20,7 +20,7 @@ object Configs { val mixinPackages by setting("MixinPackage", listOf("net/spartanb312/client/mixins/")) val generateRemap by setting("DumpMappings", true) val remapOutput by setting("MappingsOutput", "mappings.json") - val parallel by setting("ParallelProcessing", false) + val useComputeMax by setting("UseComputeMax", false) val customDictionary by setting("CustomDictionary", listOf()) val dictionaryStartIndex by setting("DictionaryStartIndex", 0) val corruptOutput by setting("CorruptOutput", false) diff --git a/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/resource/ResourceCache.kt b/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/resource/ResourceCache.kt index 483dbf0..8bf26fb 100644 --- a/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/resource/ResourceCache.kt +++ b/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/resource/ResourceCache.kt @@ -90,14 +90,16 @@ class ResourceCache(private val input: String, private val libs: List) { Logger.info("Writing classes...") for (classNode in classes.values) { if (classNode.name == "module-info" || classNode.name.shouldRemove) continue + val classInfo = hierarchy.getClassInfo(classNode) + val useComputeMax = Configs.Settings.useComputeMax || classInfo.missingDependencies || classNode.isExcluded val byteArray = try { - ClassDumper(this@ResourceCache, hierarchy, false).apply { + ClassDumper(this@ResourceCache, hierarchy, useComputeMax).apply { classNode.accept(this) }.toByteArray() } catch (ignore: Exception) { - Logger.error("Failed to dump class ${classNode.name}. Force use COMPUTE_MAXS") + Logger.error("Failed to dump class ${classNode.name}. Trying ${if (useComputeMax) "COMPUTE_FRAMES" else "COMPUTE_MAXS"}") try { - ClassDumper(this@ResourceCache, hierarchy, true).apply { + ClassDumper(this@ResourceCache, hierarchy, !useComputeMax).apply { classNode.accept(this) }.toByteArray() } catch (exception: Exception) { diff --git a/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/transformers/redirect/InvokeDynamicTransformer.kt b/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/transformers/redirect/InvokeDynamicTransformer.kt index 80a5986..91c573e 100644 --- a/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/transformers/redirect/InvokeDynamicTransformer.kt +++ b/grunt-main/src/main/kotlin/net/spartanb312/grunt/process/transformers/redirect/InvokeDynamicTransformer.kt @@ -29,7 +29,7 @@ import kotlin.random.Random object InvokeDynamicTransformer : Transformer("InvokeDynamic", Category.Redirect) { private val rate by setting("ReplacePercentage", 10) - private val massiveRandom by setting("MassiveRandomBlank", true) + private val massiveRandom by setting("MassiveRandomBlank", false) private val exclusion by setting("Exclusion", listOf()) override fun ResourceCache.transform() {