mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16defac82e | ||
|
|
16483d4ea1 | ||
|
|
28909812bb | ||
|
|
e5580b84b7 | ||
|
|
607ca5beea | ||
|
|
744906e33a | ||
|
|
c1557ec3c2 | ||
|
|
4ac1a3dedf | ||
|
|
a26f952212 | ||
|
|
83ee68c0b0 | ||
|
|
a5ff932125 | ||
|
|
0d820eddd4 | ||
|
|
83c651ce39 | ||
|
|
7cd88944d4 | ||
|
|
dff52ecd71 | ||
|
|
da34d97d9d | ||
|
|
a27405b8d1 | ||
|
|
7a443276a5 | ||
|
|
e34090c809 | ||
|
|
72e8ae252c | ||
|
|
347c480bdc | ||
|
|
e0b9474621 | ||
|
|
8ad1e899a3 | ||
|
|
3b6bb5edbc | ||
|
|
c4e7d694c1 | ||
|
|
e00de1a326 | ||
|
|
e9ee999558 | ||
|
|
a1aacf25fe | ||
|
|
0c2f3e5523 | ||
|
|
a6978cffbf | ||
|
|
2332ecf984 | ||
|
|
9cd73c84a6 | ||
|
|
ab544a78d3 | ||
|
|
5b0abf97c8 | ||
|
|
587b684035 | ||
|
|
90dafb0df0 | ||
|
|
aff05a4cf3 | ||
|
|
1ddac54256 | ||
|
|
fcf9088aa5 | ||
|
|
374dbc7a4b | ||
|
|
d25ba7adc8 | ||
|
|
05c88ae33a | ||
|
|
e2d564d32a | ||
|
|
225092130e | ||
|
|
eefca22aa3 | ||
|
|
19bbb88e52 | ||
|
|
18886e5128 | ||
|
|
47dfa83cff | ||
|
|
0940c532f2 | ||
|
|
d80f106140 |
No files matched your search
+3
-3
@@ -34,9 +34,9 @@
|
|||||||
/projects/**/run/
|
/projects/**/run/
|
||||||
/projects/**/*.launch
|
/projects/**/*.launch
|
||||||
/repo/
|
/repo/
|
||||||
src/generated/resources/.cache/
|
src/generated/resources/**/.cache/
|
||||||
src/generated_test/resources/.cache/
|
src/generated_test/resources/**/.cache/
|
||||||
src/generated_mdk/resources/.cache/
|
src/generated_mdk/resources/**/.cache/
|
||||||
|
|
||||||
#Patch rejects
|
#Patch rejects
|
||||||
#/patches-/
|
#/patches-/
|
||||||
|
|||||||
+244
-466
File diff suppressed because it is too large.
Load diff
@@ -1,73 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.Optional
|
|
||||||
import org.gradle.api.tasks.OutputFile
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
import java.util.zip.ZipEntry
|
|
||||||
import java.util.zip.ZipInputStream
|
|
||||||
import java.util.zip.ZipOutputStream
|
|
||||||
|
|
||||||
abstract class Crowdin extends DefaultTask {
|
|
||||||
@Input abstract Property<String> getId()
|
|
||||||
@Input @Optional abstract Property<String> getKey()
|
|
||||||
@Input boolean json = true
|
|
||||||
@OutputFile abstract RegularFileProperty getOutput()
|
|
||||||
@OutputFile abstract RegularFileProperty getExport()
|
|
||||||
|
|
||||||
Crowdin() {
|
|
||||||
outputs.upToDateWhen{ false }
|
|
||||||
id.convention('minecraft-forge')
|
|
||||||
output.convention(project.layout.buildDirectory.dir(name).map {it.file("output.zip") })
|
|
||||||
export.convention(project.layout.buildDirectory.dir(name).map {it.file("export.json") })
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
def run() {
|
|
||||||
File outputFile = output.get().asFile
|
|
||||||
File exportFile = export.get().asFile
|
|
||||||
if (outputFile.exists())
|
|
||||||
outputFile.delete()
|
|
||||||
|
|
||||||
if (!key.isPresent())
|
|
||||||
return
|
|
||||||
String key = this.key.get()
|
|
||||||
String id = this.id.get()
|
|
||||||
|
|
||||||
// Force an export
|
|
||||||
new URL("https://api.crowdin.com/api/project/${id}/export?key=${key}").withInputStream { i ->
|
|
||||||
exportFile.withOutputStream { it << i }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!exportFile.text.contains('success')) {
|
|
||||||
throw new RuntimeException("Crowdin export failed, see ${exportFile} for more info")
|
|
||||||
}
|
|
||||||
|
|
||||||
new URL("https://api.crowdin.com/api/project/${id}/download/all.zip?key=${key}").withInputStream { i ->
|
|
||||||
new ZipInputStream(i).withCloseable { zin ->
|
|
||||||
outputFile.withOutputStream { out ->
|
|
||||||
new ZipOutputStream(out).withCloseable { zout ->
|
|
||||||
ZipEntry zein
|
|
||||||
while ((zein = zin.nextEntry) != null) {
|
|
||||||
if (zein.isDirectory()) {
|
|
||||||
zout.putNextEntry(new ZipEntry(zein.name))
|
|
||||||
} else {
|
|
||||||
// 1.13+ uses json
|
|
||||||
if (zein.name.endsWith('.json') == json) {
|
|
||||||
ZipEntry zeout = new ZipEntry(json ? zein.name.toLowerCase() : zein.name)
|
|
||||||
zeout.time = 1
|
|
||||||
zout.putNextEntry(zeout)
|
|
||||||
zout << zin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package net.minecraftforge.forge.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
import java.util.zip.ZipOutputStream
|
||||||
|
|
||||||
|
abstract class DevInstallerJar extends DefaultTask {
|
||||||
|
@OutputFile abstract RegularFileProperty getOutput()
|
||||||
|
@InputFile abstract RegularFileProperty getInput()
|
||||||
|
|
||||||
|
DevInstallerJar() {
|
||||||
|
output.convention(project.layout.buildDirectory.file('libs/' + project.name + '-' + project.version + '-installer-dev.jar'))
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
protected void exec() {
|
||||||
|
try (def zos = new ZipOutputStream(output.get().asFile.newDataOutputStream())) {
|
||||||
|
def seen = [] as Set
|
||||||
|
def deps = [:] as java.util.TreeMap
|
||||||
|
try (def base = new ZipFile(input.get().asFile)) {
|
||||||
|
base.entries().each { entry ->
|
||||||
|
zos.putNextEntry(entry)
|
||||||
|
def data = base.getInputStream(entry).bytes
|
||||||
|
zos.write(data)
|
||||||
|
|
||||||
|
if (entry.name == 'install_profile.json' || entry.name == 'version.json') {
|
||||||
|
def json = new JsonSlurper().parse(data)
|
||||||
|
json.libraries.each { lib ->
|
||||||
|
deps.put(lib.name, lib.downloads.artifact)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.name.startsWith('maven/'))
|
||||||
|
seen.add(entry.name.substring(6))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def resolved = project.configurations.installer.resolvedConfiguration.resolvedArtifacts
|
||||||
|
|
||||||
|
deps.each { name, info ->
|
||||||
|
if (seen.contains(info.path))
|
||||||
|
return
|
||||||
|
|
||||||
|
def art = resolved.find { "${it.moduleVersion.id.group}:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}" == name }
|
||||||
|
|
||||||
|
def file = null
|
||||||
|
if (art != null) {
|
||||||
|
if (!Util.checkExists(info.url))
|
||||||
|
file = art.file
|
||||||
|
} else {
|
||||||
|
// TODO download missing things
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file != null) {
|
||||||
|
//println('maven/' + info.path)
|
||||||
|
zos.putNextEntry(new ZipEntry('maven/' + info.path))
|
||||||
|
zos.write(file.bytes)
|
||||||
|
seen.add(info.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.tasks.InputDirectory
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
abstract class FixPatchImports extends DefaultTask {
|
|
||||||
|
|
||||||
@InputDirectory abstract DirectoryProperty getClean()
|
|
||||||
@InputDirectory abstract DirectoryProperty getPatched()
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
void run() {
|
|
||||||
final patchedPath = getPatched().get().asFile.toPath()
|
|
||||||
final cleanPath = getClean().get().asFile.toPath()
|
|
||||||
|
|
||||||
try (final var stream = Files.find(patchedPath, Integer.MAX_VALUE, (path, attr) -> path.toString().endsWith('.java'))) {
|
|
||||||
final itr = stream.iterator()
|
|
||||||
while (itr.hasNext()) {
|
|
||||||
final next = itr.next()
|
|
||||||
final clean = cleanPath.resolve(patchedPath.relativize(next).toString())
|
|
||||||
|
|
||||||
final patchedLines = Files.readAllLines(next)
|
|
||||||
final cleanLines = Files.readAllLines(clean)
|
|
||||||
|
|
||||||
final patchedImport = patchedLines.findLastIndexOf(2) { it.startsWith('import ') }
|
|
||||||
final cleanImport = cleanLines.findLastIndexOf(2) { it.startsWith('import ') }
|
|
||||||
|
|
||||||
if (cleanImport !== patchedImport) {
|
|
||||||
patchedLines.removeIf { it.startsWith('import ') }
|
|
||||||
patchedLines.addAll(2, cleanLines.subList(2, cleanImport + 1))
|
|
||||||
Files.write(next, patchedLines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -127,7 +127,7 @@ public class Util {
|
|||||||
return getArtifacts(project, cfg, true)
|
return getArtifacts(project, cfg, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkExists(url) {
|
static boolean checkExists(url) {
|
||||||
try {
|
try {
|
||||||
def code = new URL(url).openConnection().with {
|
def code = new URL(url).openConnection().with {
|
||||||
requestMethod = 'HEAD'
|
requestMethod = 'HEAD'
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java-library'
|
||||||
|
id 'eclipse'
|
||||||
|
id 'net.minecraftforge.gradle.patcher' version '[6.0.16,6.2)'
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluationDependsOn(':mcp')
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.forgespi)
|
||||||
|
}
|
||||||
|
|
||||||
|
patcher {
|
||||||
|
parent = project(':mcp')
|
||||||
|
mcVersion = MC_VERSION
|
||||||
|
patchedSrc = file('src/main/java')
|
||||||
|
|
||||||
|
mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION
|
||||||
|
|
||||||
|
runs {
|
||||||
|
clean_client {
|
||||||
|
client true
|
||||||
|
taskName 'clean_client'
|
||||||
|
ideaModule "${rootProject.name}.${project.name}.main"
|
||||||
|
|
||||||
|
main 'net.minecraft.client.main.Main'
|
||||||
|
workingDirectory project.file('run/client')
|
||||||
|
|
||||||
|
args '--gameDir', '.'
|
||||||
|
args '--version', MC_VERSION
|
||||||
|
args '--assetsDir', downloadAssets.output
|
||||||
|
args '--assetIndex', '{asset_index}'
|
||||||
|
args '--accessToken', '0'
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_server {
|
||||||
|
client false
|
||||||
|
taskName 'clean_server'
|
||||||
|
ideaModule "${rootProject.name}.${project.name}.main"
|
||||||
|
|
||||||
|
main 'net.minecraft.server.Main'
|
||||||
|
workingDirectory project.file('run/server')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eclipse.classpath.file.whenMerged {
|
||||||
|
// Disable optional warnings on the minecraft decompiled source code. It just muddies the warning window and hides warnings in our own codebase
|
||||||
|
def src = entries.find { it.path == 'src/main/java' }
|
||||||
|
src.entryAttributes['ignore_optional_problems'] = 'true'
|
||||||
|
}
|
||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
MinecraftForge
|
MinecraftForge
|
||||||
=============
|
=============
|
||||||
[][Download]
|
[][Download]
|
||||||
[][Download] [][Discord] [][Patreon]
|
)][Download] [][Discord] [][Patreon]
|
||||||
|
|
||||||
Forge is a free, open-source modding API all of your favourite mods use!
|
Forge is a free, open-source modding API all of your favourite mods use!
|
||||||
@@ -73,4 +73,4 @@ Please ensure you have a valid email address associated with your GitHub account
|
|||||||
[ForgeDev]: https://docs.minecraftforge.net/en/latest/forgedev/
|
[ForgeDev]: https://docs.minecraftforge.net/en/latest/forgedev/
|
||||||
[Pull-Requests]: https://docs.minecraftforge.net/en/latest/forgedev/#making-changes-and-pull-requests
|
[Pull-Requests]: https://docs.minecraftforge.net/en/latest/forgedev/#making-changes-and-pull-requests
|
||||||
|
|
||||||
[Patreon]: https://www.patreon.com/MinecraftForge
|
[Patreon]: https://www.patreon.com/LexManos
|
||||||
@@ -9,12 +9,12 @@ plugins {
|
|||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
compileOnly(libs.nulls)
|
||||||
|
|
||||||
api("net.minecraftforge:eventbus:${EVENTBUS_VERSION}")
|
api(libs.eventbus)
|
||||||
|
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
implementation("commons-io:commons-io:${COMMONS_IO_VERSION}")
|
implementation(libs.commons.io)
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.github.ben-manes.versions'
|
|
||||||
id 'org.javamodularity.moduleplugin' version '1.8.7' apply false
|
id 'org.javamodularity.moduleplugin' version '1.8.7' apply false
|
||||||
id 'org.cadixdev.licenser'
|
id 'org.cadixdev.licenser'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
@@ -7,7 +6,6 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
import org.gradle.internal.os.OperatingSystem
|
import org.gradle.internal.os.OperatingSystem
|
||||||
|
|
||||||
switch (OperatingSystem.current()) {
|
switch (OperatingSystem.current()) {
|
||||||
case OperatingSystem.LINUX:
|
case OperatingSystem.LINUX:
|
||||||
project.ext.lwjglNatives = "natives-linux"
|
project.ext.lwjglNatives = "natives-linux"
|
||||||
@@ -20,22 +18,15 @@ switch (OperatingSystem.current()) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|
||||||
|
|
||||||
java.withSourcesJar()
|
java.withSourcesJar()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly('org.jetbrains:annotations:23.0.0')
|
compileOnly(libs.nulls)
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
implementation(project(':fmlcore'))
|
implementation(project(':fmlcore'))
|
||||||
implementation('org.lwjgl:lwjgl:3.3.1')
|
implementation(libs.bundles.lwjgl)
|
||||||
implementation('org.lwjgl:lwjgl-glfw:3.3.1')
|
|
||||||
implementation('org.lwjgl:lwjgl-opengl:3.3.1')
|
|
||||||
implementation('org.lwjgl:lwjgl-stb:3.3.1')
|
|
||||||
implementation('org.lwjgl:lwjgl-tinyfd:3.3.1')
|
|
||||||
implementation('org.slf4j:slf4j-api:1.8.0-beta4')
|
implementation('org.slf4j:slf4j-api:1.8.0-beta4')
|
||||||
implementation("net.sf.jopt-simple:jopt-simple:${JOPT_SIMPLE_VERSION}")
|
implementation(libs.jopt.simple)
|
||||||
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.2')
|
testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.2')
|
||||||
testImplementation('org.powermock:powermock-core:2.0.9')
|
testImplementation('org.powermock:powermock-core:2.0.9')
|
||||||
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.8.2')
|
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.8.2')
|
||||||
@@ -50,31 +41,16 @@ test {
|
|||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
jar {
|
||||||
MANIFESTS = [
|
manifest {
|
||||||
'': [
|
attributes([
|
||||||
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
||||||
'Git-Commit': GIT_INFO.abbreviatedId,
|
|
||||||
'Git-Branch': GIT_INFO.branch,
|
|
||||||
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
|
|
||||||
] as LinkedHashMap,
|
|
||||||
'net/minecraftforge/fml/earlydisplay/': [
|
|
||||||
'Specification-Title': 'FMLEarlyDisplay',
|
'Specification-Title': 'FMLEarlyDisplay',
|
||||||
'Specification-Vendor': 'Forge Development LLC',
|
'Specification-Vendor': 'Forge Development LLC',
|
||||||
'Specification-Version': '1',
|
'Specification-Version': '1',
|
||||||
'Implementation-Title': 'FML Early Display',
|
'Implementation-Title': 'FML Early Display',
|
||||||
'Implementation-Version': '1.0',
|
'Implementation-Version': '1.0',
|
||||||
'Implementation-Vendor': 'Forge'
|
'Implementation-Vendor': 'Forge'
|
||||||
] as LinkedHashMap
|
] as LinkedHashMap, 'net/minecraftforge/fml/earlydisplay/')
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
jar.doFirst {
|
|
||||||
MANIFESTS.each { pkg, values ->
|
|
||||||
if (pkg == '')
|
|
||||||
manifest.attributes(values)
|
|
||||||
else
|
|
||||||
manifest.attributes(values, pkg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-2
@@ -40,11 +40,13 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -86,6 +88,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
|||||||
private int framecount;
|
private int framecount;
|
||||||
private EarlyFramebuffer framebuffer;
|
private EarlyFramebuffer framebuffer;
|
||||||
private ScheduledFuture<?> windowTick;
|
private ScheduledFuture<?> windowTick;
|
||||||
|
private ScheduledFuture<?> initializationFuture;
|
||||||
|
|
||||||
private PerformanceInfo performanceInfo;
|
private PerformanceInfo performanceInfo;
|
||||||
private ScheduledFuture<?> performanceTick;
|
private ScheduledFuture<?> performanceTick;
|
||||||
@@ -264,7 +267,6 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
|||||||
public void render(int alpha) {
|
public void render(int alpha) {
|
||||||
var currentVAO = glGetInteger(GL_VERTEX_ARRAY_BINDING);
|
var currentVAO = glGetInteger(GL_VERTEX_ARRAY_BINDING);
|
||||||
var currentFB = glGetInteger(GL_READ_FRAMEBUFFER_BINDING);
|
var currentFB = glGetInteger(GL_READ_FRAMEBUFFER_BINDING);
|
||||||
glfwSwapInterval(0);
|
|
||||||
glViewport(0, 0, this.context.scaledWidth(), this.context.scaledHeight());
|
glViewport(0, 0, this.context.scaledWidth(), this.context.scaledHeight());
|
||||||
RenderElement.globalAlpha = alpha;
|
RenderElement.globalAlpha = alpha;
|
||||||
framebuffer.activate();
|
framebuffer.activate();
|
||||||
@@ -287,7 +289,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
|||||||
return thread;
|
return thread;
|
||||||
});
|
});
|
||||||
initWindow(mcVersion);
|
initWindow(mcVersion);
|
||||||
renderScheduler.schedule(() -> initRender(mcVersion, forgeVersion), 1, TimeUnit.MILLISECONDS);
|
this.initializationFuture = renderScheduler.schedule(() -> initRender(mcVersion, forgeVersion), 1, TimeUnit.MILLISECONDS);
|
||||||
return this::periodicTick;
|
return this::periodicTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,6 +520,16 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
|||||||
* @return the Window we own.
|
* @return the Window we own.
|
||||||
*/
|
*/
|
||||||
public long setupMinecraftWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitorSupplier) {
|
public long setupMinecraftWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitorSupplier) {
|
||||||
|
// wait for the window to actually be initialized
|
||||||
|
try {
|
||||||
|
this.initializationFuture.get(30, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
Thread.dumpStack();
|
||||||
|
crashElegantly("We seem to be having trouble initializing the window, waited for 30 seconds");
|
||||||
|
}
|
||||||
|
|
||||||
// we have to spin wait for the window ticker
|
// we have to spin wait for the window ticker
|
||||||
ImmediateWindowHandler.updateProgress("Initializing Game Graphics");
|
ImmediateWindowHandler.updateProgress("Initializing Game Graphics");
|
||||||
while (!this.windowTick.isDone()) {
|
while (!this.windowTick.isDone()) {
|
||||||
|
|||||||
+25
-34
@@ -10,38 +10,35 @@ dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|||||||
configurations.forEach{ it.transitive = false }
|
configurations.forEach{ it.transitive = false }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
compileOnly(libs.nulls)
|
||||||
|
|
||||||
api("org.ow2.asm:asm:${ASM_VERSION}")
|
api(libs.bundles.asm) // Needed by all the black magic
|
||||||
api("org.ow2.asm:asm-tree:${ASM_VERSION}")
|
api(libs.forgespi)
|
||||||
api("org.ow2.asm:asm-commons:${ASM_VERSION}")
|
api(libs.mergetool.api)
|
||||||
api("net.minecraftforge:forgespi:${SPI_VERSION}")
|
api(libs.log4j.api)
|
||||||
api("net.minecraftforge:mergetool:${MERGETOOL_VERSION}:api")
|
api(libs.slf4j.api)
|
||||||
api("org.apache.logging.log4j:log4j-api:${LOG4J_VERSION}")
|
api(libs.guava)
|
||||||
api("org.slf4j:slf4j-api:${SLF4J_API_VERSION}")
|
api(libs.gson)
|
||||||
api("com.google.guava:guava:${GUAVA_VERSION}")
|
api(libs.maven.artifact)
|
||||||
api("com.google.code.gson:gson:${GSON_VERSION}")
|
api(libs.apache.commons)
|
||||||
api("org.apache.maven:maven-artifact:${APACHE_MAVEN_ARTIFACT_VERSION}")
|
api(libs.bundles.night.config)
|
||||||
api("org.apache.commons:commons-lang3:${APACHE_COMMONS_LANG3_VERSION}")
|
api(libs.modlauncher)
|
||||||
api("com.electronwill.night-config:core:${NIGHTCONFIG_VERSION}")
|
api(libs.coremods)
|
||||||
api("com.electronwill.night-config:toml:${NIGHTCONFIG_VERSION}")
|
api(libs.mojang.logging)
|
||||||
api("cpw.mods:modlauncher:${MODLAUNCHER_VERSION}")
|
api(libs.jarjar.selector)
|
||||||
api("net.minecraftforge:coremods:${COREMODS_VERSION}")
|
api(libs.jarjar.meta)
|
||||||
api("com.mojang:logging:${MOJANG_LOGGING_VERSION}")
|
|
||||||
api "net.minecraftforge:JarJarSelector:${JARJAR_VERSION}"
|
|
||||||
api "net.minecraftforge:JarJarMetadata:${JARJAR_VERSION}"
|
|
||||||
|
|
||||||
implementation("net.sf.jopt-simple:jopt-simple:${JOPT_SIMPLE_VERSION}")
|
implementation(libs.jopt.simple)
|
||||||
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
|
implementation(libs.securemodules)
|
||||||
implementation("net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}")
|
implementation(libs.accesstransformers)
|
||||||
implementation("net.minecrell:terminalconsoleappender:${TERMINALCONSOLEAPPENDER_VERSION}")
|
implementation(libs.terminalconsoleappender)
|
||||||
// implementation("org.jline:jline:${JLINE_VERSION}")
|
implementation(libs.jimfs)
|
||||||
|
|
||||||
implementation("org.apache.logging.log4j:log4j-core:${LOG4J_VERSION}")
|
implementation(libs.log4j.core)
|
||||||
annotationProcessor("org.apache.logging.log4j:log4j-core:${LOG4J_VERSION}")
|
annotationProcessor(libs.log4j.core)
|
||||||
|
|
||||||
testCompileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
testCompileOnly(libs.nulls)
|
||||||
testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}")
|
testRuntimeOnly(libs.bootstrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
@@ -51,12 +48,6 @@ task sourcesJar(type: Jar) {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
MANIFESTS = [
|
MANIFESTS = [
|
||||||
'/': [
|
|
||||||
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
||||||
'Git-Commit': GIT_INFO.abbreviatedId,
|
|
||||||
'Git-Branch': GIT_INFO.branch,
|
|
||||||
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
|
|
||||||
] as LinkedHashMap,
|
|
||||||
'net/minecraftforge/fml/loading/': [
|
'net/minecraftforge/fml/loading/': [
|
||||||
'Specification-Title': 'FMLLoader',
|
'Specification-Title': 'FMLLoader',
|
||||||
'Specification-Vendor': 'Forge Development LLC',
|
'Specification-Vendor': 'Forge Development LLC',
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
|||||||
return lst != null && lst.stream().anyMatch(n -> n.desc.equals(OBJECT_HOLDER));
|
return lst != null && lst.stream().anyMatch(n -> n.desc.equals(OBJECT_HOLDER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private String getValue(List<AnnotationNode> lst)
|
private String getValue(List<AnnotationNode> lst)
|
||||||
{
|
{
|
||||||
AnnotationNode ann = lst.stream().filter(n -> n.desc.equals(OBJECT_HOLDER)).findFirst().get();
|
AnnotationNode ann = lst.stream().filter(n -> n.desc.equals(OBJECT_HOLDER)).findFirst().get();
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import org.objectweb.asm.tree.MethodNode;
|
|||||||
|
|
||||||
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.Marker;
|
|
||||||
import org.slf4j.MarkerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies specified enums to allow runtime extension by making the $VALUES field non-final and
|
* Modifies specified enums to allow runtime extension by making the $VALUES field non-final and
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import java.util.List;
|
|||||||
* or server.
|
* or server.
|
||||||
*/
|
*/
|
||||||
public class EarlyLoadingException extends RuntimeException {
|
public class EarlyLoadingException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 2302192216172508006L;
|
||||||
|
|
||||||
public static class ExceptionData {
|
public static class ExceptionData {
|
||||||
private final IModInfo modInfo;
|
private final IModInfo modInfo;
|
||||||
private final String i18message;
|
private final String i18message;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public class FMLConfig
|
|||||||
private final String entry;
|
private final String entry;
|
||||||
private final Object defaultValue;
|
private final Object defaultValue;
|
||||||
private final String comment;
|
private final String comment;
|
||||||
private final Class<?> valueType;
|
|
||||||
private final Function<Object, Object> entryFunction;
|
private final Function<Object, Object> entryFunction;
|
||||||
|
|
||||||
ConfigValue(final String entry, final Object defaultValue, final String comment) {
|
ConfigValue(final String entry, final Object defaultValue, final String comment) {
|
||||||
@@ -52,7 +51,6 @@ public class FMLConfig
|
|||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.valueType = defaultValue.getClass();
|
|
||||||
this.entryFunction = entryFunction;
|
this.entryFunction = entryFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
|||||||
import net.minecraftforge.fml.loading.moddiscovery.ModValidator;
|
import net.minecraftforge.fml.loading.moddiscovery.ModValidator;
|
||||||
import net.minecraftforge.accesstransformer.service.AccessTransformerService;
|
import net.minecraftforge.accesstransformer.service.AccessTransformerService;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
|
||||||
import net.minecraftforge.fml.loading.targets.CommonLaunchHandler;
|
import net.minecraftforge.fml.loading.targets.CommonLaunchHandler;
|
||||||
import net.minecraftforge.forgespi.Environment;
|
import net.minecraftforge.forgespi.Environment;
|
||||||
import net.minecraftforge.forgespi.coremod.ICoreModProvider;
|
import net.minecraftforge.forgespi.coremod.ICoreModProvider;
|
||||||
@@ -137,6 +136,7 @@ public class FMLLoader
|
|||||||
throw new RuntimeException("Missing launch handler: " + launchTarget);
|
throw new RuntimeException("Missing launch handler: " + launchTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: What the fuck is the point of using a service if you require a specific concrete class
|
||||||
if (!(launchHandler.get() instanceof CommonLaunchHandler)) {
|
if (!(launchHandler.get() instanceof CommonLaunchHandler)) {
|
||||||
LOGGER.error(CORE, "Incompatible Launch handler found - type {}, cannot continue", launchHandler.get().getClass().getName());
|
LOGGER.error(CORE, "Incompatible Launch handler found - type {}, cannot continue", launchHandler.get().getClass().getName());
|
||||||
throw new RuntimeException("Incompatible launch handler found");
|
throw new RuntimeException("Incompatible launch handler found");
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ public class FMLServiceProvider implements ITransformationService
|
|||||||
targetMcpMappings = option.value(mappingsOption);
|
targetMcpMappings = option.value(mappingsOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<ITransformer> transformers()
|
public @NotNull List<ITransformer> transformers()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class FileUtils
|
|
||||||
{
|
|
||||||
|
|
||||||
public static String fileExtension(final Path path) {
|
|
||||||
String fileName = path.getFileName().toString();
|
|
||||||
int idx = fileName.lastIndexOf('.');
|
|
||||||
if (idx > -1) {
|
|
||||||
return fileName.substring(idx+1);
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matchFileName(String path, String... matches) {
|
|
||||||
// Extract file name from path
|
|
||||||
String name = path.substring(Math.min(path.lastIndexOf(File.separatorChar) + 1, path.length()));
|
|
||||||
// Check if it contains any of the desired keywords
|
|
||||||
for (String match : matches) {
|
|
||||||
if (name.contains(match)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ public class ImmediateWindowHandler {
|
|||||||
|
|
||||||
private static ProgressMeter earlyProgress;
|
private static ProgressMeter earlyProgress;
|
||||||
public static void load(final String launchTarget, final String[] arguments) {
|
public static void load(final String launchTarget, final String[] arguments) {
|
||||||
if (!List.of("forgeclient", "forgeclientuserdev", "forgeclientdev").contains(launchTarget)) {
|
if (!launchTarget.contains("client")) {
|
||||||
provider = new DummyProvider();
|
provider = new DummyProvider();
|
||||||
LOGGER.info("ImmediateWindowProvider not loading because launch target is {}", launchTarget);
|
LOGGER.info("ImmediateWindowProvider not loading because launch target is {}", launchTarget);
|
||||||
} else if (!FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_CONTROL)) {
|
} else if (!FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_CONTROL)) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.Optional;
|
|||||||
* Finds Version data from a package, with possible default values
|
* Finds Version data from a package, with possible default values
|
||||||
*/
|
*/
|
||||||
public class JarVersionLookupHandler {
|
public class JarVersionLookupHandler {
|
||||||
|
|
||||||
public static Optional<String> getImplementationVersion(final String pkgName) {
|
public static Optional<String> getImplementationVersion(final String pkgName) {
|
||||||
// Note that with Java 9, you'll probably want the module's version data, hence pulling this out
|
// Note that with Java 9, you'll probably want the module's version data, hence pulling this out
|
||||||
final String pkgVersion = Package.getPackage(pkgName).getImplementationVersion();
|
final String pkgVersion = Package.getPackage(pkgName).getImplementationVersion();
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.mojang.logging.LogUtils;
|
|||||||
import cpw.mods.modlauncher.Launcher;
|
import cpw.mods.modlauncher.Launcher;
|
||||||
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
||||||
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
|
||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator;
|
import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
|||||||
-3
@@ -7,7 +7,6 @@ package net.minecraftforge.fml.loading;
|
|||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import cpw.mods.modlauncher.Launcher;
|
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
import cpw.mods.modlauncher.api.NamedPath;
|
import cpw.mods.modlauncher.api.NamedPath;
|
||||||
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
|
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
|
||||||
@@ -19,8 +18,6 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ServiceLoader;
|
|
||||||
import java.util.zip.ZipFile;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
|
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.net.URLStreamHandler;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.jar.Manifest;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
|
||||||
|
|
||||||
public class ModJarURLHandler extends URLStreamHandler
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
|
||||||
// modjar://modid/path/to/file
|
|
||||||
@Override
|
|
||||||
protected URLConnection openConnection(URL url) {
|
|
||||||
return new ModJarURLConnection(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int hashCode(final URL u) {
|
|
||||||
return Objects.hash(u.getHost(), u.getFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean equals(final URL u1, final URL u2) {
|
|
||||||
return Objects.equals(u1.getProtocol(), u2.getProtocol())
|
|
||||||
&& Objects.equals(u1.getHost(), u2.getHost())
|
|
||||||
&& Objects.equals(u1.getFile(), u2.getFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ModJarURLConnection extends URLConnection {
|
|
||||||
private Path resource;
|
|
||||||
private String modpath;
|
|
||||||
private String modid;
|
|
||||||
private Optional<Manifest> manifest;
|
|
||||||
|
|
||||||
public ModJarURLConnection(final URL url) {
|
|
||||||
super(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connect()
|
|
||||||
{
|
|
||||||
// if (resource == null) {
|
|
||||||
// modid = url.getHost();
|
|
||||||
// // trim first char
|
|
||||||
// modpath = url.getPath().substring(1);
|
|
||||||
// resource = FMLLoader.getLoadingModList().getModFileById(modid).getFile().findResource(modpath);
|
|
||||||
// manifest = FMLLoader.getLoadingModList().getModFileById(modid).getManifest();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream getInputStream() throws IOException
|
|
||||||
{
|
|
||||||
connect();
|
|
||||||
LOGGER.trace(CORE, "Loading modjar URL {} got resource {} {}", url, resource, resource != null ? Files.exists(resource) : "missing");
|
|
||||||
return Files.newInputStream(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getContentLengthLong() {
|
|
||||||
try {
|
|
||||||
connect();
|
|
||||||
return Files.size(resource);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return -1L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to cache protectiondomains by "top level object" aka the modid
|
|
||||||
@Override
|
|
||||||
public URL getURL() {
|
|
||||||
return LamdbaExceptionUtils.uncheck(()->new URL("modjar://"+modid));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Manifest> getManifest() {
|
|
||||||
return manifest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ import com.google.common.graph.MutableGraph;
|
|||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator;
|
import net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator;
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.fml.loading.EarlyLoadingException.ExceptionData;
|
import net.minecraftforge.fml.loading.EarlyLoadingException.ExceptionData;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
@@ -72,7 +71,6 @@ public class ModSorter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
|
||||||
private void sort()
|
private void sort()
|
||||||
{
|
{
|
||||||
// lambdas are identity based, so sorting them is impossible unless you hold reference to them
|
// lambdas are identity based, so sorting them is impossible unless you hold reference to them
|
||||||
@@ -121,7 +119,6 @@ public class ModSorter
|
|||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
|
||||||
private void addDependency(MutableGraph<ModFileInfo> topoGraph, IModInfo.ModVersion dep)
|
private void addDependency(MutableGraph<ModFileInfo> topoGraph, IModInfo.ModVersion dep)
|
||||||
{
|
{
|
||||||
final ModFileInfo self = (ModFileInfo)dep.getOwner().getOwningFile();
|
final ModFileInfo self = (ModFileInfo)dep.getOwner().getOwningFile();
|
||||||
@@ -133,6 +130,7 @@ public class ModSorter
|
|||||||
switch (dep.getOrdering()) {
|
switch (dep.getOrdering()) {
|
||||||
case BEFORE -> topoGraph.putEdge(self, target);
|
case BEFORE -> topoGraph.putEdge(self, target);
|
||||||
case AFTER -> topoGraph.putEdge(target, self);
|
case AFTER -> topoGraph.putEdge(target, self);
|
||||||
|
default -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-32
@@ -27,8 +27,7 @@ import java.util.Optional;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
public abstract class AbstractModProvider implements IModProvider
|
public abstract class AbstractModProvider implements IModProvider {
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
protected static final String MODS_TOML = "META-INF/mods.toml";
|
protected static final String MODS_TOML = "META-INF/mods.toml";
|
||||||
protected static final String MANIFEST = "META-INF/MANIFEST.MF";
|
protected static final String MANIFEST = "META-INF/MANIFEST.MF";
|
||||||
@@ -36,26 +35,24 @@ public abstract class AbstractModProvider implements IModProvider
|
|||||||
protected IModLocator.ModFileOrException createMod(Path... path) {
|
protected IModLocator.ModFileOrException createMod(Path... path) {
|
||||||
var mjm = new ModJarMetadata();
|
var mjm = new ModJarMetadata();
|
||||||
var sj = SecureJar.from(
|
var sj = SecureJar.from(
|
||||||
Manifest::new,
|
Manifest::new,
|
||||||
jar -> jar.moduleDataProvider().findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path),
|
jar -> jar.moduleDataProvider().findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path),
|
||||||
(root, p) -> true,
|
path
|
||||||
path
|
|
||||||
);
|
);
|
||||||
|
|
||||||
IModFile mod;
|
IModFile mod;
|
||||||
var type = sj.moduleDataProvider().getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
var type = sj.moduleDataProvider().getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
||||||
if (type == null) {
|
if (type == null)
|
||||||
type = getDefaultJarModType();
|
type = getDefaultJarModType();
|
||||||
}
|
|
||||||
if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) {
|
if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) {
|
||||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
||||||
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
||||||
} else if (type != null) {
|
} else if (type != null) {
|
||||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path);
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path);
|
||||||
mod = new ModFile(sj, this, this::manifestParser, type);
|
mod = new ModFile(sj, this, this::manifestParser, type);
|
||||||
} else {
|
} else
|
||||||
return new IModLocator.ModFileOrException(null, new ModFileLoadingException("Invalid mod file found "+ Arrays.toString(path)));
|
return new IModLocator.ModFileOrException(null, new ModFileLoadingException("Invalid mod file found " + Arrays.toString(path)));
|
||||||
}
|
|
||||||
|
|
||||||
mjm.setModFile(mod);
|
mjm.setModFile(mod);
|
||||||
return new IModLocator.ModFileOrException(mod, null);
|
return new IModLocator.ModFileOrException(mod, null);
|
||||||
@@ -88,36 +85,19 @@ public abstract class AbstractModProvider implements IModProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
private record DefaultModFileInfo(IModFile mod, String license, IConfigurable configurable) implements IModFileInfo, IConfigurable {
|
private record DefaultModFileInfo(IModFile mod, String license, IConfigurable configurable) implements IModFileInfo, IConfigurable {
|
||||||
@Override
|
@Override public <T> Optional<T> getConfigElement(final String... strings) { return Optional.empty(); }
|
||||||
public <T> Optional<T> getConfigElement(final String... strings)
|
@Override public List<? extends IConfigurable> getConfigList(final String... strings) { return null; }
|
||||||
{
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends IConfigurable> getConfigList(final String... strings)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public List<IModInfo> getMods() { return Collections.emptyList(); }
|
@Override public List<IModInfo> getMods() { return Collections.emptyList(); }
|
||||||
@Override public List<LanguageSpec> requiredLanguageLoaders() { return Collections.emptyList(); }
|
@Override public List<LanguageSpec> requiredLanguageLoaders() { return Collections.emptyList(); }
|
||||||
@Override public boolean showAsResourcePack() { return false; }
|
@Override public boolean showAsResourcePack() { return false; }
|
||||||
@Override public Map<String, Object> getFileProperties() { return Collections.emptyMap(); }
|
@Override public Map<String, Object> getFileProperties() { return Collections.emptyMap(); }
|
||||||
@Override
|
@Override public String getLicense() { return license; }
|
||||||
public String getLicense() { return license; }
|
|
||||||
|
|
||||||
@Override public IModFile getFile() { return mod; }
|
@Override public IModFile getFile() { return mod; }
|
||||||
@Override public IConfigurable getConfig() { return configurable; }
|
@Override public IConfigurable getConfig() { return configurable; }
|
||||||
|
|
||||||
// These Should never be called as it's only called from ModJarMetadata.version and we bypass that
|
// These Should never be called as it's only called from ModJarMetadata.version and we bypass that
|
||||||
@Override public String moduleName() { return mod.getSecureJar().name(); }
|
@Override public String moduleName() { return mod.getSecureJar().name(); }
|
||||||
@Override public String versionString() { return null; }
|
@Override public String versionString() { return null; }
|
||||||
@Override public List<String> usesServices() { return null; }
|
@Override public List<String> usesServices() { return null; }
|
||||||
|
@Override public String toString() { return "IModFileInfo(" + mod.getFilePath() + ")"; }
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "IModFileInfo(" + mod.getFilePath() + ")";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-12
@@ -9,13 +9,11 @@ import com.mojang.logging.LogUtils;
|
|||||||
import net.minecraftforge.fml.loading.ImmediateWindowHandler;
|
import net.minecraftforge.fml.loading.ImmediateWindowHandler;
|
||||||
import net.minecraftforge.fml.loading.LoadingModList;
|
import net.minecraftforge.fml.loading.LoadingModList;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
|
||||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
@@ -32,9 +30,6 @@ public class BackgroundScanHandler
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final ExecutorService modContentScanner;
|
private final ExecutorService modContentScanner;
|
||||||
private final List<ModFile> pendingFiles;
|
|
||||||
private final List<ModFile> scannedFiles;
|
|
||||||
private final List<ModFile> allFiles;
|
|
||||||
private final List<ModFile> modFiles;
|
private final List<ModFile> modFiles;
|
||||||
private ScanStatus status;
|
private ScanStatus status;
|
||||||
private LoadingModList loadingModList;
|
private LoadingModList loadingModList;
|
||||||
@@ -46,9 +41,6 @@ public class BackgroundScanHandler
|
|||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
return thread;
|
return thread;
|
||||||
});
|
});
|
||||||
scannedFiles = new ArrayList<>();
|
|
||||||
pendingFiles = new ArrayList<>();
|
|
||||||
allFiles = new ArrayList<>();
|
|
||||||
status = ScanStatus.NOT_STARTED;
|
status = ScanStatus.NOT_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +55,6 @@ public class BackgroundScanHandler
|
|||||||
}
|
}
|
||||||
status = ScanStatus.RUNNING;
|
status = ScanStatus.RUNNING;
|
||||||
ImmediateWindowHandler.updateProgress("Scanning mod candidates");
|
ImmediateWindowHandler.updateProgress("Scanning mod candidates");
|
||||||
allFiles.add(file);
|
|
||||||
pendingFiles.add(file);
|
|
||||||
final CompletableFuture<ModFileScanData> future = CompletableFuture.supplyAsync(file::compileContent, modContentScanner)
|
final CompletableFuture<ModFileScanData> future = CompletableFuture.supplyAsync(file::compileContent, modContentScanner)
|
||||||
.whenComplete(file::setScanResult)
|
.whenComplete(file::setScanResult)
|
||||||
.whenComplete((r,t)-> this.addCompletedFile(file,r,t));
|
.whenComplete((r,t)-> this.addCompletedFile(file,r,t));
|
||||||
@@ -76,8 +66,6 @@ public class BackgroundScanHandler
|
|||||||
status = ScanStatus.ERRORED;
|
status = ScanStatus.ERRORED;
|
||||||
LOGGER.error(LogMarkers.SCAN,"An error occurred scanning file {}", file, throwable);
|
LOGGER.error(LogMarkers.SCAN,"An error occurred scanning file {}", file, throwable);
|
||||||
}
|
}
|
||||||
pendingFiles.remove(file);
|
|
||||||
scannedFiles.add(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadingModList(LoadingModList loadingModList)
|
public void setLoadingModList(LoadingModList loadingModList)
|
||||||
|
|||||||
+1
-23
@@ -12,12 +12,9 @@ import org.slf4j.Logger;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -25,8 +22,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ClasspathLocator extends AbstractJarFileModLocator
|
public class ClasspathLocator extends AbstractJarFileModLocator {
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
|
private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
@@ -73,22 +69,4 @@ public class ClasspathLocator extends AbstractJarFileModLocator
|
|||||||
var launchTarget = (String) arguments.get("launchTarget");
|
var launchTarget = (String) arguments.get("launchTarget");
|
||||||
enabled = launchTarget != null && launchTarget.contains("dev");
|
enabled = launchTarget != null && launchTarget.contains("dev");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path findJarPathFor(final String resourceName, final String jarName, final URL resource) {
|
|
||||||
try {
|
|
||||||
Path path;
|
|
||||||
final URI uri = resource.toURI();
|
|
||||||
if (uri.getScheme().equals("jar") && uri.getRawSchemeSpecificPart().contains("!/")) {
|
|
||||||
int lastExcl = uri.getRawSchemeSpecificPart().lastIndexOf("!/");
|
|
||||||
path = Paths.get(new URI(uri.getRawSchemeSpecificPart().substring(0, lastExcl)));
|
|
||||||
} else {
|
|
||||||
path = Paths.get(new URI("file://"+uri.getRawSchemeSpecificPart().substring(0, uri.getRawSchemeSpecificPart().length()-resourceName.length())));
|
|
||||||
}
|
|
||||||
//LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
|
|
||||||
return path;
|
|
||||||
} catch (NullPointerException | URISyntaxException e) {
|
|
||||||
LOGGER.error(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName);
|
|
||||||
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -34,7 +34,7 @@ public class ExplodedDirectoryLocator implements IModLocator {
|
|||||||
explodedMods.forEach(explodedMod ->
|
explodedMods.forEach(explodedMod ->
|
||||||
ModJarMetadata.buildFile(this,
|
ModJarMetadata.buildFile(this,
|
||||||
jar->jar.moduleDataProvider().findFile("/META-INF/mods.toml").isPresent(),
|
jar->jar.moduleDataProvider().findFile("/META-INF/mods.toml").isPresent(),
|
||||||
(a,b) -> true,
|
null,
|
||||||
explodedMod.paths().toArray(Path[]::new))
|
explodedMod.paths().toArray(Path[]::new))
|
||||||
.ifPresentOrElse(f->mods.put(explodedMod, f), () -> LOGGER.warn(LogMarkers.LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString())));
|
.ifPresentOrElse(f->mods.put(explodedMod, f), () -> LOGGER.warn(LogMarkers.LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString())));
|
||||||
return mods.values().stream().map(mf->new IModLocator.ModFileOrException(mf, null)).toList();
|
return mods.values().stream().map(mf->new IModLocator.ModFileOrException(mf, null)).toList();
|
||||||
|
|||||||
+3
-4
@@ -11,12 +11,11 @@ import net.minecraftforge.forgespi.locating.ModFileLoadingException;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class InvalidModFileException extends ModFileLoadingException
|
public class InvalidModFileException extends ModFileLoadingException {
|
||||||
{
|
private static final long serialVersionUID = 1230464325917450374L;
|
||||||
private final IModFileInfo modFileInfo;
|
private final IModFileInfo modFileInfo;
|
||||||
|
|
||||||
public InvalidModFileException(String message, IModFileInfo modFileInfo)
|
public InvalidModFileException(String message, IModFileInfo modFileInfo) {
|
||||||
{
|
|
||||||
super(String.format(Locale.ROOT, "%s (%s)", message, Optional.ofNullable(modFileInfo).map(mf->mf.getFile().getFileName()).orElse("MISSING FILE NAME")));
|
super(String.format(Locale.ROOT, "%s (%s)", message, Optional.ofNullable(modFileInfo).map(mf->mf.getFile().getFileName()).orElse("MISSING FILE NAME")));
|
||||||
this.modFileInfo = modFileInfo;
|
this.modFileInfo = modFileInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-29
@@ -10,72 +10,58 @@ import org.objectweb.asm.Opcodes;
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class ModAnnotationVisitor extends AnnotationVisitor
|
public class ModAnnotationVisitor extends AnnotationVisitor {
|
||||||
{
|
|
||||||
private final ModAnnotation annotation;
|
private final ModAnnotation annotation;
|
||||||
private LinkedList<ModAnnotation> annotations;
|
private LinkedList<ModAnnotation> annotations;
|
||||||
private boolean array;
|
private boolean array;
|
||||||
private String name;
|
|
||||||
private boolean isSubAnnotation;
|
private boolean isSubAnnotation;
|
||||||
|
|
||||||
public ModAnnotationVisitor(LinkedList<ModAnnotation> annotations, ModAnnotation annotation)
|
public ModAnnotationVisitor(LinkedList<ModAnnotation> annotations, ModAnnotation annotation) {
|
||||||
{
|
|
||||||
super(Opcodes.ASM9);
|
super(Opcodes.ASM9);
|
||||||
this.annotations = annotations;
|
this.annotations = annotations;
|
||||||
this.annotation = annotation;
|
this.annotation = annotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModAnnotationVisitor(LinkedList<ModAnnotation> annotations, ModAnnotation annotation, String name)
|
public ModAnnotationVisitor(LinkedList<ModAnnotation> annotations, ModAnnotation annotation, String name) {
|
||||||
{
|
|
||||||
this(annotations, annotation);
|
this(annotations, annotation);
|
||||||
this.array = true;
|
this.array = true;
|
||||||
this.name = name;
|
|
||||||
annotation.addArray(name);
|
annotation.addArray(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModAnnotationVisitor(LinkedList<ModAnnotation> annotations, ModAnnotation annotation, boolean isSubAnnotation)
|
public ModAnnotationVisitor(LinkedList<ModAnnotation> annotations, ModAnnotation annotation, boolean isSubAnnotation) {
|
||||||
{
|
|
||||||
this(annotations, annotation);
|
this(annotations, annotation);
|
||||||
this.isSubAnnotation = true;
|
this.isSubAnnotation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(String key, Object value)
|
public void visit(String key, Object value) {
|
||||||
{
|
|
||||||
annotation.addProperty(key, value);
|
annotation.addProperty(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitEnum(String name, String desc, String value)
|
public void visitEnum(String name, String desc, String value) {
|
||||||
{
|
|
||||||
annotation.addEnumProperty(name, desc, value);
|
annotation.addEnumProperty(name, desc, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitArray(String name)
|
public AnnotationVisitor visitArray(String name) {
|
||||||
{
|
|
||||||
return new ModAnnotationVisitor(annotations, annotation, name);
|
return new ModAnnotationVisitor(annotations, annotation, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitAnnotation(String name, String desc)
|
public AnnotationVisitor visitAnnotation(String name, String desc) {
|
||||||
{
|
var ma = annotations.getFirst();
|
||||||
ModAnnotation ma = annotations.getFirst();
|
var childAnnotation = ma.addChildAnnotation(name, desc);
|
||||||
final ModAnnotation childAnnotation = ma.addChildAnnotation(name, desc);
|
|
||||||
annotations.addFirst(childAnnotation);
|
annotations.addFirst(childAnnotation);
|
||||||
return new ModAnnotationVisitor(annotations, childAnnotation,true);
|
return new ModAnnotationVisitor(annotations, childAnnotation, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitEnd()
|
public void visitEnd() {
|
||||||
{
|
|
||||||
if (array)
|
if (array)
|
||||||
{
|
|
||||||
annotation.endArray();
|
annotation.endArray();
|
||||||
}
|
|
||||||
|
|
||||||
if (isSubAnnotation)
|
if (isSubAnnotation)
|
||||||
{
|
annotations.addLast(annotations.removeFirst());
|
||||||
ModAnnotation child = annotations.removeFirst();
|
|
||||||
annotations.addLast(child);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-22
@@ -15,58 +15,49 @@ import org.objectweb.asm.Type;
|
|||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ModClassVisitor extends ClassVisitor
|
public class ModClassVisitor extends ClassVisitor {
|
||||||
{
|
|
||||||
private Type asmType;
|
private Type asmType;
|
||||||
private Type asmSuperType;
|
private Type asmSuperType;
|
||||||
private Set<Type> interfaces;
|
private Set<Type> interfaces;
|
||||||
private final LinkedList<ModAnnotation> annotations = new LinkedList<>();
|
private final LinkedList<ModAnnotation> annotations = new LinkedList<>();
|
||||||
public ModClassVisitor()
|
|
||||||
{
|
public ModClassVisitor() {
|
||||||
super(Opcodes.ASM9);
|
super(Opcodes.ASM9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
|
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||||
{
|
|
||||||
this.asmType = Type.getObjectType(name);
|
this.asmType = Type.getObjectType(name);
|
||||||
this.asmSuperType = superName != null && superName.length() > 0 ? Type.getObjectType(superName) : null;
|
this.asmSuperType = superName != null && !superName.isEmpty() ? Type.getObjectType(superName) : null;
|
||||||
this.interfaces = Stream.of(interfaces).map(Type::getObjectType).collect(Collectors.toSet());
|
this.interfaces = Stream.of(interfaces).map(Type::getObjectType).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationVisitor visitAnnotation(final String annotationName, final boolean runtimeVisible)
|
public AnnotationVisitor visitAnnotation(final String annotationName, final boolean runtimeVisible) {
|
||||||
{
|
|
||||||
ModAnnotation ann = new ModAnnotation(ElementType.TYPE, Type.getType(annotationName), this.asmType.getClassName());
|
ModAnnotation ann = new ModAnnotation(ElementType.TYPE, Type.getType(annotationName), this.asmType.getClassName());
|
||||||
annotations.addFirst(ann);
|
annotations.addFirst(ann);
|
||||||
return new ModAnnotationVisitor(annotations, ann);
|
return new ModAnnotationVisitor(annotations, ann);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
|
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
|
||||||
{
|
|
||||||
return new ModFieldVisitor(name, annotations);
|
return new ModFieldVisitor(name, annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
|
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||||
{
|
|
||||||
return new ModMethodVisitor(name, desc, annotations);
|
return new ModMethodVisitor(name, desc, annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildData(final Set<ModFileScanData.ClassData> classes, final Set<ModFileScanData.AnnotationData> annotations) {
|
public void buildData(final Set<ModFileScanData.ClassData> classes, final Set<ModFileScanData.AnnotationData> baked) {
|
||||||
classes.add(new ModFileScanData.ClassData(this.asmType, this.asmSuperType, this.interfaces));
|
classes.add(new ModFileScanData.ClassData(this.asmType, this.asmSuperType, this.interfaces));
|
||||||
final List<ModFileScanData.AnnotationData> collect = this.annotations.stream().
|
for (var a : this.annotations) {
|
||||||
filter(ma->ModFileScanData.interestingAnnotations().test(ma.getASMType())).
|
//if (ModFileScanData.interestingAnnotations().test(a.getASMType())) // Always true, so who cares. Left as a note to remove this in SPI later.
|
||||||
map(a -> ModAnnotation.fromModAnnotation(this.asmType, a)).collect(Collectors.toList());
|
baked.add(ModAnnotation.fromModAnnotation(this.asmType, a));
|
||||||
annotations.addAll(collect);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,6 @@ import com.mojang.logging.LogUtils;
|
|||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
@@ -207,8 +206,11 @@ public class ModFile implements IModFile {
|
|||||||
this.securityStatus = status;
|
this.securityStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactVersion getJarVersion()
|
public SecureJar.Status getSecurityStatus() {
|
||||||
{
|
return this.securityStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactVersion getJarVersion() {
|
||||||
return new DefaultArtifactVersion(this.jarVersion);
|
return new DefaultArtifactVersion(this.jarVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import java.nio.file.Path;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ModFileParser {
|
public class ModFileParser {
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
this.displayName = config.<String>getConfigElement("displayName")
|
this.displayName = config.<String>getConfigElement("displayName")
|
||||||
.orElse(this.modId);
|
.orElse(this.modId);
|
||||||
this.description = config.<String>getConfigElement("description")
|
this.description = config.<String>getConfigElement("description")
|
||||||
.orElse("MISSING DESCRIPTION");
|
.orElse("MISSING DESCRIPTION")
|
||||||
|
.replace("\r\n", "\n").stripIndent();
|
||||||
this.logoFile = Optional.ofNullable(config.<String>getConfigElement("logoFile")
|
this.logoFile = Optional.ofNullable(config.<String>getConfigElement("logoFile")
|
||||||
.orElseGet(() -> ownFile.flatMap(mf -> mf.<String>getConfigElement("logoFile"))
|
.orElseGet(() -> ownFile.flatMap(mf -> mf.<String>getConfigElement("logoFile"))
|
||||||
.orElse(null)));
|
.orElse(null)));
|
||||||
@@ -205,7 +206,7 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
private final boolean mandatory;
|
private final boolean mandatory;
|
||||||
private final Ordering ordering;
|
private final Ordering ordering;
|
||||||
private final DependencySide side;
|
private final DependencySide side;
|
||||||
private Optional<URL> referralUrl;
|
private final Optional<URL> referralUrl;
|
||||||
|
|
||||||
public ModVersion(final IModInfo owner, final IConfigurable config) {
|
public ModVersion(final IModInfo owner, final IConfigurable config) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ public final class ModJarMetadata implements JarMetadata {
|
|||||||
// TODO: Remove helper functions to cleanup api
|
// TODO: Remove helper functions to cleanup api
|
||||||
@Deprecated(forRemoval = true, since="1.18")
|
@Deprecated(forRemoval = true, since="1.18")
|
||||||
static IModFile buildFile(IModLocator locator, Path... files) {
|
static IModFile buildFile(IModLocator locator, Path... files) {
|
||||||
return buildFile(locator, j->true, (a,b) -> true, files).orElseThrow(()->new IllegalArgumentException("Failed to find valid JAR file"));
|
return buildFile(locator, j->true, null, files).orElseThrow(()->new IllegalArgumentException("Failed to find valid JAR file"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove helper functions to cleanup api
|
// TODO: Remove helper functions to cleanup api
|
||||||
|
|||||||
+7
-2
@@ -7,7 +7,6 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
|||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
import net.minecraftforge.fml.loading.FileUtils;
|
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.fml.loading.MavenCoordinateResolver;
|
import net.minecraftforge.fml.loading.MavenCoordinateResolver;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
@@ -63,7 +62,7 @@ public class ModListHandler {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
String extension = FileUtils.fileExtension(filePath);
|
String extension = fileExtension(filePath);
|
||||||
if (Objects.equals("list",extension)) {
|
if (Objects.equals("list",extension)) {
|
||||||
return readListFile(filePath).stream().filter(s -> !s.isEmpty()).collect(Collectors.toList());
|
return readListFile(filePath).stream().filter(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
@@ -72,6 +71,12 @@ public class ModListHandler {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String fileExtension(final Path path) {
|
||||||
|
String fileName = path.getFileName().toString();
|
||||||
|
int idx = fileName.lastIndexOf('.');
|
||||||
|
return idx > -1 ? fileName.substring(idx+1) : "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple list file, ending in ".list" with one mod coordinate per line
|
* Simple list file, ending in ".list" with one mod coordinate per line
|
||||||
* @param filePath path
|
* @param filePath path
|
||||||
|
|||||||
+2
-3
@@ -9,7 +9,6 @@ import com.mojang.logging.LogUtils;
|
|||||||
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
||||||
import cpw.mods.modlauncher.api.ITransformationService;
|
import cpw.mods.modlauncher.api.ITransformationService;
|
||||||
import net.minecraftforge.fml.loading.*;
|
import net.minecraftforge.fml.loading.*;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -23,7 +22,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ModValidator {
|
public class ModValidator {
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final Map<IModFile.Type, List<ModFile>> modFiles;
|
//private final Map<IModFile.Type, List<ModFile>> modFiles;
|
||||||
private final List<ModFile> candidatePlugins;
|
private final List<ModFile> candidatePlugins;
|
||||||
private final List<ModFile> candidateMods;
|
private final List<ModFile> candidateMods;
|
||||||
private LoadingModList loadingModList;
|
private LoadingModList loadingModList;
|
||||||
@@ -31,7 +30,7 @@ public class ModValidator {
|
|||||||
private final List<EarlyLoadingException.ExceptionData> discoveryErrorData;
|
private final List<EarlyLoadingException.ExceptionData> discoveryErrorData;
|
||||||
|
|
||||||
public ModValidator(final Map<IModFile.Type, List<ModFile>> modFiles, final List<IModFileInfo> brokenFiles, final List<EarlyLoadingException.ExceptionData> discoveryErrorData) {
|
public ModValidator(final Map<IModFile.Type, List<ModFile>> modFiles, final List<IModFileInfo> brokenFiles, final List<EarlyLoadingException.ExceptionData> discoveryErrorData) {
|
||||||
this.modFiles = modFiles;
|
//this.modFiles = modFiles;
|
||||||
this.candidateMods = lst(modFiles.get(IModFile.Type.MOD));
|
this.candidateMods = lst(modFiles.get(IModFile.Type.MOD));
|
||||||
this.candidateMods.addAll(lst(modFiles.get(IModFile.Type.GAMELIBRARY)));
|
this.candidateMods.addAll(lst(modFiles.get(IModFile.Type.GAMELIBRARY)));
|
||||||
this.candidatePlugins = lst(modFiles.get(IModFile.Type.LANGPROVIDER));
|
this.candidatePlugins = lst(modFiles.get(IModFile.Type.LANGPROVIDER));
|
||||||
|
|||||||
-2
@@ -10,8 +10,6 @@ import com.google.common.base.CharMatcher;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
public class StartupNotificationManager {
|
public class StartupNotificationManager {
|
||||||
private static volatile EnumMap<Message.MessageType, List<Message>> messages = new EnumMap<>(Message.MessageType.class);
|
private static volatile EnumMap<Message.MessageType, List<Message>> messages = new EnumMap<>(Message.MessageType.class);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -19,6 +21,7 @@ import java.util.function.Supplier;
|
|||||||
* A class that attempts to parse command line arguments into key value pairs to allow addition and editing.
|
* A class that attempts to parse command line arguments into key value pairs to allow addition and editing.
|
||||||
* Can not use JOptSimple as that doesn't parse out the values for keys unless the spec says it has a value.
|
* Can not use JOptSimple as that doesn't parse out the values for keys unless the spec says it has a value.
|
||||||
*/
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
class ArgumentList {
|
class ArgumentList {
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private List<Supplier<String[]>> entries = new ArrayList<>();
|
private List<Supplier<String[]>> entries = new ArrayList<>();
|
||||||
|
|||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.ServiceRunner;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonClientLaunchHandler extends CommonLaunchHandler {
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
@Override public String getNaming() { return "srg"; }
|
|
||||||
@Override public boolean isProduction() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ServiceRunner makeService(final String[] arguments, final ModuleLayer gameLayer) {
|
|
||||||
return ()->clientService(arguments, gameLayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
final var vers = FMLLoader.versionInfo();
|
|
||||||
var mc = LibraryFinder.findPathForMaven("net.minecraft", "client", "", "srg", vers.mcAndMCPVersion());
|
|
||||||
var mcextra = LibraryFinder.findPathForMaven("net.minecraft", "client", "", "extra", vers.mcAndMCPVersion());
|
|
||||||
var mcstream = Stream.<Path>builder().add(mc).add(mcextra);
|
|
||||||
var modstream = Stream.<List<Path>>builder();
|
|
||||||
|
|
||||||
processMCStream(vers, mcstream, modstream);
|
|
||||||
|
|
||||||
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
|
||||||
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
var lowcodelang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "lowcodelanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), (a,b) -> true, modstream.build().toList(), List.of(fmlcore, javafmllang, lowcodelang, mclang));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods);
|
|
||||||
}
|
|
||||||
+103
-54
@@ -7,46 +7,30 @@ package net.minecraftforge.fml.loading.targets;
|
|||||||
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import cpw.mods.modlauncher.api.ServiceRunner;
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.fml.loading.FileUtils;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
||||||
|
protected CommonDevLaunchHandler(LaunchType type, String prefix) {
|
||||||
|
super(type, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
@Override public String getNaming() { return "mcp"; }
|
@Override public String getNaming() { return "mcp"; }
|
||||||
@Override public boolean isProduction() { return false; }
|
@Override public boolean isProduction() { return false; }
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
// Minecraft is extra jar {resources} + our exploded directories in dev
|
|
||||||
final var mcstream = Stream.<Path>builder();
|
|
||||||
|
|
||||||
// The extra jar is on the classpath, so try and pull it out of the legacy classpath
|
|
||||||
var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find client-extra").split(File.pathSeparator);
|
|
||||||
var extra = findJarOnClasspath(legacyCP, "client-extra");
|
|
||||||
|
|
||||||
// The MC code/Patcher edits are in exploded directories
|
|
||||||
final var modstream = Stream.<List<Path>>builder();
|
|
||||||
final var mods = getModClasses();
|
|
||||||
final var minecraft = mods.remove("minecraft");
|
|
||||||
if (minecraft == null)
|
|
||||||
throw new IllegalStateException("Could not find 'minecraft' mod paths.");
|
|
||||||
minecraft.stream().distinct().forEach(mcstream::add);
|
|
||||||
mods.values().forEach(modstream::add);
|
|
||||||
|
|
||||||
mcstream.add(extra);
|
|
||||||
var mcFilter = getMcFilter(extra, minecraft, modstream);
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), mcFilter, modstream.build().toList(), getFmlStuff(legacyCP));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] preLaunch(String[] arguments, ModuleLayer layer) {
|
protected String[] preLaunch(String[] arguments, ModuleLayer layer) {
|
||||||
super.preLaunch(arguments, layer);
|
super.preLaunch(arguments, layer);
|
||||||
@@ -79,34 +63,34 @@ public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
|||||||
return args.getArguments();
|
return args.getArguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Path> getFmlStuff(String[] classpath) {
|
protected List<Path> getLibraries(String[] classpath) {
|
||||||
// We also want the FML things, fmlcore, javafmllanguage, mclanguage, I don't like hard coding these, but hey whatever works for now.
|
// TODO: These should all be FMLModType: LIBRARY, find them that way?
|
||||||
return Arrays.stream(classpath)
|
// Or at the very least include version info
|
||||||
.filter(e -> FileUtils.matchFileName(e, "fmlcore", "javafmllanguage", "lowcodelanguage", "mclanguage"))
|
var fmlcore = findJarOnClasspath(classpath, "fmlcore");
|
||||||
.map(Paths::get)
|
var javafmllang = findJarOnClasspath(classpath, "javafmllanguage");
|
||||||
.toList();
|
var lowcodelang = findJarOnClasspath(classpath, "lowcodelanguage");
|
||||||
|
var mclang = findJarOnClasspath(classpath, "mclanguage");
|
||||||
|
return List.of(fmlcore, javafmllang, lowcodelang, mclang);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Path findJarOnClasspath(String[] classpath, String match) {
|
protected BiPredicate<String, String> getMcFilter(Path extra, List<Path> minecraft) {
|
||||||
return Paths.get(Arrays.stream(classpath)
|
var packages = getPackages(); // Pulled out so it is passed to the lambda as value
|
||||||
.filter(e -> FileUtils.matchFileName(e, match))
|
var extraPath = extra.toString().replace('\\', '/');
|
||||||
.findFirst()
|
|
||||||
.orElseThrow(() -> new IllegalStateException("Could not find " + match + " in classpath")));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BiPredicate<String, String> getMcFilter(Path extra, List<Path> minecraft, Stream.Builder<List<Path>> mods) {
|
|
||||||
final var packages = getPackages();
|
|
||||||
final var extraPath = extra.toString().replace('\\', '/');
|
|
||||||
|
|
||||||
// We serve everything, except for things in the forge packages.
|
// We serve everything, except for things in the forge packages.
|
||||||
BiPredicate<String, String> mcFilter = (path, base) -> {
|
BiPredicate<String, String> mcFilter = (path, base) -> {
|
||||||
if (base.equals(extraPath) ||
|
if (base.equals(extraPath) ||
|
||||||
path.endsWith("/")) return true;
|
path.endsWith("/")) return true;
|
||||||
for (var pkg : packages)
|
for (var pkg : packages)
|
||||||
if (path.startsWith(pkg)) return false;
|
if (path.startsWith(pkg)) return false;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return mcFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Path getForgeMod(List<Path> minecraft) {
|
||||||
|
var packages = getPackages(); // Pulled out so it is passed to the lambda as value
|
||||||
// We need to separate out our resources/code so that we can show up as a different data pack.
|
// We need to separate out our resources/code so that we can show up as a different data pack.
|
||||||
var modJar = SecureJar.from((path, base) -> {
|
var modJar = SecureJar.from((path, base) -> {
|
||||||
if (!path.endsWith(".class")) return true;
|
if (!path.endsWith(".class")) return true;
|
||||||
@@ -114,14 +98,18 @@ public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
|||||||
if (path.startsWith(pkg)) return true;
|
if (path.startsWith(pkg)) return true;
|
||||||
return false;
|
return false;
|
||||||
}, minecraft.stream().distinct().toArray(Path[]::new));
|
}, minecraft.stream().distinct().toArray(Path[]::new));
|
||||||
//modJar.getPackages().stream().sorted().forEach(System.out::println);
|
|
||||||
mods.add(List.of(modJar.getRootPath()));
|
|
||||||
|
|
||||||
return mcFilter;
|
//modJar.getPackages().stream().sorted().forEach(System.out::println);
|
||||||
|
return modJar.getRootPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getPackages() {
|
private static String[] getPackages() {
|
||||||
return new String[]{ "net/minecraftforge/", "META-INF/services/", "META-INF/coremods.json", "META-INF/mods.toml" };
|
return new String[] {
|
||||||
|
"net/minecraftforge/",
|
||||||
|
"META-INF/services/",
|
||||||
|
"META-INF/coremods.json",
|
||||||
|
"META-INF/mods.toml"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getRandomNumbers(int length) {
|
private static String getRandomNumbers(int length) {
|
||||||
@@ -131,9 +119,70 @@ public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ServiceRunner makeService(final String[] arguments, final ModuleLayer gameLayer) {
|
protected ServiceRunner makeService(final String[] arguments, final ModuleLayer gameLayer) {
|
||||||
var args = preLaunch(arguments, gameLayer);
|
return super.makeService(preLaunch(arguments, gameLayer), gameLayer);
|
||||||
return ()->devService(args, gameLayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void devService(final String[] arguments, final ModuleLayer gameLayer) throws Throwable;
|
// TODO: Get rid of this string based classpath crap when I re-write mod loader
|
||||||
|
protected static Map<String, List<Path>> getModClasses() {
|
||||||
|
var modClasses = Optional.ofNullable(System.getenv("MOD_CLASSES")).orElse("");
|
||||||
|
LOGGER.debug(LogMarkers.CORE, "Got mod coordinates {} from env", modClasses);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* So MOD_CLASSES at the end of the day is a Map<ModId, List<Path>> but because we want to shove that into a single string.
|
||||||
|
* And pass it in as an environment variable.. instead od using json, or a file path, or anything sane, cpw did hacky string stuff
|
||||||
|
* Basically what we want to do is split the string by File.pathSeperator to get each key-value pair.
|
||||||
|
* Then we find the magic string "%%" and split on that. Using the first half as the mod id and the second as the path.
|
||||||
|
* BUT the modID is optional, and if not specified {why wouldn't it be?} it uses "defaultmodid"
|
||||||
|
* Anyways, it was stream hell, but now it's simpler to debug/understand.
|
||||||
|
*/
|
||||||
|
Map<String, List<Path>> ret = new HashMap<>();
|
||||||
|
var entries = modClasses.split(File.pathSeparator);
|
||||||
|
for (var entry : entries) {
|
||||||
|
var modid = "defaultmodid";
|
||||||
|
var path = entry;
|
||||||
|
|
||||||
|
int idx = entry.indexOf("%%");
|
||||||
|
if (idx != -1) {
|
||||||
|
modid = entry.substring(0, idx);
|
||||||
|
path = entry.substring(idx + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = Paths.get(path);
|
||||||
|
var lst = ret.computeIfAbsent(modid, k -> new ArrayList<>());
|
||||||
|
if (!lst.contains(p))
|
||||||
|
lst.add(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.debug(LogMarkers.CORE, "Found supplied mod coordinates:");
|
||||||
|
ret.forEach((k, v) -> {
|
||||||
|
if (v.size() == 1)
|
||||||
|
LOGGER.debug(LogMarkers.CORE, "\t{}: {}", k, v.get(0));
|
||||||
|
else {
|
||||||
|
LOGGER.debug(LogMarkers.CORE, "\t{}:", k);
|
||||||
|
v.forEach(e -> LOGGER.debug("\t\t{}", e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Path findJarOnClasspath(String[] classpath, String match) {
|
||||||
|
String ret = null;
|
||||||
|
|
||||||
|
for (var entry : classpath) {
|
||||||
|
int idx = entry.lastIndexOf(File.separatorChar);
|
||||||
|
if (idx == -1) continue;
|
||||||
|
|
||||||
|
var name = entry.substring(idx + 1);
|
||||||
|
if (name.startsWith(match)) {
|
||||||
|
ret = entry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == null)
|
||||||
|
new IllegalStateException("Could not find " + match + " in classpath");
|
||||||
|
|
||||||
|
return Paths.get(ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+38
-51
@@ -10,49 +10,52 @@ import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
|||||||
import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder;
|
import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder;
|
||||||
import cpw.mods.modlauncher.api.ServiceRunner;
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import org.apache.logging.log4j.core.LoggerContext;
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
import org.apache.logging.log4j.core.config.ConfigurationFactory;
|
import org.apache.logging.log4j.core.config.ConfigurationFactory;
|
||||||
import org.apache.logging.log4j.core.config.ConfigurationSource;
|
import org.apache.logging.log4j.core.config.ConfigurationSource;
|
||||||
import org.apache.logging.log4j.core.config.Configurator;
|
import org.apache.logging.log4j.core.config.Configurator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import sun.misc.Unsafe;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is required by FMLLoader because ILaunchHandlerService doesn't have the context we need.
|
||||||
|
* I need to clean this up to make proper api. But that involves editing ModLauncher itself which i'm not gunna do right now.
|
||||||
|
*
|
||||||
|
* So until that happens, guess this is public api.
|
||||||
|
*/
|
||||||
public abstract class CommonLaunchHandler implements ILaunchHandlerService {
|
public abstract class CommonLaunchHandler implements ILaunchHandlerService {
|
||||||
public record LocatedPaths(List<Path> minecraftPaths, BiPredicate<String, String> minecraftFilter, List<List<Path>> otherModPaths, List<Path> otherArtifacts) {}
|
public record LocatedPaths(
|
||||||
|
List<Path> minecraftPaths,
|
||||||
|
BiPredicate<String, String> minecraftFilter,
|
||||||
|
List<List<Path>> otherModPaths,
|
||||||
|
List<Path> otherArtifacts
|
||||||
|
) {}
|
||||||
|
|
||||||
protected static final Logger LOGGER = LogUtils.getLogger();
|
protected static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public abstract Dist getDist();
|
private final LaunchType type;
|
||||||
|
private final String prefix;
|
||||||
|
|
||||||
|
protected CommonLaunchHandler(LaunchType type, String prefix) {
|
||||||
|
this.type = type;
|
||||||
|
this.prefix = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String name() { return this.prefix + this.type.name(); }
|
||||||
|
public Dist getDist() { return this.type.dist(); }
|
||||||
|
public boolean isData() { return this.type.data(); }
|
||||||
|
public boolean isProduction() { return false; }
|
||||||
public abstract String getNaming();
|
public abstract String getNaming();
|
||||||
|
|
||||||
public boolean isProduction() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isData() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract LocatedPaths getMinecraftPaths();
|
public abstract LocatedPaths getMinecraftPaths();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder) {
|
public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] preLaunch(String[] arguments, ModuleLayer layer) {
|
protected String[] preLaunch(String[] arguments, ModuleLayer layer) {
|
||||||
@@ -69,45 +72,29 @@ public abstract class CommonLaunchHandler implements ILaunchHandlerService {
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Map<String, List<Path>> getModClasses() {
|
|
||||||
final String modClasses = Optional.ofNullable(System.getenv("MOD_CLASSES")).orElse("");
|
|
||||||
LOGGER.debug(LogMarkers.CORE, "Got mod coordinates {} from env", modClasses);
|
|
||||||
|
|
||||||
record ExplodedModPath(String modid, Path path) {}
|
|
||||||
// "a/b/;c/d/;" -> "modid%%c:\fish\pepper;modid%%c:\fish2\pepper2\;modid2%%c:\fishy\bums;modid2%%c:\hmm"
|
|
||||||
final var modClassPaths = Arrays.stream(modClasses.split(File.pathSeparator))
|
|
||||||
.map(inp -> inp.split("%%", 2))
|
|
||||||
.map(splitString -> new ExplodedModPath(splitString.length == 1 ? "defaultmodid" : splitString[0], Paths.get(splitString[splitString.length - 1])))
|
|
||||||
.collect(Collectors.groupingBy(ExplodedModPath::modid, Collectors.mapping(ExplodedModPath::path, Collectors.toList())));
|
|
||||||
|
|
||||||
LOGGER.debug(LogMarkers.CORE, "Found supplied mod coordinates [{}]", modClassPaths);
|
|
||||||
|
|
||||||
//final var explodedTargets = ((Map<String, List<ExplodedDirectoryLocator.ExplodedMod>>)arguments).computeIfAbsent("explodedTargets", a -> new ArrayList<>());
|
|
||||||
//modClassPaths.forEach((modlabel,paths) -> explodedTargets.add(new ExplodedDirectoryLocator.ExplodedMod(modlabel, paths)));
|
|
||||||
return modClassPaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServiceRunner launchService(final String[] arguments, final ModuleLayer gameLayer) {
|
public ServiceRunner launchService(final String[] arguments, final ModuleLayer gameLayer) {
|
||||||
FMLLoader.beforeStart(gameLayer);
|
FMLLoader.beforeStart(gameLayer);
|
||||||
return makeService(arguments, gameLayer);
|
return makeService(arguments, gameLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ServiceRunner makeService(final String[] arguments, final ModuleLayer gameLayer);
|
protected ServiceRunner makeService(final String[] arguments, final ModuleLayer gameLayer) {
|
||||||
|
return () -> runTarget(this.type.module(), this.type.main(), arguments, gameLayer);
|
||||||
protected void clientService(final String[] arguments, final ModuleLayer layer) throws Throwable {
|
|
||||||
runTarget("net.minecraft.client.main.Main", arguments, layer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void serverService(final String[] arguments, final ModuleLayer layer) throws Throwable {
|
protected record LaunchType(String name, String module, String main, Dist dist, boolean data) {};
|
||||||
runTarget("net.minecraft.server.Main", arguments, layer);
|
protected static final LaunchType CLIENT = new LaunchType("client", "minecraft", "net.minecraft.client.main.Main", Dist.CLIENT, false);
|
||||||
}
|
protected static final LaunchType DATA = new LaunchType("data", "minecraft", "net.minecraft.data.Main", Dist.CLIENT, true);
|
||||||
|
protected static final LaunchType SERVER = new LaunchType("server", "minecraft", "net.minecraft.server.Main", Dist.DEDICATED_SERVER, false);
|
||||||
|
protected static final LaunchType SERVER_GAMETEST = new LaunchType("server_gametest", "forge", "net.minecraftforge.gametest.GameTestMain", Dist.DEDICATED_SERVER, false);
|
||||||
|
|
||||||
protected void dataService(final String[] arguments, final ModuleLayer layer) throws Throwable {
|
protected void runTarget(String module, String target, final String[] arguments, final ModuleLayer layer) throws Throwable {
|
||||||
runTarget("net.minecraft.data.Main", arguments, layer);
|
var mod = layer.findModule(module).orElseThrow();
|
||||||
}
|
if (mod == null) throw new IllegalStateException("Could not find module " + module);
|
||||||
|
var cls = Class.forName(mod, target);
|
||||||
protected void runTarget(final String target, final String[] arguments, final ModuleLayer layer) throws Throwable {
|
if (cls == null) throw new IllegalStateException("Could not find class " + target + " in module " + module);
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),target).getMethod("main", String[].class).invoke(null, (Object)arguments);
|
var mtd = cls.getMethod("main", String[].class);
|
||||||
|
if (mtd == null) throw new IllegalStateException("Class " + target + " in module " + module + " does not have a main(String[]) method");
|
||||||
|
mtd.invoke(null, (Object)arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
import cpw.mods.modlauncher.api.ServiceRunner;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonServerLaunchHandler extends CommonLaunchHandler {
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
@Override public String getNaming() { return "srg"; }
|
|
||||||
@Override public boolean isProduction() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ServiceRunner makeService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> serverService(arguments, layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
final var vers = FMLLoader.versionInfo();
|
|
||||||
var mc = LibraryFinder.findPathForMaven("net.minecraft", "server", "", "srg", vers.mcAndMCPVersion());
|
|
||||||
var mcextra = LibraryFinder.findPathForMaven("net.minecraft", "server", "", "extra", vers.mcAndMCPVersion());
|
|
||||||
var mcextra_filtered = SecureJar.from( // We only want it for it's resources. So filter everything else out.
|
|
||||||
(path, base) -> {
|
|
||||||
return path.equals("META-INF/versions/") || // This is required because it bypasses our filter for the manifest, and it's a multi-release jar.
|
|
||||||
(!path.endsWith(".class") &&
|
|
||||||
!path.startsWith("META-INF/"));
|
|
||||||
}, mcextra
|
|
||||||
);
|
|
||||||
BiPredicate<String, String> filter = (path, base) -> true;
|
|
||||||
|
|
||||||
var mcstream = Stream.<Path>builder().add(mc).add(mcextra_filtered.getRootPath());
|
|
||||||
var modstream = Stream.<List<Path>>builder();
|
|
||||||
|
|
||||||
filter = processMCStream(vers, mcstream, filter, modstream);
|
|
||||||
|
|
||||||
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
|
||||||
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
var lowcodelang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "lowcodelanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), filter, modstream.build().toList(), List.of(fmlcore, javafmllang, lowcodelang, mclang));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract BiPredicate<String, String> processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, BiPredicate<String, String> filter, Stream.Builder<List<Path>> mods);
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonUserdevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
final var vers = FMLLoader.versionInfo();
|
|
||||||
|
|
||||||
// Minecraft is extra jar {resources} + forge jar {patches}
|
|
||||||
final var mcstream = Stream.<Path>builder();
|
|
||||||
// Mod code is in exploded directories
|
|
||||||
final var modstream = Stream.<List<Path>>builder();
|
|
||||||
|
|
||||||
// The MC extra and forge jars are on the classpath, so try and pull them out
|
|
||||||
var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find userdev jars").split(File.pathSeparator);
|
|
||||||
var extra = findJarOnClasspath(legacyCP, "client-extra");
|
|
||||||
|
|
||||||
processStreams(legacyCP, vers, mcstream, modstream);
|
|
||||||
getModClasses().forEach((modid, paths) -> modstream.add(paths));
|
|
||||||
|
|
||||||
var minecraft = mcstream.build().collect(Collectors.toList());
|
|
||||||
var mcFilter = getMcFilter(extra, minecraft, modstream);
|
|
||||||
minecraft.add(extra); // Add extra late so the filter is made correctly
|
|
||||||
return new LocatedPaths(minecraft, mcFilter, modstream.build().toList(), getFmlStuff(legacyCP));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods);
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeClientDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeclientdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
clientService(arguments, layer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
public class ForgeClientLaunchHandler extends CommonClientLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeclient"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods) {
|
|
||||||
var forgepatches = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "client", versionInfo.mcAndForgeVersion());
|
|
||||||
var forgejar = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "universal", versionInfo.mcAndForgeVersion());
|
|
||||||
mc.add(forgepatches);
|
|
||||||
mods.add(List.of(forgejar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeClientUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public String name() { return "forgeclientuserdev"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
clientService(arguments, layer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeDataDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgedatadev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
@Override public boolean isData() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeDataUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public String name() { return "forgedatauserdev"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isData() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
dataService(arguments, layer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+295
@@ -0,0 +1,295 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.nio.file.spi.FileSystemProvider;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.objectweb.asm.AnnotationVisitor;
|
||||||
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.objectweb.asm.ClassVisitor;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import com.electronwill.nightconfig.core.Config;
|
||||||
|
import com.electronwill.nightconfig.core.file.FileNotFoundAction;
|
||||||
|
import com.electronwill.nightconfig.core.io.WritingMode;
|
||||||
|
import com.electronwill.nightconfig.toml.TomlParser;
|
||||||
|
import com.electronwill.nightconfig.toml.TomlWriter;
|
||||||
|
import com.google.common.jimfs.Jimfs;
|
||||||
|
|
||||||
|
import cpw.mods.niofs.union.UnionFileSystemProvider;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
abstract class ForgeDevLaunchHandler extends CommonDevLaunchHandler {
|
||||||
|
private static final String MODS_TOML = "META-INF/mods.toml";
|
||||||
|
private static final String PACK_META = "pack.mcmeta";
|
||||||
|
private static final UnionFileSystemProvider UFSP = (UnionFileSystemProvider)FileSystemProvider.installedProviders().stream().filter(fsp->fsp.getScheme().equals("union")).findFirst().orElseThrow(()->new IllegalStateException("Couldn't find UnionFileSystemProvider"));
|
||||||
|
|
||||||
|
private ForgeDevLaunchHandler(LaunchType type) {
|
||||||
|
super(type, "forge_dev_");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocatedPaths getMinecraftPaths() {
|
||||||
|
// Our exploded directories in development include all mods and minecraft itself.
|
||||||
|
var mods = getModClasses();
|
||||||
|
|
||||||
|
// The extra jar is on the classpath, so try and pull it out of the legacy classpath
|
||||||
|
var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find client-extra").split(File.pathSeparator);
|
||||||
|
var extra = findJarOnClasspath(legacyCP, "client-extra");
|
||||||
|
|
||||||
|
|
||||||
|
// Minecraft is extra jar {resources} + our exploded directories in dev
|
||||||
|
var minecraft = mods.remove("minecraft");
|
||||||
|
if (minecraft == null)
|
||||||
|
throw new IllegalStateException("Could not find 'minecraft' mod paths.");
|
||||||
|
var mcFilter = getMcFilter(extra, minecraft);
|
||||||
|
|
||||||
|
// The MC code/Patcher edits are in exploded directories
|
||||||
|
var modstream = Stream.<List<Path>>builder();
|
||||||
|
var forge = this.getForgeMod(minecraft);
|
||||||
|
modstream.add(List.of(forge));
|
||||||
|
|
||||||
|
// Explode our test mods into a framework that treats them all as separate jars.
|
||||||
|
var tests = mods.remove("tests");
|
||||||
|
if (tests != null)
|
||||||
|
explodeTestMods(tests).forEach(modstream::add);
|
||||||
|
|
||||||
|
mods.values().forEach(modstream::add);
|
||||||
|
|
||||||
|
return new LocatedPaths(
|
||||||
|
Stream.concat(minecraft.stream(), List.of(extra).stream()).toList(),
|
||||||
|
mcFilter,
|
||||||
|
modstream.build().toList(),
|
||||||
|
getLibraries(legacyCP)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<Path>> explodeTestMods(List<Path> paths) {
|
||||||
|
var mod = new ArrayList<List<Path>>();
|
||||||
|
var memory = Jimfs.newFileSystem();
|
||||||
|
|
||||||
|
// First lets find all class files, that have the @Mod annotation and map packages to modids.
|
||||||
|
var packages = findTestModPackages(paths);
|
||||||
|
for (var entry : packages.entrySet()) {
|
||||||
|
var pkg = entry.getKey();
|
||||||
|
var modids = entry.getValue();
|
||||||
|
|
||||||
|
var resourcePaths = new LinkedHashSet<Path>();
|
||||||
|
// Jump down into the package for resources
|
||||||
|
paths.stream()
|
||||||
|
.<Path>mapMulti((p, c) -> modids.forEach(id -> c.accept(p.resolve(id))))
|
||||||
|
.filter(Files::exists).forEach(resourcePaths::add);
|
||||||
|
|
||||||
|
var root = memory.getPath(modids.iterator().next()); // use the first modid as our root
|
||||||
|
buildModsToml(resourcePaths, modids, root);
|
||||||
|
buildPackMeta(resourcePaths, root);
|
||||||
|
|
||||||
|
if (Files.exists(root))
|
||||||
|
resourcePaths.add(root);
|
||||||
|
|
||||||
|
// We want just the class files from the root of the input paths. So make a new union with a filter.
|
||||||
|
var classes = UFSP.newFileSystem(
|
||||||
|
(path, base) -> {
|
||||||
|
if (path.endsWith("/")) {
|
||||||
|
if (path.startsWith("/"))
|
||||||
|
path = path.substring(1);
|
||||||
|
return pkg.startsWith(path) || path.startsWith(pkg);
|
||||||
|
}
|
||||||
|
return path.endsWith(".class") && path.startsWith(pkg);
|
||||||
|
}, paths.toArray(Path[]::new));
|
||||||
|
// And we want the resources, and none of the classes, just in case things get kinda fucky and somehow a package overlaps a sub package {shading?}
|
||||||
|
var resources = UFSP.newFileSystem((path, base) -> !path.endsWith(".class"), resourcePaths.toArray(Path[]::new));
|
||||||
|
|
||||||
|
mod.add(List.of(classes.getRoot(), resources.getRoot()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find all the @Mods so we can generate tomls, and so we can pick packages. Right now it doesn't allow mods in parent directories,
|
||||||
|
// I could make it merge all the way up, but I think this would be fine.
|
||||||
|
private Map<String, Set<String>> findTestModPackages(List<Path> paths) {
|
||||||
|
var mods = new HashMap<String, Set<String>>();
|
||||||
|
for (var path : paths) {
|
||||||
|
try (var files = Files.walk(path)) {
|
||||||
|
var classes = files
|
||||||
|
.filter(Files::isRegularFile)
|
||||||
|
.filter(p -> p.getFileName().toString().endsWith(".class"))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
for (var cls : classes) {
|
||||||
|
try (var is = Files.newInputStream(cls)) {
|
||||||
|
var reader = new ClassReader(is);
|
||||||
|
reader.accept(new ClassVisitor(Opcodes.ASM9) {
|
||||||
|
private String clsName;
|
||||||
|
@Override
|
||||||
|
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||||
|
this.clsName = name;
|
||||||
|
super.visit(version, access, name, signature, superName, interfaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationVisitor visitAnnotation(String name, boolean runtime) {
|
||||||
|
if (!"Lnet/minecraftforge/fml/common/Mod;".equals(name))
|
||||||
|
return super.visitAnnotation(name, runtime);
|
||||||
|
|
||||||
|
return new AnnotationVisitor(Opcodes.ASM9) {
|
||||||
|
@Override
|
||||||
|
public void visit(String key, Object value) {
|
||||||
|
if ("value".equals(key)) {
|
||||||
|
int idx = clsName.lastIndexOf('/');
|
||||||
|
var pkg = clsName.substring(0, idx);
|
||||||
|
mods.computeIfAbsent(pkg, k -> new HashSet<>()).add((String)value);
|
||||||
|
|
||||||
|
idx = pkg.lastIndexOf('/');
|
||||||
|
while (idx != -1) {
|
||||||
|
pkg = pkg.substring(0, idx);
|
||||||
|
idx = pkg.lastIndexOf('/');
|
||||||
|
if (mods.containsKey(pkg))
|
||||||
|
throw new IllegalStateException("Invalid ForgeDev test mod layout, conflicting packages: " + pkg + " for " + clsName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
sneak(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mods;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builds or update the mods.toml file for all @Mods in this package
|
||||||
|
private void buildModsToml(Set<Path> resources, Set<String> modids, Path root) {
|
||||||
|
var toml = resources.stream()
|
||||||
|
.map(p -> p.resolve(MODS_TOML))
|
||||||
|
.filter(Files::exists)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
Config cfg = null;
|
||||||
|
|
||||||
|
if (toml != null)
|
||||||
|
cfg = new TomlParser().parse(toml, FileNotFoundAction.READ_NOTHING);
|
||||||
|
else
|
||||||
|
cfg = Config.inMemory();
|
||||||
|
|
||||||
|
boolean modified = false;
|
||||||
|
var defaults = Map.of(
|
||||||
|
"modLoader", "javafml",
|
||||||
|
"loaderVersion", "[0,)",
|
||||||
|
"license", "Doesnt fucking matter"
|
||||||
|
);
|
||||||
|
|
||||||
|
for (var key : defaults.keySet()) {
|
||||||
|
if (!cfg.contains(key)) {
|
||||||
|
cfg.set(key, defaults.get(key));
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var modlist = new ArrayList<Config>();
|
||||||
|
if (cfg.contains("mods")) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
var existing = ((List<Config>)cfg.get("mods"));
|
||||||
|
modlist.addAll(existing);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var modid : modids) {
|
||||||
|
if (!modlist.stream().anyMatch(c -> modid.equals(c.get("modId")))) {
|
||||||
|
modified = true;
|
||||||
|
var tmp = Config.inMemory();
|
||||||
|
tmp.set("modId", modid);
|
||||||
|
modlist.add(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.set("mods", modlist);
|
||||||
|
|
||||||
|
if (modified) {
|
||||||
|
var target = root.resolve(MODS_TOML);
|
||||||
|
try {
|
||||||
|
Files.createDirectories(target.getParent());
|
||||||
|
new TomlWriter().write(cfg, target, WritingMode.REPLACE);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException("Failed to create in memory toml: " + target, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is optional, it just hides a warning screen when starting up. I should probably remove this once I restructure how data gen for test mods work and make it generate there.
|
||||||
|
private void buildPackMeta(Set<Path> paths, Path root) {
|
||||||
|
var existing = paths.stream()
|
||||||
|
.map(p -> p.resolve(PACK_META))
|
||||||
|
.filter(Files::exists)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (existing != null)
|
||||||
|
return;
|
||||||
|
var target = root.resolve(PACK_META);
|
||||||
|
try {
|
||||||
|
Files.createDirectories(target.getParent());
|
||||||
|
Files.writeString(target,
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"pack": {
|
||||||
|
"description": "doesn't matter",
|
||||||
|
"pack_format": 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""", StandardCharsets.UTF_8, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException("Failed to make in memory pack.mcmeta: " + target, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static <E extends Throwable, R> R sneak(Throwable e) throws E {
|
||||||
|
throw (E)e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Client extends ForgeDevLaunchHandler {
|
||||||
|
public Client() {
|
||||||
|
super(CLIENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Data extends ForgeDevLaunchHandler {
|
||||||
|
public Data() {
|
||||||
|
super(DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Server extends ForgeDevLaunchHandler {
|
||||||
|
public Server() {
|
||||||
|
super(SERVER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ServerGameTest extends ForgeDevLaunchHandler {
|
||||||
|
public ServerGameTest() {
|
||||||
|
super(SERVER_GAMETEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeGametestDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgegametestserverdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
Class.forName(layer.findModule("forge").orElseThrow(), "net.minecraftforge.gametest.GameTestMain").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeGametestUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgegametestserveruserdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
Class.forName(layer.findModule("forge").orElseThrow(), "net.minecraftforge.gametest.GameTestMain").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BiPredicate;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import net.minecraftforge.fml.loading.LibraryFinder;
|
||||||
|
import net.minecraftforge.fml.loading.VersionInfo;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
abstract class ForgeProdLaunchHandler extends CommonLaunchHandler {
|
||||||
|
protected ForgeProdLaunchHandler(LaunchType type) {
|
||||||
|
super(type, "forge_");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String getNaming() { return "srg"; }
|
||||||
|
@Override public boolean isProduction() { return true; }
|
||||||
|
|
||||||
|
protected Path mvn(VersionInfo info, String artifact) {
|
||||||
|
return mvn(info, artifact, "");
|
||||||
|
}
|
||||||
|
protected Path mvn(VersionInfo info, String artifact, String classifier) {
|
||||||
|
return mvn(info.forgeGroup(), artifact, classifier, info.mcAndForgeVersion());
|
||||||
|
}
|
||||||
|
protected Path mvn(String group, String artifact, String classifier, String version) {
|
||||||
|
return LibraryFinder.findPathForMaven(group, artifact, "", classifier, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocatedPaths getMinecraftPaths() {
|
||||||
|
var vers = FMLLoader.versionInfo();
|
||||||
|
|
||||||
|
// Minecraft
|
||||||
|
var mc = getMCPaths(vers);
|
||||||
|
|
||||||
|
// mods (Forge)
|
||||||
|
var forgejar = mvn(vers, "forge", "universal");
|
||||||
|
|
||||||
|
// Libraries
|
||||||
|
var fmlcore = mvn(vers, "fmlcore");
|
||||||
|
var javafmllang = mvn(vers, "javafmllanguage");
|
||||||
|
var lowcodelang = mvn(vers, "lowcodelanguage");
|
||||||
|
var mclang = mvn(vers, "mclanguage");
|
||||||
|
|
||||||
|
return new LocatedPaths(
|
||||||
|
mc,
|
||||||
|
null,
|
||||||
|
List.of(List.of(forgejar)),
|
||||||
|
List.of(fmlcore, javafmllang, lowcodelang, mclang)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract List<Path> getMCPaths(VersionInfo vers);
|
||||||
|
|
||||||
|
public static class Client extends ForgeProdLaunchHandler {
|
||||||
|
public Client() {
|
||||||
|
super(CLIENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Path> getMCPaths(VersionInfo vers) {
|
||||||
|
var mc = mvn("net.minecraft", "client", "srg", vers.mcAndMCPVersion());
|
||||||
|
var mcextra = mvn("net.minecraft", "client", "extra", vers.mcAndMCPVersion());
|
||||||
|
var patches = mvn(vers, "forge", "client");
|
||||||
|
return List.of(mc, mcextra, patches);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static class Server extends ForgeProdLaunchHandler {
|
||||||
|
public Server() {
|
||||||
|
super(SERVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Path> getMCPaths(VersionInfo vers) {
|
||||||
|
var mc = mvn("net.minecraft", "server", "srg", vers.mcAndMCPVersion());
|
||||||
|
var mcextra = mvn("net.minecraft", "server", "extra", vers.mcAndMCPVersion());
|
||||||
|
var patches = mvn(vers, "forge", "server");
|
||||||
|
|
||||||
|
// TODO: Get rid of this by filtering the file at install time.
|
||||||
|
// We only want it for it's resources. So filter everything else out.
|
||||||
|
BiPredicate<String, String> filter = (path, base) -> {
|
||||||
|
return path.equals("META-INF/versions/") || // This is required because it bypasses our filter for the manifest, and it's a multi-release jar.
|
||||||
|
(!path.endsWith(".class") && !path.startsWith("META-INF/"));
|
||||||
|
};
|
||||||
|
mcextra = SecureJar.from(filter, mcextra).getRootPath();
|
||||||
|
|
||||||
|
return List.of(mc, mcextra, patches);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeServerDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeserverdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
serverService(arguments, layer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class ForgeServerLaunchHandler extends CommonServerLaunchHandler implements ILaunchHandlerService {
|
|
||||||
@Override public String name() { return "forgeserver"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BiPredicate<String, String> processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, BiPredicate<String, String> filter, Stream.Builder<List<Path>> mods) {
|
|
||||||
var forgepatches = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "server", versionInfo.mcAndForgeVersion());
|
|
||||||
var forgejar = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "universal", versionInfo.mcAndForgeVersion());
|
|
||||||
mc.add(forgepatches);
|
|
||||||
mods.add(List.of(forgejar));
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public class ForgeServerUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeserveruserdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void devService(String[] arguments, ModuleLayer layer) throws Throwable {
|
|
||||||
serverService(arguments, layer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+60
-6
@@ -5,16 +5,70 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public abstract class ForgeUserdevLaunchHandler extends CommonUserdevLaunchHandler {
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
abstract class ForgeUserdevLaunchHandler extends CommonDevLaunchHandler {
|
||||||
|
private ForgeUserdevLaunchHandler(LaunchType type) {
|
||||||
|
super(type, "forge_userdev_");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods) {
|
public LocatedPaths getMinecraftPaths() {
|
||||||
var forge = findJarOnClasspath(classpath, "forge-" + versionInfo.mcAndForgeVersion());
|
var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find userdev jars").split(File.pathSeparator);
|
||||||
mc.add(forge);
|
var vers = FMLLoader.versionInfo();
|
||||||
|
|
||||||
|
// Minecraft is extra jar {resources} + forge jar {patches}
|
||||||
|
// The MC extra and forge jars are on the classpath, so try and pull them out
|
||||||
|
var extra = findJarOnClasspath(legacyCP, "client-extra");
|
||||||
|
var forge = findJarOnClasspath(legacyCP, "forge-" + vers.mcAndForgeVersion());
|
||||||
|
// We need to filter the forge jar to just MC code
|
||||||
|
var filter = getMcFilter(extra, List.of(forge));
|
||||||
|
|
||||||
|
// Mods is forge classes + anything from MOD_CLASSES
|
||||||
|
var modstream = Stream.<List<Path>>builder();
|
||||||
|
// We want the forge as a seperate mod jar.
|
||||||
|
var forgemod = this.getForgeMod(List.of(forge));
|
||||||
|
modstream.add(List.of(forgemod));
|
||||||
|
// Mod code is in exploded directories
|
||||||
|
getModClasses().forEach((modid, paths) -> modstream.add(paths));
|
||||||
|
|
||||||
|
return new LocatedPaths(
|
||||||
|
List.of(forge, extra),
|
||||||
|
filter,
|
||||||
|
modstream.build().toList(),
|
||||||
|
getLibraries(legacyCP)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Client extends ForgeUserdevLaunchHandler {
|
||||||
|
public Client() {
|
||||||
|
super(CLIENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Data extends ForgeUserdevLaunchHandler {
|
||||||
|
public Data() {
|
||||||
|
super(DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Server extends ForgeUserdevLaunchHandler {
|
||||||
|
public Server() {
|
||||||
|
super(SERVER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ServerGameTest extends ForgeUserdevLaunchHandler {
|
||||||
|
public ServerGameTest() {
|
||||||
|
super(SERVER_GAMETEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
@@ -11,6 +11,7 @@ import java.util.Set;
|
|||||||
* An exception thrown for graphs with cycles as an argument for topological sort.
|
* An exception thrown for graphs with cycles as an argument for topological sort.
|
||||||
*/
|
*/
|
||||||
public final class CyclePresentException extends IllegalArgumentException {
|
public final class CyclePresentException extends IllegalArgumentException {
|
||||||
|
private static final long serialVersionUID = -2609660010927054667L;
|
||||||
private final Set<Set<?>> cycles;
|
private final Set<Set<?>> cycles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.server;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.InvalidLauncherSetupException;
|
|
||||||
import cpw.mods.modlauncher.Launcher;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.security.CodeSource;
|
|
||||||
import java.security.ProtectionDomain;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
import java.util.jar.Manifest;
|
|
||||||
|
|
||||||
public class ServerMain {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
Class.forName("cpw.mods.modlauncher.Launcher", false, ClassLoader.getSystemClassLoader());
|
|
||||||
Class.forName("net.minecraftforge.forgespi.Environment", false, ClassLoader.getSystemClassLoader());
|
|
||||||
} catch (ClassNotFoundException cnfe) {
|
|
||||||
System.err.println("FATAL ERROR, You need to run the installer. The libraries required to launch a server are missing");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String launchArgs = Optional.ofNullable(ServerMain.class.getProtectionDomain()).
|
|
||||||
map(ProtectionDomain::getCodeSource).
|
|
||||||
map(CodeSource::getLocation).
|
|
||||||
map(ServerMain::urlToManifest).
|
|
||||||
map(Manifest::getMainAttributes).
|
|
||||||
map(a -> a.getValue("ServerLaunchArgs")).
|
|
||||||
orElseThrow(ServerMain::throwMissingManifest);
|
|
||||||
String[] defaultargs = launchArgs.split(" ");
|
|
||||||
String[] result = new String[args.length + defaultargs.length];
|
|
||||||
System.arraycopy(defaultargs, 0, result, 0, defaultargs.length);
|
|
||||||
System.arraycopy(args, 0, result, defaultargs.length, args.length);
|
|
||||||
// separate class, so the exception can resolve
|
|
||||||
new Runner().runLauncher(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Runner {
|
|
||||||
private void runLauncher(final String[] result) {
|
|
||||||
try {
|
|
||||||
Launcher.main(result);
|
|
||||||
} catch (InvalidLauncherSetupException e) {
|
|
||||||
System.err.println("The server is missing critical libraries and cannot load. Please run the installer to correct this");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static Manifest urlToManifest(URL url) {
|
|
||||||
try {
|
|
||||||
return new JarFile(new File(url.toURI())).getManifest();
|
|
||||||
} catch (URISyntaxException | IOException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RuntimeException throwMissingManifest() {
|
|
||||||
System.err.println("This is not being run from a valid JAR file, essential data is missing.");
|
|
||||||
return new RuntimeException("Missing the manifest");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
+15
-10
@@ -1,10 +1,15 @@
|
|||||||
net.minecraftforge.fml.loading.targets.ForgeClientLaunchHandler
|
# Production
|
||||||
net.minecraftforge.fml.loading.targets.ForgeClientDevLaunchHandler
|
net.minecraftforge.fml.loading.targets.ForgeProdLaunchHandler$Client
|
||||||
net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler
|
net.minecraftforge.fml.loading.targets.ForgeProdLaunchHandler$Server
|
||||||
net.minecraftforge.fml.loading.targets.ForgeServerLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeServerDevLaunchHandler
|
# Mod Developers
|
||||||
net.minecraftforge.fml.loading.targets.ForgeServerUserdevLaunchHandler
|
net.minecraftforge.fml.loading.targets.ForgeUserdevLaunchHandler$Client
|
||||||
net.minecraftforge.fml.loading.targets.ForgeDataDevLaunchHandler
|
net.minecraftforge.fml.loading.targets.ForgeUserdevLaunchHandler$Data
|
||||||
net.minecraftforge.fml.loading.targets.ForgeDataUserdevLaunchHandler
|
net.minecraftforge.fml.loading.targets.ForgeUserdevLaunchHandler$Server
|
||||||
net.minecraftforge.fml.loading.targets.ForgeGametestDevLaunchHandler
|
net.minecraftforge.fml.loading.targets.ForgeUserdevLaunchHandler$ServerGameTest
|
||||||
net.minecraftforge.fml.loading.targets.ForgeGametestUserdevLaunchHandler
|
|
||||||
|
#Working on Forge itself
|
||||||
|
net.minecraftforge.fml.loading.targets.ForgeDevLaunchHandler$Client
|
||||||
|
net.minecraftforge.fml.loading.targets.ForgeDevLaunchHandler$Data
|
||||||
|
net.minecraftforge.fml.loading.targets.ForgeDevLaunchHandler$Server
|
||||||
|
net.minecraftforge.fml.loading.targets.ForgeDevLaunchHandler$ServerGameTest
|
||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -85,9 +85,6 @@ done
|
|||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
||||||
@@ -144,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
@@ -152,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Collect all arguments for the java command;
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ plugins {
|
|||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
compileOnly(libs.nulls)
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
implementation(project(':fmlcore'))
|
implementation(project(':fmlcore'))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.apache.logging.log4j.Marker;
|
import org.apache.logging.log4j.Marker;
|
||||||
import org.apache.logging.log4j.MarkerManager;
|
import org.apache.logging.log4j.MarkerManager;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class FMLModContainer extends ModContainer
|
public class FMLModContainer extends ModContainer
|
||||||
@@ -70,6 +72,11 @@ public class FMLModContainer extends ModContainer
|
|||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
|
// When a mod constructor throws an exception, it's wrapped in an InvocationTargetException which hides the
|
||||||
|
// actual exception from the mod loading error screen.
|
||||||
|
if (e instanceof InvocationTargetException wrapped)
|
||||||
|
e = Objects.requireNonNullElse(wrapped.getCause(), e); // unwrap the exception
|
||||||
|
|
||||||
LOGGER.error(LOADING,"Failed to create mod instance. ModID: {}, class {}", getModId(), modClass.getName(), e);
|
LOGGER.error(LOADING,"Failed to create mod instance. ModID: {}, class {}", getModId(), modClass.getName(), e);
|
||||||
throw new ModLoadingException(modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, modClass);
|
throw new ModLoadingException(modInfo, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmod", e, modClass);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,33 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.github.ben-manes.versions'
|
|
||||||
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
||||||
id 'org.cadixdev.licenser'
|
id 'org.cadixdev.licenser'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'jacoco'
|
id 'jacoco'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|
||||||
|
|
||||||
java.withSourcesJar()
|
java.withSourcesJar()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
compileOnly(libs.nulls)
|
||||||
|
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
implementation(project(':fmlcore'))
|
implementation(project(':fmlcore'))
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
tasks.named('jar', Jar).configure {
|
||||||
MANIFESTS = [
|
manifest {
|
||||||
'': [
|
attributes([
|
||||||
'FMLModType': 'LANGPROVIDER',
|
'Automatic-Module-Name': project.name.toLowerCase(),
|
||||||
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
'FMLModType': 'LANGPROVIDER'
|
||||||
'Git-Commit': GIT_INFO.abbreviatedId,
|
] as java.util.LinkedHashMap)
|
||||||
'Git-Branch': GIT_INFO.branch,
|
attributes([
|
||||||
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
|
'Specification-Title': 'LowCodeMod',
|
||||||
] as LinkedHashMap,
|
|
||||||
'net/minecraftforge/fml/loading/': [
|
|
||||||
'Specification-Title': 'FMLLoader',
|
|
||||||
'Specification-Vendor': 'Forge Development LLC',
|
'Specification-Vendor': 'Forge Development LLC',
|
||||||
'Specification-Version': '1',
|
'Specification-Version': '1.0',
|
||||||
'Implementation-Title': 'FML Loader',
|
'Implementation-Title': project.name,
|
||||||
'Implementation-Version': '1.0',
|
'Implementation-Version': FORGE_VERSION.split('\\.')[0], //project.version, TODO: Split out into a real versioned system, for now use the default that net.minecraftforge.fml.loading.LanguageLoadingProvider.loadLanguageProviders() used
|
||||||
'Implementation-Vendor': 'Forge'
|
'Implementation-Vendor': 'Forge Development LLC'
|
||||||
] as LinkedHashMap
|
] as java.util.LinkedHashMap, 'net/minecraftforge/fml/lowcodemod/')
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
jar.doFirst {
|
|
||||||
manifest.attributes['Automatic-Module-Name'] = project.name
|
|
||||||
MANIFESTS.each { pkg, values ->
|
|
||||||
if (pkg == '')
|
|
||||||
manifest.attributes(values)
|
|
||||||
else
|
|
||||||
manifest.attributes(values, pkg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-38
@@ -1,51 +1,33 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.github.ben-manes.versions'
|
|
||||||
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
|
||||||
id 'org.cadixdev.licenser'
|
id 'org.cadixdev.licenser'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'jacoco'
|
id 'jacoco'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
compileOnly(libs.nulls)
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
implementation(project(':fmlcore'))
|
implementation(project(':fmlcore'))
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
java {
|
||||||
archiveClassifier = 'sources'
|
withSourcesJar()
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
tasks.named('jar', Jar).configure {
|
||||||
MANIFESTS = [
|
manifest {
|
||||||
'': [
|
attributes([
|
||||||
|
'Automatic-Module-Name': project.name.toLowerCase(),
|
||||||
'FMLModType': 'LANGPROVIDER',
|
'FMLModType': 'LANGPROVIDER',
|
||||||
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
] as LinkedHashMap)
|
||||||
'Git-Commit': GIT_INFO.abbreviatedId,
|
attributes([
|
||||||
'Git-Branch': GIT_INFO.branch,
|
'Specification-Title': 'MCLanguage',
|
||||||
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
|
|
||||||
] as LinkedHashMap,
|
|
||||||
'net/minecraftforge/fml/mclanguageprovider/': [
|
|
||||||
'Specification-Title': 'FMLLoader',
|
|
||||||
'Specification-Vendor': 'Forge Development LLC',
|
'Specification-Vendor': 'Forge Development LLC',
|
||||||
'Specification-Version': '1',
|
'Specification-Version': '1',
|
||||||
'Implementation-Title': 'FML Loader',
|
'Implementation-Title': 'MCLanguage',
|
||||||
'Implementation-Version': '1.0',
|
'Implementation-Version': '1.0',
|
||||||
'Implementation-Vendor': 'Forge'
|
'Implementation-Vendor': 'Forge Development LLC',
|
||||||
] as LinkedHashMap
|
] as LinkedHashMap, 'net/minecraftforge/fml/mclanguageprovider/')
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
jar.doFirst {
|
|
||||||
manifest.attributes['Automatic-Module-Name'] = project.name
|
|
||||||
MANIFESTS.each { pkg, values ->
|
|
||||||
if (pkg == '')
|
|
||||||
manifest.attributes(values)
|
|
||||||
else
|
|
||||||
manifest.attributes(values, pkg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,16 +37,9 @@ tasks.withType(JavaCompile) {
|
|||||||
|
|
||||||
license {
|
license {
|
||||||
header = rootProject.file('LICENSE-header.txt')
|
header = rootProject.file('LICENSE-header.txt')
|
||||||
|
|
||||||
include 'net/minecraftforge/'
|
include 'net/minecraftforge/'
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives jar
|
|
||||||
archives sourcesJar
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing.publications.mavenJava(MavenPublication) {
|
publishing.publications.mavenJava(MavenPublication) {
|
||||||
from components.java
|
from components.java
|
||||||
artifact sourcesJar
|
|
||||||
}
|
}
|
||||||
+7
-7
@@ -16,19 +16,19 @@ Step 1: Open your command-line and browse to the folder where you extracted the
|
|||||||
|
|
||||||
Step 2: You're left with a choice.
|
Step 2: You're left with a choice.
|
||||||
If you prefer to use Eclipse:
|
If you prefer to use Eclipse:
|
||||||
1. Run the following command: `gradlew genEclipseRuns` (`./gradlew genEclipseRuns` if you are on Mac/Linux)
|
1. Run the following command: `./gradlew genEclipseRuns`
|
||||||
2. Open Eclipse, Import > Existing Gradle Project > Select Folder
|
2. Open Eclipse, Import > Existing Gradle Project > Select Folder
|
||||||
or run `gradlew eclipse` to generate the project.
|
or run `gradlew eclipse` to generate the project.
|
||||||
|
|
||||||
If you prefer to use IntelliJ:
|
If you prefer to use IntelliJ:
|
||||||
1. Open IDEA, and import project.
|
1. Open IDEA, and import project.
|
||||||
2. Select your build.gradle file and have it import.
|
2. Select your build.gradle file and have it import.
|
||||||
3. Run the following command: `gradlew genIntellijRuns` (`./gradlew genIntellijRuns` if you are on Mac/Linux)
|
3. Run the following command: `./gradlew genIntellijRuns`
|
||||||
4. Refresh the Gradle Project in IDEA if required.
|
4. Refresh the Gradle Project in IDEA if required.
|
||||||
|
|
||||||
If at any point you are missing libraries in your IDE, or you've run into problems you can
|
If at any point you are missing libraries in your IDE, or you've run into problems you can
|
||||||
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
|
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
|
||||||
{this does not affect your code} and then start the process again.
|
(this does not affect your code) and then start the process again.
|
||||||
|
|
||||||
Mapping Names:
|
Mapping Names:
|
||||||
=============================
|
=============================
|
||||||
@@ -40,7 +40,7 @@ https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
|||||||
|
|
||||||
Additional Resources:
|
Additional Resources:
|
||||||
=========================
|
=========================
|
||||||
Community Documentation: https://mcforge.readthedocs.io/en/latest/gettingstarted/
|
Community Documentation: https://docs.minecraftforge.net/en/latest/gettingstarted/
|
||||||
LexManos' Install Video: https://www.youtube.com/watch?v=8VEdtQLuLO0
|
LexManos' Install Video: https://youtu.be/8VEdtQLuLO0
|
||||||
Forge Forum: https://forums.minecraftforge.net/
|
Forge Forums: https://forums.minecraftforge.net/
|
||||||
Forge Discord: https://discord.gg/UvedJ9m
|
Forge Discord: https://discord.minecraftforge.net/
|
||||||
+1
-1
@@ -2,7 +2,7 @@ plugins {
|
|||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = mod_version
|
version = mod_version
|
||||||
|
|||||||
+1
-1
@@ -9,5 +9,5 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/CrashReport.java
|
--- a/net/minecraft/CrashReport.java
|
||||||
+++ b/net/minecraft/CrashReport.java
|
+++ b/net/minecraft/CrashReport.java
|
||||||
@@ -57,14 +_,8 @@
|
@@ -57,14 +_,9 @@
|
||||||
if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) {
|
if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) {
|
||||||
p_127520_.append("-- Head --\n");
|
p_127520_.append("-- Head --\n");
|
||||||
p_127520_.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
|
p_127520_.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
- }
|
- }
|
||||||
-
|
-
|
||||||
- p_127520_.append("\n");
|
- p_127520_.append("\n");
|
||||||
|
+ p_127520_.append(net.minecraftforge.logging.CrashReportAnalyser.appendSuspectedMods(this.exception, this.uncategorizedStackTrace));
|
||||||
+ p_127520_.append("Stacktrace:");
|
+ p_127520_.append("Stacktrace:");
|
||||||
+ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace));
|
+ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace));
|
||||||
}
|
}
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
this.systemReport.appendToCrashReportString(p_127520_);
|
this.systemReport.appendToCrashReportString(p_127520_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,23 +_,13 @@
|
@@ -91,18 +_,7 @@
|
||||||
throwable.setStackTrace(this.exception.getStackTrace());
|
throwable.setStackTrace(this.exception.getStackTrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,9 +46,3 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFriendlyReport() {
|
public String getFriendlyReport() {
|
||||||
StringBuilder stringbuilder = new StringBuilder();
|
|
||||||
stringbuilder.append("---- Minecraft Crash Report ----\n");
|
|
||||||
+ net.minecraftforge.logging.CrashReportExtender.addCrashReportHeader(stringbuilder, this);
|
|
||||||
stringbuilder.append("// ");
|
|
||||||
stringbuilder.append(getErrorComment());
|
|
||||||
stringbuilder.append("\n\n");
|
|
||||||
@@ -8,10 +8,10 @@
|
|||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
public static Advancement fromJson(JsonObject p_300691_, DeserializationContext p_300053_) {
|
public static Advancement fromJson(JsonObject p_300691_, DeserializationContext p_300053_) {
|
||||||
+ return fromJson(p_300691_, p_300053_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY);
|
+ return fromJson(p_300691_, p_300053_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static Advancement fromJson(JsonObject p_300691_, DeserializationContext p_300053_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) {
|
+ public static Advancement fromJson(JsonObject p_300691_, DeserializationContext p_300053_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) {
|
||||||
+ //if ((p_300691_ = net.minecraftforge.common.crafting.ConditionalAdvancement.processConditional(p_300691_, context)) == null) return null;
|
+ if ((p_300691_ = net.minecraftforge.common.ForgeHooks.readConditionalAdvancement(context, p_300691_)) == null) return null;
|
||||||
Optional<ResourceLocation> optional = p_300691_.has("parent") ? Optional.of(new ResourceLocation(GsonHelper.getAsString(p_300691_, "parent"))) : Optional.empty();
|
Optional<ResourceLocation> optional = p_300691_.has("parent") ? Optional.of(new ResourceLocation(GsonHelper.getAsString(p_300691_, "parent"))) : Optional.empty();
|
||||||
Optional<DisplayInfo> optional1 = p_300691_.has("display") ? Optional.of(DisplayInfo.fromJson(GsonHelper.getAsJsonObject(p_300691_, "display"))) : Optional.empty();
|
Optional<DisplayInfo> optional1 = p_300691_.has("display") ? Optional.of(DisplayInfo.fromJson(GsonHelper.getAsJsonObject(p_300691_, "display"))) : Optional.empty();
|
||||||
AdvancementRewards advancementrewards = p_300691_.has("rewards") ? AdvancementRewards.deserialize(GsonHelper.getAsJsonObject(p_300691_, "rewards")) : AdvancementRewards.EMPTY;
|
AdvancementRewards advancementrewards = p_300691_.has("rewards") ? AdvancementRewards.deserialize(GsonHelper.getAsJsonObject(p_300691_, "rewards")) : AdvancementRewards.EMPTY;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/advancements/CriteriaTriggers.java
|
||||||
|
+++ b/net/minecraft/advancements/CriteriaTriggers.java
|
||||||
|
@@ -46,7 +_,7 @@
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
public class CriteriaTriggers {
|
||||||
|
- private static final BiMap<ResourceLocation, CriterionTrigger<?>> CRITERIA = HashBiMap.create();
|
||||||
|
+ private static final BiMap<ResourceLocation, CriterionTrigger<?>> CRITERIA = com.google.common.collect.Maps.synchronizedBiMap(HashBiMap.create());
|
||||||
|
public static final ImpossibleTrigger IMPOSSIBLE = register("impossible", new ImpossibleTrigger());
|
||||||
|
public static final KilledTrigger PLAYER_KILLED_ENTITY = register("player_killed_entity", new KilledTrigger());
|
||||||
|
public static final KilledTrigger ENTITY_KILLED_PLAYER = register("entity_killed_player", new KilledTrigger());
|
||||||
@@ -90,10 +90,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String saveString() {
|
public String saveString() {
|
||||||
@@ -184,4 +_,84 @@
|
@@ -183,5 +_,89 @@
|
||||||
|
|
||||||
public void setDown(boolean p_90846_) {
|
public void setDown(boolean p_90846_) {
|
||||||
this.isDown = p_90846_;
|
this.isDown = p_90846_;
|
||||||
}
|
+ }
|
||||||
+
|
+
|
||||||
+ /****************** Forge Start *****************************/
|
+ /****************** Forge Start *****************************/
|
||||||
+ private net.minecraftforge.client.settings.KeyModifier keyModifierDefault = net.minecraftforge.client.settings.KeyModifier.NONE;
|
+ private net.minecraftforge.client.settings.KeyModifier keyModifierDefault = net.minecraftforge.client.settings.KeyModifier.NONE;
|
||||||
@@ -165,13 +166,17 @@
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode) {
|
+ public void setKeyModifierAndCode(@org.jetbrains.annotations.Nullable net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode) {
|
||||||
+ this.key = keyCode;
|
|
||||||
+ if (keyModifier.matches(keyCode))
|
|
||||||
+ keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE;
|
|
||||||
+ MAP.remove(this);
|
+ MAP.remove(this);
|
||||||
|
+
|
||||||
|
+ if (keyModifier == null)
|
||||||
|
+ keyModifier = net.minecraftforge.client.settings.KeyModifier.getModifier(this.key);
|
||||||
|
+ if (keyModifier == null || keyCode == InputConstants.UNKNOWN || net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(keyCode))
|
||||||
|
+ keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE;
|
||||||
|
+
|
||||||
|
+ this.key = keyCode;
|
||||||
+ this.keyModifier = keyModifier;
|
+ this.keyModifier = keyModifier;
|
||||||
|
+
|
||||||
+ MAP.put(keyCode, this);
|
+ MAP.put(keyCode, this);
|
||||||
+ }
|
}
|
||||||
+ /****************** Forge End *****************************/
|
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,5 @@
|
|||||||
--- a/net/minecraft/client/KeyboardHandler.java
|
--- a/net/minecraft/client/KeyboardHandler.java
|
||||||
+++ b/net/minecraft/client/KeyboardHandler.java
|
+++ b/net/minecraft/client/KeyboardHandler.java
|
||||||
@@ -340,7 +_,9 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (p_90897_ == 1 && (!(this.minecraft.screen instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).lastKeySelection <= Util.getMillis() - 20L)) {
|
|
||||||
+
|
|
||||||
+ if ((!(this.minecraft.screen instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).lastKeySelection <= Util.getMillis() - 20L)) {
|
|
||||||
+ if (p_90897_ == 1) {
|
|
||||||
if (this.minecraft.options.keyFullscreen.matches(p_90895_, p_90896_)) {
|
|
||||||
this.minecraft.getWindow().toggleFullScreen();
|
|
||||||
this.minecraft.options.fullscreen().set(this.minecraft.getWindow().isFullscreen());
|
|
||||||
@@ -358,6 +_,8 @@
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
+ } else if (p_90897_ == 0 /*GLFW_RELEASE*/ && this.minecraft.screen instanceof KeyBindsScreen)
|
|
||||||
+ ((KeyBindsScreen)this.minecraft.screen).selectedKey = null; //Forge: Unset pure modifiers.
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.minecraft.getNarrator().isActive() && this.minecraft.options.narratorHotkey().get()) {
|
|
||||||
@@ -380,11 +_,15 @@
|
@@ -380,11 +_,15 @@
|
||||||
Screen.wrapScreenError(() -> {
|
Screen.wrapScreenError(() -> {
|
||||||
if (p_90897_ != 1 && p_90897_ != 2) {
|
if (p_90897_ != 1 && p_90897_ != 2) {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
StringBuilder stringbuilder = new StringBuilder("Minecraft");
|
StringBuilder stringbuilder = new StringBuilder("Minecraft");
|
||||||
if (checkModStatus().shouldReportAsModified()) {
|
if (checkModStatus().shouldReportAsModified()) {
|
||||||
- stringbuilder.append("*");
|
- stringbuilder.append("*");
|
||||||
+ stringbuilder.append(' ').append(net.minecraftforge.forge.snapshots.ForgeSnapshotsMod.BRANDING_NAME).append('*');
|
+ stringbuilder.append(" Forge").append('*');
|
||||||
}
|
}
|
||||||
|
|
||||||
stringbuilder.append(" ");
|
stringbuilder.append(" ");
|
||||||
@@ -200,6 +200,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.fpsPieResults != null) {
|
if (this.fpsPieResults != null) {
|
||||||
|
@@ -1223,6 +_,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pause = flag1;
|
||||||
|
+ net.minecraftforge.client.ForgeHooksClient.onClientPauseUpdate(this.pause);
|
||||||
|
}
|
||||||
|
|
||||||
|
long l = Util.getNanos();
|
||||||
@@ -1302,10 +_,12 @@
|
@@ -1302,10 +_,12 @@
|
||||||
this.window.setGuiScale((double)i);
|
this.window.setGuiScale((double)i);
|
||||||
if (this.screen != null) {
|
if (this.screen != null) {
|
||||||
|
|||||||
@@ -18,11 +18,10 @@
|
|||||||
this.minecraft = p_92138_;
|
this.minecraft = p_92138_;
|
||||||
this.optionsFile = new File(p_92139_, "options.txt");
|
this.optionsFile = new File(p_92139_, "options.txt");
|
||||||
boolean flag = p_92138_.is64Bit();
|
boolean flag = p_92138_.is64Bit();
|
||||||
@@ -957,11 +_,21 @@
|
@@ -957,11 +_,20 @@
|
||||||
p_168428_.process("telemetryOptInExtra", this.telemetryOptInExtra);
|
p_168428_.process("telemetryOptInExtra", this.telemetryOptInExtra);
|
||||||
this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility);
|
this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility);
|
||||||
|
|
||||||
+ net.minecraftforge.forge.snapshots.ForgeSnapshotsMod.processOptions(p_168428_);
|
|
||||||
+ processOptionsForge(p_168428_);
|
+ processOptionsForge(p_168428_);
|
||||||
+ }
|
+ }
|
||||||
+ // FORGE: split off to allow reloading options after mod loading is done
|
+ // FORGE: split off to allow reloading options after mod loading is done
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@
|
|||||||
this.renderInside(p_282589_, p_282255_, p_283354_, i, j);
|
this.renderInside(p_282589_, p_282255_, p_283354_, i, j);
|
||||||
this.renderWindow(p_282589_, i, j);
|
this.renderWindow(p_282589_, i, j);
|
||||||
this.renderTooltips(p_282589_, p_282255_, p_283354_, i, j);
|
this.renderTooltips(p_282589_, p_282255_, p_283354_, i, j);
|
||||||
+ super.render(p_282589_, p_282255_, p_283354_, p_283123_);
|
+ this.renderables.forEach(r -> r.render(p_282589_, p_282255_, p_283354_, p_283123_));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mouseDragged(double p_97347_, double p_97348_, int p_97349_, double p_97350_, double p_97351_) {
|
public boolean mouseDragged(double p_97347_, double p_97348_, int p_97349_, double p_97350_, double p_97351_) {
|
||||||
|
|||||||
@@ -9,9 +9,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getRowWidth() {
|
public int getRowWidth() {
|
||||||
@@ -129,10 +_,11 @@
|
@@ -128,11 +_,13 @@
|
||||||
|
this.name = p_193917_;
|
||||||
this.changeButton = Button.builder(p_193917_, (p_269618_) -> {
|
this.changeButton = Button.builder(p_193917_, (p_269618_) -> {
|
||||||
KeyBindsList.this.keyBindsScreen.selectedKey = p_193916_;
|
KeyBindsList.this.keyBindsScreen.selectedKey = p_193916_;
|
||||||
|
+ p_193916_.setKeyModifierAndCode(null, com.mojang.blaze3d.platform.InputConstants.UNKNOWN);
|
||||||
KeyBindsList.this.resetMappingAndUpdateButtons();
|
KeyBindsList.this.resetMappingAndUpdateButtons();
|
||||||
- }).bounds(0, 0, 75, 20).createNarration((p_253311_) -> {
|
- }).bounds(0, 0, 75, 20).createNarration((p_253311_) -> {
|
||||||
+ }).bounds(0, 0, 75 + 20 /* Forge: Add space */, 20).createNarration((p_253311_) -> {
|
+ }).bounds(0, 0, 75 + 20 /* Forge: Add space */, 20).createNarration((p_253311_) -> {
|
||||||
|
|||||||
+25
-5
@@ -9,18 +9,38 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.keyBindsList.resetMappingAndUpdateButtons();
|
this.keyBindsList.resetMappingAndUpdateButtons();
|
||||||
@@ -55,11 +_,14 @@
|
@@ -55,11 +_,13 @@
|
||||||
public boolean keyPressed(int p_193987_, int p_193988_, int p_193989_) {
|
public boolean keyPressed(int p_193987_, int p_193988_, int p_193989_) {
|
||||||
if (this.selectedKey != null) {
|
if (this.selectedKey != null) {
|
||||||
if (p_193987_ == 256) {
|
if (p_193987_ == 256) {
|
||||||
+ this.selectedKey.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.UNKNOWN);
|
+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.UNKNOWN);
|
||||||
this.options.setKey(this.selectedKey, InputConstants.UNKNOWN);
|
this.options.setKey(this.selectedKey, InputConstants.UNKNOWN);
|
||||||
} else {
|
} else {
|
||||||
+ this.selectedKey.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.getKey(p_193987_, p_193988_));
|
+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_193987_, p_193988_));
|
||||||
this.options.setKey(this.selectedKey, InputConstants.getKey(p_193987_, p_193988_));
|
this.options.setKey(this.selectedKey, InputConstants.getKey(p_193987_, p_193988_));
|
||||||
}
|
}
|
||||||
|
-
|
||||||
+ if(!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey()))
|
+ if (p_193987_ == 256 || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey()))
|
||||||
this.selectedKey = null;
|
this.selectedKey = null;
|
||||||
this.lastKeySelection = Util.getMillis();
|
this.lastKeySelection = Util.getMillis();
|
||||||
this.keyBindsList.resetMappingAndUpdateButtons();
|
this.keyBindsList.resetMappingAndUpdateButtons();
|
||||||
|
@@ -67,6 +_,19 @@
|
||||||
|
} else {
|
||||||
|
return super.keyPressed(p_193987_, p_193988_, p_193989_);
|
||||||
|
}
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
|
||||||
|
+ // Forge: We wait for a second key above if the first press is a modifier
|
||||||
|
+ // but if they release the modifier then set it explicitly.
|
||||||
|
+ var key = InputConstants.getKey(keyCode, scanCode);
|
||||||
|
+ if (this.selectedKey != null && this.selectedKey.getKey() == key) {
|
||||||
|
+ this.selectedKey = null;
|
||||||
|
+ this.lastKeySelection = Util.getMillis();
|
||||||
|
+ this.keyBindsList.resetMappingAndUpdateButtons();
|
||||||
|
+ }
|
||||||
|
+ return super.keyReleased(keyCode, scanCode, modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(GuiGraphics p_282556_, int p_193992_, int p_193993_, float p_193994_) {
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--- a/net/minecraft/data/recipes/CraftingRecipeBuilder.java
|
||||||
|
+++ b/net/minecraft/data/recipes/CraftingRecipeBuilder.java
|
||||||
|
@@ -31,8 +_,15 @@
|
||||||
|
this.category = p_250313_;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private net.minecraftforge.common.crafting.conditions.ICondition condition;
|
||||||
|
+ public <R extends CraftingResult> R withCondition(net.minecraftforge.common.crafting.conditions.ICondition condition) {
|
||||||
|
+ this.condition = condition;
|
||||||
|
+ return (R)this;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public void serializeRecipeData(JsonObject p_250456_) {
|
||||||
|
p_250456_.addProperty("category", this.category.getSerializedName());
|
||||||
|
+ net.minecraftforge.common.ForgeHooks.writeCondition(this.condition, p_250456_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
--- a/net/minecraft/data/recipes/FinishedRecipe.java
|
||||||
|
+++ b/net/minecraft/data/recipes/FinishedRecipe.java
|
||||||
|
@@ -23,4 +_,12 @@
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
AdvancementHolder advancement();
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ default AdvancementData advancementData() {
|
||||||
|
+ var adv = this.advancement();
|
||||||
|
+ return adv == null ? null : new AdvancementData(adv.id(), adv.value().serializeToJson());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ record AdvancementData(ResourceLocation id, JsonObject data) {}
|
||||||
|
}
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
--- a/net/minecraft/data/recipes/RecipeProvider.java
|
--- a/net/minecraft/data/recipes/RecipeProvider.java
|
||||||
+++ b/net/minecraft/data/recipes/RecipeProvider.java
|
+++ b/net/minecraft/data/recipes/RecipeProvider.java
|
||||||
@@ -93,7 +_,9 @@
|
@@ -90,10 +_,11 @@
|
||||||
AdvancementHolder advancementholder = p_300066_.advancement();
|
throw new IllegalStateException("Duplicate recipe " + p_300066_.id());
|
||||||
if (advancementholder != null) {
|
} else {
|
||||||
JsonObject jsonobject = advancementholder.value().serializeToJson();
|
list.add(DataProvider.saveStable(p_254020_, p_300066_.serializeRecipe(), RecipeProvider.this.recipePathProvider.json(p_300066_.id())));
|
||||||
|
- AdvancementHolder advancementholder = p_300066_.advancement();
|
||||||
|
- if (advancementholder != null) {
|
||||||
|
- JsonObject jsonobject = advancementholder.value().serializeToJson();
|
||||||
- list.add(DataProvider.saveStable(p_254020_, jsonobject, RecipeProvider.this.advancementPathProvider.json(advancementholder.id())));
|
- list.add(DataProvider.saveStable(p_254020_, jsonobject, RecipeProvider.this.advancementPathProvider.json(advancementholder.id())));
|
||||||
+ var saveAdvancementFuture = saveAdvancement(p_254020_, jsonobject, advancementholder, p_300066_);
|
+ var advancementdata = p_300066_.advancementData();
|
||||||
|
+ if (advancementdata != null) {
|
||||||
|
+ var saveAdvancementFuture = saveAdvancement(p_254020_, advancementdata.id(), advancementdata.data(), p_300066_);
|
||||||
+ if (saveAdvancementFuture != null)
|
+ if (saveAdvancementFuture != null)
|
||||||
+ list.add(saveAdvancementFuture);
|
+ list.add(saveAdvancementFuture);
|
||||||
}
|
}
|
||||||
@@ -23,8 +28,8 @@
|
|||||||
+ * @return A completable future that saves the advancement to disk, or null to cancel saving the advancement.
|
+ * @return A completable future that saves the advancement to disk, or null to cancel saving the advancement.
|
||||||
+ */
|
+ */
|
||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ protected CompletableFuture<?> saveAdvancement(CachedOutput output, JsonObject advancementJson, AdvancementHolder holder, FinishedRecipe finishedRecipe) {
|
+ protected CompletableFuture<?> saveAdvancement(CachedOutput output, ResourceLocation advancementId, JsonObject advancementJson, FinishedRecipe finishedRecipe) {
|
||||||
+ return DataProvider.saveStable(output, advancementJson, this.advancementPathProvider.json(holder.id()));
|
+ return DataProvider.saveStable(output, advancementJson, this.advancementPathProvider.json(advancementId));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CompletableFuture<?> buildAdvancement(CachedOutput p_253674_, AdvancementHolder p_297687_) {
|
protected CompletableFuture<?> buildAdvancement(CachedOutput p_253674_, AdvancementHolder p_297687_) {
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--- a/net/minecraft/data/recipes/ShapedRecipeBuilder.java
|
||||||
|
+++ b/net/minecraft/data/recipes/ShapedRecipeBuilder.java
|
||||||
|
@@ -101,7 +_,14 @@
|
||||||
|
this.ensureValid(p_126142_);
|
||||||
|
Advancement.Builder advancement$builder = p_298334_.advancement().addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(p_126142_)).rewards(AdvancementRewards.Builder.recipe(p_126142_)).requirements(AdvancementRequirements.Strategy.OR);
|
||||||
|
this.criteria.forEach(advancement$builder::addCriterion);
|
||||||
|
- p_298334_.accept(new ShapedRecipeBuilder.Result(p_126142_, this.result, this.count, this.group == null ? "" : this.group, determineBookCategory(this.category), this.rows, this.key, advancement$builder.build(p_126142_.withPrefix("recipes/" + this.category.getFolderName() + "/")), this.showNotification));
|
||||||
|
+ p_298334_.accept(new ShapedRecipeBuilder.Result(p_126142_, this.result, this.count, this.group == null ? "" : this.group, determineBookCategory(this.category), this.rows, this.key, advancement$builder.build(p_126142_.withPrefix("recipes/" + this.category.getFolderName() + "/")), this.showNotification).withCondition(this.condition));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ private net.minecraftforge.common.crafting.conditions.ICondition condition;
|
||||||
|
+ public ShapedRecipeBuilder condition(net.minecraftforge.common.crafting.conditions.ICondition condition) {
|
||||||
|
+ this.condition = condition;
|
||||||
|
+ return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureValid(ResourceLocation p_126144_) {
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--- a/net/minecraft/data/recipes/ShapelessRecipeBuilder.java
|
||||||
|
+++ b/net/minecraft/data/recipes/ShapelessRecipeBuilder.java
|
||||||
|
@@ -91,7 +_,14 @@
|
||||||
|
this.ensureValid(p_126206_);
|
||||||
|
Advancement.Builder advancement$builder = p_300117_.advancement().addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(p_126206_)).rewards(AdvancementRewards.Builder.recipe(p_126206_)).requirements(AdvancementRequirements.Strategy.OR);
|
||||||
|
this.criteria.forEach(advancement$builder::addCriterion);
|
||||||
|
- p_300117_.accept(new ShapelessRecipeBuilder.Result(p_126206_, this.result, this.count, this.group == null ? "" : this.group, determineBookCategory(this.category), this.ingredients, advancement$builder.build(p_126206_.withPrefix("recipes/" + this.category.getFolderName() + "/"))));
|
||||||
|
+ p_300117_.accept(new ShapelessRecipeBuilder.Result(p_126206_, this.result, this.count, this.group == null ? "" : this.group, determineBookCategory(this.category), this.ingredients, advancement$builder.build(p_126206_.withPrefix("recipes/" + this.category.getFolderName() + "/"))).withCondition(this.condition));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ private net.minecraftforge.common.crafting.conditions.ICondition condition;
|
||||||
|
+ public ShapelessRecipeBuilder condition(net.minecraftforge.common.crafting.conditions.ICondition condition) {
|
||||||
|
+ this.condition = condition;
|
||||||
|
+ return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureValid(ResourceLocation p_126208_) {
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
--- a/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java
|
||||||
|
+++ b/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java
|
||||||
|
@@ -80,7 +_,14 @@
|
||||||
|
this.ensureValid(p_126264_);
|
||||||
|
Advancement.Builder advancement$builder = p_299448_.advancement().addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(p_126264_)).rewards(AdvancementRewards.Builder.recipe(p_126264_)).requirements(AdvancementRequirements.Strategy.OR);
|
||||||
|
this.criteria.forEach(advancement$builder::addCriterion);
|
||||||
|
- p_299448_.accept(new SimpleCookingRecipeBuilder.Result(p_126264_, this.group == null ? "" : this.group, this.bookCategory, this.ingredient, this.result, this.experience, this.cookingTime, advancement$builder.build(p_126264_.withPrefix("recipes/" + this.category.getFolderName() + "/")), this.serializer));
|
||||||
|
+ p_299448_.accept(new SimpleCookingRecipeBuilder.Result(p_126264_, this.group == null ? "" : this.group, this.bookCategory, this.ingredient, this.result, this.experience, this.cookingTime, advancement$builder.build(p_126264_.withPrefix("recipes/" + this.category.getFolderName() + "/")), this.serializer, this.condition));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ private net.minecraftforge.common.crafting.conditions.ICondition condition;
|
||||||
|
+ public SimpleCookingRecipeBuilder condition(net.minecraftforge.common.crafting.conditions.ICondition condition) {
|
||||||
|
+ this.condition = condition;
|
||||||
|
+ return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CookingBookCategory determineSmeltingRecipeCategory(ItemLike p_251938_) {
|
||||||
|
@@ -113,8 +_,13 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- static record Result(ResourceLocation id, String group, CookingBookCategory category, Ingredient ingredient, Item result, float experience, int cookingTime, AdvancementHolder advancement, RecipeSerializer<? extends AbstractCookingRecipe> type) implements FinishedRecipe {
|
||||||
|
+ static record Result(ResourceLocation id, String group, CookingBookCategory category, Ingredient ingredient, Item result, float experience, int cookingTime, AdvancementHolder advancement, RecipeSerializer<? extends AbstractCookingRecipe> type, net.minecraftforge.common.crafting.conditions.ICondition condition) implements FinishedRecipe {
|
||||||
|
+ public Result(ResourceLocation id, String group, CookingBookCategory category, Ingredient ingredient, Item result, float experience, int cookingTime, AdvancementHolder advancement, RecipeSerializer<? extends AbstractCookingRecipe> type) {
|
||||||
|
+ this(id, group, category, ingredient, result, experience, cookingTime, advancement, type, null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public void serializeRecipeData(JsonObject p_126297_) {
|
||||||
|
+ net.minecraftforge.common.ForgeHooks.writeCondition(this.condition, p_126297_);
|
||||||
|
if (!this.group.isEmpty()) {
|
||||||
|
p_126297_.addProperty("group", this.group);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
--- a/net/minecraft/data/recipes/SingleItemRecipeBuilder.java
|
||||||
|
+++ b/net/minecraft/data/recipes/SingleItemRecipeBuilder.java
|
||||||
|
@@ -61,7 +_,14 @@
|
||||||
|
this.ensureValid(p_126328_);
|
||||||
|
Advancement.Builder advancement$builder = p_298439_.advancement().addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(p_126328_)).rewards(AdvancementRewards.Builder.recipe(p_126328_)).requirements(AdvancementRequirements.Strategy.OR);
|
||||||
|
this.criteria.forEach(advancement$builder::addCriterion);
|
||||||
|
- p_298439_.accept(new SingleItemRecipeBuilder.Result(p_126328_, this.type, this.group == null ? "" : this.group, this.ingredient, this.result, this.count, advancement$builder.build(p_126328_.withPrefix("recipes/" + this.category.getFolderName() + "/"))));
|
||||||
|
+ p_298439_.accept(new SingleItemRecipeBuilder.Result(p_126328_, this.type, this.group == null ? "" : this.group, this.ingredient, this.result, this.count, advancement$builder.build(p_126328_.withPrefix("recipes/" + this.category.getFolderName() + "/")), condition));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ private net.minecraftforge.common.crafting.conditions.ICondition condition;
|
||||||
|
+ public SingleItemRecipeBuilder condition(net.minecraftforge.common.crafting.conditions.ICondition condition) {
|
||||||
|
+ this.condition = condition;
|
||||||
|
+ return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureValid(ResourceLocation p_126330_) {
|
||||||
|
@@ -70,8 +_,13 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static record Result(ResourceLocation id, RecipeSerializer<?> type, String group, Ingredient ingredient, Item result, int count, AdvancementHolder advancement) implements FinishedRecipe {
|
||||||
|
+ public static record Result(ResourceLocation id, RecipeSerializer<?> type, String group, Ingredient ingredient, Item result, int count, AdvancementHolder advancement, net.minecraftforge.common.crafting.conditions.ICondition condition) implements FinishedRecipe {
|
||||||
|
+ Result(ResourceLocation id, RecipeSerializer<?> type, String group, Ingredient ingredient, Item result, int count, AdvancementHolder advancement) {
|
||||||
|
+ this(id, type, group, ingredient, result, count, advancement, null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public void serializeRecipeData(JsonObject p_126349_) {
|
||||||
|
+ net.minecraftforge.common.ForgeHooks.writeCondition(this.condition, p_126349_);
|
||||||
|
if (!this.group.isEmpty()) {
|
||||||
|
p_126349_.addProperty("group", this.group);
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
--- a/net/minecraft/gametest/framework/GameTest.java
|
|
||||||
+++ b/net/minecraft/gametest/framework/GameTest.java
|
|
||||||
@@ -16,6 +_,11 @@
|
|
||||||
|
|
||||||
boolean required() default true;
|
|
||||||
|
|
||||||
+ /**
|
|
||||||
+ * The namespace of where to grab the structure from, generally a mod id.
|
|
||||||
+ */
|
|
||||||
+ String templateNamespace() default "";
|
|
||||||
+
|
|
||||||
String template() default "";
|
|
||||||
|
|
||||||
long setupTicks() default 0L;
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/gametest/framework/GameTestHelper.java
|
||||||
|
+++ b/net/minecraft/gametest/framework/GameTestHelper.java
|
||||||
|
@@ -54,7 +_,7 @@
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
-public class GameTestHelper {
|
||||||
|
+public class GameTestHelper implements net.minecraftforge.common.extensions.IForgeGameTestHelper {
|
||||||
|
private final GameTestInfo testInfo;
|
||||||
|
private boolean finalCheckAdded;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/gametest/framework/GameTestRegistry.java
|
--- a/net/minecraft/gametest/framework/GameTestRegistry.java
|
||||||
+++ b/net/minecraft/gametest/framework/GameTestRegistry.java
|
+++ b/net/minecraft/gametest/framework/GameTestRegistry.java
|
||||||
@@ -25,21 +_,33 @@
|
@@ -25,22 +_,31 @@
|
||||||
private static final Map<String, Consumer<ServerLevel>> AFTER_BATCH_FUNCTIONS = Maps.newHashMap();
|
private static final Map<String, Consumer<ServerLevel>> AFTER_BATCH_FUNCTIONS = Maps.newHashMap();
|
||||||
private static final Collection<TestFunction> LAST_FAILED_TESTS = Sets.newHashSet();
|
private static final Collection<TestFunction> LAST_FAILED_TESTS = Sets.newHashSet();
|
||||||
|
|
||||||
@@ -15,27 +15,27 @@
|
|||||||
public static void register(Method p_177504_) {
|
public static void register(Method p_177504_) {
|
||||||
+ register(p_177504_, java.util.Set.of());
|
+ register(p_177504_, java.util.Set.of());
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */
|
+ /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
+ public static void register(Method p_177504_, java.util.Set<String> allowedNamespaces) {
|
+ public static void register(Method p_177504_, java.util.Set<String> allowed) {
|
||||||
String s = p_177504_.getDeclaringClass().getSimpleName();
|
String s = p_177504_.getDeclaringClass().getSimpleName();
|
||||||
GameTest gametest = p_177504_.getAnnotation(GameTest.class);
|
GameTest gametest = p_177504_.getAnnotation(GameTest.class);
|
||||||
- if (gametest != null) {
|
if (gametest != null) {
|
||||||
+ if (gametest != null && (allowedNamespaces.isEmpty() || allowedNamespaces.contains(net.minecraftforge.gametest.ForgeGameTestHooks.getTemplateNamespace(p_177504_)))) {
|
- TEST_FUNCTIONS.add(turnMethodIntoTestFunction(p_177504_));
|
||||||
TEST_FUNCTIONS.add(turnMethodIntoTestFunction(p_177504_));
|
- TEST_CLASS_NAMES.add(s);
|
||||||
TEST_CLASS_NAMES.add(s);
|
+ net.minecraftforge.gametest.ForgeGameTestHooks.addTest(TEST_FUNCTIONS, TEST_CLASS_NAMES, allowed, turnMethodIntoTestFunction(p_177504_));
|
||||||
}
|
}
|
||||||
|
|
||||||
GameTestGenerator gametestgenerator = p_177504_.getAnnotation(GameTestGenerator.class);
|
GameTestGenerator gametestgenerator = p_177504_.getAnnotation(GameTestGenerator.class);
|
||||||
if (gametestgenerator != null) {
|
if (gametestgenerator != null) {
|
||||||
- TEST_FUNCTIONS.addAll(useTestGeneratorMethod(p_177504_));
|
- TEST_FUNCTIONS.addAll(useTestGeneratorMethod(p_177504_));
|
||||||
+ Collection<TestFunction> testFunctions = new java.util.ArrayList<>(useTestGeneratorMethod(p_177504_));
|
- TEST_CLASS_NAMES.add(s);
|
||||||
+ if (!allowedNamespaces.isEmpty())
|
+ for (var func : useTestGeneratorMethod(p_177504_))
|
||||||
+ testFunctions.removeIf(t -> !allowedNamespaces.contains(new net.minecraft.resources.ResourceLocation(t.getStructureName()).getNamespace()));
|
+ net.minecraftforge.gametest.ForgeGameTestHooks.addTest(TEST_FUNCTIONS, TEST_CLASS_NAMES, allowed, func);
|
||||||
+ TEST_FUNCTIONS.addAll(testFunctions);
|
|
||||||
TEST_CLASS_NAMES.add(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerBatchFunction(p_177504_, BeforeBatch.class, BeforeBatch::batch, BEFORE_BATCH_FUNCTIONS);
|
||||||
@@ -104,7 +_,9 @@
|
@@ -104,7 +_,9 @@
|
||||||
|
|
||||||
private static Collection<TestFunction> useTestGeneratorMethod(Method p_177514_) {
|
private static Collection<TestFunction> useTestGeneratorMethod(Method p_177514_) {
|
||||||
@@ -47,18 +47,19 @@
|
|||||||
return (Collection)p_177514_.invoke(object);
|
return (Collection)p_177514_.invoke(object);
|
||||||
} catch (ReflectiveOperationException reflectiveoperationexception) {
|
} catch (ReflectiveOperationException reflectiveoperationexception) {
|
||||||
throw new RuntimeException(reflectiveoperationexception);
|
throw new RuntimeException(reflectiveoperationexception);
|
||||||
@@ -115,8 +_,9 @@
|
@@ -115,9 +_,9 @@
|
||||||
GameTest gametest = p_177516_.getAnnotation(GameTest.class);
|
GameTest gametest = p_177516_.getAnnotation(GameTest.class);
|
||||||
String s = p_177516_.getDeclaringClass().getSimpleName();
|
String s = p_177516_.getDeclaringClass().getSimpleName();
|
||||||
String s1 = s.toLowerCase();
|
String s1 = s.toLowerCase();
|
||||||
- String s2 = s1 + "." + p_177516_.getName().toLowerCase();
|
- String s2 = s1 + "." + p_177516_.getName().toLowerCase();
|
||||||
- String s3 = gametest.template().isEmpty() ? s2 : s1 + "." + gametest.template();
|
- String s3 = gametest.template().isEmpty() ? s2 : s1 + "." + gametest.template();
|
||||||
+ boolean prefixGameTestTemplate = net.minecraftforge.gametest.ForgeGameTestHooks.prefixGameTestTemplate(p_177516_);
|
- String s4 = gametest.batch();
|
||||||
+ String s2 = (prefixGameTestTemplate ? s1 + "." : "") + p_177516_.getName().toLowerCase();
|
+ String s2 = net.minecraftforge.gametest.ForgeGameTestHooks.getTestName(p_177516_, gametest);
|
||||||
+ String s3 = net.minecraftforge.gametest.ForgeGameTestHooks.getTemplateNamespace(p_177516_) + ":" + (gametest.template().isEmpty() ? s2 : (prefixGameTestTemplate ? s1 + "." : "") + gametest.template());
|
+ String s3 = net.minecraftforge.gametest.ForgeGameTestHooks.getTestTemplate(p_177516_, gametest, s2);
|
||||||
String s4 = gametest.batch();
|
+ String s4 = net.minecraftforge.gametest.ForgeGameTestHooks.getTestBatch(p_177516_, gametest);
|
||||||
Rotation rotation = StructureUtils.getRotationForRotationSteps(gametest.rotationSteps());
|
Rotation rotation = StructureUtils.getRotationForRotationSteps(gametest.rotationSteps());
|
||||||
return new TestFunction(s4, s2, s3, rotation, gametest.timeoutTicks(), gametest.setupTicks(), gametest.required(), gametest.requiredSuccesses(), gametest.attempts(), (Consumer<net.minecraft.gametest.framework.GameTestHelper>)turnMethodIntoConsumer(p_177516_));
|
return new TestFunction(s4, s2, s3, rotation, gametest.timeoutTicks(), gametest.setupTicks(), gametest.required(), gametest.requiredSuccesses(), gametest.attempts(), (Consumer<net.minecraft.gametest.framework.GameTestHelper>)turnMethodIntoConsumer(p_177516_));
|
||||||
|
}
|
||||||
@@ -125,7 +_,9 @@
|
@@ -125,7 +_,9 @@
|
||||||
private static Consumer<?> turnMethodIntoConsumer(Method p_177520_) {
|
private static Consumer<?> turnMethodIntoConsumer(Method p_177520_) {
|
||||||
return (p_177512_) -> {
|
return (p_177512_) -> {
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
--- a/net/minecraft/nbt/CompoundTag.java
|
--- a/net/minecraft/nbt/CompoundTag.java
|
||||||
+++ b/net/minecraft/nbt/CompoundTag.java
|
+++ b/net/minecraft/nbt/CompoundTag.java
|
||||||
|
@@ -19,6 +_,10 @@
|
||||||
|
import net.minecraft.ReportedException;
|
||||||
|
|
||||||
|
public class CompoundTag implements Tag {
|
||||||
|
+ public static net.minecraftforge.common.util.INBTBuilder.Builder builder() {
|
||||||
|
+ return (new net.minecraftforge.common.util.INBTBuilder(){}).nbt();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public static final Codec<CompoundTag> CODEC = Codec.PASSTHROUGH.comapFlatMap((p_274781_) -> {
|
||||||
|
Tag tag = p_274781_.convert(NbtOps.INSTANCE).getValue();
|
||||||
|
return tag instanceof CompoundTag ? DataResult.success((CompoundTag)tag) : DataResult.error(() -> {
|
||||||
@@ -204,6 +_,7 @@
|
@@ -204,6 +_,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -81,8 +81,8 @@
|
|||||||
+ MinecraftServer dedicatedserver1;
|
+ MinecraftServer dedicatedserver1;
|
||||||
+ if (gametestEnabled) {
|
+ if (gametestEnabled) {
|
||||||
+ net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests();
|
+ net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests();
|
||||||
+ java.util.Collection<net.minecraft.gametest.framework.GameTestBatch> testBatches = net.minecraft.gametest.framework.GameTestRunner.groupTestsIntoBatches(net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions());
|
+ var testBatches = net.minecraft.gametest.framework.GameTestRunner.groupTestsIntoBatches(net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions());
|
||||||
+ net.minecraft.core.BlockPos spawnPos = optionset.valueOf(spawnPosOpt);
|
+ var spawnPos = optionset.valueOf(spawnPosOpt);
|
||||||
+ dedicatedserver1 = new net.minecraft.gametest.framework.GameTestServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, testBatches, spawnPos);
|
+ dedicatedserver1 = new net.minecraft.gametest.framework.GameTestServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, testBatches, spawnPos);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ dedicatedserver1 = new DedicatedServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services, LoggerChunkProgressListener::new);
|
+ dedicatedserver1 = new DedicatedServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services, LoggerChunkProgressListener::new);
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
--- a/net/minecraft/server/PlayerAdvancements.java
|
--- a/net/minecraft/server/PlayerAdvancements.java
|
||||||
+++ b/net/minecraft/server/PlayerAdvancements.java
|
+++ b/net/minecraft/server/PlayerAdvancements.java
|
||||||
@@ -171,6 +_,8 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean award(AdvancementHolder p_298135_, String p_135990_) {
|
|
||||||
+ // Forge: don't grant advancements for fake players
|
|
||||||
+ if (this.player instanceof net.minecraftforge.common.util.FakePlayer) return false;
|
|
||||||
boolean flag = false;
|
|
||||||
AdvancementProgress advancementprogress = this.getOrStartProgress(p_298135_);
|
|
||||||
boolean flag1 = advancementprogress.isDone();
|
|
||||||
@@ -178,6 +_,7 @@
|
@@ -178,6 +_,7 @@
|
||||||
this.unregisterListeners(p_298135_);
|
this.unregisterListeners(p_298135_);
|
||||||
this.progressChanged.add(p_298135_);
|
this.progressChanged.add(p_298135_);
|
||||||
|
|||||||
@@ -31,14 +31,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return levelchunk;
|
return levelchunk;
|
||||||
@@ -756,6 +_,7 @@
|
|
||||||
for(ServerPlayer serverplayer : this.playerMap.getAllPlayers()) {
|
|
||||||
if (serverplayer.getChunkTrackingView().contains(chunkpos)) {
|
|
||||||
markChunkPendingToSend(serverplayer, p_299599_);
|
|
||||||
+ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(serverplayer, p_299599_, this.level);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -823,6 +_,7 @@
|
@@ -823,6 +_,7 @@
|
||||||
|
|
||||||
this.level.getProfiler().incrementCounter("chunkSave");
|
this.level.getProfiler().incrementCounter("chunkSave");
|
||||||
@@ -47,22 +39,6 @@
|
|||||||
this.write(chunkpos, compoundtag);
|
this.write(chunkpos, compoundtag);
|
||||||
this.markPosition(chunkpos, chunkstatus.getChunkType());
|
this.markPosition(chunkpos, chunkstatus.getChunkType());
|
||||||
return true;
|
return true;
|
||||||
@@ -877,6 +_,7 @@
|
|
||||||
LevelChunk levelchunk = this.getChunkToSend(p_298062_.toLong());
|
|
||||||
if (levelchunk != null) {
|
|
||||||
markChunkPendingToSend(p_297974_, levelchunk);
|
|
||||||
+ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_297974_, levelchunk, this.level);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1099,6 +_,7 @@
|
|
||||||
this.markChunkPendingToSend(p_301380_, p_296566_);
|
|
||||||
}, (p_296568_) -> {
|
|
||||||
dropChunk(p_301380_, p_296568_);
|
|
||||||
+ net.minecraftforge.event.ForgeEventFactory.fireChunkUnWatch(p_301380_, p_296568_, this.level);
|
|
||||||
});
|
|
||||||
p_301380_.setChunkTrackingView(p_301057_);
|
|
||||||
}
|
|
||||||
@@ -1118,7 +_,7 @@
|
@@ -1118,7 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,13 @@
|
|||||||
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
Component component = this.getCombatTracker().getDeathMessage();
|
Component component = this.getCombatTracker().getDeathMessage();
|
||||||
@@ -715,11 +_,13 @@
|
@@ -715,11 +_,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
- public Entity changeDimension(ServerLevel p_9180_) {
|
- public Entity changeDimension(ServerLevel p_9180_) {
|
||||||
+ public Entity changeDimension(ServerLevel p_9180_, net.minecraftforge.common.util.ITeleporter teleporter) {
|
+ public Entity changeDimension(ServerLevel p_9180_, net.minecraftforge.common.util.ITeleporter teleporter) {
|
||||||
+ if (!net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_9180_.dimension()))
|
+ if (net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_9180_.dimension())) return null;
|
||||||
+ return null;
|
|
||||||
this.isChangingDimension = true;
|
this.isChangingDimension = true;
|
||||||
ServerLevel serverlevel = this.serverLevel();
|
ServerLevel serverlevel = this.serverLevel();
|
||||||
ResourceKey<Level> resourcekey = serverlevel.dimension();
|
ResourceKey<Level> resourcekey = serverlevel.dimension();
|
||||||
@@ -171,12 +170,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void swing(InteractionHand p_9031_) {
|
public void swing(InteractionHand p_9031_) {
|
||||||
@@ -1412,21 +_,23 @@
|
@@ -1413,20 +_,23 @@
|
||||||
this.stopRiding();
|
|
||||||
if (p_9000_ == this.level()) {
|
if (p_9000_ == this.level()) {
|
||||||
this.connection.teleport(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_);
|
this.connection.teleport(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_);
|
||||||
- } else {
|
} else {
|
||||||
+ } else if (!net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_9000_.dimension())) {
|
+ if (net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_9000_.dimension())) return;
|
||||||
ServerLevel serverlevel = this.serverLevel();
|
ServerLevel serverlevel = this.serverLevel();
|
||||||
LevelData leveldata = p_9000_.getLevelData();
|
LevelData leveldata = p_9000_.getLevelData();
|
||||||
this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(p_9000_), (byte)3));
|
this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(p_9000_), (byte)3));
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--- a/net/minecraft/server/network/PlayerChunkSender.java
|
||||||
|
+++ b/net/minecraft/server/network/PlayerChunkSender.java
|
||||||
|
@@ -45,6 +_,7 @@
|
||||||
|
public void dropChunk(ServerPlayer p_298166_, ChunkPos p_300687_) {
|
||||||
|
if (!this.pendingChunks.remove(p_300687_.toLong()) && p_298166_.isAlive()) {
|
||||||
|
p_298166_.connection.send(new ClientboundForgetLevelChunkPacket(p_300687_));
|
||||||
|
+ net.minecraftforge.event.ForgeEventFactory.fireChunkUnWatch(p_298166_, p_300687_, (ServerLevel) p_298166_.level());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -79,6 +_,7 @@
|
||||||
|
p_299748_.send(new ClientboundLevelChunkWithLightPacket(p_297712_, p_298120_.getLightEngine(), (BitSet)null, (BitSet)null));
|
||||||
|
ChunkPos chunkpos = p_297712_.getPos();
|
||||||
|
DebugPackets.sendPoiPacketsForChunk(p_298120_, chunkpos);
|
||||||
|
+ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_299748_.player, p_297712_, p_298120_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LevelChunk> collectChunksToSend(ChunkMap p_298180_, ChunkPos p_298514_) {
|
||||||
@@ -86,15 +86,6 @@
|
|||||||
|
|
||||||
serverstatscounter = new ServerStatsCounter(this.server, file2);
|
serverstatscounter = new ServerStatsCounter(this.server, file2);
|
||||||
this.stats.put(uuid, serverstatscounter);
|
this.stats.put(uuid, serverstatscounter);
|
||||||
@@ -797,6 +_,8 @@
|
|
||||||
this.advancements.put(uuid, playeradvancements);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Forge: don't overwrite active player with a fake one.
|
|
||||||
+ if (!(p_11297_ instanceof net.minecraftforge.common.util.FakePlayer))
|
|
||||||
playeradvancements.setPlayer(p_11297_);
|
|
||||||
return playeradvancements;
|
|
||||||
}
|
|
||||||
@@ -826,7 +_,7 @@
|
@@ -826,7 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 274 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user