Skip to content

Commit

Permalink
[neo]forge: also resolve library jij
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Sep 26, 2024
1 parent 632d363 commit 7f13d99
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import net.minecraftforge.fml.loading.UniqueModListBuilder
import net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator
import net.minecraftforge.fml.loading.moddiscovery.ModFile
import net.minecraftforge.fml.loading.moddiscovery.createModsFolderLocator
import net.minecraftforge.forgespi.locating.IModFile
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import kotlin.io.path.Path
import kotlin.io.path.inputStream
import kotlin.io.path.name
import kotlin.io.path.writeText
import kotlin.jvm.optionals.getOrNull

@Suppress("UnstableApiUsage")
fun main(args: Array<String>) {
Expand All @@ -28,17 +28,22 @@ fun main(args: Array<String>) {
val meta = StringBuilder()
val uniqueModFiles = UniqueModListBuilder(combinedModFiles)
.buildUniqueList().modFiles
.filter { it.type == IModFile.Type.MOD }

for (modFile in uniqueModFiles) {
val mod = modFile.modInfos[0]
val path = outputDir.resolve("${mod.modId}-${mod.version}")
val jar = modFile.secureJar.moduleDataProvider().descriptor()
val mod = modFile.modInfos.firstOrNull()

val id = mod?.modId ?: jar.name()
val version = mod?.version ?: jar.rawVersion().getOrNull()
if (version == null) continue

val path = outputDir.resolve("${id}-${version}")
Files.copy(modFile.filePath.inputStream(), path, StandardCopyOption.REPLACE_EXISTING)
meta.append(path.name)
.append("\t")
.append(mod.modId)
.append(id)
.append("\t")
.append(mod.version)
.append(version)
.append("\n")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlin.io.path.Path
import kotlin.io.path.inputStream
import kotlin.io.path.name
import kotlin.io.path.writeText
import kotlin.jvm.optionals.getOrNull

@Suppress("UnstableApiUsage")
fun main(args: Array<String>) {
Expand Down Expand Up @@ -47,14 +48,20 @@ fun main(args: Array<String>) {

val meta = StringBuilder()
for (modFile in candidateMods) {
val mod = modFile.modInfos.firstOrNull() ?: continue
val path = outputDir.resolve("${mod.modId}-${mod.version}")
val jar = modFile.secureJar.moduleDataProvider().descriptor()
val mod = modFile.modInfos.firstOrNull()

val id = mod?.modId ?: jar.name()
val version = mod?.version ?: jar.rawVersion().getOrNull()
if (version == null) continue

val path = outputDir.resolve("${id}-${version}")
Files.copy(modFile.filePath.inputStream(), path, StandardCopyOption.REPLACE_EXISTING)
meta.append(path.name)
.append("\t")
.append(mod.modId)
.append(id)
.append("\t")
.append(mod.version)
.append(version)
.append("\n")
}

Expand Down

0 comments on commit 7f13d99

Please sign in to comment.