-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
kotlin { | ||
jvmToolchain(21) | ||
} | ||
|
||
repositories { | ||
maven("https://maven.neoforged.net/releases/") | ||
maven("https://libraries.minecraft.net/") | ||
} | ||
|
||
dependencies { | ||
shade("net.neoforged.fancymodloader:loader:4.0.29") { isTransitive = false } | ||
|
||
implementation("com.google.guava:guava:32.1.2-jre") | ||
implementation("org.apache.maven:maven-artifact:3.8.1") | ||
implementation("com.electronwill.night-config:core:3.7.3") | ||
implementation("com.electronwill.night-config:toml:3.7.3") | ||
implementation("org.apache.logging.log4j:log4j-api:2.22.1") | ||
implementation("org.apache.logging.log4j:log4j-core:2.22.1") | ||
implementation("org.slf4j:slf4j-api:2.0.16") | ||
implementation("com.google.code.gson:gson:2.11.0") | ||
|
||
implementation("com.mojang:logging:1.2.7") { isTransitive = false } | ||
implementation("cpw.mods:modlauncher:11.0.3") { isTransitive = false } | ||
implementation("cpw.mods:securejarhandler:3.0.7") { isTransitive = false } | ||
implementation("net.neoforged:JarJarFileSystems:0.4.1") { isTransitive = false } | ||
implementation("net.neoforged:JarJarMetadata:0.4.1") { isTransitive = false } | ||
implementation("net.neoforged:JarJarSelector:0.4.1") { isTransitive = false } | ||
implementation("net.neoforged:mergetool:2.0.0:api") | ||
} | ||
|
||
tasks.shadowJar { | ||
exclude("log4j2*") | ||
exclude("META-INF/org/apache/logging/**") | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
from(components["java"]) | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...esolver-neoforge/src/main/kotlin/lol/bai/explosion/resolver/neoforge/FakeLaunchContext.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package lol.bai.explosion.resolver.neoforge | ||
|
||
import net.neoforged.fml.loading.moddiscovery.locators.JarInJarDependencyLocator | ||
import net.neoforged.fml.loading.moddiscovery.locators.ModsFolderLocator | ||
import net.neoforged.fml.loading.moddiscovery.readers.JarModsDotTomlModFileReader | ||
import net.neoforged.fml.loading.moddiscovery.readers.NestedLibraryModReader | ||
import net.neoforged.neoforgespi.ILaunchContext | ||
import net.neoforged.neoforgespi.locating.IDependencyLocator | ||
import net.neoforged.neoforgespi.locating.IModFileCandidateLocator | ||
import net.neoforged.neoforgespi.locating.IModFileReader | ||
import java.nio.file.Path | ||
import java.util.* | ||
import java.util.stream.Stream | ||
|
||
class FakeLaunchContext( | ||
private val modsFolder: Path | ||
) : ILaunchContext { | ||
@Suppress("NOTHING_TO_INLINE") | ||
private inline fun unsupported(): Nothing { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
override fun environment() = unsupported() | ||
override fun modLists() = unsupported() | ||
override fun mods() = unsupported() | ||
override fun mavenRoots() = unsupported() | ||
|
||
override fun isLocated(p0: Path) = false | ||
override fun addLocated(p0: Path) = true | ||
|
||
override fun <T : Any?> loadServices(service: Class<T>): Stream<ServiceLoader.Provider<T>> { | ||
return when (service) { | ||
IModFileCandidateLocator::class.java -> Stream.of( | ||
Fake(ModsFolderLocator(modsFolder, "explosion!!!")) | ||
) | ||
|
||
IModFileReader::class.java -> Stream.of( | ||
Fake(JarModsDotTomlModFileReader()), | ||
Fake(NestedLibraryModReader()) | ||
) | ||
|
||
IDependencyLocator::class.java -> Stream.of( | ||
Fake(JarInJarDependencyLocator()) | ||
) | ||
|
||
else -> unsupported() | ||
} | ||
} | ||
} | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
private class Fake<T>(val instance: Any) : ServiceLoader.Provider<T> { | ||
override fun get() = instance as T | ||
override fun type() = instance::class.java as Class<T> | ||
} |
62 changes: 62 additions & 0 deletions
62
explosion-resolver-neoforge/src/main/kotlin/lol/bai/explosion/resolver/neoforge/Main.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package lol.bai.explosion.resolver.neoforge | ||
|
||
import net.neoforged.fml.loading.ImmediateWindowHandler | ||
import net.neoforged.fml.loading.moddiscovery.ModDiscoverer | ||
import net.neoforged.fml.loading.moddiscovery.ModFile | ||
import net.neoforged.fml.loading.moddiscovery.ModValidator | ||
import net.neoforged.fml.loading.progress.ProgressMeter | ||
import net.neoforged.fml.loading.progress.StartupNotificationManager | ||
import java.lang.invoke.MethodHandles | ||
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 | ||
|
||
@Suppress("UnstableApiUsage") | ||
fun main(args: Array<String>) { | ||
val (inputDirStr, outputDirStr) = args | ||
val inputDir = Path(inputDirStr) | ||
val outputDir = Path(outputDirStr) | ||
|
||
@Suppress("LocalVariableName") | ||
run { | ||
val ImmediateWindowHandler = ImmediateWindowHandler::class.java | ||
val ProgressMeter = ProgressMeter::class.java | ||
|
||
MethodHandles | ||
.privateLookupIn(ImmediateWindowHandler, MethodHandles.lookup()) | ||
.findStaticVarHandle(ImmediateWindowHandler, "earlyProgress", ProgressMeter) | ||
.set(StartupNotificationManager.addProgressBar("explosion!!!", 0)) | ||
} | ||
|
||
val discoverer = ModDiscoverer(FakeLaunchContext(inputDir)) | ||
val validator = discoverer.discoverMods() | ||
|
||
@Suppress("LocalVariableName", "UNCHECKED_CAST") | ||
val candidateMods = validator.run { | ||
val ModValidator = ModValidator::class.java | ||
val List = List::class.java | ||
|
||
MethodHandles | ||
.privateLookupIn(ModValidator, MethodHandles.lookup()) | ||
.findVarHandle(ModValidator, "candidateMods", List) | ||
.get(this) as List<ModFile> | ||
} | ||
|
||
val meta = StringBuilder() | ||
for (modFile in candidateMods) { | ||
val mod = modFile.modInfos.firstOrNull() ?: continue | ||
val path = outputDir.resolve("${mod.modId}-${mod.version}") | ||
Files.copy(modFile.filePath.inputStream(), path, StandardCopyOption.REPLACE_EXISTING) | ||
meta.append(path.name) | ||
.append("\t") | ||
.append(mod.modId) | ||
.append("\t") | ||
.append(mod.version) | ||
.append("\n") | ||
} | ||
|
||
outputDir.resolve("__meta.txt").writeText(meta.toString()) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
plugins { | ||
id 'net.neoforged.moddev' version '1.0.17' | ||
id 'lol.bai.explosion' | ||
} | ||
|
||
neoForge { | ||
version = "21.1.58" | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "https://cursemaven.com" | ||
content { | ||
includeGroup "curse.maven" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation explosion.neoforge("curse.maven:ender-io-64578:5720393") | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
gradlePluginPortal() | ||
maven { url = 'https://maven.neoforged.net/releases' } | ||
} | ||
} | ||
|
||
includeBuild ".." |
This file contains 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