-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
9a0151e
commit 0885d10
Showing
127 changed files
with
254,060 additions
and
91 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
122 changes: 62 additions & 60 deletions
122
buildSrc/src/main/groovy/net/minecraftforge/mcpconfig/tasks/DownloadAssets.groovy
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 |
---|---|---|
@@ -1,70 +1,72 @@ | ||
package net.minecraftforge.mcpconfig.tasks | ||
|
||
import org.gradle.api.* | ||
import org.gradle.api.file.* | ||
import org.gradle.api.tasks.* | ||
import de.undercouch.gradle.tasks.download.* | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.ConfigurableFileCollection | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFiles | ||
import org.gradle.api.tasks.OutputFile | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.jvm.toolchain.JavaToolchainService | ||
import org.gradle.process.ExecOperations | ||
import org.gradle.work.DisableCachingByDefault | ||
|
||
public abstract class DownloadAssets extends DefaultTask { | ||
@InputFile abstract RegularFileProperty getJson() | ||
@OutputDirectory abstract RegularFileProperty getDest() | ||
@Internal DownloadAction indexAction | ||
@Internal DownloadAction assetAction | ||
import javax.inject.Inject | ||
|
||
DownloadAssets() { | ||
indexAction = new DownloadAction(project, this) | ||
indexAction.onlyIfModified(true) | ||
indexAction.useETag('all') | ||
assetAction = new DownloadAction(project, this) | ||
assetAction.overwrite(false) | ||
assetAction.useETag('all') | ||
} | ||
|
||
@TaskAction | ||
def exec() { | ||
Utils.init() | ||
|
||
def dl = json.get().getAsFile().json.assetIndex | ||
def index = new File(dest.get().getAsFile(), 'indexes/' + dl.id + '.json') | ||
if (index.sha1 != dl.sha1) { | ||
indexAction.src dl.url | ||
indexAction.dest index | ||
indexAction.execute().join() | ||
} | ||
|
||
def assets = [] as Set // Some assets are copies of other assets | ||
@DisableCachingByDefault(because = "has its own caching") | ||
abstract class DownloadAssets extends DefaultTask { | ||
/** | ||
* Writes a JSON file detailing the path to the asset index and asset root. | ||
*/ | ||
@OutputFile | ||
abstract RegularFileProperty getAssetJson() | ||
|
||
/** | ||
* Points to the single executable jar for | ||
* https://projects.neoforged.net/neoforged/neoformruntime | ||
*/ | ||
@InputFiles | ||
abstract ConfigurableFileCollection getNfrt(); | ||
|
||
assetAction.dest(new File(dest.get().getAsFile(), 'objects')) | ||
index.json.objects.each { asset -> | ||
def key = asset.value.hash.take(2) + '/' + asset.value.hash | ||
def target = new File(dest.get().getAsFile(), 'objects/' + key) | ||
if (!target.exists() && assets.add(asset.value.hash)) { | ||
assetAction.src('https://resources.download.minecraft.net/' + key) | ||
} | ||
} | ||
/** | ||
* The Minecraft version matching the NeoForge version to install. | ||
*/ | ||
@Input | ||
abstract Property<String> getMinecraftVersion(); | ||
|
||
if (assets.size() > 1) { | ||
assetAction.eachFile(new Action<DownloadDetails>() { | ||
@Override | ||
public void execute(DownloadDetails details) { | ||
details.relativePath = new RelativePath(false, details.sourceURL.toString().replace('https://resources.download.minecraft.net/', '')) | ||
} | ||
}) | ||
} else if (assets.size() == 1) { | ||
assetAction.dest(new File(dest.get().getAsFile(), 'objects/' + assets[0].take(2) + '/' + assets[0])) | ||
} | ||
@Inject | ||
abstract ExecOperations getExecOperations(); | ||
|
||
if (!assets.isEmpty()) { | ||
assetAction.execute() | ||
} | ||
@Inject | ||
abstract JavaToolchainService getJavaToolchainService(); | ||
|
||
@Input | ||
abstract Property<String> getJavaExecutable(); | ||
|
||
DownloadAssets() { | ||
// Run NFRT with Java 21 | ||
getJavaExecutable().set( | ||
getJavaToolchainService() | ||
.launcherFor { spec -> spec.languageVersion = JavaLanguageVersion.of(21) } | ||
.map { it.executablePath.asFile.absolutePath } | ||
) | ||
} | ||
|
||
def download(def url, def target) { | ||
def ret = new DownloadAction(project, this) | ||
ret.overwrite(false) | ||
ret.useETag('all') | ||
ret.src url | ||
ret.dest target | ||
ret.execute() | ||
@TaskAction | ||
def exec() { | ||
// Download Minecraft Assets and write asset index and location to JSON file to read back for starting the game | ||
execOperations.javaexec(spec -> { | ||
spec.executable = getJavaExecutable().get() | ||
spec.classpath(getNfrt().getSingleFile()); | ||
spec.args( | ||
"download-assets", | ||
"--minecraft-version", | ||
minecraftVersion.get(), | ||
"--write-json", | ||
assetJson.get().asFile.getAbsolutePath() | ||
); | ||
}); | ||
} | ||
} | ||
} |
Binary file not shown.
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,39 @@ | ||
{ | ||
"official": true, | ||
"merge_patches": true, | ||
"java_target": 21, | ||
"encoding": "UTF-8", | ||
"test_remap_official": false, | ||
"fernflower": { | ||
"version": "org.vineflower:vineflower:1.10.1", | ||
"java_version": 21, | ||
"args": ["--decompile-inner", "--remove-bridge", "--decompile-generics", "--ascii-strings", "--remove-synthetic", "--include-classpath", "--variable-renaming=jad", "--ignore-invalid-bytecode", "--bytecode-source-mapping", "--dump-code-lines", "--indent-string= ", "--log-level=TRACE", "-cfg", "{libraries}", "{input}", "{output}"], | ||
"jvmargs": ["-Xmx4G"] | ||
}, | ||
"merge": { | ||
"version": "net.neoforged:mergetool:2.0.3:fatjar", | ||
"args": ["--client", "{client}", "--server", "{server}", "--ann", "{version}", "--output", "{output}", "--inject", "false"], | ||
"jvmargs": [] | ||
}, | ||
"rename": { | ||
"version": "net.neoforged:AutoRenamingTool:2.0.4:all", | ||
"args": ["--input", "{input}", "--output", "{output}", "--map", "{mappings}", "--cfg", "{libraries}", "--ann-fix", "--ids-fix", "--src-fix", "--record-fix", "--unfinal-params"] | ||
}, | ||
"bundler_extract_jar": { | ||
"version": "net.neoforged.installertools:installertools:2.1.2:fatjar", | ||
"args": ["--task", "bundler_extract", "--input", "{input}", "--output", "{output}", "--jar-only"] | ||
}, | ||
"bundler_extract_libs": { | ||
"version": "net.neoforged.installertools:installertools:2.1.2:fatjar", | ||
"args": ["--task", "bundler_extract", "--input", "{input}", "--output", "{output}", "--libraries"] | ||
}, | ||
"mergemap": { | ||
"version": "net.neoforged.installertools:installertools:2.1.2:fatjar", | ||
"args": ["--task", "MERGE_MAPPING", "--left", "{mappings}", "--right", "{official}", "--right-names", "right,left", "--classes", "--fields", "--methods", "--output", "{output}"] | ||
}, | ||
"libraries": { | ||
"client": ["com.google.code.findbugs:jsr305:3.0.2", "ca.weblite:java-objc-bridge:1.1", "org.jetbrains:annotations:26.0.1"], | ||
"server": ["com.google.code.findbugs:jsr305:3.0.2", "org.jetbrains:annotations:26.0.1"], | ||
"joined": ["com.google.code.findbugs:jsr305:3.0.2", "ca.weblite:java-objc-bridge:1.1", "net.neoforged:mergetool:2.0.3:api", "org.jetbrains:annotations:26.0.1"] | ||
} | ||
} |
Oops, something went wrong.