mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f2f5c02a0 | ||
|
|
7a6843fa4a | ||
|
|
f0ecf16c6b | ||
|
|
8998fa71b2 | ||
|
|
4e677a7558 | ||
|
|
07254b36d7 | ||
|
|
a51b8d256d | ||
|
|
75fcd9448e | ||
|
|
6b45999702 | ||
|
|
a4f52f4057 | ||
|
|
b8b3201372 | ||
|
|
41deadc1e2 | ||
|
|
82e8d06e54 | ||
|
|
51db5f2ff7 | ||
|
|
2ec9e515ff | ||
|
|
0579572148 | ||
|
|
83f4e6353c | ||
|
|
130953e519 | ||
|
|
7981093591 | ||
|
|
79112d6208 | ||
|
|
a3eb6263f4 | ||
|
|
d91bc9c73d | ||
|
|
c807665ab9 | ||
|
|
7b97c181b9 | ||
|
|
c42b0847d2 | ||
|
|
f182cb00c1 | ||
|
|
3181b5da23 | ||
|
|
983c119477 | ||
|
|
874ff1bba2 | ||
|
|
06d9d89f98 | ||
|
|
c713bad8c3 | ||
|
|
fe19491822 | ||
|
|
c80e8a1aca | ||
|
|
6845c094ab | ||
|
|
3c1126a7b4 | ||
|
|
326e0329b9 | ||
|
|
f9d0daa91c | ||
|
|
094200e687 | ||
|
|
bb4818630c | ||
|
|
7af3155b39 | ||
|
|
d988b4a811 | ||
|
|
18f5bdb7ca | ||
|
|
f41d493552 | ||
|
|
8cd2c9c63f | ||
|
|
427b335cac | ||
|
|
2049096c6f | ||
|
|
98d4fa6dc2 | ||
|
|
5306471aec | ||
|
|
aa8818b049 | ||
|
|
2d86f17363 | ||
|
|
3a36a01913 | ||
|
|
47d70a7f31 | ||
|
|
d5b5e6f4db | ||
|
|
e76d814439 | ||
|
|
b8b40e1f54 | ||
|
|
5e8c786406 | ||
|
|
5b8224f839 | ||
|
|
cd621eb081 | ||
|
|
b1113f0363 | ||
|
|
daf5933b79 | ||
|
|
47fd2e8604 | ||
|
|
05297fd72f | ||
|
|
f20cf19f94 | ||
|
|
061cd3da53 | ||
|
|
03202a8ab4 | ||
|
|
8a67be4afd | ||
|
|
4c1ab67f33 | ||
|
|
7e06a2105f | ||
|
|
4a0c8be742 | ||
|
|
0c030ee5e1 | ||
|
|
1134fac54c | ||
|
|
ac44d72530 | ||
|
|
12468bd8d2 | ||
|
|
a98eeb9d08 | ||
|
|
b558b132cd | ||
|
|
c102633566 | ||
|
|
cce002ad29 | ||
|
|
b1ed321438 | ||
|
|
c7c2478cb0 | ||
|
|
b70d99489b | ||
|
|
57f45eaca0 | ||
|
|
52fcc4d649 | ||
|
|
959ab9abc9 | ||
|
|
c3a91872fe | ||
|
|
4d074f0a1e | ||
|
|
c2225ab1da | ||
|
|
bb03b1a7d1 | ||
|
|
be7275443f | ||
|
|
dc1c973684 | ||
|
|
06d568408c | ||
|
|
2256e88fb4 | ||
|
|
9b962c8ff0 | ||
|
|
7656b75992 | ||
|
|
58a5449c2f | ||
|
|
702abe0665 | ||
|
|
2070b77fd4 | ||
|
|
fd00822015 | ||
|
|
17565c0ea2 | ||
|
|
22668ad2c2 | ||
|
|
0dcc3d700d | ||
|
|
2ab3d9b8a3 | ||
|
|
d578d8f6df | ||
|
|
fd61016a7e | ||
|
|
7f77d24f45 | ||
|
|
3ebdcb34d1 | ||
|
|
05240fecf7 | ||
|
|
d5860d7cfa | ||
|
|
7bb97dafda | ||
|
|
ca90babc4a | ||
|
|
4b813e4319 | ||
|
|
fa84c22662 | ||
|
|
2ae640b530 | ||
|
|
4f95a20c5e | ||
|
|
915d570b17 | ||
|
|
5979636ee5 | ||
|
|
5acfc6ae3c | ||
|
|
48341120fb | ||
|
|
ff45bb4c27 | ||
|
|
eabba46595 | ||
|
|
683bf99fe4 | ||
|
|
2a05c7c01d | ||
|
|
e386229b66 | ||
|
|
59b8ec5625 | ||
|
|
50ae5db357 | ||
|
|
3aa99a1250 | ||
|
|
00c8513129 | ||
|
|
9c1404fecc | ||
|
|
c11686ab6c | ||
|
|
2818984f6c | ||
|
|
db225ed04a | ||
|
|
0ec4c34a34 | ||
|
|
597ebc3267 | ||
|
|
e16f54eebe | ||
|
|
27480c15fa | ||
|
|
df0dea59f3 | ||
|
|
d7bc564512 | ||
|
|
e6a73ef36c | ||
|
|
1ba7c6aecd | ||
|
|
7c5e95222e | ||
|
|
38df3d2a15 | ||
|
|
3beaa817f3 | ||
|
|
3ebd7ba0ef | ||
|
|
1ba9c34650 | ||
|
|
2f9e726aea | ||
|
|
ade2b8cc80 | ||
|
|
9b144f4541 | ||
|
|
0c35436217 | ||
|
|
0e66b7b217 | ||
|
|
4ed9117799 |
No files matched your search
@@ -1,16 +0,0 @@
|
|||||||
# Configuration for support-requests - https://github.com/dessant/support-requests
|
|
||||||
|
|
||||||
# Label used to mark issues as support requests
|
|
||||||
supportLabel: Forum
|
|
||||||
# Comment to post on issues marked as support requests. Add a link
|
|
||||||
# to a support page, or set to `false` to disable
|
|
||||||
supportComment: >
|
|
||||||
👋 We use the issue tracker exclusively for final bug reports and feature requests.
|
|
||||||
However, this issue appears to be better suited for the
|
|
||||||
[Forge Support Forums](http://www.minecraftforge.net/forum/forum/18-support-bug-reports/).
|
|
||||||
Please create a new topic on the support forum with this issue, and the conversation can
|
|
||||||
continue there.
|
|
||||||
# Whether to close issues marked as support requests
|
|
||||||
close: true
|
|
||||||
# Whether to lock issues marked as support requests
|
|
||||||
lock: true
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
name: Support Requests
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types:
|
||||||
|
- labeled
|
||||||
|
- unlabeled
|
||||||
|
- reopened
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
support:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: dessant/support-requests@v2
|
||||||
|
with:
|
||||||
|
support-label: Forum
|
||||||
|
issue-comment: >
|
||||||
|
:wave: We use the issue tracker exclusively for final bug reports and feature requests.
|
||||||
|
However, this issue appears to be better suited for the
|
||||||
|
[Forge Support Forums](https://forums.minecraftforge.net/) or
|
||||||
|
[Forge Discord](https://discord.gg/UvedJ9m). Please create a new topic on the support forum
|
||||||
|
with this issue or ask in the `#tech-support` channel in the Discord server, and the
|
||||||
|
conversation can continue there.
|
||||||
|
lock-issue: true
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
/projects/**/*.launch
|
/projects/**/*.launch
|
||||||
/repo/
|
/repo/
|
||||||
src/generated/resources/.cache/
|
src/generated/resources/.cache/
|
||||||
|
src/generated_test/resources/.cache/
|
||||||
|
|
||||||
#Patch rejects
|
#Patch rejects
|
||||||
/patches-/
|
/patches-/
|
||||||
|
|||||||
+156
-52
@@ -1,14 +1,3 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
maven { url = 'https://maven.minecraftforge.net/' }
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:[5.1.39,)'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
import groovy.json.JsonBuilder
|
import groovy.json.JsonBuilder
|
||||||
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
@@ -31,6 +20,8 @@ plugins {
|
|||||||
id 'net.minecraftforge.gradleutils' version '2.+'
|
id 'net.minecraftforge.gradleutils' version '2.+'
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'de.undercouch.download' version '4.1.2'
|
id 'de.undercouch.download' version '4.1.2'
|
||||||
|
id 'net.minecraftforge.gradle.patcher' version '[5.1.50,5.2.0)' apply false
|
||||||
|
id 'net.minecraftforge.gradle.mcp' version '[5.1.50,5.2.0)' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.init() //Init all our extension methods!
|
Util.init() //Init all our extension methods!
|
||||||
@@ -45,32 +36,48 @@ ext {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
MAPPING_CHANNEL = 'official'
|
MAPPING_CHANNEL = 'official'
|
||||||
MAPPING_VERSION = '1.18.2'
|
MAPPING_VERSION = '1.19.2'
|
||||||
MC_VERSION = '1.18.2'
|
MC_VERSION = '1.19.2'
|
||||||
MCP_VERSION = '20220404.173914'
|
MC_NEXT_VERSION = '1.20'
|
||||||
SPI_VERSION = '4.0.10'
|
MCP_VERSION = '20220805.130853'
|
||||||
|
SPI_VERSION = '6.0.0'
|
||||||
ACCESSTRANSFORMERS_VERSION = '8.0.4'
|
ACCESSTRANSFORMERS_VERSION = '8.0.4'
|
||||||
COREMODS_VERSION = '5.0.1'
|
COREMODS_VERSION = '5.0.1'
|
||||||
EVENTBUS_VERSION = '5.0.3'
|
EVENTBUS_VERSION = '6.0.3'
|
||||||
MODLAUNCHER_VERSION = '9.1.3'
|
MODLAUNCHER_VERSION = '10.0.8'
|
||||||
SECUREJARHANDLER_VERSION = '1.0.3'
|
SECUREJARHANDLER_VERSION = '2.1.4'
|
||||||
BOOTSTRAPLAUNCHER_VERSION = '1.0.0'
|
BOOTSTRAPLAUNCHER_VERSION = '1.1.2'
|
||||||
ASM_VERSION = '9.2'
|
ASM_VERSION = '9.3'
|
||||||
INSTALLER_VERSION = '2.1.+'
|
INSTALLER_VERSION = '2.1.+'
|
||||||
MIXIN_VERSION = '0.8.5'
|
MIXIN_VERSION = '0.8.5'
|
||||||
|
TERMINALCONSOLEAPPENDER_VERSION = '1.2.0'
|
||||||
|
JLINE_VERSION = '3.12.+'
|
||||||
|
NIGHTCONFIG_VERSION = '3.6.4'
|
||||||
|
JETBRAINS_ANNOTATIONS_VERSION = '23.0.0'
|
||||||
|
SLF4J_API_VERSION = '1.8.0-beta4'
|
||||||
|
APACHE_MAVEN_ARTIFACT_VERSION = '3.8.5'
|
||||||
|
|
||||||
|
// These versions should be kept in sync with the version manifest JSON
|
||||||
|
// To use a version newer than the version manifest JSON, the dependency must be added to the installer configuration
|
||||||
|
MOJANG_LOGGING_VERSION = '1.0.0'
|
||||||
|
LOG4J_VERSION = '2.17.0'
|
||||||
|
GUAVA_VERSION = '31.0.1-jre'
|
||||||
|
GSON_VERSION = '2.8.9'
|
||||||
|
APACHE_COMMONS_LANG3_VERSION = '3.12.0'
|
||||||
|
JOPT_SIMPLE_VERSION = '5.0.4'
|
||||||
|
COMMONS_IO_VERSION = '2.11.0'
|
||||||
|
JARJAR_VERSION = '0.3.16'
|
||||||
|
|
||||||
GIT_INFO = gradleutils.gitInfo
|
GIT_INFO = gradleutils.gitInfo
|
||||||
VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION)
|
VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION)
|
||||||
// FML_VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, 'FML', MC_VERSION)
|
// FML_VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, 'FML', MC_VERSION)
|
||||||
FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1)
|
FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1)
|
||||||
|
|
||||||
SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0'
|
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.1.1:fatjar'
|
||||||
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar'
|
|
||||||
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.3.0'
|
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.3.0'
|
||||||
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
|
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
|
||||||
FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all'
|
FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all'
|
||||||
MIN_TAG_FOR_CHANGELOG = "39.0"
|
MIN_TAG_FOR_CHANGELOG = "41.0"
|
||||||
LAST_RB = GIT_INFO.tag.rsplit('.', 1)[1] as int >= 1 ? GIT_INFO.tag + '.0' : null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println('Version: ' + VERSION +
|
println('Version: ' + VERSION +
|
||||||
@@ -89,7 +96,7 @@ def extraTxts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
task downloadVersionManifest(type: Download) {
|
task downloadVersionManifest(type: Download) {
|
||||||
src 'https://launchermeta.mojang.com/mc/game/version_manifest_v2.json'
|
src 'https://piston-meta.mojang.com/mc/game/version_manifest_v2.json'
|
||||||
dest file('build/versions/version_manifest.json')
|
dest file('build/versions/version_manifest.json')
|
||||||
useETag 'all'
|
useETag 'all'
|
||||||
onlyIfModified true
|
onlyIfModified true
|
||||||
@@ -138,6 +145,10 @@ subprojects {
|
|||||||
name = 'forge'
|
name = 'forge'
|
||||||
url = 'https://maven.minecraftforge.net/'
|
url = 'https://maven.minecraftforge.net/'
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = 'minecraft'
|
||||||
|
url = 'https://libraries.minecraft.net/'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||||
@@ -251,6 +262,7 @@ def sharedDeps = {
|
|||||||
moduleonly "org.ow2.asm:asm-util:${ASM_VERSION}"
|
moduleonly "org.ow2.asm:asm-util:${ASM_VERSION}"
|
||||||
moduleonly "org.ow2.asm:asm-analysis:${ASM_VERSION}"
|
moduleonly "org.ow2.asm:asm-analysis:${ASM_VERSION}"
|
||||||
moduleonly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
|
moduleonly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
|
||||||
|
moduleonly "net.minecraftforge:JarJarFileSystems:${JARJAR_VERSION}"
|
||||||
|
|
||||||
installer "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}"
|
installer "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}"
|
||||||
installer "org.ow2.asm:asm:${ASM_VERSION}"
|
installer "org.ow2.asm:asm:${ASM_VERSION}"
|
||||||
@@ -259,21 +271,23 @@ def sharedDeps = {
|
|||||||
installer "org.ow2.asm:asm-util:${ASM_VERSION}"
|
installer "org.ow2.asm:asm-util:${ASM_VERSION}"
|
||||||
installer "org.ow2.asm:asm-analysis:${ASM_VERSION}"
|
installer "org.ow2.asm:asm-analysis:${ASM_VERSION}"
|
||||||
installer "net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}"
|
installer "net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}"
|
||||||
installer 'org.antlr:antlr4-runtime:4.9.1' //Dep of AccessTransformer
|
installer 'org.antlr:antlr4-runtime:4.9.1' // Dep of AccessTransformer
|
||||||
installer "net.minecraftforge:eventbus:${EVENTBUS_VERSION}"
|
installer "net.minecraftforge:eventbus:${EVENTBUS_VERSION}"
|
||||||
installer "net.minecraftforge:forgespi:${SPI_VERSION}"
|
installer "net.minecraftforge:forgespi:${SPI_VERSION}"
|
||||||
installer "net.minecraftforge:coremods:${COREMODS_VERSION}"
|
installer "net.minecraftforge:coremods:${COREMODS_VERSION}"
|
||||||
installer "cpw.mods:modlauncher:${MODLAUNCHER_VERSION}"
|
installer "cpw.mods:modlauncher:${MODLAUNCHER_VERSION}"
|
||||||
installer 'net.minecraftforge:unsafe:0.2.+'
|
installer 'net.minecraftforge:unsafe:0.2.+'
|
||||||
installer 'com.electronwill.night-config:core:3.6.4'
|
installer "com.electronwill.night-config:core:${NIGHTCONFIG_VERSION}"
|
||||||
installer 'com.electronwill.night-config:toml:3.6.4'
|
installer "com.electronwill.night-config:toml:${NIGHTCONFIG_VERSION}"
|
||||||
installer 'org.apache.maven:maven-artifact:3.6.3'
|
installer "org.apache.maven:maven-artifact:${APACHE_MAVEN_ARTIFACT_VERSION}"
|
||||||
installer 'net.jodah:typetools:0.8.3'
|
installer 'net.jodah:typetools:0.8.3'
|
||||||
installer 'net.minecrell:terminalconsoleappender:1.2.0'
|
installer "net.minecrell:terminalconsoleappender:${TERMINALCONSOLEAPPENDER_VERSION}"
|
||||||
installer 'org.jline:jline-reader:3.12.+' //Dep of TerminaalConsoleeAppender
|
installer "org.jline:jline-reader:${JLINE_VERSION}" // Dep of TerminalConsoleAppender
|
||||||
installer 'org.jline:jline-terminal:3.12.+' //Dep of TerminaalConsoleeAppender
|
installer "org.jline:jline-terminal:${JLINE_VERSION}" // Dep of TerminalConsoleAppender
|
||||||
installer "org.spongepowered:mixin:${MIXIN_VERSION}"
|
installer "org.spongepowered:mixin:${MIXIN_VERSION}"
|
||||||
installer 'org.openjdk.nashorn:nashorn-core:15.3'
|
installer 'org.openjdk.nashorn:nashorn-core:15.3'
|
||||||
|
installer "net.minecraftforge:JarJarSelector:${JARJAR_VERSION}"
|
||||||
|
installer "net.minecraftforge:JarJarMetadata:${JARJAR_VERSION}"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
installer 'org.lwjgl:lwjgl:3.2.2'
|
installer 'org.lwjgl:lwjgl:3.2.2'
|
||||||
@@ -366,7 +380,8 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
environment 'MOD_CLASSES', '{source_roots}'
|
environment 'MOD_CLASSES', '{source_roots}'
|
||||||
environment 'MCP_MAPPINGS', '{mcp_mappings}'
|
environment 'MCP_MAPPINGS', '{mcp_mappings}'
|
||||||
|
|
||||||
property 'nativesDirectory', '{natives}'
|
// Natives are loaded from the classpath now in all cases
|
||||||
|
// property 'nativesDirectory', '{natives}'
|
||||||
if (prj.name == 'forge') {
|
if (prj.name == 'forge') {
|
||||||
property 'forge.enableGameTest', 'true'
|
property 'forge.enableGameTest', 'true'
|
||||||
}
|
}
|
||||||
@@ -420,6 +435,8 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
run.args '--fml.forgeGroup', prj.group
|
run.args '--fml.forgeGroup', prj.group
|
||||||
run.args '--fml.mcpVersion', MCP_VERSION
|
run.args '--fml.mcpVersion', MCP_VERSION
|
||||||
|
|
||||||
|
run.jvmArgs '-Djava.net.preferIPv6Addresses=system'
|
||||||
|
|
||||||
if (run.name.contains('client')) {
|
if (run.name.contains('client')) {
|
||||||
run.client true
|
run.client true
|
||||||
} else {
|
} else {
|
||||||
@@ -429,7 +446,7 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
// SecureJarHandler bootstrap values.
|
// SecureJarHandler bootstrap values.
|
||||||
run.property 'ignoreList', prj.configurations.moduleonly.files.collect {it.name.replaceAll(/([-_]([.\d]*\d+)|\.jar$)/, '') }.join(',') + ",client-extra,fmlcore,javafmllanguage,lowcodelanguage,mclanguage,${prj.name}-"
|
run.property 'ignoreList', prj.configurations.moduleonly.files.collect {it.name.replaceAll(/([-_]([.\d]*\d+)|\.jar$)/, '') }.join(',') + ",client-extra,fmlcore,javafmllanguage,lowcodelanguage,mclanguage,${prj.name}-"
|
||||||
// FIXME: Without this jna doesn't work at runtime. Someone figure out why please?
|
// FIXME: Without this jna doesn't work at runtime. Someone figure out why please?
|
||||||
run.property 'mergeModules', 'jna-5.10.0.jar,jna-platform-5.10.0.jar,java-objc-bridge-1.0.0.jar'
|
run.property 'mergeModules', 'jna-5.10.0.jar,jna-platform-5.10.0.jar'
|
||||||
if (userdevRuns.contains(run)) {
|
if (userdevRuns.contains(run)) {
|
||||||
run.property 'legacyClassPath.file', '{minecraft_classpath_file}'
|
run.property 'legacyClassPath.file', '{minecraft_classpath_file}'
|
||||||
run.jvmArgs '-p', '{modules}'
|
run.jvmArgs '-p', '{modules}'
|
||||||
@@ -440,6 +457,7 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
run.jvmArgs '--add-modules', 'ALL-MODULE-PATH'
|
run.jvmArgs '--add-modules', 'ALL-MODULE-PATH'
|
||||||
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
|
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
|
||||||
run.jvmArgs '--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler'
|
run.jvmArgs '--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler'
|
||||||
|
run.jvmArgs '--add-opens', 'java.base/java.lang.invoke=cpw.mods.securejarhandler'
|
||||||
run.jvmArgs '--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler'
|
run.jvmArgs '--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler'
|
||||||
run.jvmArgs '--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
|
run.jvmArgs '--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
|
||||||
}
|
}
|
||||||
@@ -448,7 +466,8 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
run.workingDirectory prj.file('run')
|
run.workingDirectory prj.file('run')
|
||||||
|
|
||||||
if (run.name.contains('client') || run.name.contains('data')) {
|
if (run.name.contains('client') || run.name.contains('data')) {
|
||||||
run.property 'nativesDirectory', prj.extractNatives.output.get().asFile
|
// Natives are loaded from the classpath now in all cases
|
||||||
|
// run.property 'nativesDirectory', prj.extractNatives.output.get().asFile
|
||||||
run.args '--assetsDir', prj.downloadAssets.output
|
run.args '--assetsDir', prj.downloadAssets.output
|
||||||
run.args '--assetIndex', "{asset_index}"
|
run.args '--assetIndex', "{asset_index}"
|
||||||
}
|
}
|
||||||
@@ -630,6 +649,7 @@ project(':fmlonly') {
|
|||||||
'--add-modules', 'ALL-MODULE-PATH',
|
'--add-modules', 'ALL-MODULE-PATH',
|
||||||
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
|
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
|
||||||
'--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler',
|
'--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler',
|
||||||
|
'--add-opens', 'java.base/java.lang.invoke=cpw.mods.securejarhandler',
|
||||||
'--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler',
|
'--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler',
|
||||||
'--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
|
'--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
|
||||||
]
|
]
|
||||||
@@ -1049,6 +1069,8 @@ project(':forge') {
|
|||||||
'--mod', 'tag_based_tool_types',
|
'--mod', 'tag_based_tool_types',
|
||||||
'--mod', 'custom_transformtype_test',
|
'--mod', 'custom_transformtype_test',
|
||||||
'--mod', 'data_pack_registries_test',
|
'--mod', 'data_pack_registries_test',
|
||||||
|
'--mod', 'biome_modifiers_test',
|
||||||
|
'--mod', 'structure_modifiers_test',
|
||||||
'--output', rootProject.file('src/generated_test/resources/'),
|
'--output', rootProject.file('src/generated_test/resources/'),
|
||||||
'--existing', sourceSets.main.resources.srcDirs[0],
|
'--existing', sourceSets.main.resources.srcDirs[0],
|
||||||
'--existing', sourceSets.test.resources.srcDirs[0]
|
'--existing', sourceSets.test.resources.srcDirs[0]
|
||||||
@@ -1180,18 +1202,28 @@ project(':forge') {
|
|||||||
lineEnding = '\n'
|
lineEnding = '\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
def baseForgeVersion = LAST_RB == null ? null : "${MC_VERSION}-${LAST_RB}"
|
def baseForgeVersion = System.getProperty("forge.compatibility_check_version")
|
||||||
|
if (baseForgeVersion == null)
|
||||||
|
baseForgeVersion = "${MC_VERSION}-${GIT_INFO.tag}.0"
|
||||||
|
if (baseForgeVersion == "null")
|
||||||
|
baseForgeVersion = null // Allow disabling from system property if not wanted
|
||||||
|
def baseForgeUniversal = null
|
||||||
|
if (baseForgeVersion != null)
|
||||||
|
baseForgeUniversal = project.dependencies.create("net.minecraftforge:forge:${baseForgeVersion}:universal")
|
||||||
|
def jarCompatibilityTaskSetup = { task ->
|
||||||
|
task.group = 'jar compatibility'
|
||||||
|
task.onlyIf {
|
||||||
|
baseForgeVersion != null
|
||||||
|
}
|
||||||
|
task.inputs.property 'baseForgeVersion', baseForgeVersion
|
||||||
|
}
|
||||||
|
|
||||||
task downloadBaseCompatibilityBinPatches(type: DownloadBaseCompatibilityBinPatches) {
|
task downloadBaseCompatibilityBinPatches(type: DownloadBaseCompatibilityBinPatches) {
|
||||||
inputVersion = baseForgeVersion
|
inputVersion = baseForgeVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
task applyBaseCompatibilityJarBinPatches(type: ApplyBinPatches) {
|
task applyBaseCompatibilityJarBinPatches(type: ApplyBinPatches) {
|
||||||
group = 'jar compatibility'
|
jarCompatibilityTaskSetup(it)
|
||||||
onlyIf {
|
|
||||||
baseForgeVersion != null
|
|
||||||
}
|
|
||||||
inputs.property 'baseForgeVersion', baseForgeVersion
|
|
||||||
|
|
||||||
clean = createJoinedSRG.output
|
clean = createJoinedSRG.output
|
||||||
patch = downloadBaseCompatibilityBinPatches.output
|
patch = downloadBaseCompatibilityBinPatches.output
|
||||||
@@ -1199,23 +1231,16 @@ project(':forge') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
task checkJarCompatibility(type: CheckJarCompatibility) {
|
task checkJarCompatibility(type: CheckJarCompatibility) {
|
||||||
group = 'jar compatibility'
|
jarCompatibilityTaskSetup(it)
|
||||||
onlyIf {
|
|
||||||
baseForgeVersion != null
|
|
||||||
}
|
|
||||||
inputs.property 'baseForgeVersion', baseForgeVersion
|
|
||||||
|
|
||||||
if (baseForgeVersion != null) {
|
if (baseForgeVersion != null) {
|
||||||
def baseForgeUniversal = project.configurations.detachedConfiguration(project.dependencies.create("net.minecraftforge:forge:${baseForgeVersion}:universal"))
|
|
||||||
def fmlLibs = project.configurations.detachedConfiguration(PACKED_DEPS.collect {
|
def fmlLibs = project.configurations.detachedConfiguration(PACKED_DEPS.collect {
|
||||||
def artifactId = it.split(':')[1]
|
def artifactId = it.split(':')[1]
|
||||||
return project.dependencies.create("net.minecraftforge:${artifactId}:${baseForgeVersion}")
|
return project.dependencies.create("net.minecraftforge:${artifactId}:${baseForgeVersion}")
|
||||||
}.toArray(Dependency[]::new))
|
}.toArray(Dependency[]::new))
|
||||||
|
|
||||||
baseJar = project.tasks.applyBaseCompatibilityJarBinPatches.output
|
baseJar = project.tasks.applyBaseCompatibilityJarBinPatches.output
|
||||||
baseLibraries.from(project.file(project.provider {
|
baseLibraries.from(project.configurations.detachedConfiguration(baseForgeUniversal))
|
||||||
baseForgeUniversal.resolve().iterator().next()
|
|
||||||
}))
|
|
||||||
baseLibraries.from(project.tasks.createJoinedSRG.output)
|
baseLibraries.from(project.tasks.createJoinedSRG.output)
|
||||||
baseLibraries.from(fmlLibs)
|
baseLibraries.from(fmlLibs)
|
||||||
|
|
||||||
@@ -1247,13 +1272,15 @@ project(':forge') {
|
|||||||
'--fml.mcVersion', MC_VERSION,
|
'--fml.mcVersion', MC_VERSION,
|
||||||
'--fml.forgeGroup', project.group,
|
'--fml.forgeGroup', project.group,
|
||||||
'--fml.mcpVersion', MCP_VERSION],
|
'--fml.mcpVersion', MCP_VERSION],
|
||||||
jvm: ["-DignoreList=${forge_client.properties.ignoreList},\${version_name}.jar",
|
jvm: ['-Djava.net.preferIPv6Addresses=system',
|
||||||
|
"-DignoreList=${forge_client.properties.ignoreList},\${version_name}.jar",
|
||||||
"-DmergeModules=${forge_client.properties.mergeModules}",
|
"-DmergeModules=${forge_client.properties.mergeModules}",
|
||||||
'-DlibraryDirectory=${library_directory}',
|
'-DlibraryDirectory=${library_directory}',
|
||||||
'-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{'${library_directory}/' + it.downloads.artifact.path}.join('${classpath_separator}'),
|
'-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{'${library_directory}/' + it.downloads.artifact.path}.join('${classpath_separator}'),
|
||||||
'--add-modules', 'ALL-MODULE-PATH',
|
'--add-modules', 'ALL-MODULE-PATH',
|
||||||
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
|
// Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript
|
||||||
'--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler',
|
'--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler',
|
||||||
|
'--add-opens', 'java.base/java.lang.invoke=cpw.mods.securejarhandler',
|
||||||
'--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler',
|
'--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler',
|
||||||
'--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
|
'--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming'
|
||||||
]
|
]
|
||||||
@@ -1537,7 +1564,7 @@ project(':forge') {
|
|||||||
MAPPING_CHANNEL: MAPPING_CHANNEL,
|
MAPPING_CHANNEL: MAPPING_CHANNEL,
|
||||||
MAPPING_VERSION: MAPPING_VERSION,
|
MAPPING_VERSION: MAPPING_VERSION,
|
||||||
FORGE_SPEC_VERSION: SPEC_VERSION.split("\\.")[0],
|
FORGE_SPEC_VERSION: SPEC_VERSION.split("\\.")[0],
|
||||||
MC_NEXT_VERSION: "1."+((MC_VERSION.split("[\\.-]")[1] as int)+1)
|
MC_NEXT_VERSION: MC_NEXT_VERSION
|
||||||
])
|
])
|
||||||
rename 'gitignore\\.txt', '.gitignore'
|
rename 'gitignore\\.txt', '.gitignore'
|
||||||
rename 'gitattributes\\.txt', '.gitattributes'
|
rename 'gitattributes\\.txt', '.gitattributes'
|
||||||
@@ -1578,6 +1605,83 @@ project(':forge') {
|
|||||||
sourceSets.test.java.srcDirs.each { extractMappedNew.addTarget it }
|
sourceSets.test.java.srcDirs.each { extractMappedNew.addTarget it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named('javadoc', Javadoc).configure {
|
||||||
|
description 'Generates the combined javadocs for the FML projects and the main Forge project'
|
||||||
|
var includedProjects = [ ':fmlcore', ':fmlloader', ':javafmllanguage', ':mclanguage' ]
|
||||||
|
source includedProjects.collect { project(it).sourceSets.main.allJava }
|
||||||
|
classpath = classpath + files(includedProjects.collect { project(it).sourceSets.main.compileClasspath })
|
||||||
|
|
||||||
|
var docsDir = rootProject.file('src/docs/')
|
||||||
|
inputs.dir(docsDir)
|
||||||
|
.withPropertyName('docs resources directory')
|
||||||
|
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||||
|
.optional()
|
||||||
|
|
||||||
|
failOnError = false
|
||||||
|
|
||||||
|
// Exclude the Minecraft classes if not enabled
|
||||||
|
if (!project.hasProperty('generateAllDocumentation')) {
|
||||||
|
exclude 'net/minecraft/**'
|
||||||
|
exclude 'com/mojang/**'
|
||||||
|
}
|
||||||
|
exclude 'mcp/**'
|
||||||
|
|
||||||
|
options.addStringOption('Xdoclint:all,-missing', '-public')
|
||||||
|
options {
|
||||||
|
stylesheetFile = new File(docsDir, 'stylesheet.css')
|
||||||
|
|
||||||
|
tags = [
|
||||||
|
'apiNote:a:<em>API Note:</em>',
|
||||||
|
'implSpec:a:<em>Implementation Requirements:</em>',
|
||||||
|
'implNote:a:<em>Implementation Note:</em>'
|
||||||
|
]
|
||||||
|
|
||||||
|
groups = [
|
||||||
|
'Forge Mod Loader': [
|
||||||
|
'net.minecraftforge.fml.common.asm*',
|
||||||
|
'net.minecraftforge.fml.loading*',
|
||||||
|
'net.minecraftforge.fml.server*'
|
||||||
|
],
|
||||||
|
'FML Core': [
|
||||||
|
'net.minecraftforge.fml',
|
||||||
|
'net.minecraftforge.fml.config*',
|
||||||
|
'net.minecraftforge.fml.event*',
|
||||||
|
'net.minecraftforge.fml.util*'
|
||||||
|
],
|
||||||
|
'FML Common': [
|
||||||
|
'net.minecraftforge.fml.core',
|
||||||
|
'net.minecraftforge.fml.event.config',
|
||||||
|
'net.minecraftforge.fml.event.lifecycle'
|
||||||
|
],
|
||||||
|
'FML Java/MC Language Providers': [
|
||||||
|
'net.minecraftforge.fml.common',
|
||||||
|
'net.minecraftforge.fml.javafmlmod',
|
||||||
|
'net.minecraftforge.fml.mclanguageprovider'
|
||||||
|
],
|
||||||
|
'Minecraft Forge API': [
|
||||||
|
'net.minecraftforge*'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
author = false
|
||||||
|
noSince = true
|
||||||
|
noHelp = true
|
||||||
|
|
||||||
|
bottom = "Minecraft Forge is an open source modding API for Minecraft: Java Edition, licensed under the Lesser GNU General Public License, version 2.1."
|
||||||
|
windowTitle = "Minecraft Forge API ${VERSION}"
|
||||||
|
docTitle = "Minecraft Forge API - ${FORGE_VERSION} for Minecraft ${MC_VERSION}"
|
||||||
|
header = "<div style=\"margin-top: 9px;padding: 5px 6px;\"><strong>${FORGE_VERSION} for Minecraft ${MC_VERSION}</strong></div>"
|
||||||
|
}
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
project.copy {
|
||||||
|
from docsDir
|
||||||
|
exclude '/stylesheet.css'
|
||||||
|
into destinationDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ repositories {
|
|||||||
maven { url = 'https://maven.minecraftforge.net/' }
|
maven { url = 'https://maven.minecraftforge.net/' }
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.ow2.asm:asm:9.1'
|
implementation 'org.ow2.asm:asm:9.3'
|
||||||
implementation 'org.ow2.asm:asm-tree:9.1'
|
implementation 'org.ow2.asm:asm-tree:9.3'
|
||||||
implementation 'net.minecraftforge:srgutils:0.4.+'
|
implementation 'net.minecraftforge:srgutils:0.4.+'
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
Contributing to Forge
|
Contributing to Forge
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
1) Keep patches to Minecraft classes minimal. If you need a lot of things done, you may either add to relevant forge classes or make a new class.
|
1) Keep patches to Minecraft classes together. If you need a lot of things done, you may either add to relevant forge classes or make a new class. Try not to spread out your patches across multiple disjoint lines, as this makes maintenance of your patches difficult.
|
||||||
|
|
||||||
2) An example mod must be provided for all PRs adding events/hooks to Forge. Whether it's a full mod using your proposed hooks, or just a pastebin containing a simple example, an example mod is required. Please also explain in detail what your new hook does.
|
2) TODO: Test Mods
|
||||||
|
|
||||||
3) Follow Forge coding guidelines (braces on newlines, spaces instead of tabs, etc)
|
3) Follow the code style of the class you're working in (braces on newlines & spaces instead of tabs in Forge classes, inline brackets in patches, etc).
|
||||||
|
|
||||||
For more information, refer to [the wiki](https://github.com/MinecraftForge/MinecraftForge/wiki/If-you-want-to-contribute-to-Forge)
|
For more information, refer to [the wiki](https://github.com/MinecraftForge/MinecraftForge/wiki/If-you-want-to-contribute-to-Forge)
|
||||||
|
|
||||||
|
|||||||
+13
-12
@@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
MinecraftForge
|
MinecraftForge
|
||||||
=============
|
=============
|
||||||
[](https://files.minecraftforge.net)
|
[](https://files.minecraftforge.net)
|
||||||
[](https://files.minecraftforge.net) [](https://discord.gg/UvedJ9m) [](https://www.patreon.com/LexManos)
|
)](https://files.minecraftforge.net) [](https://discord.gg/UvedJ9m) [](https://www.patreon.com/LexManos)
|
||||||
|
|
||||||
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!
|
||||||
|
|
||||||
| Version | Support |
|
| Version | Support |
|
||||||
| ------------- | ------------- |
|
|---------| ------------- |
|
||||||
| 1.18.x | Active |
|
| 1.19.x | Active |
|
||||||
| 1.16.x | LTS |
|
| 1.18.x | LTS |
|
||||||
|
|
||||||
* [Download]
|
* [Download]
|
||||||
* [Forum]
|
* [Forum]
|
||||||
@@ -29,7 +29,7 @@ You can download the installer for the *Recommended Build* or the
|
|||||||
into your vanilla launcher environment, where you can then create a new
|
into your vanilla launcher environment, where you can then create a new
|
||||||
profile using that version and play the game!
|
profile using that version and play the game!
|
||||||
|
|
||||||
For support and questions, visit [the Support Forum](https://www.minecraftforge.net/forum/forum/18-support-bug-reports/).
|
For support and questions, visit [the Support Forum](https://www.minecraftforge.net/forum/forum/18-support-bug-reports/) or [the Forge Discord server](https://discord.gg/forge).
|
||||||
|
|
||||||
[Here is a short video from Rorax showing how to install and setup Forge.](https://www.youtube.com/watch?v=lB3ArN_-3Oc)
|
[Here is a short video from Rorax showing how to install and setup Forge.](https://www.youtube.com/watch?v=lB3ArN_-3Oc)
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ For support and questions, visit [the Support Forum](https://www.minecraftforge.
|
|||||||
|
|
||||||
If you wish to actually inspect Forge, submit PRs or otherwise work
|
If you wish to actually inspect Forge, submit PRs or otherwise work
|
||||||
with Forge itself, you're in the right place!
|
with Forge itself, you're in the right place!
|
||||||
|
|
||||||
[See the guide to setting up a Forge workspace](http://mcforge.readthedocs.io/en/latest/forgedev/).
|
[See the guide to setting up a Forge workspace](http://mcforge.readthedocs.io/en/latest/forgedev/).
|
||||||
|
|
||||||
### Pull requests
|
### Pull requests
|
||||||
@@ -51,13 +51,14 @@ If you wish to actually inspect Forge, submit PRs or otherwise work
|
|||||||
Please read the contributing guidelines found [here](CONTRIBUTING.md) before making a pull request.
|
Please read the contributing guidelines found [here](CONTRIBUTING.md) before making a pull request.
|
||||||
|
|
||||||
### Contributor License Agreement
|
### Contributor License Agreement
|
||||||
We require all contributors to acknowledge the [Forge Contributor
|
We require all contributors to acknowledge the [Forge Contributor License Agreement](https://cla-assistant.io/MinecraftForge/MinecraftForge).
|
||||||
License Agreement](https://cla-assistant.io/MinecraftForge/MinecraftForge). Please ensure you have a valid email address
|
Please ensure you have a valid email address associated with your GitHub account to do this. If you have previously
|
||||||
associated with your GitHub account to do this. If you have previously
|
|
||||||
signed it, you should be OK.
|
signed it, you should be OK.
|
||||||
|
|
||||||
#### Donate
|
#### Donate
|
||||||
*Forge is a large project with many collaborators working on it around the clock. Forge is and will always remain free to use and modify. However, it costs money to run such a large project as this, so please consider [becoming a patron](https://www.patreon.com/LexManos).*
|
*Forge is a large project with many collaborators working on it around the clock. Forge is and will always remain free
|
||||||
|
to use and modify. However, it costs money to run such a large project as this, so please consider
|
||||||
|
[becoming a patron](https://www.patreon.com/LexManos).*
|
||||||
|
|
||||||
[Download]: https://files.minecraftforge.net/
|
[Download]: https://files.minecraftforge.net/
|
||||||
[Forum]: https://www.minecraftforge.net/forum/
|
[Forum]: https://www.minecraftforge.net/forum/
|
||||||
|
|||||||
+3
-2
@@ -76,7 +76,7 @@ If you're certain you've found an issue that is directly caused by Forge, you ha
|
|||||||
|
|
||||||
1. **Forge Forums:** There's a dedicated [Support & Bug Report](http://www.minecraftforge.net/forum/forum/18-support-bug-reports/) section on the Forge forums, which is led by team of moderators and volunteers who will try to deal with your reports as quickly as possible. *As a player you should probably report here first.*
|
1. **Forge Forums:** There's a dedicated [Support & Bug Report](http://www.minecraftforge.net/forum/forum/18-support-bug-reports/) section on the Forge forums, which is led by team of moderators and volunteers who will try to deal with your reports as quickly as possible. *As a player you should probably report here first.*
|
||||||
- For modders, there also is a separate [Modder Support](http://www.minecraftforge.net/forum/forum/70-modder-support/) section where you can ask all your development-related questions. *You should prefer this section for coding help.*
|
- For modders, there also is a separate [Modder Support](http://www.minecraftforge.net/forum/forum/70-modder-support/) section where you can ask all your development-related questions. *You should prefer this section for coding help.*
|
||||||
2. **Forge IRC Channel:** You can find a lot of help on the official [`#minecraftforge`](irc://irc.esper.net:6667/minecraftforge) channel on EsperNet. Especially smaller issues that you quickly need help with could be reported there. *Be aware that the channel is more suited towards development questions, so while you may get support there as a player, you should almost always prefer the forums.*
|
2. **Forge Discord Server:** You can find a lot of help on the official [Discord Server](https://discord.gg/forge), especially smaller issues that you quickly need help with. *Be aware that the channel is more suited towards development questions, so while you may get support there as a player, you should almost always prefer the forums.*
|
||||||
3. **Forge Issue Tracker:** If you're absolutely certain that you've found an issue in the Forge codebase (e.g. you're a modder yourself and have analyzed the stacktrace and relevant code), don't refrain from reporting it on this repository's [issue tracker](https://github.com/MinecraftForge/MinecraftForge/issues). *Please do not use the issues as a means of getting coding help. For developers, the IRC and the [official documentation](https://mcforge.readthedocs.io) are the best sources of information.*
|
3. **Forge Issue Tracker:** If you're absolutely certain that you've found an issue in the Forge codebase (e.g. you're a modder yourself and have analyzed the stacktrace and relevant code), don't refrain from reporting it on this repository's [issue tracker](https://github.com/MinecraftForge/MinecraftForge/issues). *Please do not use the issues as a means of getting coding help. For developers, the IRC and the [official documentation](https://mcforge.readthedocs.io) are the best sources of information.*
|
||||||
|
|
||||||
### Mod Support
|
### Mod Support
|
||||||
@@ -84,7 +84,8 @@ If you're certain you've found an issue that is directly caused by Forge, you ha
|
|||||||
A lot of mods also use GitHub or other source management systems and their integrated issue trackers. The following options will give you the best chances of reporting your issue in the right place:
|
A lot of mods also use GitHub or other source management systems and their integrated issue trackers. The following options will give you the best chances of reporting your issue in the right place:
|
||||||
|
|
||||||
- **CurseForge:** Many mods are hosted on the [CurseForge platform](https://minecraft.curseforge.com) nowadays. Chances are you already downloaded them from there or as a part of a modpack hosted there. Projects may specify an issue reporting link on their own page, so simply look for it on the mod's project page and you should be directed to the preferred means of error reporting.
|
- **CurseForge:** Many mods are hosted on the [CurseForge platform](https://minecraft.curseforge.com) nowadays. Chances are you already downloaded them from there or as a part of a modpack hosted there. Projects may specify an issue reporting link on their own page, so simply look for it on the mod's project page and you should be directed to the preferred means of error reporting.
|
||||||
- **Searching for a repository directly:** You may need to try and find a repository directly on source control sites. The most common ones are [GitHub](https://github.com) and [BitBucket](https://bitbucket.org). Both come with search capabilities, so simply try to search for the mod's name.
|
- **Modrinth:** Some modders use [Modrinth](https://modrinth.com/mods) to host their mods, but be mindful that not all mods on this platform are for the Forge modloader.
|
||||||
|
- **Searching for a repository directly:** You may need to try and find a repository directly on source control sites. The most common ones are [GitHub](https://github.com), [GitLab](https://gitlab.com), and [BitBucket](https://bitbucket.org). Both come with search capabilities, so simply try to search for the mod's name.
|
||||||
|
|
||||||
### Vanilla Support
|
### Vanilla Support
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ apply plugin: 'org.javamodularity.moduleplugin'
|
|||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly('org.jetbrains:annotations:21.0.1')
|
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
||||||
|
|
||||||
|
api("net.minecraftforge:eventbus:${EVENTBUS_VERSION}")
|
||||||
|
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
api('net.minecraftforge:eventbus:5.0.+')
|
implementation("commons-io:commons-io:${COMMONS_IO_VERSION}")
|
||||||
implementation('commons-io:commons-io:2.5')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
|
|||||||
@@ -8,41 +8,92 @@ package net.minecraftforge.fml;
|
|||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An extension point for a mod container.
|
||||||
|
*
|
||||||
|
* <p>An extension point can be registered for a mod container using {@link ModContainer#registerExtensionPoint(Class, Supplier)}
|
||||||
|
* and retrieved (if present) using {@link ModContainer#getCustomExtension(Class)}. An extension point allows a mod to
|
||||||
|
* supply an arbitrary value as a record class to another mod or framework through their mod container class, avoiding
|
||||||
|
* the use of {@link InterModComms} or other external frameworks to pass around these values.</p>
|
||||||
|
*
|
||||||
|
* <p>The usual way to declare an extension point is to implement this interface on a record class, with the type
|
||||||
|
* parameter being a reference to the class itself. For example, {@code record MyExtension(...) extends
|
||||||
|
* IExtensionPoint<MyExtension>} would declare an extension point which supplies a {@code MyExtension} object. However,
|
||||||
|
* there is no hard requirement that an extension point's type parameter must be in reference to itself; the type
|
||||||
|
* parameter may reference another record class instead.</p>
|
||||||
|
*
|
||||||
|
* @param <T> the type of the record which is held by the extension point
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused") // Type parameter T
|
||||||
public interface IExtensionPoint<T extends Record>
|
public interface IExtensionPoint<T extends Record>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Compatibility display test for the mod.
|
* Extension point for the compatibility display test used on the server selection screen.
|
||||||
* Used for displaying compatibility with remote servers with the same mod, and on disk saves.
|
|
||||||
*
|
*
|
||||||
* The supplier provides my "local" version for sending across the impl or writing to disk
|
* <em>Note: "server" and "client" refers to the {@linkplain net.minecraftforge.api.distmarker.Dist#DEDICATED_SERVER dedicated server}
|
||||||
* The predicate tests the version from a remote instance or save for acceptability (Boolean is true for impl, false for local save)
|
* and {@linkplain net.minecraftforge.api.distmarker.Dist#CLIENT game client} physical distributions, rather than the
|
||||||
* and returns true if the version is compatible.
|
* {@linkplain LogicalSide logical server and client}.</em>
|
||||||
*
|
*
|
||||||
* <p>Return {@code net.minecraftforge.network.NetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored
|
* <p>The {@link Supplier} provides the local compatibility version, which is sent from the server to the client
|
||||||
* as a server side only mod.</p>
|
* for multiplayer connections or stored to disk for the world save. The {@link BiPredicate} accepts the remote
|
||||||
* <p>Return true in the predicate for all values of the input string (when impl boolean is true) if you are client side,
|
* compatibility version and a boolean indicating whether the remote version is from the server or a world save,
|
||||||
* and don't care about matching any potential server version.</p>
|
* where {@code true} means it is from the server and {@code false} means it is from the world save. The return
|
||||||
|
* value of the predicate determines whether the remote version is "compatible" for the purposes of the display test.</p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>The local compatibility version may be of the value {@link net.minecraftforge.network.NetworkConstants#IGNORESERVERONLY},
|
||||||
* Examples: A server only mod
|
* in which case clients will ignore the mod's presence if it is present on the server but not on the client.
|
||||||
* </p>
|
* However, the remote version test predicate must still accept this value as a remote version in order to display
|
||||||
|
* as compatible if the mod is present on the client.</p>
|
||||||
|
*
|
||||||
|
* <p><strong>The compatibility display test does not necessarily indicate the success or failure of an actual
|
||||||
|
* connection attempt.</strong> Factors such as display test extension misconfiguration, truncation of ping data,
|
||||||
|
* difference of registry data or network channels between server and client, and others may cause the result of the
|
||||||
|
* compatibility test to not reflect the actual likelihood of a connection successfully being established between
|
||||||
|
* the server and the client.</p>
|
||||||
|
*
|
||||||
|
* <p>An example declaration of a display test extension registration for a regular mod (requires to be present on
|
||||||
|
* server and client) is as follows:</p>
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* registerExtensionPoint(DisplayTest.class, ()->new DisplayTest(
|
* String compatibilityVersion = "1"; // Could be linked with a network channel version or mod version
|
||||||
* ()->NetworkConstants.IGNORESERVERONLY, // ignore me, I'm a server only mod
|
* ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
|
||||||
* (s,b)->true // i accept anything from the server or the save, if I'm asked
|
* () -> new IExtensionPoint.DisplayTest(
|
||||||
* )
|
* () -> compatibilityVersion,
|
||||||
|
* (remoteVersion, isFromServer) -> remoteVersion.equals(compatibilityVersion)
|
||||||
|
* )
|
||||||
|
* );
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>An example declaration of a display test extension registration for a <em>server-side-only</em> mod (does not
|
||||||
* Examples: A client only mod
|
* require to be present on the client) is as follows:</p>
|
||||||
* </p>
|
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* registerExtensionPoint(DisplayTest.class, ()->new DisplayTest(
|
* ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
|
||||||
* ()->"anything. i don't care", // if i'm actually on the server, this string is sent but i'm a client only mod, so it won't be
|
* () -> new IExtensionPoint.DisplayTest(
|
||||||
* (remoteversionstring,networkbool)->networkbool // i accept anything from the server, by returning true if it's asking about the server
|
* // Ignore this mod if not present on the client
|
||||||
* )
|
* () -> NetworkConstants.IGNORESERVERONLY,
|
||||||
|
* // If present on the client, accept any version if from a server
|
||||||
|
* (remoteVersion, isFromServer) -> isFromServer
|
||||||
|
* )
|
||||||
|
* );
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
|
* <p>An example declaration of a display test extension registration for a <em>client-side-only</em> mod (does not
|
||||||
|
* require to be present on the server) is as follows:</p>
|
||||||
|
* <pre>{@code
|
||||||
|
* ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
|
||||||
|
* () -> new IExtensionPoint.DisplayTest(
|
||||||
|
* // Send any version from server to client, since we will be accepting any version as well
|
||||||
|
* () -> "dQw4w9WgXcQ",
|
||||||
|
* // Accept any version on the client, from server or from save
|
||||||
|
* (remoteVersion, isFromServer) -> true
|
||||||
|
* )
|
||||||
|
* );
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @see net.minecraftforge.network.ServerStatusPing
|
||||||
|
* @see net.minecraftforge.client.ForgeHooksClient#processForgeListPingData(net.minecraft.network.protocol.status.ServerStatus, net.minecraft.client.multiplayer.ServerData)
|
||||||
*/
|
*/
|
||||||
record DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) implements IExtensionPoint<DisplayTest> {}
|
@SuppressWarnings("JavadocReference") // reference to NetworkConstants, ForgeHooksClient
|
||||||
|
record DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) implements IExtensionPoint<DisplayTest> {
|
||||||
|
public static final String IGNORESERVERONLY = "OHNOES\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,23 +8,79 @@ package net.minecraftforge.fml;
|
|||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mod loading state. During mod loading, the mod loader transitions between states in a defined sorted list of states,
|
||||||
|
* grouped into various {@link ModLoadingPhase phases}.
|
||||||
|
*
|
||||||
|
* @see IModStateProvider
|
||||||
|
*/
|
||||||
public interface IModLoadingState {
|
public interface IModLoadingState {
|
||||||
|
/**
|
||||||
|
* {@return the name of this state}
|
||||||
|
*/
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return the name of the state immediately previous to this state} This may be a blank name, which indicates this
|
||||||
|
* is either the first mod loading state or an exceptional mod loading state (such as a situation where errors
|
||||||
|
* prevent the loading process from continuing normally).
|
||||||
|
*/
|
||||||
String previous();
|
String previous();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return the mod loading phase this state belongs to} For exceptional mod loading states, this should be
|
||||||
|
* {@link ModLoadingPhase#ERROR}.
|
||||||
|
*/
|
||||||
ModLoadingPhase phase();
|
ModLoadingPhase phase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return a function returning a human-friendly message for this state}
|
||||||
|
*/
|
||||||
Function<ModList, String> message();
|
Function<ModList, String> message();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return an optional runnable, which runs before starting the transition from this state to the next}
|
||||||
|
* @see #buildTransition(Executor, Executor, Function, Function)
|
||||||
|
*/
|
||||||
Optional<Consumer<ModList>> inlineRunnable();
|
Optional<Consumer<ModList>> inlineRunnable();
|
||||||
|
|
||||||
default <T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor) {
|
/**
|
||||||
return buildTransition(syncExecutor, parallelExecutor, e->CompletableFuture.runAsync(()->{}, e), e->CompletableFuture.runAsync(()->{}, e));
|
* Builds the transition task for this state with a blank pre-sync and post-sync task.
|
||||||
|
*
|
||||||
|
* @param syncExecutor a synchronous executor
|
||||||
|
* @param parallelExecutor a parallel executor
|
||||||
|
* @param <T> a type of event fired on the mod-specific event bus
|
||||||
|
* @return a transition task for this state
|
||||||
|
* @see #buildTransition(Executor, Executor, Function, Function)
|
||||||
|
*/
|
||||||
|
default <T extends Event & IModBusEvent>
|
||||||
|
Optional<CompletableFuture<Void>> buildTransition(final Executor syncExecutor,
|
||||||
|
final Executor parallelExecutor) {
|
||||||
|
return buildTransition(syncExecutor, parallelExecutor,
|
||||||
|
e -> CompletableFuture.runAsync(() -> {}, e),
|
||||||
|
e -> CompletableFuture.runAsync(() -> {}, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
<T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(Executor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask);
|
/**
|
||||||
|
* Builds the transition task for this state. The pre-sync and post-sync task functions allow the transition builder
|
||||||
|
* to run these tasks on the same executor as the actual event dispatch and pre/post hooks.
|
||||||
|
*
|
||||||
|
* @param syncExecutor a synchronous executor
|
||||||
|
* @param parallelExecutor a parallel executor
|
||||||
|
* @param preSyncTask a function which returns a task to run before event pre-dispatch hook
|
||||||
|
* @param postSyncTask a function which returns a task to run after event post-dispatch hook
|
||||||
|
* @param <T> a type of event fired on the mod-specific event bus
|
||||||
|
* @return a transition task for this state
|
||||||
|
*/
|
||||||
|
<T extends Event & IModBusEvent>
|
||||||
|
Optional<CompletableFuture<Void>> buildTransition(final Executor syncExecutor,
|
||||||
|
final Executor parallelExecutor,
|
||||||
|
final Function<Executor, CompletableFuture<Void>> preSyncTask,
|
||||||
|
final Function<Executor, CompletableFuture<Void>> postSyncTask);
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,15 @@ package net.minecraftforge.fml;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a list of mod loading states which the mod loader may transition between.
|
||||||
|
*
|
||||||
|
* <p>There may be multiple mod state providers in a single application, where all states from each provider is
|
||||||
|
* combined into a single list and ordered.</p>
|
||||||
|
*/
|
||||||
public interface IModStateProvider {
|
public interface IModStateProvider {
|
||||||
|
/**
|
||||||
|
* {@return the list of mod loading states known to this provider}
|
||||||
|
*/
|
||||||
List<IModLoadingState> getAllStates();
|
List<IModLoadingState> getAllStates();
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ import net.minecraftforge.eventbus.api.Event;
|
|||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@@ -24,18 +23,26 @@ public interface IModStateTransition {
|
|||||||
return new NoopTransition();
|
return new NoopTransition();
|
||||||
}
|
}
|
||||||
|
|
||||||
default <T extends Event & IModBusEvent> CompletableFuture<List<Throwable>> build(Executor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
default <T extends Event & IModBusEvent>
|
||||||
List<CompletableFuture<List<Throwable>>> cfs = new ArrayList<>();
|
CompletableFuture<Void> build(final Executor syncExecutor,
|
||||||
|
final Executor parallelExecutor,
|
||||||
|
final Function<Executor, CompletableFuture<Void>> preSyncTask,
|
||||||
|
final Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
||||||
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||||
|
|
||||||
this.eventFunctionStream().get()
|
this.eventFunctionStream().get()
|
||||||
.map(f->(EventGenerator<T>)f)
|
.map(f -> (EventGenerator<T>) f)
|
||||||
.reduce((head, tail)-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, head, ModLoadingStage::currentState, tail))
|
.reduce((head, tail) -> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, futures, head, ModLoadingStage::currentState, tail))
|
||||||
.ifPresent(last-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, last, nextModLoadingStage(), null));
|
.ifPresent(last -> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, futures, last, nextModLoadingStage(), null));
|
||||||
|
|
||||||
final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor);
|
final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor);
|
||||||
final CompletableFuture<List<Throwable>> eventDispatchCF = ModList.gather(cfs).thenCompose(ModList::completableFutureFromExceptionList);
|
final CompletableFuture<Void> eventDispatchCF = ModList.gather(futures).thenCompose(ModList::completableFutureFromExceptionList);
|
||||||
final CompletableFuture<List<Throwable>> postEventDispatchCF = preSyncTaskCF.thenComposeAsync(n -> eventDispatchCF, parallelExecutor).thenApply(r -> {
|
final CompletableFuture<Void> postEventDispatchCF = preSyncTaskCF
|
||||||
postSyncTask.apply(syncExecutor);
|
.thenComposeAsync(n -> eventDispatchCF, parallelExecutor)
|
||||||
return r;
|
.thenApply(r -> {
|
||||||
});
|
postSyncTask.apply(syncExecutor);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
return this.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF);
|
return this.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,18 +50,31 @@ public interface IModStateTransition {
|
|||||||
return ModLoadingStage::nextState;
|
return ModLoadingStage::nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends Event & IModBusEvent> EventGenerator<T> addCompletableFutureTaskForModDispatch(final Executor syncExecutor, final Executor parallelExecutor, final List<CompletableFuture<List<Throwable>>> completeableFutures, final EventGenerator<T> eventGenerator, BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextState, final EventGenerator<T> nextGenerator) {
|
private <T extends Event & IModBusEvent>
|
||||||
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)preDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator));
|
EventGenerator<T> addCompletableFutureTaskForModDispatch(final Executor syncExecutor,
|
||||||
completeableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector().apply(syncExecutor, parallelExecutor)));
|
final Executor parallelExecutor,
|
||||||
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)postDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator));
|
final List<CompletableFuture<Void>> completableFutures,
|
||||||
|
final EventGenerator<T> eventGenerator,
|
||||||
|
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextState,
|
||||||
|
final EventGenerator<T> nextGenerator) {
|
||||||
|
final Executor selectedExecutor = threadSelector().apply(syncExecutor, parallelExecutor);
|
||||||
|
|
||||||
|
var preDispatchHook = (BiFunction<Executor, EventGenerator<T>, CompletableFuture<Void>>) preDispatchHook();
|
||||||
|
completableFutures.add(preDispatchHook.apply(selectedExecutor, eventGenerator));
|
||||||
|
|
||||||
|
completableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector().apply(syncExecutor, parallelExecutor)));
|
||||||
|
|
||||||
|
var postDispatchHook = (BiFunction<Executor, EventGenerator<T>, CompletableFuture<Void>>) postDispatchHook();
|
||||||
|
completableFutures.add(postDispatchHook.apply(selectedExecutor, eventGenerator));
|
||||||
|
|
||||||
return nextGenerator;
|
return nextGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
Supplier<Stream<EventGenerator<?>>> eventFunctionStream();
|
Supplier<Stream<EventGenerator<?>>> eventFunctionStream();
|
||||||
ThreadSelector threadSelector();
|
ThreadSelector threadSelector();
|
||||||
BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator();
|
BiFunction<Executor, CompletableFuture<Void>, CompletableFuture<Void>> finalActivityGenerator();
|
||||||
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook();
|
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> preDispatchHook();
|
||||||
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook();
|
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> postDispatchHook();
|
||||||
|
|
||||||
interface EventGenerator<T extends Event & IModBusEvent> extends Function<ModContainer, T> {
|
interface EventGenerator<T extends Event & IModBusEvent> extends Function<ModContainer, T> {
|
||||||
static <FN extends Event & IModBusEvent> EventGenerator<FN> fromFunction(Function<ModContainer, FN> fn) {
|
static <FN extends Event & IModBusEvent> EventGenerator<FN> fromFunction(Function<ModContainer, FN> fn) {
|
||||||
@@ -76,17 +96,17 @@ record NoopTransition() implements IModStateTransition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator() {
|
public BiFunction<Executor, CompletableFuture<Void>, CompletableFuture<Void>> finalActivityGenerator() {
|
||||||
return (e, t) -> t.thenApplyAsync(Function.identity(), e);
|
return (e, t) -> t.thenApplyAsync(Function.identity(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook() {
|
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> preDispatchHook() {
|
||||||
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList());
|
return (t, f)-> CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook() {
|
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> postDispatchHook() {
|
||||||
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList());
|
return (t, f)-> CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,41 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml;
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A logical side of the Minecraft game.
|
||||||
|
* <p>
|
||||||
|
* The {@linkplain Dist#CLIENT client distribution} has a copy of the logical client and the logical server, while the
|
||||||
|
* {@linkplain Dist#DEDICATED_SERVER dedicated server distribution} only holds
|
||||||
|
* the logical server.
|
||||||
|
*
|
||||||
|
* @see Dist
|
||||||
|
*/
|
||||||
public enum LogicalSide
|
public enum LogicalSide
|
||||||
{
|
{
|
||||||
CLIENT, SERVER;
|
/**
|
||||||
|
* The logical client of the Minecraft game, which interfaces with the player's inputs and renders the player's
|
||||||
|
* viewpoint.
|
||||||
|
* <p>
|
||||||
|
* The logical client is only shipped with the client distribution of the game.
|
||||||
|
*
|
||||||
|
* @see Dist#CLIENT
|
||||||
|
*/
|
||||||
|
CLIENT,
|
||||||
|
/**
|
||||||
|
* The logical server of the Minecraft game, responsible for connecting to clients and running the simulation logic
|
||||||
|
* on the level.
|
||||||
|
* <p>
|
||||||
|
* The logical server is shipped with both client and dedicated server distributions. The client distribution runs
|
||||||
|
* the logical server for singleplayer mode and LAN play.
|
||||||
|
*
|
||||||
|
* @see Dist#DEDICATED_SERVER
|
||||||
|
*/
|
||||||
|
SERVER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the logical side is a server.
|
* {@return if this logical side is the server}
|
||||||
*/
|
*/
|
||||||
public boolean isServer()
|
public boolean isServer()
|
||||||
{
|
{
|
||||||
@@ -18,7 +47,7 @@ public enum LogicalSide
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the logical side is a client.
|
* {@return if the logical side is the client}
|
||||||
*/
|
*/
|
||||||
public boolean isClient()
|
public boolean isClient()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,9 +56,24 @@ public abstract class ModContainer
|
|||||||
this.namespace = this.modId;
|
this.namespace = this.modId;
|
||||||
this.modInfo = info;
|
this.modInfo = info;
|
||||||
this.modLoadingStage = ModLoadingStage.CONSTRUCT;
|
this.modLoadingStage = ModLoadingStage.CONSTRUCT;
|
||||||
// default displaytest extension checks for version string match
|
|
||||||
registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(()->this.modInfo.getVersion().toString(),
|
final String displayTestString = info.getConfig().<String>getConfigElement("displayTest").orElse("MATCH_VERSION"); // missing defaults to DEFAULT type
|
||||||
(incoming, isNetwork)->Objects.equals(incoming, this.modInfo.getVersion().toString())));
|
Supplier<IExtensionPoint.DisplayTest> displayTestSupplier = switch (displayTestString) {
|
||||||
|
case "MATCH_VERSION" -> // default displaytest checks for version string match
|
||||||
|
() -> new IExtensionPoint.DisplayTest(() -> this.modInfo.getVersion().toString(),
|
||||||
|
(incoming, isNetwork) -> Objects.equals(incoming, this.modInfo.getVersion().toString()));
|
||||||
|
case "IGNORE_SERVER_VERSION" -> // Ignores any version information coming from the server - use for server only mods
|
||||||
|
() -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (incoming, isNetwork) -> true);
|
||||||
|
case "IGNORE_ALL_VERSION" -> // Ignores all information and provides no information
|
||||||
|
() -> new IExtensionPoint.DisplayTest(() -> "", (incoming, isNetwork) -> true);
|
||||||
|
case "NONE" -> null; // NO display test at all - use this if you're going to do your own display test
|
||||||
|
default -> // any other value throws an exception
|
||||||
|
throw new IllegalArgumentException("Invalid displayTest value supplied in mods.toml");
|
||||||
|
};
|
||||||
|
if (displayTestSupplier != null)
|
||||||
|
registerExtensionPoint(IExtensionPoint.DisplayTest.class, displayTestSupplier);
|
||||||
|
else
|
||||||
|
extensionPoints.remove(IExtensionPoint.DisplayTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.AbstractMap;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -54,6 +54,7 @@ public class ModList
|
|||||||
private List<ModContainer> mods;
|
private List<ModContainer> mods;
|
||||||
private Map<String, ModContainer> indexedMods;
|
private Map<String, ModContainer> indexedMods;
|
||||||
private List<ModFileScanData> modFileScanData;
|
private List<ModFileScanData> modFileScanData;
|
||||||
|
private List<ModContainer> sortedContainers;
|
||||||
|
|
||||||
private ModList(final List<ModFile> modFiles, final List<ModInfo> sortedList)
|
private ModList(final List<ModFile> modFiles, final List<ModInfo> sortedList)
|
||||||
{
|
{
|
||||||
@@ -111,7 +112,7 @@ public class ModList
|
|||||||
return this.fileById.get(modid);
|
return this.fileById.get(modid);
|
||||||
}
|
}
|
||||||
|
|
||||||
<T extends Event & IModBusEvent> Function<Executor, CompletableFuture<List<Throwable>>> futureVisitor(
|
<T extends Event & IModBusEvent> Function<Executor, CompletableFuture<Void>> futureVisitor(
|
||||||
final IModStateTransition.EventGenerator<T> eventGenerator,
|
final IModStateTransition.EventGenerator<T> eventGenerator,
|
||||||
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> stateChange) {
|
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> stateChange) {
|
||||||
return executor -> gather(
|
return executor -> gather(
|
||||||
@@ -120,12 +121,12 @@ public class ModList
|
|||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.thenComposeAsync(ModList::completableFutureFromExceptionList, executor);
|
.thenComposeAsync(ModList::completableFutureFromExceptionList, executor);
|
||||||
}
|
}
|
||||||
static CompletionStage<List<Throwable>> completableFutureFromExceptionList(List<? extends Map.Entry<?, Throwable>> t) {
|
static CompletionStage<Void> completableFutureFromExceptionList(List<? extends Map.Entry<?, Throwable>> t) {
|
||||||
if (t.stream().noneMatch(e->e.getValue()!=null)) {
|
if (t.stream().noneMatch(e->e.getValue()!=null)) {
|
||||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
return CompletableFuture.completedFuture(null);
|
||||||
} else {
|
} else {
|
||||||
final List<Throwable> throwables = t.stream().filter(e -> e.getValue() != null).map(Map.Entry::getValue).collect(Collectors.toList());
|
final List<Throwable> throwables = t.stream().filter(e -> e.getValue() != null).map(Map.Entry::getValue).collect(Collectors.toList());
|
||||||
CompletableFuture<List<Throwable>> cf = new CompletableFuture<>();
|
CompletableFuture<Void> cf = new CompletableFuture<>();
|
||||||
final RuntimeException accumulator = new RuntimeException();
|
final RuntimeException accumulator = new RuntimeException();
|
||||||
cf.completeExceptionally(accumulator);
|
cf.completeExceptionally(accumulator);
|
||||||
throwables.forEach(exception -> {
|
throwables.forEach(exception -> {
|
||||||
@@ -156,6 +157,7 @@ public class ModList
|
|||||||
void setLoadedMods(final List<ModContainer> modContainers)
|
void setLoadedMods(final List<ModContainer> modContainers)
|
||||||
{
|
{
|
||||||
this.mods = modContainers;
|
this.mods = modContainers;
|
||||||
|
this.sortedContainers = modContainers.stream().sorted(Comparator.comparingInt(c->sortedList.indexOf(c.getModInfo()))).toList();
|
||||||
this.indexedMods = modContainers.stream().collect(Collectors.toMap(ModContainer::getModId, Function.identity()));
|
this.indexedMods = modContainers.stream().collect(Collectors.toMap(ModContainer::getModId, Function.identity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +221,10 @@ public class ModList
|
|||||||
indexedMods.forEach(modContainerConsumer);
|
indexedMods.forEach(modContainerConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forEachModInOrder(Consumer<ModContainer> containerConsumer) {
|
||||||
|
this.sortedContainers.forEach(containerConsumer);
|
||||||
|
}
|
||||||
|
|
||||||
public <T> Stream<T> applyForEachModContainer(Function<ModContainer, T> function) {
|
public <T> Stream<T> applyForEachModContainer(Function<ModContainer, T> function) {
|
||||||
return indexedMods.values().stream().map(function);
|
return indexedMods.values().stream().map(function);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,22 @@ package net.minecraftforge.fml;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.LoadingModList;
|
import net.minecraftforge.fml.loading.LoadingModList;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier;
|
import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
|
import net.minecraftforge.forgespi.locating.ForgeFeature;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -28,6 +32,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -96,7 +101,7 @@ public class ModLoader
|
|||||||
.map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName()))
|
.map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
FMLLoader.getLoadingModList().getModFiles().stream()
|
FMLLoader.getLoadingModList().getModFiles().stream()
|
||||||
.filter(ModFileInfo::missingLicense) //Search for files with missing licenses
|
.filter(ModFileInfo::missingLicense)
|
||||||
.filter(modFileInfo -> modFileInfo.getMods().stream().noneMatch(thisModInfo -> this.loadingExceptions.stream().map(ModLoadingException::getModInfo).anyMatch(otherInfo -> otherInfo == thisModInfo))) //Ignore files where any other mod already encountered an error
|
.filter(modFileInfo -> modFileInfo.getMods().stream().noneMatch(thisModInfo -> this.loadingExceptions.stream().map(ModLoadingException::getModInfo).anyMatch(otherInfo -> otherInfo == thisModInfo))) //Ignore files where any other mod already encountered an error
|
||||||
.map(modFileInfo -> new ModLoadingException(null, ModLoadingStage.VALIDATE, "fml.modloading.missinglicense", null, modFileInfo.getFile()))
|
.map(modFileInfo -> new ModLoadingException(null, ModLoadingStage.VALIDATE, "fml.modloading.missinglicense", null, modFileInfo.getFile()))
|
||||||
.forEach(this.loadingExceptions::add);
|
.forEach(this.loadingExceptions::add);
|
||||||
@@ -133,6 +138,7 @@ public class ModLoader
|
|||||||
* @param periodicTask Optional periodic task to perform on the main thread while other activities run
|
* @param periodicTask Optional periodic task to perform on the main thread while other activities run
|
||||||
*/
|
*/
|
||||||
public void gatherAndInitializeMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
public void gatherAndInitializeMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
||||||
|
ForgeFeature.registerFeature("java_version", ForgeFeature.VersionFeatureTest.forVersionString(IModInfo.DependencySide.SERVER, System.getProperty("java.version")));
|
||||||
loadingStateValid = true;
|
loadingStateValid = true;
|
||||||
statusConsumer.ifPresent(c->c.accept("Waiting for scan to complete"));
|
statusConsumer.ifPresent(c->c.accept("Waiting for scan to complete"));
|
||||||
FMLLoader.backgroundScanHandler.waitForScanToComplete(periodicTask);
|
FMLLoader.backgroundScanHandler.waitForScanToComplete(periodicTask);
|
||||||
@@ -145,6 +151,22 @@ public class ModLoader
|
|||||||
loadingStateValid = false;
|
loadingStateValid = false;
|
||||||
throw new LoadingFailedException(loadingExceptions);
|
throw new LoadingFailedException(loadingExceptions);
|
||||||
}
|
}
|
||||||
|
statusConsumer.ifPresent(c->c.accept("Validating features"));
|
||||||
|
List<? extends ForgeFeature.Bound> failedBounds = loadingModList.getMods().stream()
|
||||||
|
.map(ModInfo::getForgeFeatures)
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.filter(bound -> !ForgeFeature.testFeature(FMLEnvironment.dist, bound))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!failedBounds.isEmpty()) {
|
||||||
|
LOGGER.fatal(CORE, "Failed to validate feature bounds for mods");
|
||||||
|
modList.setLoadedMods(Collections.emptyList());
|
||||||
|
loadingStateValid = false;
|
||||||
|
throw new LoadingFailedException(failedBounds.stream()
|
||||||
|
.map(fb -> new ModLoadingException(fb.modInfo(), ModLoadingStage.CONSTRUCT, "fml.modloading.feature.missing", null, fb.featureName(), fb.featureBound(), ForgeFeature.featureValue(fb)))
|
||||||
|
.toList());
|
||||||
|
}
|
||||||
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Building Mod List"));
|
statusConsumer.ifPresent(c->c.accept("Building Mod List"));
|
||||||
final List<ModContainer> modContainers = loadingModList.getModFiles().stream()
|
final List<ModContainer> modContainers = loadingModList.getModFiles().stream()
|
||||||
.map(ModFileInfo::getFile)
|
.map(ModFileInfo::getFile)
|
||||||
@@ -196,7 +218,7 @@ public class ModLoader
|
|||||||
state.buildTransition(syncExecutor, parallelExecutor, preSyncTask, postSyncTask).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t));
|
state.buildTransition(syncExecutor, parallelExecutor, preSyncTask, postSyncTask).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture<List<Throwable>> transition) {
|
private void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture<Void> transition) {
|
||||||
while (!transition.isDone()) {
|
while (!transition.isDone()) {
|
||||||
syncExecutor.drive(ticker);
|
syncExecutor.drive(ticker);
|
||||||
}
|
}
|
||||||
@@ -222,7 +244,7 @@ public class ModLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ModContainer> buildMods(final ModFile modFile)
|
private List<ModContainer> buildMods(final IModFile modFile)
|
||||||
{
|
{
|
||||||
final Map<String, IModInfo> modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity()));
|
final Map<String, IModInfo> modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity()));
|
||||||
|
|
||||||
@@ -244,7 +266,7 @@ public class ModLoader
|
|||||||
return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).collect(Collectors.toList());
|
return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModContainer buildModContainerFromTOML(final ModFile modFile, final Map<String, IModInfo> modInfoMap, final Map.Entry<String, ? extends IModLanguageProvider.IModLanguageLoader> idToProviderEntry) {
|
private ModContainer buildModContainerFromTOML(final IModFile modFile, final Map<String, IModInfo> modInfoMap, final Map.Entry<String, ? extends IModLanguageProvider.IModLanguageLoader> idToProviderEntry) {
|
||||||
try {
|
try {
|
||||||
final String modId = idToProviderEntry.getKey();
|
final String modId = idToProviderEntry.getKey();
|
||||||
final IModLanguageProvider.IModLanguageLoader languageLoader = idToProviderEntry.getValue();
|
final IModLanguageProvider.IModLanguageLoader languageLoader = idToProviderEntry.getValue();
|
||||||
@@ -273,7 +295,7 @@ public class ModLoader
|
|||||||
LOGGER.error("Cowardly refusing to send event generator to a broken mod state");
|
LOGGER.error("Cowardly refusing to send event generator to a broken mod state");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ModList.get().forEachModContainer((id, mc) -> mc.acceptEvent(generator.apply(mc)));
|
ModList.get().forEachModInOrder(mc -> mc.acceptEvent(generator.apply(mc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Event & IModBusEvent> void postEvent(T e) {
|
public <T extends Event & IModBusEvent> void postEvent(T e) {
|
||||||
@@ -281,7 +303,18 @@ public class ModLoader
|
|||||||
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ModList.get().forEachModContainer((id, mc) -> mc.acceptEvent(e));
|
ModList.get().forEachModInOrder(mc -> mc.acceptEvent(e));
|
||||||
|
}
|
||||||
|
public <T extends Event & IModBusEvent> void postEventWithWrapInModOrder(T e, BiConsumer<ModContainer, T> pre, BiConsumer<ModContainer, T> post) {
|
||||||
|
if (!loadingStateValid) {
|
||||||
|
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ModList.get().forEachModInOrder(mc -> {
|
||||||
|
pre.accept(mc, e);
|
||||||
|
mc.acceptEvent(e);
|
||||||
|
post.accept(mc, e);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ModLoadingWarning> getWarnings()
|
public List<ModLoadingWarning> getWarnings()
|
||||||
|
|||||||
@@ -5,10 +5,34 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml;
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Phases of mod loading, for grouping mod loading states.
|
||||||
|
*/
|
||||||
public enum ModLoadingPhase {
|
public enum ModLoadingPhase {
|
||||||
|
/**
|
||||||
|
* Special phase for exceptional situations and error handling, where mod loading cannot continue normally.
|
||||||
|
*
|
||||||
|
* <p>There is conventionally only one state with this phase.</p>
|
||||||
|
*/
|
||||||
ERROR, // Special state for error handling
|
ERROR, // Special state for error handling
|
||||||
|
/**
|
||||||
|
* Phase for discovering and gathering mods for loading.
|
||||||
|
*/
|
||||||
GATHER,
|
GATHER,
|
||||||
|
/**
|
||||||
|
* Phase for the loading of mods found from mod discovery.
|
||||||
|
*
|
||||||
|
* @see #GATHER
|
||||||
|
*/
|
||||||
LOAD,
|
LOAD,
|
||||||
|
/**
|
||||||
|
* Phase after mod loading has completed, for post-loading tasks.
|
||||||
|
*
|
||||||
|
* @see #LOAD
|
||||||
|
*/
|
||||||
COMPLETE,
|
COMPLETE,
|
||||||
DONE;
|
/**
|
||||||
|
* Marker phase for the last state in the full mod loading process.
|
||||||
|
*/
|
||||||
|
DONE
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,53 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml;
|
package net.minecraftforge.fml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mod loading stage of mod containers during the mod loading process. These will have a corresponding {@link ModLoadingState}
|
||||||
|
* in the basic mod loading process provided by FML.
|
||||||
|
*
|
||||||
|
* <p>Each mod loading stage has a global {@link DeferredWorkQueue}, which is populated during the execution of the state
|
||||||
|
* associated with this stage and emptied at the end of the state's execution.</p>
|
||||||
|
*/
|
||||||
public enum ModLoadingStage
|
public enum ModLoadingStage
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Special stage for exceptional situations and error handling.
|
||||||
|
*/
|
||||||
ERROR,
|
ERROR,
|
||||||
|
/**
|
||||||
|
* Validation of the mod list.
|
||||||
|
* TODO: figure out where this is used and why this exists instead of CONSTRUCT being the first normal stage
|
||||||
|
*/
|
||||||
VALIDATE,
|
VALIDATE,
|
||||||
|
/**
|
||||||
|
* Default stage of mod containers after construction.
|
||||||
|
*/
|
||||||
CONSTRUCT,
|
CONSTRUCT,
|
||||||
|
/**
|
||||||
|
* Common (non-side-specific) setup and initialization.
|
||||||
|
*/
|
||||||
COMMON_SETUP,
|
COMMON_SETUP,
|
||||||
|
/**
|
||||||
|
* Side-specific setup and initialization.
|
||||||
|
*
|
||||||
|
* @see net.minecraftforge.api.distmarker.Dist
|
||||||
|
*/
|
||||||
SIDED_SETUP,
|
SIDED_SETUP,
|
||||||
|
/**
|
||||||
|
* Stage for enqueuing {@link net.minecraftforge.fml.InterModComms} messages for later processing.
|
||||||
|
*/
|
||||||
ENQUEUE_IMC,
|
ENQUEUE_IMC,
|
||||||
|
/**
|
||||||
|
* Stage for processing received messages though {@link net.minecraftforge.fml.InterModComms}.
|
||||||
|
*/
|
||||||
PROCESS_IMC,
|
PROCESS_IMC,
|
||||||
|
/**
|
||||||
|
* Marks the completion of mod loading for this container.
|
||||||
|
*/
|
||||||
COMPLETE,
|
COMPLETE,
|
||||||
|
/**
|
||||||
|
* Marks the completion of the full mod loading process.
|
||||||
|
*/
|
||||||
DONE;
|
DONE;
|
||||||
|
|
||||||
private final DeferredWorkQueue deferredWorkQueue;
|
private final DeferredWorkQueue deferredWorkQueue;
|
||||||
@@ -23,14 +60,27 @@ public enum ModLoadingStage
|
|||||||
deferredWorkQueue = new DeferredWorkQueue(this);
|
deferredWorkQueue = new DeferredWorkQueue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return the next stage after this stage, or {@link #ERROR} if the exception is not {@code null}}
|
||||||
|
*
|
||||||
|
* @param exception the exception that occurred during this stage, may be {@code null}
|
||||||
|
*/
|
||||||
ModLoadingStage nextState(Throwable exception) {
|
ModLoadingStage nextState(Throwable exception) {
|
||||||
return exception != null ? ERROR : values()[this.ordinal()+1];
|
return exception != null ? ERROR : values()[this.ordinal()+1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return this stage, or {@link #ERROR} if the exception is not {@code null}}
|
||||||
|
*
|
||||||
|
* @param exception the exception that occurred during this stage, may be {@code null}
|
||||||
|
*/
|
||||||
public ModLoadingStage currentState(Throwable exception) {
|
public ModLoadingStage currentState(Throwable exception) {
|
||||||
return exception != null ? ERROR : this;
|
return exception != null ? ERROR : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return the deferred work queue for this stage}
|
||||||
|
*/
|
||||||
public DeferredWorkQueue getDeferredWorkQueue() {
|
public DeferredWorkQueue getDeferredWorkQueue() {
|
||||||
return deferredWorkQueue;
|
return deferredWorkQueue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,31 +8,91 @@ package net.minecraftforge.fml;
|
|||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public record ModLoadingState(String name, String previous, Function<ModList, String> message, ModLoadingPhase phase, Optional<Consumer<ModList>> inlineRunnable, Optional<IModStateTransition> transition) implements IModLoadingState {
|
/**
|
||||||
|
* Implementation of the {@link IModLoadingState} interface.
|
||||||
|
*
|
||||||
|
* @param name the name of this state
|
||||||
|
* @param previous the name of the state immediately previous to this state
|
||||||
|
* @param message a function returning a human-friendly message for this state
|
||||||
|
* @param phase the mod loading phase this state belongs to
|
||||||
|
* @param inlineRunnable an optional runnable, which runs before starting the transition from this state to the next
|
||||||
|
* @param transition optional state transition information
|
||||||
|
*/
|
||||||
|
public record ModLoadingState(String name, String previous,
|
||||||
|
Function<ModList, String> message,
|
||||||
|
ModLoadingPhase phase,
|
||||||
|
Optional<Consumer<ModList>> inlineRunnable,
|
||||||
|
Optional<IModStateTransition> transition) implements IModLoadingState {
|
||||||
@Override
|
@Override
|
||||||
public <T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
public <T extends Event & IModBusEvent>
|
||||||
return transition.map(t->t.build(syncExecutor, parallelExecutor, preSyncTask, postSyncTask));
|
Optional<CompletableFuture<Void>> buildTransition(final Executor syncExecutor,
|
||||||
|
final Executor parallelExecutor,
|
||||||
|
final Function<Executor, CompletableFuture<Void>> preSyncTask,
|
||||||
|
final Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
||||||
|
return transition.map(t -> t.build(syncExecutor, parallelExecutor, preSyncTask, postSyncTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return an empty mod loading state} The mod loading state has a blank human-readable message, no inline runnable,
|
||||||
|
* and no state transition information.
|
||||||
|
*
|
||||||
|
* @param name the name of the state
|
||||||
|
* @param previous the name of the immediately previous state to this state
|
||||||
|
* @param phase the mod loading phase the state belongs to
|
||||||
|
*/
|
||||||
public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) {
|
public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) {
|
||||||
return new ModLoadingState(name, previous, ml->"", phase, Optional.empty(), Optional.empty());
|
return new ModLoadingState(name, previous, ml -> "", phase, Optional.empty(), Optional.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModLoadingState withTransition(final String name, final String previous, final ModLoadingPhase phase, IModStateTransition transition) {
|
/**
|
||||||
return new ModLoadingState(name, previous, ml->"Processing transition "+name, phase, Optional.empty(), Optional.of(transition));
|
* Returns a mod loading state with state transition information and a default human-friendly message of
|
||||||
|
* {@code Processing transition [name]}.
|
||||||
|
*
|
||||||
|
* @param name the name of the state
|
||||||
|
* @param previous the name of the immediately previous state to this state
|
||||||
|
* @param phase the mod loading phase the state belongs to
|
||||||
|
* @param transition the state transition information
|
||||||
|
* @return a mod loading state with state transition information and a default message
|
||||||
|
*/
|
||||||
|
public static ModLoadingState withTransition(final String name, final String previous, final ModLoadingPhase phase,
|
||||||
|
final IModStateTransition transition) {
|
||||||
|
return new ModLoadingState(name, previous, ml -> "Processing transition " + name, phase, Optional.empty(), Optional.of(transition));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModLoadingState withTransition(final String name, final String previous, final Function<ModList, String> message, final ModLoadingPhase phase, IModStateTransition transition) {
|
/**
|
||||||
|
* Returns a mod loading state with state transition information and a custom human-friendly message function.
|
||||||
|
*
|
||||||
|
* @param name the name of the state
|
||||||
|
* @param previous the name of the immediately previous state to this state
|
||||||
|
* @param message a function returning a human-friendly message for this state
|
||||||
|
* @param phase the mod loading phase the state belongs to
|
||||||
|
* @param transition the state transition information
|
||||||
|
* @return a mod loading state with state transition information and a custom message
|
||||||
|
*/
|
||||||
|
public static ModLoadingState withTransition(final String name, final String previous,
|
||||||
|
final Function<ModList, String> message, final ModLoadingPhase phase,
|
||||||
|
final IModStateTransition transition) {
|
||||||
return new ModLoadingState(name, previous, message, phase, Optional.empty(), Optional.of(transition));
|
return new ModLoadingState(name, previous, message, phase, Optional.empty(), Optional.of(transition));
|
||||||
}
|
}
|
||||||
public static ModLoadingState withInline(final String name, final String previous, final ModLoadingPhase phase, Consumer<ModList> inline) {
|
|
||||||
return new ModLoadingState(name, previous, ml->"Processing work "+name, phase, Optional.of(inline), Optional.empty());
|
/**
|
||||||
|
* Returns a mod loading state with an inline runnable and a default human-friendly message of {@code Processing
|
||||||
|
* work [name]}.
|
||||||
|
*
|
||||||
|
* @param name the name of the state
|
||||||
|
* @param previous the name of the immediately previous state to this state
|
||||||
|
* @param phase the mod loading phase the state belongs to
|
||||||
|
* @param inline an optional runnable, which runs before starting the transition from this state to the next
|
||||||
|
* @return a mod loading state with an inline runnable and default message
|
||||||
|
*/
|
||||||
|
public static ModLoadingState withInline(final String name, final String previous, final ModLoadingPhase phase,
|
||||||
|
final Consumer<ModList> inline) {
|
||||||
|
return new ModLoadingState(name, previous, ml -> "Processing work " + name, phase, Optional.of(inline), Optional.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,14 +117,22 @@ public class VersionChecker
|
|||||||
/**
|
/**
|
||||||
* Returns the response body as a String for the given URL while following redirects
|
* Returns the response body as a String for the given URL while following redirects
|
||||||
*/
|
*/
|
||||||
private String openUrlString(URL url) throws IOException, URISyntaxException, InterruptedException {
|
private String openUrlString(URL url, IModInfo mod) throws IOException, URISyntaxException, InterruptedException {
|
||||||
URL currentUrl = url;
|
URL currentUrl = url;
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Java-http-client/").append(System.getProperty("java.version")).append(' ');
|
||||||
|
sb.append("MinecraftForge/").append(FMLLoader.versionInfo().mcAndForgeVersion()).append(' ');
|
||||||
|
sb.append(mod.getModId()).append('/').append(mod.getVersion());
|
||||||
|
final String userAgent = sb.toString();
|
||||||
|
|
||||||
for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++)
|
for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++)
|
||||||
{
|
{
|
||||||
var request = HttpRequest.newBuilder()
|
var request = HttpRequest.newBuilder()
|
||||||
.uri(currentUrl.toURI())
|
.uri(currentUrl.toURI())
|
||||||
.timeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS))
|
.timeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS))
|
||||||
.setHeader("Accept-Encoding", "gzip")
|
.setHeader("Accept-Encoding", "gzip")
|
||||||
|
.setHeader("User-Agent", userAgent)
|
||||||
.GET()
|
.GET()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -166,7 +174,7 @@ public class VersionChecker
|
|||||||
URL url = mod.getUpdateURL().get();
|
URL url = mod.getUpdateURL().get();
|
||||||
LOGGER.info("[{}] Starting version check at {}", mod.getModId(), url.toString());
|
LOGGER.info("[{}] Starting version check at {}", mod.getModId(), url.toString());
|
||||||
|
|
||||||
String data = openUrlString(url);
|
String data = openUrlString(url, mod);
|
||||||
|
|
||||||
LOGGER.debug("[{}] Received version check data:\n{}", mod.getModId(), data);
|
LOGGER.debug("[{}] Received version check data:\n{}", mod.getModId(), data);
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
|||||||
import com.electronwill.nightconfig.core.file.FileWatcher;
|
import com.electronwill.nightconfig.core.file.FileWatcher;
|
||||||
import com.electronwill.nightconfig.core.io.ParsingException;
|
import com.electronwill.nightconfig.core.io.ParsingException;
|
||||||
import com.electronwill.nightconfig.core.io.WritingMode;
|
import com.electronwill.nightconfig.core.io.WritingMode;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.FMLConfig;
|
import net.minecraftforge.fml.loading.FMLConfig;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -24,7 +24,7 @@ import java.util.function.Function;
|
|||||||
import static net.minecraftforge.fml.config.ConfigTracker.CONFIG;
|
import static net.minecraftforge.fml.config.ConfigTracker.CONFIG;
|
||||||
|
|
||||||
public class ConfigFileTypeHandler {
|
public class ConfigFileTypeHandler {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
static ConfigFileTypeHandler TOML = new ConfigFileTypeHandler();
|
static ConfigFileTypeHandler TOML = new ConfigFileTypeHandler();
|
||||||
private static final Path defaultConfigPath = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
private static final Path defaultConfigPath = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
|
||||||
|
|
||||||
|
|||||||
@@ -7,18 +7,18 @@ package net.minecraftforge.fml.config;
|
|||||||
|
|
||||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import com.mojang.logging.LogUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Marker;
|
import org.slf4j.Marker;
|
||||||
import org.apache.logging.log4j.MarkerManager;
|
import org.slf4j.MarkerFactory;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ConfigTracker {
|
public class ConfigTracker {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
static final Marker CONFIG = MarkerManager.getMarker("CONFIG");
|
static final Marker CONFIG = MarkerFactory.getMarker("CONFIG");
|
||||||
public static final ConfigTracker INSTANCE = new ConfigTracker();
|
public static final ConfigTracker INSTANCE = new ConfigTracker();
|
||||||
private final ConcurrentHashMap<String, ModConfig> fileMap;
|
private final ConcurrentHashMap<String, ModConfig> fileMap;
|
||||||
private final EnumMap<ModConfig.Type, Set<ModConfig>> configSets;
|
private final EnumMap<ModConfig.Type, Set<ModConfig>> configSets;
|
||||||
|
|||||||
+26
-19
@@ -11,29 +11,36 @@ dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|||||||
configurations.forEach{ it.transitive = false }
|
configurations.forEach{ it.transitive = false }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4')
|
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
||||||
compileOnly('org.jetbrains:annotations:23.0.0')
|
|
||||||
api("org.ow2.asm:asm:${ASM_VERSION}")
|
api("org.ow2.asm:asm:${ASM_VERSION}")
|
||||||
api("org.ow2.asm:asm-tree:${ASM_VERSION}")
|
api("org.ow2.asm:asm-tree:${ASM_VERSION}")
|
||||||
api("org.ow2.asm:asm-commons:${ASM_VERSION}")
|
api("org.ow2.asm:asm-commons:${ASM_VERSION}")
|
||||||
api('net.minecraftforge:forgespi:4.0.+')
|
api("net.minecraftforge:forgespi:${SPI_VERSION}")
|
||||||
api('org.apache.logging.log4j:log4j-api:2.17.0')
|
api("org.apache.logging.log4j:log4j-api:${LOG4J_VERSION}")
|
||||||
api('org.slf4j:slf4j-api:1.8.0-beta4')
|
api("org.slf4j:slf4j-api:${SLF4J_API_VERSION}")
|
||||||
api('com.google.guava:guava:21.0')
|
api("com.google.guava:guava:${GUAVA_VERSION}")
|
||||||
api('com.google.code.gson:gson:2.8.9')
|
api("com.google.code.gson:gson:${GSON_VERSION}")
|
||||||
api('org.apache.maven:maven-artifact:3.8.1')
|
api("org.apache.maven:maven-artifact:${APACHE_MAVEN_ARTIFACT_VERSION}")
|
||||||
api('org.apache.commons:commons-lang3:3.12.0')
|
api("org.apache.commons:commons-lang3:${APACHE_COMMONS_LANG3_VERSION}")
|
||||||
api('com.electronwill.night-config:core:3.6.4')
|
api("com.electronwill.night-config:core:${NIGHTCONFIG_VERSION}")
|
||||||
api('com.electronwill.night-config:toml:3.6.4')
|
api("com.electronwill.night-config:toml:${NIGHTCONFIG_VERSION}")
|
||||||
api('cpw.mods:modlauncher:9.0.+')
|
api("cpw.mods:modlauncher:${MODLAUNCHER_VERSION}")
|
||||||
api('net.minecraftforge:coremods:5.0.+')
|
api("net.minecraftforge:coremods:${COREMODS_VERSION}")
|
||||||
|
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("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
|
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
|
||||||
implementation('org.apache.logging.log4j:log4j-core:2.17.0')
|
implementation("net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}")
|
||||||
annotationProcessor('org.apache.logging.log4j:log4j-core:2.17.0')
|
implementation("net.minecrell:terminalconsoleappender:${TERMINALCONSOLEAPPENDER_VERSION}")
|
||||||
implementation('net.minecraftforge:accesstransformers:8.0.4')
|
// implementation("org.jline:jline:${JLINE_VERSION}")
|
||||||
implementation('net.minecrell:terminalconsoleappender:1.2.0')
|
|
||||||
// implementation('org.jline:jline:3.12.+')
|
implementation("org.apache.logging.log4j:log4j-core:${LOG4J_VERSION}")
|
||||||
testCompileOnly('org.jetbrains:annotations:21.0.0')
|
annotationProcessor("org.apache.logging.log4j:log4j-core:${LOG4J_VERSION}")
|
||||||
|
|
||||||
|
testCompileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
||||||
testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}")
|
testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-5
@@ -7,7 +7,11 @@ package net.minecraftforge.fml.common.asm;
|
|||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
@@ -20,7 +24,17 @@ import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
|||||||
* Will also de-finalize all fields in on class level annotations.
|
* Will also de-finalize all fields in on class level annotations.
|
||||||
*/
|
*/
|
||||||
public class ObjectHolderDefinalize implements ILaunchPluginService {
|
public class ObjectHolderDefinalize implements ILaunchPluginService {
|
||||||
|
// Hardcoded map of vanilla classes that should have object holders for each field of the given registry type.
|
||||||
|
// IMPORTANT: Updates to this collection must be reflected in ObjectHolderRegistry. Duplicated cuz classloaders, yay!
|
||||||
|
// Classnames are validated in ObjectHolderRegistry.
|
||||||
|
private static final Map<String, VanillaObjectHolderData> VANILLA_OBJECT_HOLDERS = Stream.of(
|
||||||
|
new VanillaObjectHolderData("net.minecraft.world.level.block.Blocks", "block", "net.minecraft.world.level.block.Block"),
|
||||||
|
new VanillaObjectHolderData("net.minecraft.world.item.Items", "item", "net.minecraft.world.item.Item"),
|
||||||
|
new VanillaObjectHolderData("net.minecraft.world.item.enchantment.Enchantments", "enchantment", "net.minecraft.world.item.enchantment.Enchantment"),
|
||||||
|
new VanillaObjectHolderData("net.minecraft.world.effect.MobEffects", "mob_effect", "net.minecraft.world.effect.MobEffect"),
|
||||||
|
new VanillaObjectHolderData("net.minecraft.core.particles.ParticleTypes", "particle_type", "net.minecraft.core.particles.ParticleType"),
|
||||||
|
new VanillaObjectHolderData("net.minecraft.sounds.SoundEvents", "sound_event", "net.minecraft.sounds.SoundEvent")
|
||||||
|
).collect(Collectors.toMap(VanillaObjectHolderData::holderClass, Function.identity()));
|
||||||
private final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
|
private final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -28,7 +42,6 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
|||||||
return "object_holder_definalize";
|
return "object_holder_definalize";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
|
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
|
||||||
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||||
|
|
||||||
@@ -73,10 +86,8 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
|||||||
changes.compareAndSet(false, prev != f.access);
|
changes.compareAndSet(false, prev != f.access);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hasHolder(classNode.visibleAnnotations)) //Class level, de-finalize all fields and add @ObjectHolder to them!
|
if (VANILLA_OBJECT_HOLDERS.containsKey(classType.getClassName())) //Class level, de-finalize all fields and add @ObjectHolder to them!
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
|
||||||
String value = getValue(classNode.visibleAnnotations);
|
|
||||||
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L")).forEach(f ->
|
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L")).forEach(f ->
|
||||||
{
|
{
|
||||||
int prev = f.access;
|
int prev = f.access;
|
||||||
@@ -95,4 +106,5 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
|||||||
return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE;
|
return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private record VanillaObjectHolderData(String holderClass, String registryName, String registryType) {}
|
||||||
}
|
}
|
||||||
+30
-17
@@ -9,9 +9,7 @@ import java.util.EnumSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
|
import com.mojang.logging.LogUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.objectweb.asm.Label;
|
import org.objectweb.asm.Label;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
@@ -21,6 +19,9 @@ import org.objectweb.asm.tree.FieldNode;
|
|||||||
import org.objectweb.asm.tree.MethodNode;
|
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.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
|
||||||
@@ -28,7 +29,7 @@ import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
|||||||
*/
|
*/
|
||||||
public class RuntimeEnumExtender implements ILaunchPluginService {
|
public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final Type STRING = Type.getType(String.class);
|
private final Type STRING = Type.getType(String.class);
|
||||||
private final Type ENUM = Type.getType(Enum.class);
|
private final Type ENUM = Type.getType(Enum.class);
|
||||||
private final Type MARKER_IFACE = Type.getType("Lnet/minecraftforge/common/IExtensibleEnum;");
|
private final Type MARKER_IFACE = Type.getType("Lnet/minecraftforge/common/IExtensibleEnum;");
|
||||||
@@ -63,43 +64,49 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
|||||||
final int flags = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC;
|
final int flags = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC;
|
||||||
|
|
||||||
FieldNode values = classNode.fields.stream().filter(f -> f.desc.contentEquals(array.getDescriptor()) && ((f.access & flags) == flags)).findFirst().orElse(null);
|
FieldNode values = classNode.fields.stream().filter(f -> f.desc.contentEquals(array.getDescriptor()) && ((f.access & flags) == flags)).findFirst().orElse(null);
|
||||||
|
|
||||||
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) {
|
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) {
|
||||||
return ComputeFlags.NO_REWRITE;
|
return ComputeFlags.NO_REWRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Static methods named "create" with first argument as a string
|
//Static methods named "create" with first argument as a string
|
||||||
List<MethodNode> candidates = classNode.methods.stream()
|
List<MethodNode> candidates = classNode.methods.stream()
|
||||||
.filter(m -> ((m.access & Opcodes.ACC_STATIC) != 0) && m.name.equals("create"))
|
.filter(m -> ((m.access & Opcodes.ACC_STATIC) != 0) && m.name.equals("create"))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (candidates.isEmpty()) {
|
if (candidates.isEmpty()) {
|
||||||
throw new IllegalStateException("IExtensibleEnum has no candidate factory methods: " + classType.getClassName());
|
throw new IllegalStateException("IExtensibleEnum has no candidate factory methods: " + classType.getClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
candidates.forEach(mtd ->
|
candidates.forEach(mtd ->
|
||||||
{
|
{
|
||||||
Type[] args = Type.getArgumentTypes(mtd.desc);
|
Type[] args = Type.getArgumentTypes(mtd.desc);
|
||||||
if (args.length == 0 || !args[0].equals(STRING)) {
|
if (args.length == 0 || !args[0].equals(STRING)) {
|
||||||
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Enum has create method without String as first parameter:\n");
|
sb.append("Enum has create method without String as first parameter:\n");
|
||||||
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
||||||
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
|
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
|
||||||
}));
|
LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
|
||||||
|
}
|
||||||
throw new IllegalStateException("Enum has create method without String as first parameter: " + mtd.name + mtd.desc);
|
throw new IllegalStateException("Enum has create method without String as first parameter: " + mtd.name + mtd.desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type ret = Type.getReturnType(mtd.desc);
|
Type ret = Type.getReturnType(mtd.desc);
|
||||||
if (!ret.equals(classType)) {
|
if (!ret.equals(classType)) {
|
||||||
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Enum has create method with incorrect return type:\n");
|
sb.append("Enum has create method with incorrect return type:\n");
|
||||||
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
||||||
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
|
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
|
||||||
sb.append(" Found: ").append(ret.getClassName()).append(", Expected: ").append(classType.getClassName());
|
sb.append(" Found: ").append(ret.getClassName()).append(", Expected: ").append(classType.getClassName());
|
||||||
}));
|
LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
|
||||||
|
}
|
||||||
throw new IllegalStateException("Enum has create method with incorrect return type: " + mtd.name + mtd.desc);
|
throw new IllegalStateException("Enum has create method with incorrect return type: " + mtd.name + mtd.desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type[] ctrArgs = new Type[args.length + 1];
|
Type[] ctrArgs = new Type[args.length + 1];
|
||||||
ctrArgs[0] = STRING;
|
ctrArgs[0] = STRING;
|
||||||
ctrArgs[1] = Type.INT_TYPE;
|
ctrArgs[1] = Type.INT_TYPE;
|
||||||
@@ -111,23 +118,29 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
|||||||
MethodNode ctr = classNode.methods.stream().filter(m -> m.name.equals("<init>") && m.desc.equals(desc)).findFirst().orElse(null);
|
MethodNode ctr = classNode.methods.stream().filter(m -> m.name.equals("<init>") && m.desc.equals(desc)).findFirst().orElse(null);
|
||||||
if (ctr == null)
|
if (ctr == null)
|
||||||
{
|
{
|
||||||
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Enum has create method with no matching constructor:\n");
|
sb.append("Enum has create method with no matching constructor:\n");
|
||||||
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
|
||||||
sb.append(" Candidate: ").append(mtd.desc).append("\n");
|
sb.append(" Candidate: ").append(mtd.desc).append("\n");
|
||||||
sb.append(" Target: ").append(desc).append("\n");
|
sb.append(" Target: ").append(desc).append("\n");
|
||||||
classNode.methods.stream().filter(m -> m.name.equals("<init>")).forEach(m -> sb.append(" : ").append(m.desc).append("\n"));
|
classNode.methods.stream().filter(m -> m.name.equals("<init>")).forEach(m -> sb.append(" : ").append(m.desc).append("\n"));
|
||||||
}));
|
LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
|
||||||
|
}
|
||||||
throw new IllegalStateException("Enum has create method with no matching constructor: " + desc);
|
throw new IllegalStateException("Enum has create method with no matching constructor: " + desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (values == null)
|
if (values == null)
|
||||||
{
|
{
|
||||||
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> {
|
if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Enum has create method but we could not find $VALUES. Found:\n");
|
sb.append("Enum has create method but we could not find $VALUES. Found:\n");
|
||||||
classNode.fields.stream().filter(f -> (f.access & Opcodes.ACC_STATIC) != 0).
|
classNode.fields.stream().filter(f -> (f.access & Opcodes.ACC_STATIC) != 0).
|
||||||
forEach(m -> sb.append(" ").append(m.name).append(" ").append(m.desc).append("\n"));
|
forEach(m -> sb.append(" ").append(m.name).append(" ").append(m.desc).append("\n"));
|
||||||
}));
|
LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
|
||||||
|
}
|
||||||
throw new IllegalStateException("Enum has create method but we could not find $VALUES");
|
throw new IllegalStateException("Enum has create method but we could not find $VALUES");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.message.Message;
|
|
||||||
import org.apache.logging.log4j.util.StringBuilderFormattable;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class AdvancedLogMessageAdapter implements Message, StringBuilderFormattable {
|
|
||||||
private static final long serialVersionUID = -8291754833965087436L;
|
|
||||||
|
|
||||||
private static final Object[] EMPTY = new Object[0];
|
|
||||||
|
|
||||||
private final Consumer<StringBuilder> logMessageBuilder;
|
|
||||||
|
|
||||||
public AdvancedLogMessageAdapter(final Consumer<StringBuilder> logMessageBuilder) {
|
|
||||||
this.logMessageBuilder = logMessageBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFormattedMessage() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFormat() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getParameters() {
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Throwable getThrowable() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void formatTo(final StringBuilder buffer) {
|
|
||||||
logMessageBuilder.accept(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
public class ClasspathLocatorUtils {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
public static 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.NamedPath;
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ClasspathTransformerDiscoverer implements ITransformerDiscoveryService {
|
||||||
|
|
||||||
|
private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NamedPath> candidates(Path gameDirectory) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NamedPath> candidates(final Path gameDirectory, final String launchTarget) {
|
||||||
|
if (launchTarget != null && launchTarget.contains("dev")) {
|
||||||
|
this.scan(gameDirectory);
|
||||||
|
}
|
||||||
|
return List.copyOf(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static List<NamedPath> found = new ArrayList<>();
|
||||||
|
|
||||||
|
public static List<Path> allExcluded() {
|
||||||
|
return found.stream().map(np->np.paths()[0]).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scan(final Path gameDirectory) {
|
||||||
|
try {
|
||||||
|
locateTransformers("META-INF/services/cpw.mods.modlauncher.api.ITransformationService");
|
||||||
|
locateTransformers("META-INF/services/net.minecraftforge.forgespi.locating.IModLocator");
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogManager.getLogger().error("Error during discovery of transform services from the classpath", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void locateTransformers(String resource) throws IOException {
|
||||||
|
final Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(resource);
|
||||||
|
while (resources.hasMoreElements()) {
|
||||||
|
URL url = resources.nextElement();
|
||||||
|
Path path = ClasspathLocatorUtils.findJarPathFor(resource, url.toString(), url);
|
||||||
|
if (legacyClasspath.stream().anyMatch(path::equals) || !Files.exists(path) || Files.isDirectory(path))
|
||||||
|
continue;
|
||||||
|
found.add(new NamedPath(path.toUri().toString(), path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ public class EarlyLoadingException extends RuntimeException {
|
|||||||
return errorMessages;
|
return errorMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
EarlyLoadingException(final String message, final Throwable originalException, List<ExceptionData> errorMessages) {
|
public EarlyLoadingException(final String message, final Throwable originalException, List<ExceptionData> errorMessages) {
|
||||||
super(message, originalException);
|
super(message, originalException);
|
||||||
this.errorMessages = errorMessages;
|
this.errorMessages = errorMessages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
|||||||
import com.electronwill.nightconfig.core.file.FileNotFoundAction;
|
import com.electronwill.nightconfig.core.file.FileNotFoundAction;
|
||||||
import com.electronwill.nightconfig.core.io.ParsingException;
|
import com.electronwill.nightconfig.core.io.ParsingException;
|
||||||
import com.electronwill.nightconfig.core.io.WritingMode;
|
import com.electronwill.nightconfig.core.io.WritingMode;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import com.mojang.logging.LogUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -21,7 +21,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
|||||||
|
|
||||||
public class FMLConfig
|
public class FMLConfig
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static FMLConfig INSTANCE = new FMLConfig();
|
private static FMLConfig INSTANCE = new FMLConfig();
|
||||||
private static ConfigSpec configSpec = new ConfigSpec();
|
private static ConfigSpec configSpec = new ConfigSpec();
|
||||||
static {
|
static {
|
||||||
@@ -29,6 +29,7 @@ public class FMLConfig
|
|||||||
configSpec.define("maxThreads", -1);
|
configSpec.define("maxThreads", -1);
|
||||||
configSpec.define("versionCheck", Boolean.TRUE);
|
configSpec.define("versionCheck", Boolean.TRUE);
|
||||||
configSpec.define("defaultConfigPath", "defaultconfigs");
|
configSpec.define("defaultConfigPath", "defaultconfigs");
|
||||||
|
configSpec.define("disableOptimizedDFU", Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommentedFileConfig configData;
|
private CommentedFileConfig configData;
|
||||||
@@ -60,11 +61,14 @@ public class FMLConfig
|
|||||||
{
|
{
|
||||||
final Path configFile = FMLPaths.FMLCONFIG.get();
|
final Path configFile = FMLPaths.FMLCONFIG.get();
|
||||||
INSTANCE.loadFrom(configFile);
|
INSTANCE.loadFrom(configFile);
|
||||||
LOGGER.trace(CORE, "Loaded FML config from {}", FMLPaths.FMLCONFIG.get());
|
if (LOGGER.isTraceEnabled(CORE))
|
||||||
LOGGER.trace(CORE, "Splash screen is {}", FMLConfig::splashScreenEnabled);
|
{
|
||||||
LOGGER.trace(CORE, "Max threads for mod loading computed at {}", FMLConfig::loadingThreadCount);
|
LOGGER.trace(CORE, "Loaded FML config from {}", FMLPaths.FMLCONFIG.get());
|
||||||
LOGGER.trace(CORE, "Version check is {}", FMLConfig::runVersionCheck);
|
LOGGER.trace(CORE, "Splash screen is {}", FMLConfig.splashScreenEnabled());
|
||||||
LOGGER.trace(CORE, "Default config paths at {}", FMLConfig::defaultConfigPath);
|
LOGGER.trace(CORE, "Max threads for mod loading computed at {}", FMLConfig.loadingThreadCount());
|
||||||
|
LOGGER.trace(CORE, "Version check is {}", FMLConfig.runVersionCheck());
|
||||||
|
LOGGER.trace(CORE, "Default config paths at {}", FMLConfig.defaultConfigPath());
|
||||||
|
}
|
||||||
FMLPaths.getOrCreateGameRelativePath(Paths.get(FMLConfig.defaultConfigPath()), "default config directory");
|
FMLPaths.getOrCreateGameRelativePath(Paths.get(FMLConfig.defaultConfigPath()), "default config directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,4 +89,8 @@ public class FMLConfig
|
|||||||
public static String defaultConfigPath() {
|
public static String defaultConfigPath() {
|
||||||
return INSTANCE.configData.<String>getOptional("defaultConfigPath").orElse("defaultconfigs");
|
return INSTANCE.configData.<String>getOptional("defaultConfigPath").orElse("defaultconfigs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isOptimizedDFUDisabled() {
|
||||||
|
return INSTANCE.configData.<Boolean>getOptional("disableOptimizedDFU").orElse(Boolean.TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.Launcher;
|
import cpw.mods.modlauncher.Launcher;
|
||||||
import cpw.mods.modlauncher.api.*;
|
import cpw.mods.modlauncher.api.*;
|
||||||
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
@@ -21,8 +22,7 @@ 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;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -35,7 +35,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
|||||||
|
|
||||||
public class FMLLoader
|
public class FMLLoader
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static AccessTransformerService accessTransformer;
|
private static AccessTransformerService accessTransformer;
|
||||||
private static ModDiscoverer modDiscoverer;
|
private static ModDiscoverer modDiscoverer;
|
||||||
private static ICoreModProvider coreModProvider;
|
private static ICoreModProvider coreModProvider;
|
||||||
@@ -62,47 +62,47 @@ public class FMLLoader
|
|||||||
final Package modLauncherPackage = ITransformationService.class.getPackage();
|
final Package modLauncherPackage = ITransformationService.class.getPackage();
|
||||||
LOGGER.debug(CORE,"FML found ModLauncher version : {}", modLauncherPackage.getImplementationVersion());
|
LOGGER.debug(CORE,"FML found ModLauncher version : {}", modLauncherPackage.getImplementationVersion());
|
||||||
if (!modLauncherPackage.isCompatibleWith("4.0")) {
|
if (!modLauncherPackage.isCompatibleWith("4.0")) {
|
||||||
LOGGER.fatal(CORE,"Found incompatible ModLauncher specification : {}, version {} from {}", modLauncherPackage.getSpecificationVersion(), modLauncherPackage.getImplementationVersion(), modLauncherPackage.getImplementationVendor());
|
LOGGER.error(CORE, "Found incompatible ModLauncher specification : {}, version {} from {}", modLauncherPackage.getSpecificationVersion(), modLauncherPackage.getImplementationVersion(), modLauncherPackage.getImplementationVendor());
|
||||||
throw new IncompatibleEnvironmentException("Incompatible modlauncher found "+modLauncherPackage.getSpecificationVersion());
|
throw new IncompatibleEnvironmentException("Incompatible modlauncher found "+modLauncherPackage.getSpecificationVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
accessTransformer = (AccessTransformerService) environment.findLaunchPlugin("accesstransformer").orElseThrow(()-> {
|
accessTransformer = (AccessTransformerService) environment.findLaunchPlugin("accesstransformer").orElseThrow(()-> {
|
||||||
LOGGER.fatal(CORE,"Access Transformer library is missing, we need this to run");
|
LOGGER.error(CORE, "Access Transformer library is missing, we need this to run");
|
||||||
return new IncompatibleEnvironmentException("Missing AccessTransformer, cannot run");
|
return new IncompatibleEnvironmentException("Missing AccessTransformer, cannot run");
|
||||||
});
|
});
|
||||||
|
|
||||||
final Package atPackage = accessTransformer.getClass().getPackage();
|
final Package atPackage = accessTransformer.getClass().getPackage();
|
||||||
LOGGER.debug(CORE,"FML found AccessTransformer version : {}", atPackage.getImplementationVersion());
|
LOGGER.debug(CORE,"FML found AccessTransformer version : {}", atPackage.getImplementationVersion());
|
||||||
if (!atPackage.isCompatibleWith("1.0")) {
|
if (!atPackage.isCompatibleWith("1.0")) {
|
||||||
LOGGER.fatal(CORE,"Found incompatible AccessTransformer specification : {}, version {} from {}", atPackage.getSpecificationVersion(), atPackage.getImplementationVersion(), atPackage.getImplementationVendor());
|
LOGGER.error(CORE, "Found incompatible AccessTransformer specification : {}, version {} from {}", atPackage.getSpecificationVersion(), atPackage.getImplementationVersion(), atPackage.getImplementationVendor());
|
||||||
throw new IncompatibleEnvironmentException("Incompatible accesstransformer found "+atPackage.getSpecificationVersion());
|
throw new IncompatibleEnvironmentException("Incompatible accesstransformer found "+atPackage.getSpecificationVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBus = environment.findLaunchPlugin("eventbus").orElseThrow(()-> {
|
eventBus = environment.findLaunchPlugin("eventbus").orElseThrow(()-> {
|
||||||
LOGGER.fatal(CORE,"Event Bus library is missing, we need this to run");
|
LOGGER.error(CORE, "Event Bus library is missing, we need this to run");
|
||||||
return new IncompatibleEnvironmentException("Missing EventBus, cannot run");
|
return new IncompatibleEnvironmentException("Missing EventBus, cannot run");
|
||||||
});
|
});
|
||||||
|
|
||||||
final Package eventBusPackage = eventBus.getClass().getPackage();
|
final Package eventBusPackage = eventBus.getClass().getPackage();
|
||||||
LOGGER.debug(CORE,"FML found EventBus version : {}", eventBusPackage.getImplementationVersion());
|
LOGGER.debug(CORE,"FML found EventBus version : {}", eventBusPackage.getImplementationVersion());
|
||||||
if (!eventBusPackage.isCompatibleWith("1.0")) {
|
if (!eventBusPackage.isCompatibleWith("1.0")) {
|
||||||
LOGGER.fatal(CORE,"Found incompatible EventBus specification : {}, version {} from {}", eventBusPackage.getSpecificationVersion(), eventBusPackage.getImplementationVersion(), eventBusPackage.getImplementationVendor());
|
LOGGER.error(CORE, "Found incompatible EventBus specification : {}, version {} from {}", eventBusPackage.getSpecificationVersion(), eventBusPackage.getImplementationVersion(), eventBusPackage.getImplementationVendor());
|
||||||
throw new IncompatibleEnvironmentException("Incompatible eventbus found "+eventBusPackage.getSpecificationVersion());
|
throw new IncompatibleEnvironmentException("Incompatible eventbus found "+eventBusPackage.getSpecificationVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeDistCleaner = (RuntimeDistCleaner)environment.findLaunchPlugin("runtimedistcleaner").orElseThrow(()-> {
|
runtimeDistCleaner = (RuntimeDistCleaner)environment.findLaunchPlugin("runtimedistcleaner").orElseThrow(()-> {
|
||||||
LOGGER.fatal(CORE,"Dist Cleaner is missing, we need this to run");
|
LOGGER.error(CORE, "Dist Cleaner is missing, we need this to run");
|
||||||
return new IncompatibleEnvironmentException("Missing DistCleaner, cannot run!");
|
return new IncompatibleEnvironmentException("Missing DistCleaner, cannot run!");
|
||||||
});
|
});
|
||||||
LOGGER.debug(CORE, "Found Runtime Dist Cleaner");
|
LOGGER.debug(CORE, "Found Runtime Dist Cleaner");
|
||||||
|
|
||||||
var coreModProviders = ServiceLoaderUtils.streamWithErrorHandling(ServiceLoader.load(FMLLoader.class.getModule().getLayer(), ICoreModProvider.class), sce -> LOGGER.fatal(CORE, "Failed to load a coremod library, expect problems", sce)).toList();
|
var coreModProviders = ServiceLoaderUtils.streamWithErrorHandling(ServiceLoader.load(FMLLoader.class.getModule().getLayer(), ICoreModProvider.class), sce -> LOGGER.error(CORE, "Failed to load a coremod library, expect problems", sce)).toList();
|
||||||
|
|
||||||
if (coreModProviders.isEmpty()) {
|
if (coreModProviders.isEmpty()) {
|
||||||
LOGGER.fatal(CORE, "Found no coremod provider. Cannot run");
|
LOGGER.error(CORE, "Found no coremod provider. Cannot run");
|
||||||
throw new IncompatibleEnvironmentException("No coremod library found");
|
throw new IncompatibleEnvironmentException("No coremod library found");
|
||||||
} else if (coreModProviders.size() > 1) {
|
} else if (coreModProviders.size() > 1) {
|
||||||
LOGGER.fatal(CORE, "Found multiple coremod providers : {}. Cannot run", coreModProviders.stream().map(p -> p.getClass().getName()).collect(Collectors.toList()));
|
LOGGER.error(CORE, "Found multiple coremod providers : {}. Cannot run", coreModProviders.stream().map(p -> p.getClass().getName()).collect(Collectors.toList()));
|
||||||
throw new IncompatibleEnvironmentException("Multiple coremod libraries found");
|
throw new IncompatibleEnvironmentException("Multiple coremod libraries found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ public class FMLLoader
|
|||||||
LOGGER.debug(CORE, "Found ForgeSPI package implementation version {}", Environment.class.getPackage().getImplementationVersion());
|
LOGGER.debug(CORE, "Found ForgeSPI package implementation version {}", Environment.class.getPackage().getImplementationVersion());
|
||||||
LOGGER.debug(CORE, "Found ForgeSPI package specification {}", Environment.class.getPackage().getSpecificationVersion());
|
LOGGER.debug(CORE, "Found ForgeSPI package specification {}", Environment.class.getPackage().getSpecificationVersion());
|
||||||
if (Integer.parseInt(Environment.class.getPackage().getSpecificationVersion()) < 2) {
|
if (Integer.parseInt(Environment.class.getPackage().getSpecificationVersion()) < 2) {
|
||||||
LOGGER.fatal(CORE, "Found an out of date ForgeSPI implementation: {}, loading cannot continue", Environment.class.getPackage().getSpecificationVersion());
|
LOGGER.error(CORE, "Found an out of date ForgeSPI implementation: {}, loading cannot continue", Environment.class.getPackage().getSpecificationVersion());
|
||||||
throw new IncompatibleEnvironmentException("ForgeSPI is out of date, we cannot continue");
|
throw new IncompatibleEnvironmentException("ForgeSPI is out of date, we cannot continue");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ public class FMLLoader
|
|||||||
Class.forName("com.electronwill.nightconfig.core.Config", false, environment.getClass().getClassLoader());
|
Class.forName("com.electronwill.nightconfig.core.Config", false, environment.getClass().getClassLoader());
|
||||||
Class.forName("com.electronwill.nightconfig.toml.TomlFormat", false, environment.getClass().getClassLoader());
|
Class.forName("com.electronwill.nightconfig.toml.TomlFormat", false, environment.getClass().getClassLoader());
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
LOGGER.fatal(CORE, "Failed to load NightConfig");
|
LOGGER.error(CORE, "Failed to load NightConfig");
|
||||||
throw new IncompatibleEnvironmentException("Missing NightConfig");
|
throw new IncompatibleEnvironmentException("Missing NightConfig");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,12 +134,12 @@ public class FMLLoader
|
|||||||
final Optional<ILaunchHandlerService> launchHandler = environment.findLaunchHandler(launchTarget);
|
final Optional<ILaunchHandlerService> launchHandler = environment.findLaunchHandler(launchTarget);
|
||||||
LOGGER.debug(CORE, "Using {} as launch service", launchTarget);
|
LOGGER.debug(CORE, "Using {} as launch service", launchTarget);
|
||||||
if (launchHandler.isEmpty()) {
|
if (launchHandler.isEmpty()) {
|
||||||
LOGGER.fatal(CORE,"Missing LaunchHandler {}, cannot continue", launchTarget);
|
LOGGER.error(CORE, "Missing LaunchHandler {}, cannot continue", launchTarget);
|
||||||
throw new RuntimeException("Missing launch handler: " + launchTarget);
|
throw new RuntimeException("Missing launch handler: " + launchTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(launchHandler.get() instanceof CommonLaunchHandler)) {
|
if (!(launchHandler.get() instanceof CommonLaunchHandler)) {
|
||||||
LOGGER.fatal(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");
|
||||||
}
|
}
|
||||||
commonLaunchHandler = (CommonLaunchHandler)launchHandler.get();
|
commonLaunchHandler = (CommonLaunchHandler)launchHandler.get();
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.api.IEnvironment;
|
import cpw.mods.modlauncher.api.IEnvironment;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -22,7 +22,7 @@ public enum FMLPaths
|
|||||||
CONFIGDIR("config"),
|
CONFIGDIR("config"),
|
||||||
FMLCONFIG(false, CONFIGDIR, "fml.toml");
|
FMLCONFIG(false, CONFIGDIR, "fml.toml");
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final Path relativePath;
|
private final Path relativePath;
|
||||||
private final boolean isDirectory;
|
private final boolean isDirectory;
|
||||||
private Path absolutePath;
|
private Path absolutePath;
|
||||||
@@ -61,7 +61,10 @@ public enum FMLPaths
|
|||||||
{
|
{
|
||||||
FileUtils.getOrCreateDirectory(path.absolutePath, path.name());
|
FileUtils.getOrCreateDirectory(path.absolutePath, path.name());
|
||||||
}
|
}
|
||||||
LOGGER.debug(CORE,"Path {} is {}", ()-> path, ()-> path.absolutePath);
|
if (LOGGER.isDebugEnabled(CORE))
|
||||||
|
{
|
||||||
|
LOGGER.debug(CORE, "Path {} is {}", path, path.absolutePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.api.*;
|
import cpw.mods.modlauncher.api.*;
|
||||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||||
import joptsimple.OptionSpecBuilder;
|
import joptsimple.OptionSpecBuilder;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
import net.minecraftforge.forgespi.Environment;
|
import net.minecraftforge.forgespi.Environment;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -26,7 +26,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
|||||||
|
|
||||||
public class FMLServiceProvider implements ITransformationService
|
public class FMLServiceProvider implements ITransformationService
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private ArgumentAcceptingOptionSpec<String> modsOption;
|
private ArgumentAcceptingOptionSpec<String> modsOption;
|
||||||
private ArgumentAcceptingOptionSpec<String> modListsOption;
|
private ArgumentAcceptingOptionSpec<String> modListsOption;
|
||||||
private ArgumentAcceptingOptionSpec<String> mavenRootsOption;
|
private ArgumentAcceptingOptionSpec<String> mavenRootsOption;
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import com.mojang.logging.LogUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.FileAlreadyExistsException;
|
import java.nio.file.FileAlreadyExistsException;
|
||||||
@@ -17,7 +17,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
|||||||
|
|
||||||
public class FileUtils
|
public class FileUtils
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public static Path getOrCreateDirectory(Path dirPath, String dirLabel) {
|
public static Path getOrCreateDirectory(Path dirPath, String dirLabel) {
|
||||||
if (!Files.isDirectory(dirPath.getParent())) {
|
if (!Files.isDirectory(dirPath.getParent())) {
|
||||||
@@ -25,20 +25,20 @@ public class FileUtils
|
|||||||
}
|
}
|
||||||
if (!Files.isDirectory(dirPath))
|
if (!Files.isDirectory(dirPath))
|
||||||
{
|
{
|
||||||
LOGGER.debug(CORE,"Making {} directory : {}", dirLabel, dirPath);
|
LOGGER.debug(CORE, "Making {} directory : {}", dirLabel, dirPath);
|
||||||
try {
|
try {
|
||||||
Files.createDirectory(dirPath);
|
Files.createDirectory(dirPath);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (e instanceof FileAlreadyExistsException) {
|
if (e instanceof FileAlreadyExistsException) {
|
||||||
LOGGER.fatal(CORE,"Failed to create {} directory - there is a file in the way", dirLabel);
|
LOGGER.error(CORE, "Failed to create {} directory - there is a file in the way", dirLabel);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.fatal(CORE,"Problem with creating {} directory (Permissions?)", dirLabel, e);
|
LOGGER.error(CORE, "Problem with creating {} directory (Permissions?)", dirLabel, e);
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Problem creating directory", e);
|
throw new RuntimeException("Problem creating directory", e);
|
||||||
}
|
}
|
||||||
LOGGER.debug(CORE,"Created {} directory : {}", dirLabel, dirPath);
|
LOGGER.debug(CORE, "Created {} directory : {}", dirLabel, dirPath);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.debug(CORE,"Found existing {} directory : {}", dirLabel, dirPath);
|
LOGGER.debug(CORE, "Found existing {} directory : {}", dirLabel, dirPath);
|
||||||
}
|
}
|
||||||
return dirPath;
|
return dirPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
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;
|
||||||
@@ -12,11 +13,10 @@ import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
|||||||
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;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -38,7 +38,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|||||||
|
|
||||||
public class LanguageLoadingProvider
|
public class LanguageLoadingProvider
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final List<IModLanguageProvider> languageProviders = new ArrayList<>();
|
private final List<IModLanguageProvider> languageProviders = new ArrayList<>();
|
||||||
private final ServiceLoader<IModLanguageProvider> serviceLoader;
|
private final ServiceLoader<IModLanguageProvider> serviceLoader;
|
||||||
private final Map<String, ModLanguageWrapper> languageProviderMap = new HashMap<>();
|
private final Map<String, ModLanguageWrapper> languageProviderMap = new HashMap<>();
|
||||||
@@ -81,7 +81,7 @@ public class LanguageLoadingProvider
|
|||||||
loadLanguageProviders();
|
loadLanguageProviders();
|
||||||
}
|
}
|
||||||
private void loadLanguageProviders() {
|
private void loadLanguageProviders() {
|
||||||
LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderUtils.streamServiceLoader(()->serviceLoader, sce->LOGGER.fatal("Problem with language loaders")).count());
|
LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderUtils.streamServiceLoader(()->serviceLoader, sce->LOGGER.error("Problem with language loaders")).count());
|
||||||
serviceLoader.forEach(languageProviders::add);
|
serviceLoader.forEach(languageProviders::add);
|
||||||
|
|
||||||
languageProviders.forEach(lp -> {
|
languageProviders.forEach(lp -> {
|
||||||
@@ -94,7 +94,7 @@ public class LanguageLoadingProvider
|
|||||||
Optional<String> implementationVersion = JarVersionLookupHandler.getImplementationVersion(lp.getClass());
|
Optional<String> implementationVersion = JarVersionLookupHandler.getImplementationVersion(lp.getClass());
|
||||||
String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.versionInfo().forgeVersion().split("\\.")[0] : null);
|
String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.versionInfo().forgeVersion().split("\\.")[0] : null);
|
||||||
if (impl == null) {
|
if (impl == null) {
|
||||||
LOGGER.fatal(CORE, "Found unversioned language provider {}", lp.name());
|
LOGGER.error(CORE, "Found unversioned language provider {}", lp.name());
|
||||||
throw new RuntimeException("Failed to find implementation version for language provider "+ lp.name());
|
throw new RuntimeException("Failed to find implementation version for language provider "+ lp.name());
|
||||||
}
|
}
|
||||||
LOGGER.debug(CORE, "Found language provider {}, version {}", lp.name(), impl);
|
LOGGER.debug(CORE, "Found language provider {}, version {}", lp.name(), impl);
|
||||||
@@ -134,7 +134,7 @@ public class LanguageLoadingProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IModLanguageProvider findLanguage(ModFile mf, String modLoader, VersionRange modLoaderVersion) {
|
public IModLanguageProvider findLanguage(ModFile mf, String modLoader, VersionRange modLoaderVersion) {
|
||||||
final String languageFileName = mf.getLocator() instanceof ExplodedDirectoryLocator ? "in-development" : mf.getFileName();
|
final String languageFileName = mf.getProvider() instanceof ExplodedDirectoryLocator ? "in-development" : mf.getFileName();
|
||||||
final ModLanguageWrapper mlw = languageProviderMap.get(modLoader);
|
final ModLanguageWrapper mlw = languageProviderMap.get(modLoader);
|
||||||
if (mlw == null) {
|
if (mlw == null) {
|
||||||
LOGGER.error(LOADING,"Missing language {} version {} wanted by {}", modLoader, modLoaderVersion, languageFileName);
|
LOGGER.error(LOADING,"Missing language {} version {} wanted by {}", modLoader, modLoaderVersion, languageFileName);
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import com.mojang.logging.LogUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||||
|
|
||||||
public class LauncherVersion {
|
public class LauncherVersion {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static final String launcherVersion;
|
private static final String launcherVersion;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import com.mojang.logging.LogUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class LibraryFinder {
|
public class LibraryFinder {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static Path libsPath;
|
private static Path libsPath;
|
||||||
static Path findLibsPath() {
|
static Path findLibsPath() {
|
||||||
if (libsPath == null) {
|
if (libsPath == null) {
|
||||||
|
|||||||
@@ -10,11 +10,18 @@ import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler;
|
|||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
|
||||||
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.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +35,7 @@ public class LoadingModList
|
|||||||
private final List<ModInfo> sortedList;
|
private final List<ModInfo> sortedList;
|
||||||
private final Map<String, ModFileInfo> fileById;
|
private final Map<String, ModFileInfo> fileById;
|
||||||
private final List<EarlyLoadingException> preLoadErrors;
|
private final List<EarlyLoadingException> preLoadErrors;
|
||||||
private List<ModFile> brokenFiles;
|
private List<IModFile> brokenFiles;
|
||||||
|
|
||||||
private LoadingModList(final List<ModFile> modFiles, final List<ModInfo> sortedList)
|
private LoadingModList(final List<ModFile> modFiles, final List<ModInfo> sortedList)
|
||||||
{
|
{
|
||||||
@@ -154,11 +161,11 @@ public class LoadingModList
|
|||||||
return preLoadErrors;
|
return preLoadErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBrokenFiles(final List<ModFile> brokenFiles) {
|
public void setBrokenFiles(final List<IModFile> brokenFiles) {
|
||||||
this.brokenFiles = brokenFiles;
|
this.brokenFiles = brokenFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ModFile> getBrokenFiles() {
|
public List<IModFile> getBrokenFiles() {
|
||||||
return this.brokenFiles;
|
return this.brokenFiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Marker;
|
import org.slf4j.Marker;
|
||||||
import org.apache.logging.log4j.MarkerManager;
|
import org.slf4j.MarkerFactory;
|
||||||
|
|
||||||
public class LogMarkers {
|
public class LogMarkers {
|
||||||
public static final Marker CORE = MarkerManager.getMarker("CORE");
|
public static final Marker CORE = MarkerFactory.getMarker("CORE");
|
||||||
public static final Marker LOADING = MarkerManager.getMarker("LOADING");
|
public static final Marker LOADING = MarkerFactory.getMarker("LOADING");
|
||||||
public static final Marker SCAN = MarkerManager.getMarker("SCAN");
|
public static final Marker SCAN = MarkerFactory.getMarker("SCAN");
|
||||||
public static final Marker SPLASH = MarkerManager.getMarker("SPLASH");
|
public static final Marker SPLASH = MarkerFactory.getMarker("SPLASH");
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.api.INameMappingService;
|
import cpw.mods.modlauncher.api.INameMappingService;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -20,7 +20,7 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
public class MCPNamingService implements INameMappingService {
|
public class MCPNamingService implements INameMappingService {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private HashMap<String, String> methods;
|
private HashMap<String, String> methods;
|
||||||
private HashMap<String, String> fields;
|
private HashMap<String, String> fields;
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -5,10 +5,11 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
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;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -19,6 +20,8 @@ import java.util.List;
|
|||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
|
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NamedPath> candidates(final Path gameDirectory) {
|
public List<NamedPath> candidates(final Path gameDirectory) {
|
||||||
ModDirTransformerDiscoverer.scan(gameDirectory);
|
ModDirTransformerDiscoverer.scan(gameDirectory);
|
||||||
@@ -40,7 +43,7 @@ public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService
|
|||||||
try (var walk = Files.walk(modsDir, 1)){
|
try (var walk = Files.walk(modsDir, 1)){
|
||||||
walk.forEach(ModDirTransformerDiscoverer::visitFile);
|
walk.forEach(ModDirTransformerDiscoverer::visitFile);
|
||||||
} catch (IOException | IllegalStateException ioe) {
|
} catch (IOException | IllegalStateException ioe) {
|
||||||
LogManager.getLogger().error("Error during early discovery", ioe);
|
LOGGER.error("Error during early discovery", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService
|
|||||||
found.add(new NamedPath(zf.getName(), path));
|
found.add(new NamedPath(zf.getName(), path));
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LogManager.getLogger().error("Zip Error when loading jar file {}", path, ioe);
|
LOGGER.error("Zip Error when loading jar file {}", path, ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -24,7 +24,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
|||||||
|
|
||||||
public class ModJarURLHandler extends URLStreamHandler
|
public class ModJarURLHandler extends URLStreamHandler
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
// modjar://modid/path/to/file
|
// modjar://modid/path/to/file
|
||||||
@Override
|
@Override
|
||||||
protected URLConnection openConnection(URL url) {
|
protected URLConnection openConnection(URL url) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package net.minecraftforge.fml.loading;
|
|||||||
|
|
||||||
import com.google.common.graph.GraphBuilder;
|
import com.google.common.graph.GraphBuilder;
|
||||||
import com.google.common.graph.MutableGraph;
|
import com.google.common.graph.MutableGraph;
|
||||||
|
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.IModFileInfo;
|
||||||
@@ -17,11 +18,9 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
|||||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||||
import net.minecraftforge.fml.loading.toposort.CyclePresentException;
|
import net.minecraftforge.fml.loading.toposort.CyclePresentException;
|
||||||
import net.minecraftforge.fml.loading.toposort.TopologicalSort;
|
import net.minecraftforge.fml.loading.toposort.TopologicalSort;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@@ -35,15 +34,16 @@ import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|||||||
|
|
||||||
public class ModSorter
|
public class ModSorter
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
private final UniqueModListBuilder uniqueModListBuilder;
|
||||||
private List<ModFile> modFiles;
|
private List<ModFile> modFiles;
|
||||||
private List<ModInfo> sortedList;
|
private List<ModInfo> sortedList;
|
||||||
private Map<String, ModInfo> modIdNameLookup;
|
private Map<String, IModInfo> modIdNameLookup;
|
||||||
private List<ModFile> systemMods;
|
private List<ModFile> systemMods;
|
||||||
|
|
||||||
private ModSorter(final List<ModFile> modFiles)
|
private ModSorter(final List<ModFile> modFiles)
|
||||||
{
|
{
|
||||||
this.modFiles = modFiles;
|
this.uniqueModListBuilder = new UniqueModListBuilder(modFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LoadingModList sort(List<ModFile> mods, final List<ExceptionData> errors)
|
public static LoadingModList sort(List<ModFile> mods, final List<ExceptionData> errors)
|
||||||
@@ -78,11 +78,12 @@ public class ModSorter
|
|||||||
// 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
|
||||||
final MutableGraph<ModFileInfo> graph = GraphBuilder.directed().build();
|
final MutableGraph<ModFileInfo> graph = GraphBuilder.directed().build();
|
||||||
AtomicInteger counter = new AtomicInteger();
|
AtomicInteger counter = new AtomicInteger();
|
||||||
Map<IModFileInfo, Integer> infos = modFiles.stream()
|
Map<ModFileInfo, Integer> infos = modFiles.stream()
|
||||||
.map(ModFile::getModFileInfo)
|
.map(ModFile::getModFileInfo)
|
||||||
.filter(ModFileInfo.class::isInstance)
|
.filter(ModFileInfo.class::isInstance)
|
||||||
|
.map(ModFileInfo.class::cast)
|
||||||
.collect(toMap(Function.identity(), e -> counter.incrementAndGet()));
|
.collect(toMap(Function.identity(), e -> counter.incrementAndGet()));
|
||||||
infos.keySet().forEach(i -> graph.addNode((ModFileInfo) i));
|
infos.keySet().forEach(graph::addNode);
|
||||||
modFiles.stream()
|
modFiles.stream()
|
||||||
.map(ModFile::getModInfos)
|
.map(ModFile::getModInfos)
|
||||||
.<IModInfo>mapMulti(Iterable::forEach)
|
.<IModInfo>mapMulti(Iterable::forEach)
|
||||||
@@ -98,11 +99,10 @@ public class ModSorter
|
|||||||
catch (CyclePresentException e)
|
catch (CyclePresentException e)
|
||||||
{
|
{
|
||||||
Set<Set<ModFileInfo>> cycles = e.getCycles();
|
Set<Set<ModFileInfo>> cycles = e.getCycles();
|
||||||
LOGGER.error(LOADING, () -> new AdvancedLogMessageAdapter(buffer ->
|
if (LOGGER.isErrorEnabled(LOADING))
|
||||||
buffer.append("Mod Sorting failed.\n")
|
{
|
||||||
.append("Detected Cycles: ")
|
LOGGER.error(LOADING, "Mod Sorting failed.\nDetected Cycles: {}\n", cycles);
|
||||||
.append(cycles)
|
}
|
||||||
.append('\n')));
|
|
||||||
var dataList = cycles.stream()
|
var dataList = cycles.stream()
|
||||||
.<ModFileInfo>mapMulti(Iterable::forEach)
|
.<ModFileInfo>mapMulti(Iterable::forEach)
|
||||||
.<IModInfo>mapMulti((mf,c)->mf.getMods().forEach(c))
|
.<IModInfo>mapMulti((mf,c)->mf.getMods().forEach(c))
|
||||||
@@ -125,10 +125,9 @@ public class ModSorter
|
|||||||
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();
|
||||||
final ModInfo targetModInfo = modIdNameLookup.get(dep.getModId());
|
final IModInfo targetModInfo = modIdNameLookup.get(dep.getModId());
|
||||||
// soft dep that doesn't exist. Just return. No edge required.
|
// soft dep that doesn't exist. Just return. No edge required.
|
||||||
if (targetModInfo == null) return;
|
if (targetModInfo == null || !(targetModInfo.getOwningFile() instanceof final ModFileInfo target)) return;
|
||||||
final ModFileInfo target = targetModInfo.getOwningFile();
|
|
||||||
if (self == target)
|
if (self == target)
|
||||||
return; // in case a jar has two mods that have dependencies between
|
return; // in case a jar has two mods that have dependencies between
|
||||||
switch (dep.getOrdering()) {
|
switch (dep.getOrdering()) {
|
||||||
@@ -139,19 +138,32 @@ public class ModSorter
|
|||||||
|
|
||||||
private void buildUniqueList()
|
private void buildUniqueList()
|
||||||
{
|
{
|
||||||
// Collect mod files by module name. This will be used for deduping purposes
|
final UniqueModListBuilder.UniqueModListData uniqueModListData = uniqueModListBuilder.buildUniqueList();
|
||||||
final Map<String, List<IModFile>> modFilesByFirstId = modFiles.stream()
|
|
||||||
.collect(groupingBy(mf -> mf.getModFileInfo().moduleName()));
|
|
||||||
|
|
||||||
|
this.modFiles = uniqueModListData.modFiles();
|
||||||
|
|
||||||
|
detectSystemMods(uniqueModListData.modFilesByFirstId());
|
||||||
|
|
||||||
|
modIdNameLookup = uniqueModListData.modFilesByFirstId().entrySet().stream()
|
||||||
|
.filter(e -> !e.getValue().get(0).getModInfos().isEmpty())
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
Map.Entry::getKey,
|
||||||
|
e -> e.getValue().get(0).getModInfos().get(0)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void detectSystemMods(final Map<String, List<ModFile>> modFilesByFirstId)
|
||||||
|
{
|
||||||
// Capture system mods (ex. MC, Forge) here, so we can keep them for later
|
// Capture system mods (ex. MC, Forge) here, so we can keep them for later
|
||||||
final Set<String> systemMods = new HashSet<>();
|
final Set<String> systemMods = new HashSet<>();
|
||||||
// The minecraft mod is always a system mod
|
// The minecraft mod is always a system mod
|
||||||
systemMods.add("minecraft");
|
systemMods.add("minecraft");
|
||||||
// Find mod file from MinecraftLocator to define the system mods
|
// Find mod file from MinecraftLocator to define the system mods
|
||||||
modFiles.stream()
|
modFiles.stream()
|
||||||
.filter(modFile -> modFile.getLocator().getClass() == MinecraftLocator.class)
|
.filter(modFile -> modFile.getProvider().getClass() == MinecraftLocator.class)
|
||||||
.map(ModFile::getSecureJar)
|
.map(ModFile::getSecureJar)
|
||||||
.map(SecureJar::getManifest)
|
.map(SecureJar::moduleDataProvider)
|
||||||
|
.map(SecureJar.ModuleDataProvider::getManifest)
|
||||||
.map(Manifest::getMainAttributes)
|
.map(Manifest::getMainAttributes)
|
||||||
.map(mf -> mf.getValue("FML-System-Mods"))
|
.map(mf -> mf.getValue("FML-System-Mods"))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
@@ -169,47 +181,6 @@ public class ModSorter
|
|||||||
throw new IllegalStateException("Failed to find system mod: " + systemMod);
|
throw new IllegalStateException("Failed to find system mod: " + systemMod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the newest by artifact version sorting of non-unique files thus identified
|
|
||||||
this.modFiles = modFilesByFirstId.entrySet().stream()
|
|
||||||
.map(this::selectNewestModInfo)
|
|
||||||
.map(Map.Entry::getValue)
|
|
||||||
.map(ModFile.class::cast)
|
|
||||||
.collect(toList());
|
|
||||||
|
|
||||||
// Transform to the full mod id list
|
|
||||||
final Map<String, List<ModInfo>> modIds = modFiles.stream()
|
|
||||||
.map(ModFile::getModInfos)
|
|
||||||
.flatMap(Collection::stream)
|
|
||||||
.map(ModInfo.class::cast)
|
|
||||||
.collect(groupingBy(IModInfo::getModId));
|
|
||||||
|
|
||||||
// Its theoretically possible that some mod has somehow moved an id to a secondary place, thus causing a dupe.
|
|
||||||
// We can't handle this
|
|
||||||
final List<ModInfo> dupedMods = modIds.values().stream()
|
|
||||||
.filter(modInfos -> modInfos.size() > 1)
|
|
||||||
.map(modInfos -> modInfos.get(0))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (!dupedMods.isEmpty()) {
|
|
||||||
final List<EarlyLoadingException.ExceptionData> duplicateModErrors = dupedMods.stream()
|
|
||||||
.map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedmod",
|
|
||||||
dm, Objects.toString(dm))).toList();
|
|
||||||
throw new EarlyLoadingException("Duplicate mods found", null, duplicateModErrors);
|
|
||||||
}
|
|
||||||
|
|
||||||
modIdNameLookup = modIds.entrySet().stream()
|
|
||||||
.collect(toMap(Map.Entry::getKey, e -> e.getValue().get(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map.Entry<String, IModFile> selectNewestModInfo(Map.Entry<String, List<IModFile>> fullList) {
|
|
||||||
List<IModFile> modInfoList = fullList.getValue();
|
|
||||||
if (modInfoList.size() > 1) {
|
|
||||||
LOGGER.debug("Found {} mods for first modid {}, selecting most recent based on version data", modInfoList.size(), fullList.getKey());
|
|
||||||
modInfoList.sort(Comparator.<IModFile, ArtifactVersion>comparing(mf -> mf.getModInfos().get(0).getVersion()).reversed());
|
|
||||||
LOGGER.debug("Selected file {} for modid {} with version {}", modInfoList.get(0).getFileName(), fullList.getKey(), modInfoList.get(0).getModInfos().get(0).getVersion());
|
|
||||||
}
|
|
||||||
return Map.entry(fullList.getKey(), modInfoList.get(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EarlyLoadingException.ExceptionData> verifyDependencyVersions()
|
private List<EarlyLoadingException.ExceptionData> verifyDependencyVersions()
|
||||||
|
|||||||
@@ -16,14 +16,11 @@ import java.util.function.Consumer;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIns;
|
import net.minecraftforge.api.distmarker.OnlyIns;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.logging.log4j.Marker;
|
|
||||||
import org.apache.logging.log4j.MarkerManager;
|
|
||||||
import org.objectweb.asm.Handle;
|
import org.objectweb.asm.Handle;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
@@ -33,11 +30,14 @@ import org.objectweb.asm.tree.AnnotationNode;
|
|||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.FieldNode;
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.Marker;
|
||||||
|
import org.slf4j.MarkerFactory;
|
||||||
|
|
||||||
public class RuntimeDistCleaner implements ILaunchPluginService
|
public class RuntimeDistCleaner implements ILaunchPluginService
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static final Marker DISTXFORM = MarkerManager.getMarker("DISTXFORM");
|
private static final Marker DISTXFORM = MarkerFactory.getMarker("DISTXFORM");
|
||||||
private static String DIST;
|
private static String DIST;
|
||||||
private static final String ONLYIN = Type.getDescriptor(OnlyIn.class);
|
private static final String ONLYIN = Type.getDescriptor(OnlyIn.class);
|
||||||
private static final String ONLYINS = Type.getDescriptor(OnlyIns.class);
|
private static final String ONLYINS = Type.getDescriptor(OnlyIns.class);
|
||||||
@@ -53,7 +53,7 @@ public class RuntimeDistCleaner implements ILaunchPluginService
|
|||||||
AtomicBoolean changes = new AtomicBoolean();
|
AtomicBoolean changes = new AtomicBoolean();
|
||||||
if (remove(classNode.visibleAnnotations, DIST))
|
if (remove(classNode.visibleAnnotations, DIST))
|
||||||
{
|
{
|
||||||
LOGGER.fatal(DISTXFORM, "Attempted to load class {} for invalid dist {}", classNode.name, DIST);
|
LOGGER.error(DISTXFORM, "Attempted to load class {} for invalid dist {}", classNode.name, DIST);
|
||||||
throw new RuntimeException("Attempted to load class "+ classNode.name + " for invalid dist "+ DIST);
|
throw new RuntimeException("Attempted to load class "+ classNode.name + " for invalid dist "+ DIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* 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 net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.*;
|
||||||
|
|
||||||
|
public class UniqueModListBuilder
|
||||||
|
{
|
||||||
|
private final static Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
private final List<ModFile> modFiles;
|
||||||
|
|
||||||
|
public UniqueModListBuilder(final List<ModFile> modFiles) {this.modFiles = modFiles;}
|
||||||
|
|
||||||
|
public UniqueModListData buildUniqueList()
|
||||||
|
{
|
||||||
|
List<ModFile> uniqueModList;
|
||||||
|
List<ModFile> uniqueLibListWithVersion;
|
||||||
|
|
||||||
|
// Collect mod files by module name. This will be used for deduping purposes
|
||||||
|
final Map<String, List<ModFile>> modFilesByFirstId = modFiles.stream()
|
||||||
|
.filter(mf -> mf.getModFileInfo() != null)
|
||||||
|
.collect(groupingBy(UniqueModListBuilder::getModId));
|
||||||
|
|
||||||
|
final Map<String, List<ModFile>> libFilesWithVersionByModuleName = modFiles.stream()
|
||||||
|
.filter(mf -> mf.getModFileInfo() == null)
|
||||||
|
.collect(groupingBy(UniqueModListBuilder::getModId));
|
||||||
|
|
||||||
|
// Select the newest by artifact version sorting of non-unique files thus identified
|
||||||
|
uniqueModList = modFilesByFirstId.entrySet().stream()
|
||||||
|
.map(this::selectNewestModInfo)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Select the newest by artifact version sorting of non-unique files thus identified
|
||||||
|
uniqueLibListWithVersion = libFilesWithVersionByModuleName.entrySet().stream()
|
||||||
|
.map(this::selectNewestModInfo)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Transform to the full mod id list
|
||||||
|
final Map<String, List<IModInfo>> modIds = uniqueModList.stream()
|
||||||
|
.filter(mf -> mf.getModFileInfo() != null) //Filter out non-mod files, we don't care about those for now.....
|
||||||
|
.map(ModFile::getModInfos)
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(groupingBy(IModInfo::getModId));
|
||||||
|
|
||||||
|
// Transform to the full lib id list
|
||||||
|
final Map<String, List<ModFile>> versionedLibIds = uniqueLibListWithVersion.stream()
|
||||||
|
.map(UniqueModListBuilder::getModId)
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
Function.identity(),
|
||||||
|
libFilesWithVersionByModuleName::get
|
||||||
|
));
|
||||||
|
|
||||||
|
// Its theoretically possible that some mod has somehow moved an id to a secondary place, thus causing a dupe.
|
||||||
|
// We can't handle this
|
||||||
|
final List<IModInfo> dupedMods = modIds.values().stream()
|
||||||
|
.filter(modInfos -> modInfos.size() > 1)
|
||||||
|
.map(modInfos -> modInfos.get(0))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!dupedMods.isEmpty()) {
|
||||||
|
final List<EarlyLoadingException.ExceptionData> duplicateModErrors = dupedMods.stream()
|
||||||
|
.map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedmod", dm, Objects.toString(dm)))
|
||||||
|
.toList();
|
||||||
|
throw new EarlyLoadingException("Duplicate mods found", null, duplicateModErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<ModFile> dupedLibs = versionedLibIds.values().stream()
|
||||||
|
.filter(modFiles -> modFiles.size() > 1)
|
||||||
|
.map(modFiles -> modFiles.get(0))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!dupedLibs.isEmpty()) {
|
||||||
|
final List<EarlyLoadingException.ExceptionData> duplicateLibErrors = dupedLibs.stream()
|
||||||
|
.map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedlib.versioned", dm, Objects.toString(dm)))
|
||||||
|
.toList();
|
||||||
|
throw new EarlyLoadingException("Duplicate plugins or libraries found", null, duplicateLibErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect unique mod files by module name. This will be used for deduping purposes
|
||||||
|
final Map<String, List<ModFile>> uniqueModFilesByFirstId = uniqueModList.stream()
|
||||||
|
.collect(groupingBy(UniqueModListBuilder::getModId));
|
||||||
|
|
||||||
|
final List<ModFile> loadedList = new ArrayList<>();
|
||||||
|
loadedList.addAll(uniqueModList);
|
||||||
|
loadedList.addAll(uniqueLibListWithVersion);
|
||||||
|
|
||||||
|
return new UniqueModListData(loadedList, uniqueModFilesByFirstId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ModFile selectNewestModInfo(Map.Entry<String, List<ModFile>> fullList) {
|
||||||
|
List<ModFile> modInfoList = fullList.getValue();
|
||||||
|
if (modInfoList.size() > 1) {
|
||||||
|
LOGGER.debug("Found {} mods for first modid {}, selecting most recent based on version data", modInfoList.size(), fullList.getKey());
|
||||||
|
modInfoList.sort(Comparator.comparing(this::getVersion).reversed());
|
||||||
|
LOGGER.debug("Selected file {} for modid {} with version {}", modInfoList.get(0).getFileName(), fullList.getKey(), this.getVersion(modInfoList.get(0)));
|
||||||
|
}
|
||||||
|
return modInfoList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArtifactVersion getVersion(final ModFile mf)
|
||||||
|
{
|
||||||
|
if (mf.getModFileInfo() == null || mf.getModInfos() == null || mf.getModInfos().isEmpty()) {
|
||||||
|
return mf.getJarVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mf.getModInfos().get(0).getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getModId(ModFile modFile) {
|
||||||
|
if (modFile.getModFileInfo() == null || modFile.getModFileInfo().getMods().isEmpty()) {
|
||||||
|
return modFile.getSecureJar().name();
|
||||||
|
}
|
||||||
|
|
||||||
|
return modFile.getModFileInfo().moduleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public record UniqueModListData(List<ModFile> modFiles, Map<String, List<ModFile>> modFilesByFirstId) {}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
@@ -18,16 +19,12 @@ public class VersionSupportMatrix {
|
|||||||
private static final HashMap<String, List<ArtifactVersion>> overrideVersions = new HashMap<>();
|
private static final HashMap<String, List<ArtifactVersion>> overrideVersions = new HashMap<>();
|
||||||
static {
|
static {
|
||||||
final ArtifactVersion version = new DefaultArtifactVersion(FMLLoader.versionInfo().mcVersion());
|
final ArtifactVersion version = new DefaultArtifactVersion(FMLLoader.versionInfo().mcVersion());
|
||||||
// if (MavenVersionAdapter.createFromVersionSpec("[1.16.4,1.16.5]").containsVersion(version)) {
|
if (MavenVersionAdapter.createFromVersionSpec("[1.19.2]").containsVersion(version)) {
|
||||||
// // 1.16.4 is Compatible with 1.16.3
|
// 1.19.2 is Compatible with 1.19.1
|
||||||
// add("languageloader.javafml", "34");
|
add("languageloader.javafml", "42");
|
||||||
// add("mod.minecraft", "1.16.3");
|
add("mod.minecraft", "1.19.1");
|
||||||
// add("mod.forge", "34.1.42");
|
add("mod.forge", "42.0.9");
|
||||||
// // 1.16.5 is Compatible with 1.16.4, and thus 1.16.3
|
}
|
||||||
// add("languageloader.javafml", "35");
|
|
||||||
// add("mod.minecraft", "1.16.4");
|
|
||||||
// add("mod.forge", "35.1.37");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
private static void add(String key, String value) {
|
private static void add(String key, String value) {
|
||||||
overrideVersions.computeIfAbsent(key, k -> new ArrayList<>()).add(new DefaultArtifactVersion(value));
|
overrideVersions.computeIfAbsent(key, k -> new ArrayList<>()).add(new DefaultArtifactVersion(value));
|
||||||
|
|||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraftforge.forgespi.locating.IDependencyLocator;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
import net.minecraftforge.forgespi.locating.ModFileLoadingException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public abstract class AbstractJarFileDependencyLocator extends AbstractJarFileModProvider implements IDependencyLocator
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
protected Optional<InputStream> loadResourceFromModFile(final IModFile modFile, final Path path) {
|
||||||
|
try {
|
||||||
|
return Optional.of(Files.newInputStream(modFile.findResource(path.toString())));
|
||||||
|
}
|
||||||
|
catch (final FileNotFoundException e) {
|
||||||
|
LOGGER.debug("Failed to load resource {} from {}, it does not contain dependency information.", path, modFile.getFileName());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
catch (final Exception e) {
|
||||||
|
LOGGER.error("Failed to load resource {} from mod {}, cause {}", path, modFile.getFileName(), e);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Optional<IModFile> loadModFileFrom(final IModFile file, final Path path) {
|
||||||
|
try {
|
||||||
|
final Path pathInModFile = file.findResource(path.toString());
|
||||||
|
return Optional.of(createMod(pathInModFile).file());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
LOGGER.error("Failed to load mod file {} from {}", path, file.getFileName());
|
||||||
|
throw new ModFileLoadingException("Failed to load mod file "+file.getFileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String identifyMod(final IModFile modFile) {
|
||||||
|
return modFile.getFileName();
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public abstract class AbstractJarFileModLocator extends AbstractJarFileModProvider implements IModLocator
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public List<IModLocator.ModFileOrException> scanMods()
|
||||||
|
{
|
||||||
|
return scanCandidates().map(this::createMod).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Stream<Path> scanCandidates();
|
||||||
|
}
|
||||||
+5
-26
@@ -5,32 +5,22 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import cpw.mods.jarhandling.JarMetadata;
|
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.jar.Manifest;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public abstract class AbstractJarFileLocator extends AbstractModLocator {
|
public abstract class AbstractJarFileModProvider extends AbstractModProvider
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
{
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scanFile(final IModFile file, final Consumer<Path> pathConsumer) {
|
public void scanFile(final IModFile file, final Consumer<Path> pathConsumer) {
|
||||||
@@ -43,15 +33,4 @@ public abstract class AbstractJarFileLocator extends AbstractModLocator {
|
|||||||
}
|
}
|
||||||
LOGGER.debug(LogMarkers.SCAN,"Scan finished: {}", file);
|
LOGGER.debug(LogMarkers.SCAN,"Scan finished: {}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IModFile> scanMods() {
|
|
||||||
return scanCandidates()
|
|
||||||
.map(this::createMod)
|
|
||||||
.filter(Optional::isPresent)
|
|
||||||
.map(Optional::get)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Stream<Path> scanCandidates();
|
|
||||||
}
|
}
|
||||||
-96
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Forge Development LLC and contributors
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import cpw.mods.jarhandling.JarMetadata;
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.jar.Manifest;
|
|
||||||
|
|
||||||
public abstract class AbstractModLocator implements IModLocator {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
protected static final String MODS_TOML = "META-INF/mods.toml";
|
|
||||||
protected static final String MANIFEST = "META-INF/MANIFEST.MF";
|
|
||||||
|
|
||||||
protected Optional<IModFile> createMod(Path... path) {
|
|
||||||
var mjm = new ModJarMetadata();
|
|
||||||
var sj = SecureJar.from(
|
|
||||||
Manifest::new,
|
|
||||||
jar -> jar.findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path),
|
|
||||||
(root, p) -> true,
|
|
||||||
path
|
|
||||||
);
|
|
||||||
|
|
||||||
IModFile mod;
|
|
||||||
var type = sj.getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
|
||||||
if (sj.findFile(MODS_TOML).isPresent()) {
|
|
||||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
|
||||||
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
|
||||||
} else if (type != null) {
|
|
||||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path);
|
|
||||||
mod = new ModFile(sj, this, this::manifestParser);
|
|
||||||
} else {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
mjm.setModFile(mod);
|
|
||||||
return Optional.of(mod);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IModFileInfo manifestParser(final IModFile mod) {
|
|
||||||
Function<String, Optional<String>> cfg = name -> Optional.ofNullable(mod.getSecureJar().getManifest().getMainAttributes().getValue(name));
|
|
||||||
var license = cfg.apply("LICENSE").orElse("");
|
|
||||||
var dummy = new IConfigurable() {
|
|
||||||
@Override
|
|
||||||
public <T> Optional<T> getConfigElement(String... key) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public List<? extends IConfigurable> getConfigList(String... key) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return new IModFileInfo() {
|
|
||||||
@Override public List<IModInfo> getMods() { return Collections.emptyList(); }
|
|
||||||
@Override public List<LanguageSpec> requiredLanguageLoaders() { return Collections.emptyList(); }
|
|
||||||
@Override public boolean showAsResourcePack() { return false; }
|
|
||||||
@Override public Map<String, Object> getFileProperties() { return Collections.emptyMap(); }
|
|
||||||
@Override public String getLicense() { return license; }
|
|
||||||
@Override public IModFile getFile() { return mod; }
|
|
||||||
@Override public IConfigurable getConfig() { return dummy; }
|
|
||||||
|
|
||||||
// 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 versionString() { return null; }
|
|
||||||
@Override public List<String> usesServices() { return null; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "IModFileInfo(" + mod.getFilePath() + ")";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(final IModFile modFile) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import cpw.mods.jarhandling.JarMetadata;
|
||||||
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
|
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||||
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModProvider;
|
||||||
|
import net.minecraftforge.forgespi.locating.ModFileLoadingException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
|
public abstract class AbstractModProvider implements IModProvider
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
protected static final String MODS_TOML = "META-INF/mods.toml";
|
||||||
|
protected static final String MANIFEST = "META-INF/MANIFEST.MF";
|
||||||
|
|
||||||
|
protected IModLocator.ModFileOrException createMod(Path... path) {
|
||||||
|
var mjm = new ModJarMetadata();
|
||||||
|
var sj = SecureJar.from(
|
||||||
|
Manifest::new,
|
||||||
|
jar -> jar.moduleDataProvider().findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path),
|
||||||
|
(root, p) -> true,
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
|
IModFile mod;
|
||||||
|
var type = sj.moduleDataProvider().getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
||||||
|
if (type == null) {
|
||||||
|
type = getDefaultJarModType();
|
||||||
|
}
|
||||||
|
if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
||||||
|
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
||||||
|
} else if (type != null) {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path);
|
||||||
|
mod = new ModFile(sj, this, this::manifestParser, type);
|
||||||
|
} else {
|
||||||
|
return new IModLocator.ModFileOrException(null, new ModFileLoadingException("Invalid mod file found "+ Arrays.toString(path)));
|
||||||
|
}
|
||||||
|
|
||||||
|
mjm.setModFile(mod);
|
||||||
|
return new IModLocator.ModFileOrException(mod, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IModFileInfo manifestParser(final IModFile mod) {
|
||||||
|
Function<String, Optional<String>> cfg = name -> Optional.ofNullable(mod.getSecureJar().moduleDataProvider().getManifest().getMainAttributes().getValue(name));
|
||||||
|
var license = cfg.apply("LICENSE").orElse("");
|
||||||
|
var dummy = new IConfigurable() {
|
||||||
|
@Override
|
||||||
|
public <T> Optional<T> getConfigElement(String... key) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<? extends IConfigurable> getConfigList(String... key) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return new DefaultModFileInfo(mod, license, dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid(final IModFile modFile) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getDefaultJarModType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private record DefaultModFileInfo(IModFile mod, String license, IConfigurable configurable) implements IModFileInfo, IConfigurable {
|
||||||
|
@Override
|
||||||
|
public <T> Optional<T> getConfigElement(final String... strings)
|
||||||
|
{
|
||||||
|
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<LanguageSpec> requiredLanguageLoaders() { return Collections.emptyList(); }
|
||||||
|
@Override public boolean showAsResourcePack() { return false; }
|
||||||
|
@Override public Map<String, Object> getFileProperties() { return Collections.emptyMap(); }
|
||||||
|
@Override
|
||||||
|
public String getLicense() { return license; }
|
||||||
|
|
||||||
|
@Override public IModFile getFile() { return mod; }
|
||||||
|
@Override public IConfigurable getConfig() { return configurable; }
|
||||||
|
|
||||||
|
// 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 versionString() { return null; }
|
||||||
|
@Override public List<String> usesServices() { return null; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "IModFileInfo(" + mod.getFilePath() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
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.forgespi.language.ModFileScanData;
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -28,7 +28,7 @@ public class BackgroundScanHandler
|
|||||||
ERRORED
|
ERRORED
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.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> pendingFiles;
|
||||||
private final List<ModFile> scannedFiles;
|
private final List<ModFile> scannedFiles;
|
||||||
|
|||||||
+9
-7
@@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.loading.ClasspathLocatorUtils;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -24,8 +25,9 @@ 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 AbstractJarFileLocator {
|
public class ClasspathLocator extends AbstractJarFileModLocator
|
||||||
private static final Logger LOGGER = LogManager.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;
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
|
|||||||
|
|
||||||
return paths.build();
|
return paths.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.fatal(LogMarkers.SCAN, "Error trying to find resources", e);
|
LOGGER.error(LogMarkers.SCAN, "Error trying to find resources", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +60,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
|
|||||||
final Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(resource);
|
final Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(resource);
|
||||||
while (resources.hasMoreElements()) {
|
while (resources.hasMoreElements()) {
|
||||||
URL url = resources.nextElement();
|
URL url = resources.nextElement();
|
||||||
Path path = findJarPathFor(resource, resource, url);
|
Path path = ClasspathLocatorUtils.findJarPathFor(resource, resource, url);
|
||||||
if (claimed.stream().anyMatch(path::equals) || !Files.exists(path) || Files.isDirectory(path))
|
if (claimed.stream().anyMatch(path::equals) || !Files.exists(path) || Files.isDirectory(path))
|
||||||
continue;
|
continue;
|
||||||
ret.add(path);
|
ret.add(path);
|
||||||
@@ -85,7 +87,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
|
|||||||
//LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
|
//LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
|
||||||
return path;
|
return path;
|
||||||
} catch (NullPointerException | URISyntaxException e) {
|
} catch (NullPointerException | URISyntaxException e) {
|
||||||
LOGGER.fatal(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName);
|
LOGGER.error(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName);
|
||||||
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
|
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -22,7 +22,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ExplodedDirectoryLocator implements IModLocator {
|
public class ExplodedDirectoryLocator implements IModLocator {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public record ExplodedMod(String modid, List<Path> paths) {}
|
public record ExplodedMod(String modid, List<Path> paths) {}
|
||||||
|
|
||||||
@@ -30,14 +30,14 @@ public class ExplodedDirectoryLocator implements IModLocator {
|
|||||||
private final Map<ExplodedMod, IModFile> mods = new HashMap<>();
|
private final Map<ExplodedMod, IModFile> mods = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IModFile> scanMods() {
|
public List<IModLocator.ModFileOrException> scanMods() {
|
||||||
explodedMods.forEach(explodedMod ->
|
explodedMods.forEach(explodedMod ->
|
||||||
ModJarMetadata.buildFile(this,
|
ModJarMetadata.buildFile(this,
|
||||||
jar->jar.findFile("/META-INF/mods.toml").isPresent(),
|
jar->jar.moduleDataProvider().findFile("/META-INF/mods.toml").isPresent(),
|
||||||
(a,b) -> true,
|
(a,b) -> true,
|
||||||
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 List.copyOf(mods.values());
|
return mods.values().stream().map(mf->new IModLocator.ModFileOrException(mf, null)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+8
-2
@@ -6,16 +6,22 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.ModFileLoadingException;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class InvalidModFileException extends RuntimeException
|
public class InvalidModFileException extends ModFileLoadingException
|
||||||
{
|
{
|
||||||
private final IModFileInfo modFileInfo;
|
private final IModFileInfo modFileInfo;
|
||||||
|
|
||||||
public InvalidModFileException(String message, IModFileInfo modFileInfo)
|
public InvalidModFileException(String message, IModFileInfo modFileInfo)
|
||||||
{
|
{
|
||||||
super(String.format(Locale.ENGLISH, "%s (%s)", message, ((ModFileInfo)modFileInfo).getFile().getFileName()));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IModFileInfo getBrokenFile() {
|
||||||
|
return modFileInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+158
@@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
import net.minecraftforge.forgespi.locating.ModFileLoadingException;
|
||||||
|
import net.minecraftforge.jarjar.selection.JarSelector;
|
||||||
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.nio.file.FileSystem;
|
||||||
|
import java.nio.file.FileSystems;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class JarInJarDependencyLocator extends AbstractJarFileDependencyLocator
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "JarInJar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IModFile> scanMods(final Iterable<IModFile> loadedMods)
|
||||||
|
{
|
||||||
|
final List<IModFile> sources = Lists.newArrayList();
|
||||||
|
loadedMods.forEach(sources::add);
|
||||||
|
|
||||||
|
final List<IModFile> dependenciesToLoad = JarSelector.detectAndSelect(sources, this::loadResourceFromModFile, this::loadModFileFrom, this::identifyMod, this::exception);
|
||||||
|
|
||||||
|
if (dependenciesToLoad.isEmpty())
|
||||||
|
{
|
||||||
|
LOGGER.info("No dependencies to load found. Skipping!");
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("Found {} dependencies adding them to mods collection", dependenciesToLoad.size());
|
||||||
|
return dependenciesToLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initArguments(final Map<String, ?> arguments)
|
||||||
|
{
|
||||||
|
// NO-OP, for now
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDefaultJarModType()
|
||||||
|
{
|
||||||
|
return IModFile.Type.GAMELIBRARY.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
|
@Override
|
||||||
|
protected Optional<IModFile> loadModFileFrom(final IModFile file, final Path path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Path pathInModFile = file.findResource(path.toString());
|
||||||
|
final URI filePathUri = new URI("jij:" + (pathInModFile.toAbsolutePath().toUri().getRawSchemeSpecificPart())).normalize();
|
||||||
|
final Map<String, ?> outerFsArgs = ImmutableMap.of("packagePath", pathInModFile);
|
||||||
|
final FileSystem zipFS = FileSystems.newFileSystem(filePathUri, outerFsArgs);
|
||||||
|
final Path pathInFS = zipFS.getPath("/");
|
||||||
|
return Optional.of(createMod(pathInFS).file());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.error("Failed to load mod file {} from {}", path, file.getFileName());
|
||||||
|
final RuntimeException exception = new ModFileLoadingException("Failed to load mod file " + file.getFileName());
|
||||||
|
exception.initCause(e);
|
||||||
|
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected EarlyLoadingException exception(Collection<JarSelector.ResolutionFailureInformation<IModFile>> failedDependencies)
|
||||||
|
{
|
||||||
|
|
||||||
|
final List<EarlyLoadingException.ExceptionData> errors = failedDependencies.stream()
|
||||||
|
.filter(entry -> !entry.sources().isEmpty()) //Should never be the case, but just to be sure
|
||||||
|
.map(this::buildExceptionData)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return new EarlyLoadingException(failedDependencies.size() + " Dependency restrictions were not met.", null, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private EarlyLoadingException.ExceptionData buildExceptionData(final JarSelector.ResolutionFailureInformation<IModFile> entry)
|
||||||
|
{
|
||||||
|
return new EarlyLoadingException.ExceptionData(
|
||||||
|
getErrorTranslationKey(entry),
|
||||||
|
entry.identifier().group() + ":" + entry.identifier().artifact(),
|
||||||
|
entry.sources()
|
||||||
|
.stream()
|
||||||
|
.flatMap(this::getModWithVersionRangeStream)
|
||||||
|
.map(this::formatError)
|
||||||
|
.collect(Collectors.joining(", "))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String getErrorTranslationKey(final JarSelector.ResolutionFailureInformation<IModFile> entry)
|
||||||
|
{
|
||||||
|
return entry.failureReason() == JarSelector.FailureReason.VERSION_RESOLUTION_FAILED ?
|
||||||
|
"fml.dependencyloading.conflictingdependencies" :
|
||||||
|
"fml.dependencyloading.mismatchedcontaineddependencies";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Stream<ModWithVersionRange> getModWithVersionRangeStream(final JarSelector.SourceWithRequestedVersionRange<IModFile> file)
|
||||||
|
{
|
||||||
|
return file.sources()
|
||||||
|
.stream()
|
||||||
|
.map(IModFile::getModFileInfo)
|
||||||
|
.flatMap(modFileInfo -> modFileInfo.getMods().stream())
|
||||||
|
.map(modInfo -> new ModWithVersionRange(modInfo, file.requestedVersionRange(), file.includedVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String formatError(final ModWithVersionRange modWithVersionRange)
|
||||||
|
{
|
||||||
|
return "\u00a7e" + modWithVersionRange.modInfo().getModId() + "\u00a7r - \u00a74" + modWithVersionRange.versionRange().toString() + "\u00a74 - \u00a72" + modWithVersionRange.artifactVersion().toString() + "\u00a72";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String identifyMod(final IModFile modFile)
|
||||||
|
{
|
||||||
|
if (modFile.getModFileInfo() == null || modFile.getModInfos().isEmpty())
|
||||||
|
{
|
||||||
|
return modFile.getFileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return modFile.getModInfos().stream().map(IModInfo::getModId).collect(Collectors.joining());
|
||||||
|
}
|
||||||
|
|
||||||
|
private record ModWithVersionRange(IModInfo modInfo, VersionRange versionRange, ArtifactVersion artifactVersion)
|
||||||
|
{}
|
||||||
|
}
|
||||||
+2
-1
@@ -15,7 +15,8 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class MavenDirectoryLocator extends AbstractJarFileLocator {
|
public class MavenDirectoryLocator extends AbstractJarFileModLocator
|
||||||
|
{
|
||||||
private List<Path> modCoords;
|
private List<Path> modCoords;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+15
-12
@@ -6,6 +6,7 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.Config;
|
import com.electronwill.nightconfig.core.Config;
|
||||||
|
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;
|
||||||
@@ -13,21 +14,24 @@ import net.minecraftforge.forgespi.language.IModFileInfo;
|
|||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.*;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class MinecraftLocator extends AbstractModLocator {
|
public class MinecraftLocator extends AbstractModProvider implements IModLocator
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
{
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IModFile> scanMods() {
|
public List<IModLocator.ModFileOrException> scanMods() {
|
||||||
final var launchHandler = FMLLoader.getLaunchHandler();
|
final var launchHandler = FMLLoader.getLaunchHandler();
|
||||||
var baseMC = launchHandler.getMinecraftPaths();
|
var baseMC = launchHandler.getMinecraftPaths();
|
||||||
var mcjar = ModJarMetadata.buildFile(j->ModFileFactory.FACTORY.build(j, this, this::buildMinecraftTOML), j->true, baseMC.minecraftFilter(), baseMC.minecraftPaths().toArray(Path[]::new)).orElseThrow();
|
var mcjar = ModJarMetadata.buildFile(j->ModFileFactory.FACTORY.build(j, this, this::buildMinecraftTOML), j->true, baseMC.minecraftFilter(), baseMC.minecraftPaths().toArray(Path[]::new)).orElseThrow();
|
||||||
@@ -36,12 +40,11 @@ public class MinecraftLocator extends AbstractModLocator {
|
|||||||
.map(sj -> new ModFile(sj, this, ModFileParser::modsTomlParser))
|
.map(sj -> new ModFile(sj, this, ModFileParser::modsTomlParser))
|
||||||
.collect(Collectors.<IModFile>toList());
|
.collect(Collectors.<IModFile>toList());
|
||||||
var othermods = baseMC.otherModPaths().stream()
|
var othermods = baseMC.otherModPaths().stream()
|
||||||
.map(p -> createMod(p.toArray(Path[]::new)).orElse(null))
|
.map(p -> createMod(p.toArray(Path[]::new)))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull);
|
||||||
.toList();
|
|
||||||
artifacts.add(mcjar);
|
artifacts.add(mcjar);
|
||||||
artifacts.addAll(othermods);
|
|
||||||
return artifacts;
|
return Stream.concat(artifacts.stream().map(f -> new ModFileOrException(f, null)), othermods).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IModFileInfo buildMinecraftTOML(final IModFile iModFile) {
|
private IModFileInfo buildMinecraftTOML(final IModFile iModFile) {
|
||||||
|
|||||||
+138
-29
@@ -5,62 +5,171 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
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.EarlyLoadingException;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
|
import net.minecraftforge.fml.loading.UniqueModListBuilder;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
import net.minecraftforge.forgespi.Environment;
|
import net.minecraftforge.forgespi.Environment;
|
||||||
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IDependencyLocator;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ModDiscoverer {
|
public class ModDiscoverer {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final ServiceLoader<IModLocator> locators;
|
private final ServiceLoader<IModLocator> modLocators;
|
||||||
private final List<IModLocator> locatorList;
|
private final ServiceLoader<IDependencyLocator> dependencyLocators;
|
||||||
|
private final List<IModLocator> modLocatorList;
|
||||||
|
private final List<IDependencyLocator> dependencyLocatorList;
|
||||||
|
|
||||||
public ModDiscoverer(Map<String, ?> arguments) {
|
public ModDiscoverer(Map<String, ?> arguments) {
|
||||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new);
|
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new);
|
||||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v-> StartupMessageManager.locatorConsumer().orElseGet(()-> s->{}));
|
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v-> StartupMessageManager.locatorConsumer().orElseGet(()-> s->{}));
|
||||||
final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow();
|
final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow();
|
||||||
locators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class);
|
modLocators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class);
|
||||||
locatorList = ServiceLoaderUtils.streamServiceLoader(()->locators, sce->LOGGER.error("Failed to load locator list", sce)).collect(Collectors.toList());
|
dependencyLocators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IDependencyLocator.class);
|
||||||
locatorList.forEach(l->l.initArguments(arguments));
|
modLocatorList = ServiceLoaderUtils.streamServiceLoader(()-> modLocators, sce->LOGGER.error("Failed to load mod locator list", sce)).collect(Collectors.toList());
|
||||||
LOGGER.debug(LogMarkers.CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(",")));
|
modLocatorList.forEach(l->l.initArguments(arguments));
|
||||||
}
|
dependencyLocatorList = ServiceLoaderUtils.streamServiceLoader(()-> dependencyLocators, sce->LOGGER.error("Failed to load dependency locator list", sce)).collect(Collectors.toList());
|
||||||
|
dependencyLocatorList.forEach(l->l.initArguments(arguments));
|
||||||
ModDiscoverer(List<IModLocator> locatorList) {
|
if (LOGGER.isDebugEnabled(LogMarkers.CORE))
|
||||||
this.locatorList = locatorList;
|
{
|
||||||
this.locators = null;
|
LOGGER.debug(LogMarkers.CORE, "Found Mod Locators : {}", modLocatorList.stream()
|
||||||
|
.map(modLocator -> "(%s:%s)".formatted(modLocator.name(),
|
||||||
|
modLocator.getClass().getPackage().getImplementationVersion())).collect(Collectors.joining(",")));
|
||||||
|
}
|
||||||
|
if (LOGGER.isDebugEnabled(LogMarkers.CORE))
|
||||||
|
{
|
||||||
|
LOGGER.debug(LogMarkers.CORE, "Found Dependency Locators : {}", dependencyLocatorList.stream()
|
||||||
|
.map(dependencyLocator -> "(%s:%s)".formatted(dependencyLocator.name(),
|
||||||
|
dependencyLocator.getClass().getPackage().getImplementationVersion())).collect(Collectors.joining(",")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModValidator discoverMods() {
|
public ModValidator discoverMods() {
|
||||||
LOGGER.debug(LogMarkers.SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", locatorList.size());
|
LOGGER.debug(LogMarkers.SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", modLocatorList.size());
|
||||||
var loadedFiles = new ArrayList<>();
|
List<ModFile> loadedFiles = new ArrayList<>();
|
||||||
for (IModLocator locator : locatorList) {
|
List<EarlyLoadingException.ExceptionData> discoveryErrorData = new ArrayList<>();
|
||||||
LOGGER.debug(LogMarkers.SCAN,"Trying locator {}", locator);
|
boolean successfullyLoadedMods = true;
|
||||||
var modFiles = locator.scanMods();
|
List<IModFileInfo> brokenFiles = new ArrayList<>();
|
||||||
for (IModFile mf : modFiles) {
|
|
||||||
LOGGER.info(LogMarkers.SCAN, "Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator());
|
|
||||||
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType()));
|
|
||||||
}
|
|
||||||
loadedFiles.addAll(modFiles);
|
|
||||||
}
|
|
||||||
final var modFilesMap = loadedFiles.stream()
|
|
||||||
.map(ModFile.class::cast)
|
|
||||||
.collect(Collectors.groupingBy(IModFile::getType));
|
|
||||||
|
|
||||||
var validator = new ModValidator(modFilesMap);
|
//Loop all mod locators to get the prime mods to load from.
|
||||||
|
for (IModLocator locator : modLocatorList) {
|
||||||
|
try {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Trying locator {}", locator);
|
||||||
|
var candidates = locator.scanMods();
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Locator {} found {} candidates or errors", locator, candidates.size());
|
||||||
|
var exceptions = candidates.stream().map(IModLocator.ModFileOrException::ex).filter(Objects::nonNull).toList();
|
||||||
|
if (!exceptions.isEmpty()) {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Locator {} found {} invalid mod files", locator, exceptions.size());
|
||||||
|
brokenFiles.addAll(exceptions.stream().map(e->e instanceof InvalidModFileException ime ? ime.getBrokenFile() : null).filter(Objects::nonNull).toList());
|
||||||
|
}
|
||||||
|
var locatedFiles = candidates.stream().map(IModLocator.ModFileOrException::file).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
|
||||||
|
var badModFiles = locatedFiles.stream().filter(file -> !(file instanceof ModFile)).toList();
|
||||||
|
if (!badModFiles.isEmpty()) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Locator {} returned {} files which is are not ModFile instances! They will be skipped!", locator, badModFiles.size());
|
||||||
|
brokenFiles.addAll(badModFiles.stream().map(IModFile::getModFileInfo).toList());
|
||||||
|
}
|
||||||
|
locatedFiles.removeAll(badModFiles);
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Locator {} found {} valid mod files", locator, locatedFiles.size());
|
||||||
|
handleLocatedFiles(loadedFiles, locatedFiles);
|
||||||
|
} catch (InvalidModFileException imfe) {
|
||||||
|
// We don't generally expect this exception, since it should come from the candidates stream above and be handled in the Locator, but just in case.
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Locator {} found an invalid mod file {}", locator, imfe.getBrokenFile(), imfe);
|
||||||
|
brokenFiles.add(imfe.getBrokenFile());
|
||||||
|
} catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to load mods with locator {}", locator, exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//First processing run of the mod list. Any duplicates will cause resolution failure and dependency loading will be skipped.
|
||||||
|
Map<IModFile.Type, List<ModFile>> modFilesMap = Maps.newHashMap();
|
||||||
|
try {
|
||||||
|
final UniqueModListBuilder modsUniqueListBuilder = new UniqueModListBuilder(loadedFiles);
|
||||||
|
final UniqueModListBuilder.UniqueModListData uniqueModsData = modsUniqueListBuilder.buildUniqueList();
|
||||||
|
|
||||||
|
//Grab the temporary results.
|
||||||
|
//This allows loading to continue to a base state, in case dependency loading fails.
|
||||||
|
modFilesMap = uniqueModsData.modFiles().stream()
|
||||||
|
.collect(Collectors.groupingBy(IModFile::getType));
|
||||||
|
loadedFiles = uniqueModsData.modFiles();
|
||||||
|
}
|
||||||
|
catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to build unique mod list after mod discovery.", exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
successfullyLoadedMods = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//We can continue loading if prime mods loaded successfully.
|
||||||
|
if (successfullyLoadedMods) {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Successfully Loaded {} mods. Attempting to load dependencies...", loadedFiles.size());
|
||||||
|
for (IDependencyLocator locator : dependencyLocatorList) {
|
||||||
|
try {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN,"Trying locator {}", locator);
|
||||||
|
final List<IModFile> locatedMods = ImmutableList.copyOf(loadedFiles);
|
||||||
|
|
||||||
|
var locatedFiles = locator.scanMods(locatedMods);
|
||||||
|
if (locatedFiles.stream().anyMatch(file -> !(file instanceof ModFile))) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "A dependency locator returned a file which is not a ModFile instance!. They will be skipped!");
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLocatedFiles(loadedFiles, locatedFiles);
|
||||||
|
}
|
||||||
|
catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to load dependencies with locator {}", locator, exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Second processing run of the mod list. Any duplicates will cause resolution failure and only the mods list will be loaded.
|
||||||
|
try {
|
||||||
|
final UniqueModListBuilder modsAndDependenciesUniqueListBuilder = new UniqueModListBuilder(loadedFiles);
|
||||||
|
final UniqueModListBuilder.UniqueModListData uniqueModsAndDependenciesData = modsAndDependenciesUniqueListBuilder.buildUniqueList();
|
||||||
|
|
||||||
|
//We now only need the mod files map, not the list.
|
||||||
|
modFilesMap = uniqueModsAndDependenciesData.modFiles().stream()
|
||||||
|
.collect(Collectors.groupingBy(IModFile::getType));
|
||||||
|
} catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to build unique mod list after dependency discovery.", exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
modFilesMap = loadedFiles.stream().collect(Collectors.groupingBy(IModFile::getType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//Failure notify the listeners.
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Mod Discovery failed. Skipping dependency discovery.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Validate the loading. With a deduplicated list, we can now successfully process the artifacts and load
|
||||||
|
//transformer plugins.
|
||||||
|
var validator = new ModValidator(modFilesMap, brokenFiles, discoveryErrorData);
|
||||||
validator.stage1Validation();
|
validator.stage1Validation();
|
||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleLocatedFiles(final List<ModFile> loadedFiles, final List<IModFile> locatedFiles)
|
||||||
|
{
|
||||||
|
var locatedModFiles = locatedFiles.stream().filter(ModFile.class::isInstance).map(ModFile.class::cast).toList();
|
||||||
|
for (IModFile mf : locatedModFiles) {
|
||||||
|
LOGGER.info(LogMarkers.SCAN, "Found mod file {} of type {} with provider {}", mf.getFileName(), mf.getType(), mf.getProvider());
|
||||||
|
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType()));
|
||||||
|
}
|
||||||
|
loadedFiles.addAll(locatedModFiles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
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;
|
||||||
@@ -15,10 +16,11 @@ import net.minecraftforge.forgespi.language.IModInfo;
|
|||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
import net.minecraftforge.forgespi.locating.IModProvider;
|
||||||
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -37,7 +39,7 @@ public class ModFile implements IModFile {
|
|||||||
// Mods either must have a mods.toml or a manifest. We can no longer just put any jar on the classpath.
|
// Mods either must have a mods.toml or a manifest. We can no longer just put any jar on the classpath.
|
||||||
@Deprecated(forRemoval = true, since = "1.18")
|
@Deprecated(forRemoval = true, since = "1.18")
|
||||||
public static final Manifest DEFAULTMANIFEST;
|
public static final Manifest DEFAULTMANIFEST;
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DEFAULTMANIFEST = new Manifest();
|
DEFAULTMANIFEST = new Manifest();
|
||||||
@@ -51,9 +53,9 @@ public class ModFile implements IModFile {
|
|||||||
private Throwable scanError;
|
private Throwable scanError;
|
||||||
private final SecureJar jar;
|
private final SecureJar jar;
|
||||||
private final Type modFileType;
|
private final Type modFileType;
|
||||||
private final Manifest manifest;
|
private final Manifest manifest;
|
||||||
private final IModLocator locator;
|
private final IModProvider provider;
|
||||||
private IModFileInfo modFileInfo;
|
private IModFileInfo modFileInfo;
|
||||||
private ModFileScanData fileModFileScanData;
|
private ModFileScanData fileModFileScanData;
|
||||||
private CompletableFuture<ModFileScanData> futureScanResult;
|
private CompletableFuture<ModFileScanData> futureScanResult;
|
||||||
private List<CoreModFile> coreMods;
|
private List<CoreModFile> coreMods;
|
||||||
@@ -62,15 +64,19 @@ public class ModFile implements IModFile {
|
|||||||
static final Attributes.Name TYPE = new Attributes.Name("FMLModType");
|
static final Attributes.Name TYPE = new Attributes.Name("FMLModType");
|
||||||
private SecureJar.Status securityStatus;
|
private SecureJar.Status securityStatus;
|
||||||
|
|
||||||
public ModFile(final SecureJar jar, final IModLocator locator, final ModFileFactory.ModFileInfoParser parser) {
|
public ModFile(final SecureJar jar, final IModProvider provider, final ModFileFactory.ModFileInfoParser parser) {
|
||||||
this.locator = locator;
|
this(jar, provider, parser, parseType(jar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModFile(final SecureJar jar, final IModProvider provider, final ModFileFactory.ModFileInfoParser parser, String type) {
|
||||||
|
this.provider = provider;
|
||||||
this.jar = jar;
|
this.jar = jar;
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
|
|
||||||
manifest = this.jar.getManifest();
|
manifest = this.jar.moduleDataProvider().getManifest();
|
||||||
final Optional<String> value = Optional.ofNullable(manifest.getMainAttributes().getValue(TYPE));
|
modFileType = Type.valueOf(type);
|
||||||
modFileType = Type.valueOf(value.orElse("MOD"));
|
|
||||||
jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("0.0NONE");
|
jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("0.0NONE");
|
||||||
|
this.modFileInfo = ModFileParser.readModList(this, this.parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -123,7 +129,7 @@ public class ModFile implements IModFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void scanFile(Consumer<Path> pathConsumer) {
|
public void scanFile(Consumer<Path> pathConsumer) {
|
||||||
locator.scanFile(this, pathConsumer);
|
provider.scanFile(this, pathConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFutureScanResult(CompletableFuture<ModFileScanData> future) {
|
public void setFutureScanResult(CompletableFuture<ModFileScanData> future) {
|
||||||
@@ -188,8 +194,8 @@ public class ModFile implements IModFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IModLocator getLocator() {
|
public IModProvider getProvider() {
|
||||||
return locator;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,4 +207,15 @@ public class ModFile implements IModFile {
|
|||||||
public void setSecurityStatus(final SecureJar.Status status) {
|
public void setSecurityStatus(final SecureJar.Status status) {
|
||||||
this.securityStatus = status;
|
this.securityStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArtifactVersion getJarVersion()
|
||||||
|
{
|
||||||
|
return new DefaultArtifactVersion(this.jarVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String parseType(final SecureJar jar) {
|
||||||
|
final Manifest m = jar.moduleDataProvider().getManifest();
|
||||||
|
final Optional<String> value = Optional.ofNullable(m.getMainAttributes().getValue(TYPE));
|
||||||
|
return value.orElse("MOD");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+10
-7
@@ -6,6 +6,7 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.fml.loading.StringUtils;
|
import net.minecraftforge.fml.loading.StringUtils;
|
||||||
@@ -13,8 +14,7 @@ import net.minecraftforge.forgespi.language.IConfigurable;
|
|||||||
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.MavenVersionAdapter;
|
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import javax.security.auth.x500.X500Principal;
|
import javax.security.auth.x500.X500Principal;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.CodeSigner;
|
import java.security.CodeSigner;
|
||||||
@@ -32,7 +32,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
public class ModFileInfo implements IModFileInfo, IConfigurable
|
public class ModFileInfo implements IModFileInfo, IConfigurable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final IConfigurable config;
|
private final IConfigurable config;
|
||||||
private final ModFile modFile;
|
private final ModFile modFile;
|
||||||
private final URL issueURL;
|
private final URL issueURL;
|
||||||
@@ -68,10 +68,13 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
|
|||||||
this.mods = modConfigs.stream()
|
this.mods = modConfigs.stream()
|
||||||
.map(mi-> new ModInfo(this, mi))
|
.map(mi-> new ModInfo(this, mi))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
LOGGER.debug(LogMarkers.LOADING, "Found valid mod file {} with {} mods - versions {}",
|
if (LOGGER.isDebugEnabled(LogMarkers.LOADING))
|
||||||
this.modFile::getFileName,
|
{
|
||||||
() -> this.mods.stream().map(IModInfo::getModId).collect(Collectors.joining(",", "{", "}")),
|
LOGGER.debug(LogMarkers.LOADING, "Found valid mod file {} with {} mods - versions {}",
|
||||||
() -> this.mods.stream().map(IModInfo::getVersion).map(Objects::toString).collect(Collectors.joining(",", "{", "}")));
|
this.modFile.getFileName(),
|
||||||
|
this.mods.stream().map(IModInfo::getModId).collect(Collectors.joining(",", "{", "}")),
|
||||||
|
this.mods.stream().map(IModInfo::getVersion).map(Objects::toString).collect(Collectors.joining(",", "{", "}")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModFileInfo(final ModFile file, final IConfigurable config, final List<LanguageSpec> languageSpecs) {
|
public ModFileInfo(final ModFile file, final IConfigurable config, final List<LanguageSpec> languageSpecs) {
|
||||||
|
|||||||
+3
-3
@@ -8,12 +8,12 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
|||||||
import com.electronwill.nightconfig.core.file.FileConfig;
|
import com.electronwill.nightconfig.core.file.FileConfig;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
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 net.minecraftforge.forgespi.locating.ModFileFactory;
|
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@@ -25,7 +25,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ModFileParser {
|
public class ModFileParser {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public static IModFileInfo readModList(final ModFile modFile, final ModFileFactory.ModFileInfoParser parser) {
|
public static IModFileInfo readModList(final ModFile modFile, final ModFileFactory.ModFileInfoParser parser) {
|
||||||
return parser.build(modFile);
|
return parser.build(modFile);
|
||||||
|
|||||||
@@ -5,16 +5,17 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.StringSubstitutor;
|
import net.minecraftforge.fml.loading.StringSubstitutor;
|
||||||
import net.minecraftforge.fml.loading.StringUtils;
|
import net.minecraftforge.fml.loading.StringUtils;
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import net.minecraftforge.forgespi.locating.ForgeFeature;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -26,10 +27,11 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ModInfo implements IModInfo, IConfigurable
|
public class ModInfo implements IModInfo, IConfigurable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1");
|
private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1");
|
||||||
private static final Pattern VALID_MODID = Pattern.compile("^[a-z][a-z0-9_]{1,63}$");
|
private static final Pattern VALID_MODID = Pattern.compile("^[a-z][a-z0-9_]{1,63}$");
|
||||||
private static final Pattern VALID_NAMESPACE = Pattern.compile("^[a-z][a-z0-9_.-]{1,63}$");
|
private static final Pattern VALID_NAMESPACE = Pattern.compile("^[a-z][a-z0-9_.-]{1,63}$");
|
||||||
|
private static final Pattern VALID_VERSION = Pattern.compile("^\\d+.*");
|
||||||
|
|
||||||
private final ModFileInfo owningFile;
|
private final ModFileInfo owningFile;
|
||||||
private final String modId;
|
private final String modId;
|
||||||
@@ -41,8 +43,11 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
private final boolean logoBlur;
|
private final boolean logoBlur;
|
||||||
private final Optional<URL> updateJSONURL;
|
private final Optional<URL> updateJSONURL;
|
||||||
private final List<? extends IModInfo.ModVersion> dependencies;
|
private final List<? extends IModInfo.ModVersion> dependencies;
|
||||||
|
|
||||||
|
private final List<ForgeFeature.Bound> features;
|
||||||
private final Map<String,Object> properties;
|
private final Map<String,Object> properties;
|
||||||
private final IConfigurable config;
|
private final IConfigurable config;
|
||||||
|
private final Optional<URL> modUrl;
|
||||||
|
|
||||||
public ModInfo(final ModFileInfo owningFile, final IConfigurable config)
|
public ModInfo(final ModFileInfo owningFile, final IConfigurable config)
|
||||||
{
|
{
|
||||||
@@ -52,12 +57,12 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
this.modId = config.<String>getConfigElement("modId")
|
this.modId = config.<String>getConfigElement("modId")
|
||||||
.orElseThrow(() -> new InvalidModFileException("Missing modId", owningFile));
|
.orElseThrow(() -> new InvalidModFileException("Missing modId", owningFile));
|
||||||
if (!VALID_MODID.matcher(this.modId).matches()) {
|
if (!VALID_MODID.matcher(this.modId).matches()) {
|
||||||
LOGGER.fatal("Invalid modId found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.modId, VALID_MODID.pattern());
|
LOGGER.error(LogUtils.FATAL_MARKER, "Invalid modId found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.modId, VALID_MODID.pattern());
|
||||||
throw new InvalidModFileException("Invalid modId found : " + this.modId, owningFile);
|
throw new InvalidModFileException("Invalid modId found : " + this.modId, owningFile);
|
||||||
}
|
}
|
||||||
this.namespace = config.<String>getConfigElement("namespace").orElse(this.modId);
|
this.namespace = config.<String>getConfigElement("namespace").orElse(this.modId);
|
||||||
if (!VALID_NAMESPACE.matcher(this.namespace).matches()) {
|
if (!VALID_NAMESPACE.matcher(this.namespace).matches()) {
|
||||||
LOGGER.fatal("Invalid override namespace found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.namespace, VALID_NAMESPACE.pattern());
|
LOGGER.error(LogUtils.FATAL_MARKER, "Invalid override namespace found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.namespace, VALID_NAMESPACE.pattern());
|
||||||
throw new InvalidModFileException("Invalid override namespace found : " + this.namespace, owningFile);
|
throw new InvalidModFileException("Invalid override namespace found : " + this.namespace, owningFile);
|
||||||
}
|
}
|
||||||
this.version = config.<String>getConfigElement("version")
|
this.version = config.<String>getConfigElement("version")
|
||||||
@@ -81,9 +86,23 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.orElse(Collections.emptyList());
|
.orElse(Collections.emptyList());
|
||||||
|
|
||||||
|
this.features = ownFile.map(mfi -> mfi.<Map<String, String>>getConfigElement("features", this.modId)
|
||||||
|
.stream()
|
||||||
|
.flatMap(m->m.entrySet().stream())
|
||||||
|
.map(e->new ForgeFeature.Bound(e.getKey(), e.getValue(), this))
|
||||||
|
.collect(Collectors.toList())).orElse(Collections.emptyList());
|
||||||
|
|
||||||
this.properties = ownFile.map(mfi -> mfi.<Map<String, Object>>getConfigElement("modproperties", this.modId)
|
this.properties = ownFile.map(mfi -> mfi.<Map<String, Object>>getConfigElement("modproperties", this.modId)
|
||||||
.orElse(Collections.emptyMap()))
|
.orElse(Collections.emptyMap()))
|
||||||
.orElse(Collections.emptyMap());
|
.orElse(Collections.emptyMap());
|
||||||
|
|
||||||
|
this.modUrl = config.<String>getConfigElement("modUrl")
|
||||||
|
.map(StringUtils::toURL);
|
||||||
|
|
||||||
|
// verify we have a valid mod version otherwise throw an exception
|
||||||
|
if (!VALID_VERSION.matcher(this.version.toString()).matches()) {
|
||||||
|
throw new InvalidModFileException("Illegal version number specified "+this.version, this.getOwningFile());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -150,6 +169,11 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends ForgeFeature.Bound> getForgeFeatures() {
|
||||||
|
return this.features;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Optional<T> getConfigElement(final String... key) {
|
public <T> Optional<T> getConfigElement(final String... key) {
|
||||||
return this.config.getConfigElement(key);
|
return this.config.getConfigElement(key);
|
||||||
@@ -160,6 +184,11 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<URL> getModURL() {
|
||||||
|
return modUrl;
|
||||||
|
}
|
||||||
|
|
||||||
class ModVersion implements net.minecraftforge.forgespi.language.IModInfo.ModVersion {
|
class ModVersion implements net.minecraftforge.forgespi.language.IModInfo.ModVersion {
|
||||||
private IModInfo owner;
|
private IModInfo owner;
|
||||||
private final String modId;
|
private final String modId;
|
||||||
@@ -167,6 +196,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;
|
||||||
|
|
||||||
public ModVersion(final IModInfo owner, final IConfigurable config) {
|
public ModVersion(final IModInfo owner, final IConfigurable config) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@@ -183,6 +213,8 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
this.side = config.<String>getConfigElement("side")
|
this.side = config.<String>getConfigElement("side")
|
||||||
.map(DependencySide::valueOf)
|
.map(DependencySide::valueOf)
|
||||||
.orElse(DependencySide.BOTH);
|
.orElse(DependencySide.BOTH);
|
||||||
|
this.referralUrl = config.<String>getConfigElement("referralUrl")
|
||||||
|
.map(StringUtils::toURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -227,6 +259,11 @@ public class ModInfo implements IModInfo, IConfigurable
|
|||||||
{
|
{
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<URL> getReferralURL() {
|
||||||
|
return referralUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-3
@@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
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.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;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -23,7 +23,7 @@ import java.util.Objects;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ModListHandler {
|
public class ModListHandler {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
/**
|
/**
|
||||||
* Reads the modList paths specified, and searches each maven root for mods matching. Returns a list of mods
|
* Reads the modList paths specified, and searches each maven root for mods matching. Returns a list of mods
|
||||||
* found.
|
* found.
|
||||||
|
|||||||
+29
-15
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
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.EarlyLoadingException;
|
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
||||||
@@ -12,27 +13,34 @@ import net.minecraftforge.fml.loading.LoadingModList;
|
|||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.fml.loading.ModSorter;
|
import net.minecraftforge.fml.loading.ModSorter;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ModValidator {
|
public class ModValidator {
|
||||||
private static final Logger LOGGER = LogManager.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;
|
||||||
private List<ModFile> brokenFiles;
|
private List<IModFile> brokenFiles;
|
||||||
|
private final List<EarlyLoadingException.ExceptionData> discoveryErrorData;
|
||||||
|
|
||||||
public ModValidator(final Map<IModFile.Type, List<ModFile>> modFiles) {
|
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));
|
||||||
this.candidatePlugins.addAll(lst(modFiles.get(IModFile.Type.LIBRARY)));
|
this.candidatePlugins.addAll(lst(modFiles.get(IModFile.Type.LIBRARY)));
|
||||||
|
this.discoveryErrorData = discoveryErrorData;
|
||||||
|
this.brokenFiles = brokenFiles.stream().map(IModFileInfo::getFile).collect(Collectors.toList()); // mutable list
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ModFile> lst(List<ModFile> files) {
|
private static List<ModFile> lst(List<ModFile> files) {
|
||||||
@@ -40,8 +48,10 @@ public class ModValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stage1Validation() {
|
public void stage1Validation() {
|
||||||
brokenFiles = validateFiles(candidateMods);
|
brokenFiles.addAll(validateFiles(candidateMods));
|
||||||
LOGGER.debug(LogMarkers.SCAN,"Found {} mod files with {} mods", candidateMods::size, ()-> candidateMods.stream().mapToInt(mf -> mf.getModInfos().size()).sum());
|
if (LOGGER.isDebugEnabled(LogMarkers.SCAN)) {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod files with {} mods", candidateMods.size(), candidateMods.stream().mapToInt(mf -> mf.getModInfos().size()).sum());
|
||||||
|
}
|
||||||
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found "+ candidateMods.size()+" modfiles to load"));
|
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found "+ candidateMods.size()+" modfiles to load"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,22 +60,22 @@ public class ModValidator {
|
|||||||
final List<ModFile> brokenFiles = new ArrayList<>();
|
final List<ModFile> brokenFiles = new ArrayList<>();
|
||||||
for (Iterator<ModFile> iterator = mods.iterator(); iterator.hasNext(); )
|
for (Iterator<ModFile> iterator = mods.iterator(); iterator.hasNext(); )
|
||||||
{
|
{
|
||||||
ModFile mod = iterator.next();
|
ModFile modFile = iterator.next();
|
||||||
if (!mod.getLocator().isValid(mod) || !mod.identifyMods()) {
|
if (!modFile.getProvider().isValid(modFile) || !modFile.identifyMods()) {
|
||||||
LOGGER.warn(LogMarkers.SCAN, "File {} has been ignored - it is invalid", mod.getFilePath());
|
LOGGER.warn(LogMarkers.SCAN, "File {} has been ignored - it is invalid", modFile.getFilePath());
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
brokenFiles.add(mod);
|
brokenFiles.add(modFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return brokenFiles;
|
return brokenFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITransformationService.Resource getPluginResources() {
|
public ITransformationService.Resource getPluginResources() {
|
||||||
return new ITransformationService.Resource(IModuleLayerManager.Layer.PLUGIN, this.candidatePlugins.stream().map(ModFile::getSecureJar).toList());
|
return new ITransformationService.Resource(IModuleLayerManager.Layer.PLUGIN, this.candidatePlugins.stream().map(IModFile::getSecureJar).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITransformationService.Resource getModResources() {
|
public ITransformationService.Resource getModResources() {
|
||||||
return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().map(ModFile::getSecureJar).toList());
|
return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().map(IModFile::getSecureJar).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EarlyLoadingException.ExceptionData> validateLanguages() {
|
private List<EarlyLoadingException.ExceptionData> validateLanguages() {
|
||||||
@@ -84,7 +94,11 @@ public class ModValidator {
|
|||||||
|
|
||||||
public BackgroundScanHandler stage2Validation() {
|
public BackgroundScanHandler stage2Validation() {
|
||||||
var errors = validateLanguages();
|
var errors = validateLanguages();
|
||||||
loadingModList = ModSorter.sort(candidateMods, errors);
|
|
||||||
|
var allErrors = new ArrayList<>(errors);
|
||||||
|
allErrors.addAll(this.discoveryErrorData);
|
||||||
|
|
||||||
|
loadingModList = ModSorter.sort(candidateMods, allErrors);
|
||||||
loadingModList.addCoreMods();
|
loadingModList.addCoreMods();
|
||||||
loadingModList.addAccessTransformers();
|
loadingModList.addAccessTransformers();
|
||||||
loadingModList.setBrokenFiles(brokenFiles);
|
loadingModList.setBrokenFiles(brokenFiles);
|
||||||
|
|||||||
+5
-4
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
|
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
|
||||||
import net.minecraftforge.fml.loading.StringUtils;
|
import net.minecraftforge.fml.loading.StringUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -23,9 +23,10 @@ import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck;
|
|||||||
/**
|
/**
|
||||||
* Support loading mods located in JAR files in the mods folder
|
* Support loading mods located in JAR files in the mods folder
|
||||||
*/
|
*/
|
||||||
public class ModsFolderLocator extends AbstractJarFileLocator {
|
public class ModsFolderLocator extends AbstractJarFileModLocator
|
||||||
|
{
|
||||||
private static final String SUFFIX = ".jar";
|
private static final String SUFFIX = ".jar";
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final Path modFolder;
|
private final Path modFolder;
|
||||||
private final String customName;
|
private final String customName;
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -19,7 +19,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Scanner {
|
public class Scanner {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final ModFile fileToScan;
|
private final ModFile fileToScan;
|
||||||
|
|
||||||
public Scanner(final ModFile fileToScan) {
|
public Scanner(final ModFile fileToScan) {
|
||||||
|
|||||||
-2
@@ -34,8 +34,6 @@ import java.util.function.IntSupplier;
|
|||||||
import java.util.function.LongSupplier;
|
import java.util.function.LongSupplier;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import static org.lwjgl.glfw.GLFW.*;
|
import static org.lwjgl.glfw.GLFW.*;
|
||||||
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import com.mojang.logging.LogUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -20,7 +20,7 @@ import java.util.function.Supplier;
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
class ArgumentList {
|
class ArgumentList {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private List<Supplier<String[]>> entries = new ArrayList<>();
|
private List<Supplier<String[]>> entries = new ArrayList<>();
|
||||||
private Map<String, EntryValue> values = new HashMap<>();
|
private Map<String, EntryValue> values = new HashMap<>();
|
||||||
|
|
||||||
|
|||||||
+2
-7
@@ -5,31 +5,26 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
import net.minecraftforge.fml.loading.LibraryFinder;
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
import net.minecraftforge.fml.loading.VersionInfo;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public abstract class CommonClientLaunchHandler extends CommonLaunchHandler {
|
public abstract class CommonClientLaunchHandler extends CommonLaunchHandler {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
@Override public Dist getDist() { return Dist.CLIENT; }
|
||||||
@Override public String getNaming() { return "srg"; }
|
@Override public String getNaming() { return "srg"; }
|
||||||
@Override public boolean isProduction() { return true; }
|
@Override public boolean isProduction() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-17
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -50,8 +49,6 @@ public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
|||||||
if (getDist().isDedicatedServer())
|
if (getDist().isDedicatedServer())
|
||||||
return arguments;
|
return arguments;
|
||||||
|
|
||||||
fixNatives();
|
|
||||||
|
|
||||||
if (isData())
|
if (isData())
|
||||||
return arguments;
|
return arguments;
|
||||||
|
|
||||||
@@ -119,18 +116,4 @@ public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
|||||||
// Generate a time-based random number, to mimic how n.m.client.Main works
|
// Generate a time-based random number, to mimic how n.m.client.Main works
|
||||||
return Long.toString(System.nanoTime() % (int) Math.pow(10, length));
|
return Long.toString(System.nanoTime() % (int) Math.pow(10, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fixNatives() {
|
|
||||||
String paths = System.getProperty("java.library.path");
|
|
||||||
String nativesDir = System.getProperty("nativesDirectory");
|
|
||||||
if (nativesDir == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(paths))
|
|
||||||
paths = nativesDir;
|
|
||||||
else
|
|
||||||
paths += File.pathSeparator + nativesDir;
|
|
||||||
|
|
||||||
System.setProperty("java.library.path", paths);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+3
-3
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
||||||
import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder;
|
import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
|||||||
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 = LogManager.getLogger();
|
protected static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public abstract Dist getDist();
|
public abstract Dist getDist();
|
||||||
|
|
||||||
|
|||||||
+2
-6
@@ -6,12 +6,11 @@
|
|||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
import net.minecraftforge.fml.loading.LibraryFinder;
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
import net.minecraftforge.fml.loading.VersionInfo;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -20,17 +19,14 @@ import java.util.function.BiPredicate;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public abstract class CommonServerLaunchHandler extends CommonLaunchHandler {
|
public abstract class CommonServerLaunchHandler extends CommonLaunchHandler {
|
||||||
protected static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
||||||
@Override public String getNaming() { return "srg"; }
|
@Override public String getNaming() { return "srg"; }
|
||||||
@Override public boolean isProduction() { return true; }
|
@Override public boolean isProduction() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@@ -13,12 +14,11 @@ public class FMLClientDevLaunchHandler extends CommonDevLaunchHandler {
|
|||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
@Override public Dist getDist() { return Dist.CLIENT; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -17,12 +18,11 @@ public class FMLClientUserdevLaunchHandler extends FMLUserdevLaunchHandler {
|
|||||||
public Dist getDist() { return Dist.CLIENT; }
|
public Dist getDist() { return Dist.CLIENT; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -20,12 +21,11 @@ public class FMLDataUserdevLaunchHandler extends FMLUserdevLaunchHandler {
|
|||||||
public boolean isData() { return true; }
|
public boolean isData() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@@ -13,12 +14,11 @@ public class FMLServerDevLaunchHandler extends CommonDevLaunchHandler {
|
|||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -14,12 +15,11 @@ public class FMLServerUserdevLaunchHandler extends FMLUserdevLaunchHandler {
|
|||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@@ -13,12 +14,11 @@ public class ForgeClientDevLaunchHandler extends CommonDevLaunchHandler {
|
|||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
@Override public Dist getDist() { return Dist.CLIENT; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -17,12 +18,11 @@ public class ForgeClientUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|||||||
public Dist getDist() { return Dist.CLIENT; }
|
public Dist getDist() { return Dist.CLIENT; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -15,12 +16,11 @@ public class ForgeDataDevLaunchHandler extends CommonDevLaunchHandler {
|
|||||||
@Override public boolean isData() { return true; }
|
@Override public boolean isData() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -20,12 +21,11 @@ public class ForgeDataUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|||||||
public boolean isData() { return true; }
|
public boolean isData() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -14,12 +15,11 @@ public class ForgeGametestDevLaunchHandler extends CommonDevLaunchHandler {
|
|||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("forge").orElseThrow(), "net.minecraftforge.gametest.GameTestMain").getMethod("main", String[].class).invoke(null, (Object)args);
|
Class.forName(layer.findModule("forge").orElseThrow(), "net.minecraftforge.gametest.GameTestMain").getMethod("main", String[].class).invoke(null, (Object)args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -14,12 +15,11 @@ public class ForgeGametestUserdevLaunchHandler extends ForgeUserdevLaunchHandler
|
|||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("forge").orElseThrow(), "net.minecraftforge.gametest.GameTestMain").getMethod("main", String[].class).invoke(null, (Object)args);
|
Class.forName(layer.findModule("forge").orElseThrow(), "net.minecraftforge.gametest.GameTestMain").getMethod("main", String[].class).invoke(null, (Object)args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@@ -13,12 +14,11 @@ public class ForgeServerDevLaunchHandler extends CommonDevLaunchHandler {
|
|||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
package net.minecraftforge.fml.loading.targets;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.ServiceRunner;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@@ -14,12 +15,11 @@ public class ForgeServerUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
public ServiceRunner launchService(String[] arguments, ModuleLayer layer) {
|
||||||
return () -> {
|
return () -> {
|
||||||
var args = preLaunch(arguments, layer);
|
var args = preLaunch(arguments, layer);
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,3 +4,5 @@ splashscreen = true
|
|||||||
maxThreads = -1
|
maxThreads = -1
|
||||||
# Enable forge global version checking
|
# Enable forge global version checking
|
||||||
versionCheck = true
|
versionCheck = true
|
||||||
|
# Disables Optimized DFU client-side.
|
||||||
|
disableOptimizedDFU = true
|
||||||
+2
-1
@@ -1 +1,2 @@
|
|||||||
net.minecraftforge.fml.loading.ModDirTransformerDiscoverer
|
net.minecraftforge.fml.loading.ModDirTransformerDiscoverer
|
||||||
|
net.minecraftforge.fml.loading.ClasspathTransformerDiscoverer
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator
|
||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -32,10 +32,10 @@
|
|||||||
# Busybox and similar reduced shells will NOT work, because this script
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
# * functions;
|
# * functions;
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
#
|
#
|
||||||
# Important for patching:
|
# Important for patching:
|
||||||
#
|
#
|
||||||
@@ -205,6 +205,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|||||||
Vendored
+8
-6
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ apply plugin: 'org.javamodularity.moduleplugin'
|
|||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly('org.jetbrains:annotations:21.0.1')
|
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
implementation(project(':fmlcore'))
|
implementation(project(':fmlcore'))
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -18,14 +18,15 @@ import net.minecraftforge.forgespi.language.IModInfo;
|
|||||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.Marker;
|
||||||
|
import org.apache.logging.log4j.MarkerManager;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|
||||||
|
|
||||||
public class FMLModContainer extends ModContainer
|
public class FMLModContainer extends ModContainer
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static final Marker LOADING = MarkerManager.getMarker("LOADING");
|
||||||
private final ModFileScanData scanResults;
|
private final ModFileScanData scanResults;
|
||||||
private final IEventBus eventBus;
|
private final IEventBus eventBus;
|
||||||
private Object modInstance;
|
private Object modInstance;
|
||||||
@@ -37,7 +38,7 @@ public class FMLModContainer extends ModContainer
|
|||||||
LOGGER.debug(LOADING,"Creating FMLModContainer instance for {}", className);
|
LOGGER.debug(LOADING,"Creating FMLModContainer instance for {}", className);
|
||||||
this.scanResults = modFileScanResults;
|
this.scanResults = modFileScanResults;
|
||||||
activityMap.put(ModLoadingStage.CONSTRUCT, this::constructMod);
|
activityMap.put(ModLoadingStage.CONSTRUCT, this::constructMod);
|
||||||
this.eventBus = BusBuilder.builder().setExceptionHandler(this::onEventFailed).setTrackPhases(false).markerType(IModBusEvent.class).build();
|
this.eventBus = BusBuilder.builder().setExceptionHandler(this::onEventFailed).setTrackPhases(false).markerType(IModBusEvent.class).useModLauncher().build();
|
||||||
this.configHandler = Optional.of(ce->this.eventBus.post(ce.self()));
|
this.configHandler = Optional.of(ce->this.eventBus.post(ce.self()));
|
||||||
final FMLJavaModLoadingContext contextExtension = new FMLJavaModLoadingContext(this);
|
final FMLJavaModLoadingContext contextExtension = new FMLJavaModLoadingContext(this);
|
||||||
this.contextExtension = () -> contextExtension;
|
this.contextExtension = () -> contextExtension;
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|
||||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
|
||||||
<application>
|
|
||||||
<!--The ID below indicates application support for Windows Vista -->
|
|
||||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
|
|
||||||
<!--The ID below indicates application support for Windows 7 -->
|
|
||||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
|
|
||||||
<!--The ID below indicates application support for Windows 8 -->
|
|
||||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
|
||||||
<!--The ID below indicates application support for Windows 8.1 -->
|
|
||||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
|
||||||
<!--The ID below indicates application supprort for Windows 10 -->
|
|
||||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
|
||||||
</application>
|
|
||||||
</compatibility>
|
|
||||||
|
|
||||||
<!-- following stuff is so the EXE doesnt ask for admin access -->
|
|
||||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
|
||||||
<security>
|
|
||||||
<requestedPrivileges>
|
|
||||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
|
||||||
</requestedPrivileges>
|
|
||||||
</security>
|
|
||||||
</trustInfo>
|
|
||||||
</assembly>
|
|
||||||
@@ -12,7 +12,8 @@ dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|||||||
java.withSourcesJar()
|
java.withSourcesJar()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly('org.jetbrains:annotations:21.0.1')
|
compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
|
||||||
|
|
||||||
implementation(project(':fmlloader'))
|
implementation(project(':fmlloader'))
|
||||||
implementation(project(':fmlcore'))
|
implementation(project(':fmlcore'))
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.lowcodemod;
|
package net.minecraftforge.fml.lowcodemod;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
import net.minecraftforge.fml.IExtensionPoint;
|
import net.minecraftforge.fml.IExtensionPoint;
|
||||||
import net.minecraftforge.fml.ModContainer;
|
import net.minecraftforge.fml.ModContainer;
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|||||||
|
|
||||||
public class LowCodeModContainer extends ModContainer
|
public class LowCodeModContainer extends ModContainer
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final ModFileScanData scanResults;
|
private final ModFileScanData scanResults;
|
||||||
private Object modInstance;
|
private Object modInstance;
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 1877 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user