mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
220cb1fd81 | ||
|
|
19abf0cb9a | ||
|
|
508d872ef3 | ||
|
|
b67c37fd6c | ||
|
|
d4a3762f21 | ||
|
|
4c7f1096e5 | ||
|
|
4ff65feb63 | ||
|
|
dbec9b3d5a | ||
|
|
28515d7c59 | ||
|
|
ca819e09f2 | ||
|
|
d28cd0352b | ||
|
|
a436118e39 |
No files matched your search
@@ -14,10 +14,3 @@
|
|||||||
*.cfg text eol=lf
|
*.cfg text eol=lf
|
||||||
*.py text eol=lf
|
*.py text eol=lf
|
||||||
*.jks binary
|
*.jks binary
|
||||||
|
|
||||||
# Disable autocrlf on generated files, they always generate with LF
|
|
||||||
src/generated/**/.cache/cache text eol=lf
|
|
||||||
src/generated/**/*.json text eol=lf
|
|
||||||
src/generated_test/**/.cache/cache text eol=lf
|
|
||||||
src/generated_test/**/*.json text eol=lf
|
|
||||||
|
|
||||||
+8
-10
@@ -9,38 +9,36 @@
|
|||||||
|
|
||||||
#idea
|
#idea
|
||||||
/.idea
|
/.idea
|
||||||
/*/out
|
|
||||||
/classes
|
/classes
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
#gradle
|
#gradle
|
||||||
/build
|
/build
|
||||||
/.gradle
|
/.gradle
|
||||||
/*/build
|
/mdk/.gradle
|
||||||
/*/.gradle
|
/mdk/build
|
||||||
|
|
||||||
# Projects repo, either ignore it, or ignore patches.
|
#occupational hazards
|
||||||
/projects/mcp/
|
/projects/mcp/
|
||||||
/projects/clean/
|
/projects/clean/
|
||||||
/projects/forge/
|
/projects/forge/
|
||||||
/projects/fmlonly/
|
|
||||||
#/patches/
|
|
||||||
|
|
||||||
#occupational hazards
|
|
||||||
/projects/**/build/
|
/projects/**/build/
|
||||||
/projects/**/out/
|
/projects/**/out/
|
||||||
/projects/**/run/
|
/projects/**/run/
|
||||||
/projects/**/*.launch
|
/projects/**/*.launch
|
||||||
/repo/
|
/repo/
|
||||||
|
/buildSrc
|
||||||
src/generated/resources/.cache/
|
src/generated/resources/.cache/
|
||||||
|
|
||||||
#Patch rejects
|
#Patch rejects
|
||||||
/patches-/
|
/patches-/
|
||||||
#*.patch.rej
|
*.patch.rej
|
||||||
/projects/*/rejects/
|
|
||||||
|
|
||||||
# FML changelog
|
# FML changelog
|
||||||
changelog.txt
|
changelog.txt
|
||||||
*.py
|
*.py
|
||||||
*.7z
|
*.7z
|
||||||
/logs/
|
/logs/
|
||||||
|
|
||||||
|
gradle.properties
|
||||||
|
!/mdk/gradle.properties
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
|
language: java
|
||||||
|
jdk: oraclejdk8
|
||||||
|
|
||||||
|
env:
|
||||||
|
- BUILD_NUMBER=9999
|
||||||
|
|
||||||
|
before_cache:
|
||||||
|
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||||
|
- rm -f $HOME/.gradle/caches/minecraft/deobfedDeps/providedDummy.jar
|
||||||
|
- rm -f $HOME/.gradle/caches/minecraft/deobfedDeps/compileDummy.jar
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.gradle/caches/
|
||||||
|
- $HOME/.gradle/wrapper/
|
||||||
|
- $TRAVIS_BUILD_DIR/build/localCache/Forge/
|
||||||
|
|
||||||
|
before_install: chmod +x gradlew
|
||||||
|
install:
|
||||||
|
- ./gradlew --refresh-dependencies
|
||||||
|
- ./gradlew ciWriteBuildNumber
|
||||||
|
script:
|
||||||
|
- travis_wait ./gradlew build -x createExe -S
|
||||||
|
- ./gradlew -p projects/Forge test -S -i
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
|
||||||
|
# skip building travis on 1.13+ - it doesn't work there
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- 1.13-pre
|
||||||
|
- 1.13.x
|
||||||
|
- 1.14.x
|
||||||
|
- /^noci-.*$/
|
||||||
Vendored
+16
-20
@@ -6,8 +6,8 @@ pipeline {
|
|||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'gradle:7-jdk16'
|
image 'gradlewrapper:latest'
|
||||||
args '-v forgegc:/home/gradle/.gradle/'
|
args '-v gradlecache:/gradlecache'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
@@ -18,6 +18,11 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
stage('fetch') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('notify_start') {
|
stage('notify_start') {
|
||||||
when {
|
when {
|
||||||
not {
|
not {
|
||||||
@@ -36,11 +41,9 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('setup') {
|
stage('setup') {
|
||||||
steps {
|
steps {
|
||||||
withGradle {
|
sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue setup'
|
||||||
sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue setup'
|
|
||||||
}
|
|
||||||
script {
|
script {
|
||||||
env.MYVERSION = sh(returnStdout: true, script: './gradlew :forge:properties -q | grep "^version:" | cut -d" " -f2').trim()
|
env.MYVERSION = sh(returnStdout: true, script: './gradlew :forge:properties -q | grep "version:" | awk \'{print $2}\'').trim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,22 +64,15 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
|
FORGE_MAVEN = credentials('forge-maven-forge-user')
|
||||||
CROWDIN = credentials('forge-crowdin')
|
CROWDIN = credentials('forge-crowdin')
|
||||||
KEYSTORE = credentials('forge-jenkins-keystore-old')
|
KEYSTORE = credentials('forge-jenkins-keystore-old')
|
||||||
KEYSTORE_KEYPASS = credentials('forge-jenkins-keystore-old-keypass')
|
KEYSTORE_KEYPASS = credentials('forge-jenkins-keystore-old-keypass')
|
||||||
KEYSTORE_STOREPASS = credentials('forge-jenkins-keystore-old-keypass')
|
KEYSTORE_STOREPASS = credentials('forge-jenkins-keystore-old-keypass')
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) {
|
sh './gradlew ${GRADLE_ARGS} :forge:publish -PforgeMavenUser=${FORGE_MAVEN_USR} -PforgeMavenPassword=${FORGE_MAVEN_PSW} -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}'
|
||||||
withGradle {
|
sh 'curl --user ${FORGE_MAVEN} http://files.minecraftforge.net/maven/manage/promote/latest/net.minecraftforge.forge/${MYVERSION}'
|
||||||
sh './gradlew ${GRADLE_ARGS} publish -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
success {
|
|
||||||
build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote net.minecraftforge:forge ${env.MYVERSION} latest")], propagate: false, wait: false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('test_publish_pr') { //Publish to local repo to test full process, but don't include credentials so it can't sign/publish to maven
|
stage('test_publish_pr') { //Publish to local repo to test full process, but don't include credentials so it can't sign/publish to maven
|
||||||
@@ -87,9 +83,7 @@ pipeline {
|
|||||||
CROWDIN = credentials('forge-crowdin')
|
CROWDIN = credentials('forge-crowdin')
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withGradle {
|
sh './gradlew ${GRADLE_ARGS} :forge:publish -PcrowdinKey=${CROWDIN}'
|
||||||
sh './gradlew ${GRADLE_ARGS} publish -PcrowdinKey=${CROWDIN}'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +91,9 @@ pipeline {
|
|||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
archiveArtifacts artifacts: 'projects/forge/build/libs/**/*.*', fingerprint: true, onlyIfSuccessful: true, allowEmptyArchive: true
|
archiveArtifacts artifacts: 'projects/forge/build/libs/**/*.*', fingerprint: true, onlyIfSuccessful: true, allowEmptyArchive: true
|
||||||
|
//junit 'build/test-results/*/*.xml'
|
||||||
|
//jacoco sourcePattern: '**/src/*/java'
|
||||||
|
|
||||||
if (env.CHANGE_ID == null) { // This is unset for non-PRs
|
if (env.CHANGE_ID == null) { // This is unset for non-PRs
|
||||||
discordSend(
|
discordSend(
|
||||||
title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}",
|
title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}",
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
Minecraft Forge
|
Minecraft Forge
|
||||||
Copyright (c) 2016-${year}.
|
Copyright (c) 2016-2019.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
+912
-1003
File diff suppressed because it is too large.
Load diff
@@ -1,3 +0,0 @@
|
|||||||
/.gradle/
|
|
||||||
/build/
|
|
||||||
/out/
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
repositories {
|
|
||||||
maven { url = 'https://maven.minecraftforge.net/' }
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
implementation 'org.ow2.asm:asm:9.1'
|
|
||||||
implementation 'org.ow2.asm:asm-tree:9.1'
|
|
||||||
implementation 'net.minecraftforge:srgutils:0.4.+'
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import groovy.json.JsonBuilder
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.OutputFile
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.objectweb.asm.ClassReader
|
|
||||||
import org.objectweb.asm.Opcodes
|
|
||||||
import org.objectweb.asm.tree.ClassNode
|
|
||||||
import org.objectweb.asm.tree.FieldNode
|
|
||||||
import org.objectweb.asm.tree.MethodNode
|
|
||||||
|
|
||||||
import java.util.zip.ZipEntry
|
|
||||||
import java.util.zip.ZipInputStream
|
|
||||||
|
|
||||||
abstract class BytecodeFinder extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getJar()
|
|
||||||
@OutputFile abstract RegularFileProperty getOutput()
|
|
||||||
|
|
||||||
BytecodeFinder() {
|
|
||||||
output.convention(project.layout.buildDirectory.dir(name).map { it.file("output.json") })
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
Util.init()
|
|
||||||
|
|
||||||
def outputFile = output.get().asFile
|
|
||||||
if (outputFile.exists())
|
|
||||||
outputFile.delete()
|
|
||||||
|
|
||||||
pre()
|
|
||||||
|
|
||||||
jar.get().asFile.withInputStream { i ->
|
|
||||||
new ZipInputStream(i).withCloseable { zin ->
|
|
||||||
ZipEntry zein
|
|
||||||
while ((zein = zin.nextEntry) != null) {
|
|
||||||
if (zein.name.endsWith('.class')) {
|
|
||||||
def node = new ClassNode(Opcodes.ASM9)
|
|
||||||
new ClassReader(zin).accept(node, 0)
|
|
||||||
process(node)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
post()
|
|
||||||
outputFile.text = new JsonBuilder(getData()).toPrettyString()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected process(ClassNode node) {
|
|
||||||
if (node.fields != null) node.fields.each { process(node, it) }
|
|
||||||
if (node.methods != null) node.methods.each { process(node, it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected pre() {}
|
|
||||||
protected process(ClassNode parent, FieldNode node) {}
|
|
||||||
protected process(ClassNode parent, MethodNode node) {}
|
|
||||||
protected post() {}
|
|
||||||
protected abstract Object getData()
|
|
||||||
}
|
|
||||||
@@ -1,267 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import net.minecraftforge.srgutils.IMappingFile
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.Optional
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.objectweb.asm.Opcodes
|
|
||||||
|
|
||||||
abstract class CheckATs extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getInheritance()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getAts()
|
|
||||||
@InputFile @Optional abstract RegularFileProperty getMappings()
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
def mappings = mappings.map { IMappingFile.load(it.asFile) }.getOrNull()
|
|
||||||
Util.init()
|
|
||||||
def parse = { line ->
|
|
||||||
def idx = line.indexOf('#')
|
|
||||||
def comment = idx == -1 ? null : line.substring(idx)
|
|
||||||
if (idx != -1) line = line.substring(0, idx - 1)
|
|
||||||
def (modifier, cls, desc) = (line.trim() + ' ').split(' ', -1)
|
|
||||||
def key = cls + (desc.isEmpty() ? '' : ' ' + desc)
|
|
||||||
return [modifier, cls, desc, comment, key]
|
|
||||||
}
|
|
||||||
def accessLevel = { access ->
|
|
||||||
if ((access & Opcodes.ACC_PUBLIC) != 0) return 3
|
|
||||||
if ((access & Opcodes.ACC_PROTECTED) != 0) return 2
|
|
||||||
if ((access & Opcodes.ACC_PRIVATE) != 0) return 0
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
def accessStr = { access ->
|
|
||||||
if (access.endsWith('-f') || access.endsWith('+f'))
|
|
||||||
return 4
|
|
||||||
switch (access.toLowerCase()) {
|
|
||||||
case 'public': return 3
|
|
||||||
case 'protected': return 2
|
|
||||||
case 'default': return 1
|
|
||||||
case 'private': return 0
|
|
||||||
default: return -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def json = inheritance.get().asFile.json()
|
|
||||||
|
|
||||||
ats.each { f ->
|
|
||||||
TreeMap lines = [:]
|
|
||||||
def group = null
|
|
||||||
for (def line : f.readLines()) {
|
|
||||||
if (line.isEmpty()) continue
|
|
||||||
if (line.startsWith('#group ')) {
|
|
||||||
def (modifier, cls, desc, comment, key) = parse.call(line.substring(7))
|
|
||||||
|
|
||||||
if (desc != '*' && desc != '*()' && desc != '<init>')
|
|
||||||
throw new IllegalStateException('Invalid group: ' + line)
|
|
||||||
|
|
||||||
group = [modifier: modifier, cls: cls, desc: desc, comment: comment,
|
|
||||||
existing: [] as Set,
|
|
||||||
children: [] as TreeSet,
|
|
||||||
group: true
|
|
||||||
]
|
|
||||||
if (lines.containsKey(key))
|
|
||||||
throw new IllegalStateException('Duplicate group: ' + line)
|
|
||||||
|
|
||||||
lines[key] = group
|
|
||||||
} else if (group != null) {
|
|
||||||
if (line.startsWith('#endgroup')) {
|
|
||||||
group = null
|
|
||||||
} else {
|
|
||||||
def (modifier, cls, desc, comment, key) = parse.call(line)
|
|
||||||
group['existing'].add(key)
|
|
||||||
}
|
|
||||||
} else if (line.startsWith('#endgroup')) {
|
|
||||||
throw new IllegalStateException('Invalid group ending: ' + line)
|
|
||||||
} else if (line.startsWith('#')) {
|
|
||||||
//Nom
|
|
||||||
} else {
|
|
||||||
def (modifier, cls, desc, comment, key) = parse.call(line)
|
|
||||||
if (lines.containsKey(key)) {
|
|
||||||
println('Duplicate: ' + line)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
lines[key] = [modifier: modifier, cls: cls, desc: desc, comment: comment, group: false]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process Groups, this will remove any entries outside the group that is covered by the group
|
|
||||||
for (def key : new ArrayList<>(lines.keySet())) {
|
|
||||||
def entry = lines.get(key)
|
|
||||||
if (entry != null && entry['group']) {
|
|
||||||
def cls = entry['cls']
|
|
||||||
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
|
||||||
if (jcls == null) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Group: ' + key)
|
|
||||||
} else if ('*' == entry['desc']) {
|
|
||||||
if (!jcls.containsKey('fields')) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Group, Class has no fields: ' + key)
|
|
||||||
} else {
|
|
||||||
jcls['fields'].each { field, value ->
|
|
||||||
def fkey = cls + ' ' + field
|
|
||||||
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
|
||||||
if (lines.containsKey(fkey)) {
|
|
||||||
lines.remove(fkey)
|
|
||||||
} else if (!entry['existing'].contains(fkey)) {
|
|
||||||
println('Added: ' + fkey)
|
|
||||||
}
|
|
||||||
entry['children'].add(fkey)
|
|
||||||
} else if (lines.containsKey(fkey)) {
|
|
||||||
lines.remove(fkey)
|
|
||||||
println('Removed: ' + fkey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
|
||||||
}
|
|
||||||
} else if ('*()' == entry['desc']) {
|
|
||||||
if (!jcls.containsKey('methods')) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Group, Class has no methods: ' + key)
|
|
||||||
} else {
|
|
||||||
jcls['methods'].each{ mtd, value ->
|
|
||||||
if (mtd.startsWith('<clinit>') || mtd.startsWith('lambda$'))
|
|
||||||
return
|
|
||||||
key = cls + ' ' + mtd.replace(' ', '')
|
|
||||||
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
|
||||||
if (lines.containsKey(key)) {
|
|
||||||
lines.remove(key)
|
|
||||||
} else if (!entry['existing'].contains(key)) {
|
|
||||||
println('Added: ' + key)
|
|
||||||
}
|
|
||||||
entry['children'].add(key)
|
|
||||||
} else if (lines.containsKey(key)) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Removed: ' + key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
|
||||||
}
|
|
||||||
} else if ('<init>' == entry['desc']) { //Make all public non-abstract subclasses
|
|
||||||
json.each{ tcls,value ->
|
|
||||||
if (!value.containsKey('methods') || ((value['access'] & Opcodes.ACC_ABSTRACT) != 0))
|
|
||||||
return
|
|
||||||
def parents = [] as Set
|
|
||||||
def parent = tcls
|
|
||||||
while (parent != null && json.containsKey(parent)) {
|
|
||||||
parents.add(parent)
|
|
||||||
def p = json[parent]
|
|
||||||
parent = p == null ? null : p['superName']
|
|
||||||
}
|
|
||||||
if (parents.contains(cls.replaceAll('\\.', '/'))) {
|
|
||||||
value['methods'].each{ mtd, v ->
|
|
||||||
if (mtd.startsWith('<init>')) {
|
|
||||||
def child = tcls.replaceAll('/', '\\.') + ' ' + mtd.replace(' ', '')
|
|
||||||
if (accessLevel.call(v['access']) < 3) {
|
|
||||||
if (lines.containsKey(child)) {
|
|
||||||
lines.remove(child)
|
|
||||||
} else if (!entry['existing'].contains(child)) {
|
|
||||||
println('Added: ' + child)
|
|
||||||
}
|
|
||||||
entry['children'].add(child)
|
|
||||||
} else if (lines.containsKey(child)) {
|
|
||||||
lines.remove(child)
|
|
||||||
println('Removed: ' + child)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process normal lines, remove invalid and remove narrowing
|
|
||||||
for (def key : new ArrayList<>(lines.keySet())) {
|
|
||||||
def entry = lines.get(key)
|
|
||||||
if (entry != null && !entry['group']) {
|
|
||||||
def cls = entry['cls']
|
|
||||||
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
|
||||||
if (jcls == null) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid: ' + key)
|
|
||||||
} else if (entry['desc'] == '') {
|
|
||||||
if (accessLevel.call(jcls['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Narrowing: ' + key)
|
|
||||||
}
|
|
||||||
} else if (!entry['desc'].contains('(')) {
|
|
||||||
if (!jcls.containsKey('fields') || !jcls['fields'].containsKey(entry['desc'])) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid: ' + key)
|
|
||||||
} else {
|
|
||||||
def value = jcls['fields'][entry['desc']]
|
|
||||||
if (accessLevel.call(value['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Narrowing: ' + key)
|
|
||||||
println(entry.comment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
def jdesc = entry['desc'].replace('(', ' (')
|
|
||||||
if (!jcls.containsKey('methods') || !jcls['methods'].containsKey(jdesc)) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid: ' + key)
|
|
||||||
} else {
|
|
||||||
def value = jcls['methods'][jdesc]
|
|
||||||
if (accessLevel.call(value['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Narrowing: ' + key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def data = []
|
|
||||||
def remapComment = { entry ->
|
|
||||||
if (!mappings || !entry || !entry.desc) return null
|
|
||||||
def comment = entry.comment?.substring(1)?.trim()
|
|
||||||
def jsonCls = json.get(entry.cls.replaceAll('\\.', '/'))
|
|
||||||
def mappingsClass = mappings?.getClass(jsonCls.name)
|
|
||||||
if (!mappingsClass) return entry.comment
|
|
||||||
def idx = entry.desc.indexOf('(')
|
|
||||||
def mappedName = idx == -1
|
|
||||||
? mappingsClass.remapField(entry.desc)
|
|
||||||
: mappingsClass.remapMethod(entry.desc.substring(0, idx), entry.desc.substring(idx))
|
|
||||||
if (!mappedName) return entry.comment
|
|
||||||
if (mappedName == '<init>')
|
|
||||||
mappedName = 'constructor'
|
|
||||||
|
|
||||||
if (comment?.startsWith(mappedName))
|
|
||||||
return '# ' + comment
|
|
||||||
if (comment && comment.indexOf(' ') != -1) {
|
|
||||||
def split = comment.split(" - ").toList()
|
|
||||||
if (split[0].indexOf(' ') != -1)
|
|
||||||
// The first string is more than one word, so append before it
|
|
||||||
return "# ${mappedName} - ${comment}"
|
|
||||||
split.remove(0)
|
|
||||||
return "# ${mappedName} - ${String.join(' - ', split)}"
|
|
||||||
}
|
|
||||||
return '# ' + mappedName
|
|
||||||
}
|
|
||||||
lines.each { key,value ->
|
|
||||||
if (!value.group) {
|
|
||||||
def comment = remapComment.call(value)
|
|
||||||
data.add(value.modifier + ' ' + key + (comment ? ' ' + comment : ''))
|
|
||||||
} else {
|
|
||||||
data.add('#group ' + value.modifier + ' ' + key + (value.comment == null ? '' : ' ' + value.comment))
|
|
||||||
value.children.each {
|
|
||||||
def line = value.modifier + ' ' + it
|
|
||||||
def (modifier, cls, desc, comment) = parse.call(line)
|
|
||||||
comment = remapComment.call([modifier: modifier, cls: cls, desc: desc, comment: comment])
|
|
||||||
data.add(line + (comment ? ' ' + comment : ''))
|
|
||||||
}
|
|
||||||
data.add('#endgroup')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f.text = data.join('\n')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
import org.objectweb.asm.ClassReader
|
|
||||||
import org.objectweb.asm.ClassVisitor
|
|
||||||
import org.objectweb.asm.MethodVisitor
|
|
||||||
import org.objectweb.asm.Opcodes
|
|
||||||
import org.objectweb.asm.Type
|
|
||||||
|
|
||||||
import java.util.zip.ZipEntry
|
|
||||||
import java.util.zip.ZipInputStream
|
|
||||||
|
|
||||||
abstract class CheckExcs extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getBinary()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getExcs()
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
Util.init()
|
|
||||||
def known = []
|
|
||||||
binary.get().asFile.withInputStream { i ->
|
|
||||||
new ZipInputStream(i).withCloseable { zin ->
|
|
||||||
def visitor = new ClassVisitor(Opcodes.ASM9) {
|
|
||||||
private String cls
|
|
||||||
@Override
|
|
||||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
|
||||||
this.cls = name
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
|
||||||
known.add(this.cls + '.' + name + descriptor)
|
|
||||||
super.visitMethod(access, name, descriptor, signature, exceptions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ZipEntry zein
|
|
||||||
while ((zein = zin.nextEntry) != null) {
|
|
||||||
if (zein.name.endsWith('.class')) {
|
|
||||||
ClassReader reader = new ClassReader(zin)
|
|
||||||
reader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
excs.each { f ->
|
|
||||||
def lines = []
|
|
||||||
f.eachLine { line ->
|
|
||||||
def idx = line.indexOf('#')
|
|
||||||
if (idx == 0 || line.isEmpty()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def comment = idx == -1 ? null : line.substring(idx)
|
|
||||||
if (idx != -1) line = line.substring(0, idx - 1)
|
|
||||||
|
|
||||||
if (!line.contains('=')) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def (key, value) = line.split('=', 2)
|
|
||||||
if (!known.contains(key)) {
|
|
||||||
println('Unknown: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def (cls, desc) = key.split('\\.', 2)
|
|
||||||
if (!desc.contains('(')) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
def name = desc.split('\\(', 2)[0]
|
|
||||||
desc = '(' + desc.split('\\(', 2)[1]
|
|
||||||
|
|
||||||
def (exceptions, args) = value.contains('|') ? value.split('|', 2) : [value, '']
|
|
||||||
|
|
||||||
if (args.split(',').length != Type.getArgumentTypes(desc).length) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
lines.add(line)
|
|
||||||
}
|
|
||||||
f.text = lines.sort().join('\n')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.InputDirectory
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.Paths
|
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
abstract class CheckPatches extends DefaultTask {
|
|
||||||
@InputDirectory abstract DirectoryProperty getPatchDir()
|
|
||||||
@Input boolean autoFix = false
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
def hasS2SArtifact = [
|
|
||||||
Paths.get("patches/minecraft/net/minecraft/client/renderer/ViewArea.java.patch"),
|
|
||||||
Paths.get("patches/minecraft/net/minecraft/data/models/blockstates/Variant.java.patch")
|
|
||||||
]
|
|
||||||
|
|
||||||
def verified = true;
|
|
||||||
patchDir.get().asFileTree.each { patch ->
|
|
||||||
def patchPath = project.rootDir.toPath().relativize(patch.toPath())
|
|
||||||
verified &= verifyPatch(patch, autoFix, patchPath.toString(), hasS2SArtifact.contains(patchPath))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!verified)
|
|
||||||
throw new RuntimeException('One or more patches failed verification. Check the log for errors.')
|
|
||||||
}
|
|
||||||
|
|
||||||
def verifyPatch(patch, fix, patchPath, hasS2SArtifact) {
|
|
||||||
def hunk_start_pattern = Pattern.compile('^@@ -[0-9,]* \\+[0-9,_]* @@$')
|
|
||||||
def white_space_pattern = Pattern.compile('^[+\\-]\\s*$')
|
|
||||||
def import_pattern = Pattern.compile('^[+\\-]\\s*import.*')
|
|
||||||
def field_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^=;]*)(=.*)?;\\s*$')
|
|
||||||
def method_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^(]*)[(]([^)]*)?[)]\\s*[{]\\s*$')
|
|
||||||
def class_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final[\\s]*)?(class|interface)([^{]*)[{]\\s*$')
|
|
||||||
|
|
||||||
def accessMap = [("private"):0, (null):1, ("protected"):2, ("public"):3]
|
|
||||||
|
|
||||||
def hasProblem = false;
|
|
||||||
def lines = patch.readLines()
|
|
||||||
|
|
||||||
def hunksStart = 0
|
|
||||||
def onlyWhiteSpace = false
|
|
||||||
|
|
||||||
def didFix = false
|
|
||||||
def newLines = []
|
|
||||||
def whiteSpaceErrors = []
|
|
||||||
|
|
||||||
// First two lines are file name ++/-- and we do not care
|
|
||||||
newLines.add(lines[0] + '\n')
|
|
||||||
newLines.add(lines[1] + '\n')
|
|
||||||
|
|
||||||
int i = 2
|
|
||||||
for (; i < lines.size(); ++i) {
|
|
||||||
def line = lines[i]
|
|
||||||
newLines.add(line + '\n')
|
|
||||||
|
|
||||||
if (hunk_start_pattern.matcher(line).find()) {
|
|
||||||
if (onlyWhiteSpace) {
|
|
||||||
if (fix || hasS2SArtifact) {
|
|
||||||
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
def toRemove = i - hunksStart;
|
|
||||||
while (toRemove-- > 0)
|
|
||||||
newLines.remove(newLines.size() - 1)
|
|
||||||
didFix = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!whiteSpaceErrors.empty)
|
|
||||||
hasProblem = true
|
|
||||||
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
|
||||||
whiteSpaceErrors.clear()
|
|
||||||
}
|
|
||||||
hunksStart = i
|
|
||||||
onlyWhiteSpace = true
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.startsWithAny('+','-')) {
|
|
||||||
def prefixChange = false
|
|
||||||
def prevLine = lines[i - 1]
|
|
||||||
|
|
||||||
if (line.charAt(0) == (char)'+' && prevLine.charAt(0) == (char)'-') {
|
|
||||||
def prevTrim = prevLine.substring(1).replaceAll("\\s", "")
|
|
||||||
def currTrim = line.substring(1).replaceAll("\\s", "")
|
|
||||||
|
|
||||||
if (prevTrim.equals(currTrim)) {
|
|
||||||
prefixChange = true
|
|
||||||
}
|
|
||||||
|
|
||||||
def pMatcher = field_pattern.matcher(prevLine)
|
|
||||||
def cMatcher = field_pattern.matcher(line)
|
|
||||||
|
|
||||||
if (pMatcher.find() && cMatcher.find() &&
|
|
||||||
pMatcher.group(6) == cMatcher.group(6) && // = ...
|
|
||||||
pMatcher.group(5) == cMatcher.group(5) && // field name
|
|
||||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
|
||||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
|
||||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
|
|
||||||
pMatcher = method_pattern.matcher(prevLine)
|
|
||||||
cMatcher = method_pattern.matcher(line)
|
|
||||||
|
|
||||||
if (pMatcher.find() && cMatcher.find() &&
|
|
||||||
pMatcher.group(6) == cMatcher.group(6) && // params
|
|
||||||
pMatcher.group(5) == cMatcher.group(5) && // <T> void name
|
|
||||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
|
||||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
|
||||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
|
|
||||||
pMatcher = class_pattern.matcher(prevLine)
|
|
||||||
cMatcher = class_pattern.matcher(line)
|
|
||||||
|
|
||||||
if (pMatcher.find() && cMatcher.find() &&
|
|
||||||
pMatcher.group(6) == cMatcher.group(6) && // ClassName<> extends ...
|
|
||||||
pMatcher.group(5) == cMatcher.group(5) && // class | interface
|
|
||||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
|
||||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
|
||||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.charAt(0) == (char)'-' && i + 1 < lines.size()) {
|
|
||||||
def nextLine = lines[i + 1]
|
|
||||||
if (nextLine.charAt(0) == (char)'+') {
|
|
||||||
def nextTrim = nextLine.substring(1).replaceAll("\\s", "")
|
|
||||||
def currTrim = line.substring(1).replaceAll("\\s", "")
|
|
||||||
|
|
||||||
if (nextTrim.equals(currTrim)) {
|
|
||||||
prefixChange = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def isWhiteSpaceChange = white_space_pattern.matcher(line).find()
|
|
||||||
|
|
||||||
if (!prefixChange && !isWhiteSpaceChange) {
|
|
||||||
onlyWhiteSpace = hasS2SArtifact && import_pattern.matcher(line).find()
|
|
||||||
}
|
|
||||||
else if (isWhiteSpaceChange) {
|
|
||||||
def prevLineChange = prevLine.startsWithAny('+','-')
|
|
||||||
def nextLineChange = i + 1 < lines.size() && lines[i + 1].startsWithAny('+','-')
|
|
||||||
|
|
||||||
if (!prevLineChange && !nextLineChange) {
|
|
||||||
whiteSpaceErrors.add(String.format("Patch contains white space change in valid hunk at line %d (cannot auto fix), file: %s", i + 1, patchPath))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.contains("\t")) {
|
|
||||||
if (!fix) {
|
|
||||||
logger.lifecycle("Patch contains tabs on line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.lifecycle("Fixing tabs on line {}, file: {}", i + 1, patchPath)
|
|
||||||
line = line.replaceAll('\t', ' ')
|
|
||||||
newLines.remove(newLines.size() - 1)
|
|
||||||
newLines.add(line + '\n')
|
|
||||||
didFix = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (import_pattern.matcher(line).find() && !hasS2SArtifact) {
|
|
||||||
logger.lifecycle("Patch contains import change on line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onlyWhiteSpace) {
|
|
||||||
if (fix || hasS2SArtifact) {
|
|
||||||
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
def toRemove = i - hunksStart;
|
|
||||||
while (toRemove-- > 0)
|
|
||||||
newLines.remove(newLines.size() - 1)
|
|
||||||
didFix = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!whiteSpaceErrors.empty)
|
|
||||||
hasProblem = true
|
|
||||||
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (didFix) {
|
|
||||||
if (newLines.size() <= 2) {
|
|
||||||
logger.lifecycle("Patch is now empty removing, file: {}", patchPath)
|
|
||||||
Files.delete(patch.toPath())
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!hasS2SArtifact)
|
|
||||||
logger.lifecycle("*** Updating patch file. Please run setup then genPatches again. ***")
|
|
||||||
patch.withWriter('UTF-8') { writer ->
|
|
||||||
newLines.each { l -> writer.write(l) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !hasProblem
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
abstract class CheckSAS extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getInheritance()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getSass()
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
Util.init()
|
|
||||||
def json = inheritance.get().asFile.json()
|
|
||||||
|
|
||||||
sass.each { f ->
|
|
||||||
def lines = []
|
|
||||||
f.eachLine { line ->
|
|
||||||
if (line[0] == '\t') return //Skip any tabbed lines, those are ones we add
|
|
||||||
def idx = line.indexOf('#')
|
|
||||||
if (idx == 0 || line.isEmpty()) {
|
|
||||||
lines.add(line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
def comment = idx == -1 ? null : line.substring(idx)
|
|
||||||
if (idx != -1) line = line.substring(0, idx - 1)
|
|
||||||
def (cls, desc) = (line.trim() + ' ').split(' ', -1)
|
|
||||||
cls = cls.replaceAll('\\.', '/')
|
|
||||||
desc = desc.replace('(', ' (')
|
|
||||||
|
|
||||||
if (json[cls] == null || (!desc.isEmpty() && (json[cls]['methods'] == null || json[cls]['methods'][desc] == null))) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//Class SAS
|
|
||||||
if (desc.isEmpty()) {
|
|
||||||
lines.add(cls + (comment == null ? '' : ' ' + comment))
|
|
||||||
if (json[cls]['methods'] != null)
|
|
||||||
(json[cls]['methods'] as TreeMap).each {
|
|
||||||
findChildMethods(json, cls, it.key).each { lines.add('\t' + it) }
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//Method SAS
|
|
||||||
lines.add(cls + ' ' + desc.replace(' ', '') + (comment == null ? '' : ' ' + comment))
|
|
||||||
findChildMethods(json, cls, desc).each { lines.add('\t' + it) }
|
|
||||||
}
|
|
||||||
f.text = lines.join('\n')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static findChildMethods(json, cls, desc)
|
|
||||||
{
|
|
||||||
return json.values().findAll{ it.methods != null && it.methods[desc] != null && it.methods[desc].override == cls}
|
|
||||||
.collect { it.name + ' ' + desc.replace(' ', '') } as TreeSet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import java.util.function.BiConsumer
|
|
||||||
|
|
||||||
public class ClosureHelper {
|
|
||||||
BiConsumer<String, Closure> callback
|
|
||||||
|
|
||||||
public ClosureHelper(Closure cl, BiConsumer<String, Closure> callback) {
|
|
||||||
this.callback = callback
|
|
||||||
apply(this, cl)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def methodMissing(String name, Object args) {
|
|
||||||
if (!args.class.isArray()) return
|
|
||||||
Object[] aargs = (Object[])args
|
|
||||||
|
|
||||||
if (aargs.length == 1 && aargs[0] instanceof Closure) {
|
|
||||||
this.callback.accept(name, (Closure)aargs[0])
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException('Unknown method: "' + name + '" with arguments ' + args + ' for ' + this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static <T> T apply(T obj, Closure cl) {
|
|
||||||
cl.delegate = obj
|
|
||||||
cl.resolveStrategy = Closure.DELEGATE_FIRST
|
|
||||||
cl()
|
|
||||||
return obj
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.Optional
|
|
||||||
import org.gradle.api.tasks.OutputFile
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
import java.util.zip.ZipEntry
|
|
||||||
import java.util.zip.ZipInputStream
|
|
||||||
import java.util.zip.ZipOutputStream
|
|
||||||
|
|
||||||
abstract class Crowdin extends DefaultTask {
|
|
||||||
@Input abstract Property<String> getId()
|
|
||||||
@Input @Optional abstract Property<String> getKey()
|
|
||||||
@Input boolean json = true
|
|
||||||
@OutputFile abstract RegularFileProperty getOutput()
|
|
||||||
@OutputFile abstract RegularFileProperty getExport()
|
|
||||||
|
|
||||||
Crowdin() {
|
|
||||||
outputs.upToDateWhen{ false }
|
|
||||||
id.convention('minecraft-forge')
|
|
||||||
output.convention(project.layout.buildDirectory.dir(name).map {it.file("output.zip") })
|
|
||||||
export.convention(project.layout.buildDirectory.dir(name).map {it.file("export.json") })
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
def run() {
|
|
||||||
File outputFile = output.get().asFile
|
|
||||||
File exportFile = export.get().asFile
|
|
||||||
if (outputFile.exists())
|
|
||||||
outputFile.delete()
|
|
||||||
|
|
||||||
if (!key.isPresent())
|
|
||||||
return
|
|
||||||
String key = this.key.get()
|
|
||||||
String id = this.id.get()
|
|
||||||
|
|
||||||
// Force an export
|
|
||||||
new URL("https://api.crowdin.com/api/project/${id}/export?key=${key}").withInputStream { i ->
|
|
||||||
exportFile.withOutputStream { it << i }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!exportFile.text.contains('success')) {
|
|
||||||
throw new RuntimeException("Crowdin export failed, see ${exportFile} for more info")
|
|
||||||
}
|
|
||||||
|
|
||||||
new URL("https://api.crowdin.com/api/project/${id}/download/all.zip?key=${key}").withInputStream { i ->
|
|
||||||
new ZipInputStream(i).withCloseable { zin ->
|
|
||||||
outputFile.withOutputStream { out ->
|
|
||||||
new ZipOutputStream(out).withCloseable { zout ->
|
|
||||||
ZipEntry zein
|
|
||||||
while ((zein = zin.nextEntry) != null) {
|
|
||||||
if (zein.isDirectory()) {
|
|
||||||
zout.putNextEntry(new ZipEntry(zein.name))
|
|
||||||
} else {
|
|
||||||
// 1.13+ uses json
|
|
||||||
if (zein.name.endsWith('.json') == json) {
|
|
||||||
ZipEntry zeout = new ZipEntry(json ? zein.name.toLowerCase() : zein.name)
|
|
||||||
zeout.time = 1
|
|
||||||
zout.putNextEntry(zeout)
|
|
||||||
zout << zin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.Internal
|
|
||||||
import org.gradle.api.tasks.OutputFile
|
|
||||||
import org.gradle.api.tasks.OutputFiles
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
|
||||||
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
abstract class DownloadLibraries extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getInput()
|
|
||||||
@OutputDirectory abstract DirectoryProperty getOutput()
|
|
||||||
@OutputFile abstract RegularFileProperty getLibrariesOutput()
|
|
||||||
|
|
||||||
DownloadLibraries() {
|
|
||||||
output.convention(project.layout.buildDirectory.dir(name))
|
|
||||||
librariesOutput.convention(project.layout.buildDirectory.dir(name).map(d -> d.file('libraries.txt')))
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
def run() {
|
|
||||||
Util.init()
|
|
||||||
File outputDir = output.get().asFile
|
|
||||||
def libraries = new ArrayList()
|
|
||||||
|
|
||||||
def json = input.get().asFile.json().libraries.each { lib ->
|
|
||||||
//TODO: Thread?
|
|
||||||
def artifacts = [lib.downloads.artifact] + lib.downloads.get('classifiers', [:]).values()
|
|
||||||
artifacts.each{ art ->
|
|
||||||
def target = new File(outputDir, art.path)
|
|
||||||
libraries.add(target.absolutePath)
|
|
||||||
if (!target.exists() || !art.sha1.equals(target.sha1())) {
|
|
||||||
project.logger.lifecycle("Downloading ${art.url}")
|
|
||||||
if (!target.parentFile.exists()) {
|
|
||||||
target.parentFile.mkdirs()
|
|
||||||
}
|
|
||||||
new URL(art.url).withInputStream { i ->
|
|
||||||
target.withOutputStream { it << i }
|
|
||||||
}
|
|
||||||
if (!art.sha1.equals(target.sha1())) {
|
|
||||||
throw new IllegalStateException("Failed to download ${art.url} to ${target.canonicalPath} SHA Mismatch")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Files.write(librariesOutput.get().asFile.toPath(), libraries)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import groovy.transform.EqualsAndHashCode
|
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
import java.util.HashMap
|
|
||||||
import java.util.TreeMap
|
|
||||||
import java.util.TreeSet
|
|
||||||
import java.util.function.BiConsumer
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.tasks.*
|
|
||||||
|
|
||||||
import org.objectweb.asm.Opcodes
|
|
||||||
import org.objectweb.asm.Type
|
|
||||||
import org.objectweb.asm.tree.ClassNode
|
|
||||||
import org.objectweb.asm.tree.FieldNode
|
|
||||||
import org.objectweb.asm.tree.MethodNode
|
|
||||||
|
|
||||||
import static org.objectweb.asm.Opcodes.*
|
|
||||||
|
|
||||||
abstract class FieldCompareFinder extends BytecodeFinder {
|
|
||||||
@Nested
|
|
||||||
Map<String, Search> fields = [:] as HashMap
|
|
||||||
@Internal
|
|
||||||
Map<Search, String> fieldsReverse = [:] as HashMap
|
|
||||||
@Internal
|
|
||||||
Map<String, Set<ObjectTarget>> targets = [:] as TreeMap
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected pre() {
|
|
||||||
//fields.each{ k,v -> logger.lifecycle("Fields: " + k + ' ' + v) }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected process(ClassNode parent, MethodNode node) {
|
|
||||||
def last = null
|
|
||||||
def parentInstance = new ObjectTarget(owner: parent.name, name: '', desc: '')
|
|
||||||
for (int x = 0; x < node.instructions.size(); x++) {
|
|
||||||
def current = node.instructions.get(x)
|
|
||||||
if (current.opcode == IF_ACMPEQ || current.opcode == IF_ACMPNE) {
|
|
||||||
if (last != null && (last.opcode == GETSTATIC || last.opcode == GETFIELD)) {
|
|
||||||
def target = new Search(cls: last.owner, name: last.name)
|
|
||||||
def wanted = fieldsReverse.get(target)
|
|
||||||
def original = fields.get(wanted)
|
|
||||||
def instance = new ObjectTarget(owner: parent.name, name: node.name, desc: node.desc)
|
|
||||||
if (wanted != null && (original.blacklist == null || (!original.blacklist.contains(instance) && !original.blacklist.contains(parentInstance)))) {
|
|
||||||
targets.computeIfAbsent(wanted, { k -> new TreeSet() }).add(instance)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
last = current
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Internal
|
|
||||||
@Override
|
|
||||||
protected Object getData() {
|
|
||||||
def ret = [:] as HashMap
|
|
||||||
targets.forEach{ k, v ->
|
|
||||||
def e = fields.get(k)
|
|
||||||
ret[k] = [
|
|
||||||
cls: e.cls,
|
|
||||||
name: e.name,
|
|
||||||
replacement: e.replacement,
|
|
||||||
targets: v
|
|
||||||
]
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
@EqualsAndHashCode(excludes = ['replacement', 'blacklist'])
|
|
||||||
public static class Search {
|
|
||||||
@Input
|
|
||||||
String cls
|
|
||||||
|
|
||||||
@Input
|
|
||||||
String name
|
|
||||||
|
|
||||||
@Input
|
|
||||||
String replacement
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@Optional
|
|
||||||
Set<ObjectTarget> blacklist
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String toString() {
|
|
||||||
return cls + '.' + name
|
|
||||||
}
|
|
||||||
|
|
||||||
def blacklist(def owner, def name, def desc) {
|
|
||||||
if (blacklist == null)
|
|
||||||
blacklist = new HashSet()
|
|
||||||
blacklist.add(new ObjectTarget(owner: owner, name: name, desc: desc))
|
|
||||||
}
|
|
||||||
def blacklist(def owner) {
|
|
||||||
blacklist(owner, '', '')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def fields(Closure cl) {
|
|
||||||
new ClosureHelper(cl, {name, ccl ->
|
|
||||||
def search = ClosureHelper.apply(new Search(), ccl)
|
|
||||||
this.fields.put(name, search)
|
|
||||||
this.fieldsReverse.put(search, name)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.tasks.bundling.Zip
|
|
||||||
import org.gradle.api.tasks.*
|
|
||||||
import org.gradle.api.provider.SetProperty
|
|
||||||
|
|
||||||
abstract class InstallerJar extends Zip {
|
|
||||||
@Input @Optional abstract SetProperty<String> getPackedDependencies()
|
|
||||||
|
|
||||||
InstallerJar() {
|
|
||||||
archiveClassifier.set('installer')
|
|
||||||
archiveExtension.set('jar') // Needs to be Zip task to not override Manifest, so set extension
|
|
||||||
destinationDirectory.set(project.layout.buildDirectory.dir('libs'))
|
|
||||||
|
|
||||||
def installerJson = project.tasks.installerJson
|
|
||||||
def launcherJson = project.tasks.launcherJson
|
|
||||||
def downloadInstaller = project.tasks.downloadInstaller
|
|
||||||
|
|
||||||
dependsOn(installerJson, launcherJson, downloadInstaller)
|
|
||||||
from(installerJson, launcherJson)
|
|
||||||
|
|
||||||
from(project.rootProject.file('/src/main/resources/url.png'))
|
|
||||||
project.afterEvaluate {
|
|
||||||
from(project.zipTree(downloadInstaller.output)) {
|
|
||||||
duplicatesStrategy = 'exclude'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!System.env.MAVEN_USER) {
|
|
||||||
dependsOn(project.universalJar)
|
|
||||||
from(project.universalJar) {
|
|
||||||
into '/maven/' + project.group.replace('.', '/') + '/' + project.universalJar.archiveBaseName.get() + '/' + project.version + '/'
|
|
||||||
}
|
|
||||||
|
|
||||||
packedDependencies.get().forEach {
|
|
||||||
def jarTask = project.rootProject.getTasks().findByPath(it)
|
|
||||||
dependsOn(jarTask)
|
|
||||||
from(jarTask) {
|
|
||||||
into '/maven/' + jarTask.project.group.replace('.', '/') + '/' + jarTask.archiveBaseName.get() + '/' + jarTask.project.version + '/'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import groovy.json.JsonBuilder
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
import org.gradle.api.provider.Property
|
|
||||||
import org.gradle.api.provider.SetProperty
|
|
||||||
import org.gradle.api.tasks.*
|
|
||||||
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
abstract class InstallerJson extends DefaultTask {
|
|
||||||
@OutputFile abstract RegularFileProperty getOutput()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getInput()
|
|
||||||
@Input @Optional abstract SetProperty<String> getPackedDependencies()
|
|
||||||
@Input @Optional final Map<String, Object> libraries = new LinkedHashMap<>()
|
|
||||||
@Input Map<String, Object> json = new LinkedHashMap<>()
|
|
||||||
@InputFile abstract RegularFileProperty getIcon()
|
|
||||||
@Input abstract Property<String> getLauncherJsonName()
|
|
||||||
@Input abstract Property<String> getLogo()
|
|
||||||
@Input abstract Property<String> getMirrors()
|
|
||||||
@Input abstract Property<String> getWelcome()
|
|
||||||
|
|
||||||
InstallerJson() {
|
|
||||||
getLauncherJsonName().convention('/version.json')
|
|
||||||
getLogo().convention('/big_logo.png')
|
|
||||||
getMirrors().convention('https://files.minecraftforge.net/mirrors-2.0.json')
|
|
||||||
getWelcome().convention("Welcome to the simple ${project.name.capitalize()} installer.")
|
|
||||||
|
|
||||||
getOutput().convention(project.layout.buildDirectory.file('install_profile.json'))
|
|
||||||
|
|
||||||
['client', 'server'].each { side ->
|
|
||||||
['slim', 'extra'].each { type ->
|
|
||||||
def tsk = project.tasks.getByName("download${side.capitalize()}${type.capitalize()}")
|
|
||||||
dependsOn(tsk)
|
|
||||||
input.from(tsk.output)
|
|
||||||
}
|
|
||||||
def tsk = project.tasks.getByName("create${side.capitalize()}SRG")
|
|
||||||
dependsOn(tsk)
|
|
||||||
input.from(tsk.output)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
project.afterEvaluate {
|
|
||||||
(packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) } + [project.universalJar]).forEach {
|
|
||||||
dependsOn(it)
|
|
||||||
input.from it.archiveFile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
def libs = libraries
|
|
||||||
for (def child : packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) } + [project.universalJar]) {
|
|
||||||
def dep = Util.getMavenDep(child)
|
|
||||||
def path = Util.getMavenPath(child)
|
|
||||||
libs.put(dep.toString(), [
|
|
||||||
name: dep,
|
|
||||||
downloads: [
|
|
||||||
artifact: [
|
|
||||||
path: path,
|
|
||||||
url: "https://maven.minecraftforge.net/${path}",
|
|
||||||
sha1: child.archiveFile.get().asFile.sha1(),
|
|
||||||
size: child.archiveFile.get().asFile.length()
|
|
||||||
]
|
|
||||||
]
|
|
||||||
])
|
|
||||||
}
|
|
||||||
json.libraries = libs.values().sort{a,b -> a.name.compareTo(b.name)}
|
|
||||||
json.icon = "data:image/png;base64," + new String(Base64.getEncoder().encode(Files.readAllBytes(icon.get().asFile.toPath())))
|
|
||||||
json.json = launcherJsonName.get()
|
|
||||||
json.logo = logo.get()
|
|
||||||
if (!mirrors.get().isEmpty())
|
|
||||||
json.mirrorList = mirrors.get()
|
|
||||||
json.welcome = welcome.get()
|
|
||||||
|
|
||||||
Files.writeString(output.get().getAsFile().toPath(), new JsonBuilder(json).toPrettyString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import groovy.json.JsonBuilder
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
import org.gradle.api.provider.SetProperty
|
|
||||||
import org.gradle.api.tasks.*
|
|
||||||
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
import static net.minecraftforge.forge.tasks.Util.getArtifacts
|
|
||||||
import static net.minecraftforge.forge.tasks.Util.iso8601Now
|
|
||||||
|
|
||||||
abstract class LauncherJson extends DefaultTask {
|
|
||||||
@OutputFile abstract RegularFileProperty getOutput()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getInput()
|
|
||||||
@Input Map<String, Object> json = new LinkedHashMap<>()
|
|
||||||
@Input @Optional abstract SetProperty<String> getPackedDependencies()
|
|
||||||
|
|
||||||
@Internal final vanilla = project.project(':mcp').file('build/mcp/downloadJson/version.json')
|
|
||||||
@Internal final timestamp = iso8601Now()
|
|
||||||
@Internal final comment = [
|
|
||||||
"Please do not automate the download and installation of Forge.",
|
|
||||||
"Our efforts are supported by ads from the download page.",
|
|
||||||
"If you MUST automate this, please consider supporting the project through https://www.patreon.com/LexManos/"
|
|
||||||
]
|
|
||||||
@Internal final id = "${project.rootProject.ext.MC_VERSION}-${project.name}${project.version.substring(project.rootProject.ext.MC_VERSION.length())}"
|
|
||||||
|
|
||||||
LauncherJson() {
|
|
||||||
getOutput().convention(project.layout.buildDirectory.file('version.json'))
|
|
||||||
|
|
||||||
dependsOn(':fmlloader:jar', 'universalJar')
|
|
||||||
getInput().from(project.tasks.universalJar.archiveFile,
|
|
||||||
project.project(':fmlloader').jar.archiveFile,
|
|
||||||
vanilla)
|
|
||||||
|
|
||||||
project.afterEvaluate {
|
|
||||||
packedDependencies.get().forEach {
|
|
||||||
def jarTask = project.rootProject.tasks.findByPath(it)
|
|
||||||
dependsOn(jarTask)
|
|
||||||
input.from jarTask.archiveFile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
if (!json.libraries)
|
|
||||||
json.libraries = []
|
|
||||||
getArtifacts(project, project.configurations.installer, false).each { key, lib -> json.libraries.add(lib) }
|
|
||||||
getArtifacts(project, project.configurations.moduleonly, false).each { key, lib -> json.libraries.add(lib) }
|
|
||||||
|
|
||||||
packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) }.forEach {
|
|
||||||
def path = Util.getMavenPath(it)
|
|
||||||
|
|
||||||
json.libraries.add([
|
|
||||||
name: Util.getMavenDep(it),
|
|
||||||
downloads: [
|
|
||||||
artifact: [
|
|
||||||
path: path,
|
|
||||||
url: "https://maven.minecraftforge.net/${path}",
|
|
||||||
sha1: it.archiveFile.get().asFile.sha1(),
|
|
||||||
size: it.archiveFile.get().asFile.length()
|
|
||||||
]
|
|
||||||
]
|
|
||||||
])
|
|
||||||
}
|
|
||||||
Files.writeString(output.get().asFile.toPath(), new JsonBuilder(json).toPrettyString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import groovy.transform.EqualsAndHashCode
|
|
||||||
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.Nested
|
|
||||||
import org.gradle.api.tasks.Optional
|
|
||||||
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public class ObjectTarget implements Comparable<ObjectTarget> {
|
|
||||||
@Input
|
|
||||||
String owner
|
|
||||||
|
|
||||||
@Input
|
|
||||||
String name
|
|
||||||
|
|
||||||
@Input
|
|
||||||
@Optional
|
|
||||||
String desc
|
|
||||||
|
|
||||||
@Override
|
|
||||||
String toString() {
|
|
||||||
if (desc == null)
|
|
||||||
return owner + '.' + name
|
|
||||||
return owner + '.' + name + desc
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
int compareTo(ObjectTarget o) {
|
|
||||||
return toString().compareTo(o.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import groovy.json.JsonSlurper
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import java.security.MessageDigest
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
public class Util {
|
|
||||||
static void init() {
|
|
||||||
File.metaClass.sha1 = { ->
|
|
||||||
MessageDigest md = MessageDigest.getInstance('SHA-1')
|
|
||||||
delegate.eachByte 4096, {bytes, size ->
|
|
||||||
md.update(bytes, 0, size)
|
|
||||||
}
|
|
||||||
return md.digest().collect {String.format "%02x", it}.join()
|
|
||||||
}
|
|
||||||
|
|
||||||
File.metaClass.json = { -> new JsonSlurper().parseText(delegate.text) }
|
|
||||||
|
|
||||||
Date.metaClass.iso8601 = { ->
|
|
||||||
def format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
|
|
||||||
def result = format.format(delegate)
|
|
||||||
return result[0..21] + ':' + result[22..-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
String.metaClass.rsplit = { String del, int limit = -1 ->
|
|
||||||
def lst = new ArrayList()
|
|
||||||
def x = 0, idx
|
|
||||||
def tmp = delegate
|
|
||||||
while ((idx = tmp.lastIndexOf(del)) != -1 && (limit == -1 || x++ < limit)) {
|
|
||||||
lst.add(0, tmp.substring(idx + del.length(), tmp.length()))
|
|
||||||
tmp = tmp.substring(0, idx)
|
|
||||||
}
|
|
||||||
lst.add(0, tmp)
|
|
||||||
return lst
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getClasspath(project, libs, artifact) {
|
|
||||||
def ret = []
|
|
||||||
artifactTree(project, artifact).each { key, lib ->
|
|
||||||
libs[lib.name] = lib
|
|
||||||
if (lib.name != artifact)
|
|
||||||
ret.add(lib.name)
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
public static def getArtifacts(project, config, classifiers) {
|
|
||||||
def ret = [:]
|
|
||||||
config.resolvedConfiguration.resolvedArtifacts.each {
|
|
||||||
def art = [
|
|
||||||
group: it.moduleVersion.id.group,
|
|
||||||
name: it.moduleVersion.id.name,
|
|
||||||
version: it.moduleVersion.id.version,
|
|
||||||
classifier: it.classifier,
|
|
||||||
extension: it.extension,
|
|
||||||
file: it.file
|
|
||||||
]
|
|
||||||
def key = art.group + ':' + art.name
|
|
||||||
def folder = "${art.group.replace('.', '/')}/${art.name}/${art.version}/"
|
|
||||||
def filename = "${art.name}-${art.version}"
|
|
||||||
if (art.classifier != null)
|
|
||||||
filename += "-${art.classifier}"
|
|
||||||
filename += ".${art.extension}"
|
|
||||||
def path = "${folder}${filename}"
|
|
||||||
def url = "https://libraries.minecraft.net/${path}"
|
|
||||||
if (!checkExists(url)) {
|
|
||||||
url = "https://maven.minecraftforge.net/${path}"
|
|
||||||
}
|
|
||||||
//TODO remove when Mojang launcher is updated
|
|
||||||
if (!classifiers && art.classifier != null) {
|
|
||||||
//Mojang launcher doesn't currently support classifiers, so... move it to part of the version, and force the extension to 'jar'
|
|
||||||
// However, keep the path normal so that our mirror system works.
|
|
||||||
art.version = "${art.version}-${art.classifier}"
|
|
||||||
art.classifier = null
|
|
||||||
art.extension = 'jar'
|
|
||||||
}
|
|
||||||
ret[key] = [
|
|
||||||
name: "${art.group}:${art.name}:${art.version}" + (art.classifier == null ? '' : ":${art.classifier}") + (art.extension == 'jar' ? '' : "@${art.extension}"),
|
|
||||||
downloads: [
|
|
||||||
artifact: [
|
|
||||||
path: path,
|
|
||||||
url: url,
|
|
||||||
sha1: sha1(art.file),
|
|
||||||
size: art.file.length()
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
public static def getMavenPath(task) {
|
|
||||||
def classifier = task.archiveClassifier.get()
|
|
||||||
def dep = "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
|
||||||
return "${task.project.group.replace('.', '/')}/${task.project.name}/${task.project.version}/${task.project.name}-${task.project.version}".toString() + (classifier == '' ? '' : '-' + classifier) + '.jar'
|
|
||||||
}
|
|
||||||
|
|
||||||
public static def getMavenDep(task) {
|
|
||||||
def classifier = task.archiveClassifier.get()
|
|
||||||
return "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
|
||||||
}
|
|
||||||
|
|
||||||
public static def iso8601Now() { new Date().iso8601() }
|
|
||||||
|
|
||||||
public static def sha1(file) {
|
|
||||||
MessageDigest md = MessageDigest.getInstance('SHA-1')
|
|
||||||
file.eachByte 4096, {bytes, size ->
|
|
||||||
md.update(bytes, 0, size)
|
|
||||||
}
|
|
||||||
return md.digest().collect {String.format "%02x", it}.join()
|
|
||||||
}
|
|
||||||
|
|
||||||
private static def artifactTree(project, artifact) {
|
|
||||||
if (!project.ext.has('tree_resolver'))
|
|
||||||
project.ext.tree_resolver = 1
|
|
||||||
def cfg = project.configurations.create('tree_resolver_' + project.ext.tree_resolver++)
|
|
||||||
def dep = project.dependencies.create(artifact)
|
|
||||||
cfg.dependencies.add(dep)
|
|
||||||
def files = cfg.resolve()
|
|
||||||
return getArtifacts(project, cfg, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean checkExists(url) {
|
|
||||||
try {
|
|
||||||
def code = new URL(url).openConnection().with {
|
|
||||||
requestMethod = 'HEAD'
|
|
||||||
connect()
|
|
||||||
responseCode
|
|
||||||
}
|
|
||||||
return code == 200
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (e.toString().contains('unable to find valid certification path to requested target'))
|
|
||||||
throw new RuntimeException('Failed to connect to ' + url + ': Missing certificate root authority, try updating java')
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+7
-7
@@ -1,17 +1,17 @@
|
|||||||

|
<img src="assets/Forge_logo.svg">
|
||||||
|
|
||||||
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) [](https://forgedev.flocker.tv/)
|
||||||
|
|
||||||
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.16.x | Active |
|
| 1.14.x | Active |
|
||||||
| 1.15.x | LTS |
|
| 1.12.x | Legacy |
|
||||||
|
|
||||||
* [Download]
|
* [Download]
|
||||||
* [Forum]
|
* [Forum]
|
||||||
@@ -60,7 +60,7 @@ We require all contributors to acknowledge the [Forge Contributor
|
|||||||
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) or buying some [cool merch](https://forgedev.flocker.tv/).*
|
||||||
|
|
||||||
[Download]: https://files.minecraftforge.net/
|
[Download]: https://files.minecraftforge.net/
|
||||||
[Forum]: https://www.minecraftforge.net/forum/
|
[Forum]: https://www.minecraftforge.net/forum/
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'com.github.ben-manes.versions'
|
|
||||||
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
|
||||||
}
|
|
||||||
apply plugin: 'java-library'
|
|
||||||
apply plugin: 'jacoco'
|
|
||||||
apply plugin: 'org.javamodularity.moduleplugin'
|
|
||||||
|
|
||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compileOnly('org.jetbrains:annotations:21.0.1')
|
|
||||||
implementation(project(':fmlloader'))
|
|
||||||
api('net.minecraftforge:eventbus:5.0.+')
|
|
||||||
implementation('commons-io:commons-io:2.5')
|
|
||||||
}
|
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
|
||||||
archiveClassifier = 'sources'
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
ext {
|
|
||||||
MANIFESTS = [
|
|
||||||
'': [
|
|
||||||
'FMLModType': 'LIBRARY',
|
|
||||||
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
||||||
'Git-Commit': GIT_INFO.abbreviatedId,
|
|
||||||
'Git-Branch': GIT_INFO.branch,
|
|
||||||
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}"
|
|
||||||
] as LinkedHashMap,
|
|
||||||
'net/minecraftforge/fml/loading/': [
|
|
||||||
'Specification-Title': 'FMLLoader',
|
|
||||||
'Specification-Vendor': 'Forge Development LLC',
|
|
||||||
'Specification-Version': '1',
|
|
||||||
'Implementation-Title': 'FML Loader',
|
|
||||||
'Implementation-Version': '1.0',
|
|
||||||
'Implementation-Vendor': 'Forge'
|
|
||||||
] as LinkedHashMap
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
jar.doFirst {
|
|
||||||
MANIFESTS.each { pkg, values ->
|
|
||||||
if (pkg == '')
|
|
||||||
manifest.attributes(values)
|
|
||||||
else
|
|
||||||
manifest.attributes(values, pkg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.compilerArgs << '-Xlint:unchecked'
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives jar
|
|
||||||
archives sourcesJar
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing.publications.mavenJava(MavenPublication) {
|
|
||||||
from components.java
|
|
||||||
artifact sourcesJar
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
|
||||||
import net.minecraftforge.eventbus.api.BusBuilder;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.fml.config.IConfigEvent;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
|
|
||||||
import java.util.ServiceLoader;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class Bindings {
|
|
||||||
private static final Bindings INSTANCE = new Bindings();
|
|
||||||
|
|
||||||
private final IBindingsProvider provider;
|
|
||||||
|
|
||||||
private Bindings() {
|
|
||||||
final var providers = ServiceLoaderUtils.streamServiceLoader(()->ServiceLoader.load(FMLLoader.getGameLayer(), IBindingsProvider.class), sce->{}).toList();
|
|
||||||
if (providers.size() != 1) {
|
|
||||||
throw new IllegalStateException("Could not find bindings provider");
|
|
||||||
}
|
|
||||||
this.provider = providers.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Supplier<IEventBus> getForgeBus() {
|
|
||||||
return INSTANCE.provider.getForgeBusSupplier();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Supplier<I18NParser> getMessageParser() {
|
|
||||||
return INSTANCE.provider.getMessageParser();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Supplier<IConfigEvent.ConfigConfig> getConfigConfiguration() {
|
|
||||||
return INSTANCE.provider.getConfigConfiguration();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class CrashReportCallables {
|
|
||||||
private static final List<ISystemReportExtender> crashCallables = Collections.synchronizedList(new ArrayList<>());
|
|
||||||
|
|
||||||
public static void registerCrashCallable(ISystemReportExtender callable)
|
|
||||||
{
|
|
||||||
crashCallables.add(callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerCrashCallable(String headerName, Supplier<String> reportGenerator) {
|
|
||||||
registerCrashCallable(new ISystemReportExtender() {
|
|
||||||
@Override
|
|
||||||
public String getLabel() {
|
|
||||||
return headerName;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String get() {
|
|
||||||
return reportGenerator.get();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ISystemReportExtender> allCrashCallables() {
|
|
||||||
return List.copyOf(crashCallables);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.Logging.LOADING;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility for running code on the main launch thread at the next available
|
|
||||||
* opportunity. There is no guaranteed order that work from various mods will be
|
|
||||||
* run, but your own work will be run sequentially.
|
|
||||||
* <p>
|
|
||||||
* <strong>Use of this class after startup is not possible.</strong> At that
|
|
||||||
* point, {@link IThreadListener} should be used instead.
|
|
||||||
* <p>
|
|
||||||
* Exceptions from tasks will be handled gracefully, causing a mod loading
|
|
||||||
* error. Tasks that take egregiously long times to run will be logged.
|
|
||||||
*/
|
|
||||||
public class DeferredWorkQueue
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
private static final Map<ModLoadingStage, DeferredWorkQueue> workQueues = new HashMap<>();
|
|
||||||
|
|
||||||
private final ConcurrentLinkedDeque<TaskInfo> tasks = new ConcurrentLinkedDeque<>();
|
|
||||||
private final ModLoadingStage modLoadingStage;
|
|
||||||
|
|
||||||
public DeferredWorkQueue(ModLoadingStage modLoadingStage) {
|
|
||||||
this.modLoadingStage = modLoadingStage;
|
|
||||||
workQueues.put(modLoadingStage, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
|
||||||
public static Optional<DeferredWorkQueue> lookup(Optional<ModLoadingStage> parallelClass) {
|
|
||||||
return Optional.ofNullable(workQueues.get(parallelClass.orElse(null)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runTasks() {
|
|
||||||
if (tasks.isEmpty()) return;
|
|
||||||
LOGGER.debug(LOADING, "Dispatching synchronous work for work queue {}: {} jobs", modLoadingStage, tasks.size());
|
|
||||||
Stopwatch timer = Stopwatch.createStarted();
|
|
||||||
tasks.forEach(t->makeRunnable(t, Runnable::run));
|
|
||||||
timer.stop();
|
|
||||||
LOGGER.debug(LOADING, "Synchronous work queue completed in {}", timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void makeRunnable(TaskInfo ti, Executor executor) {
|
|
||||||
executor.execute(() -> {
|
|
||||||
Stopwatch timer = Stopwatch.createStarted();
|
|
||||||
ti.task.run();
|
|
||||||
timer.stop();
|
|
||||||
if (timer.elapsed(TimeUnit.SECONDS) >= 1) {
|
|
||||||
LOGGER.warn(LOADING, "Mod '{}' took {} to run a deferred task.", ti.owner.getModId(), timer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletableFuture<Void> enqueueWork(final IModInfo modInfo, final Runnable work) {
|
|
||||||
return CompletableFuture.runAsync(work, r->tasks.add(new TaskInfo(modInfo, r)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> CompletableFuture<T> enqueueWork(final IModInfo modInfo, final Supplier<T> work) {
|
|
||||||
return CompletableFuture.supplyAsync(work, r->tasks.add(new TaskInfo(modInfo, r)));
|
|
||||||
}
|
|
||||||
|
|
||||||
record TaskInfo(IModInfo owner, Runnable task) {}
|
|
||||||
}
|
|
||||||
@@ -1,276 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.invoke.SerializedLambda;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use to execute code conditionally based on sidedness.
|
|
||||||
* <ul>
|
|
||||||
* <li>When you want to call something on one side and return a result {@link #safeCallWhenOn(Dist, Supplier)}</li>
|
|
||||||
* <li>When you want to call one thing on one side, another thing on the other and return a result {@link #safeRunForDist(Supplier, Supplier)}</li>
|
|
||||||
* <li>When you want to run something on one side {@link #safeRunWhenOn(Dist, Supplier)}</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public final class DistExecutor
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private DistExecutor() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the callable in the supplier only on the specified {@link Side}.
|
|
||||||
* This method is NOT sided-safe and special care needs to be taken in code using this method that implicit class
|
|
||||||
* loading is not triggered by the Callable.
|
|
||||||
*
|
|
||||||
* This method can cause unexpected ClassNotFound exceptions.
|
|
||||||
*
|
|
||||||
* Use {@link #safeCallWhenOn(Dist, Supplier)} where possible.
|
|
||||||
*
|
|
||||||
* @param dist The dist to run on
|
|
||||||
* @param toRun A supplier of the callable to run (Supplier wrapper to ensure classloading only on the appropriate dist)
|
|
||||||
* @param <T> The return type from the callable
|
|
||||||
* @return The callable's result
|
|
||||||
* @deprecated use {@link #safeCallWhenOn(Dist, Supplier)} instead. This remains for advanced use cases.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static <T> T callWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
|
|
||||||
return unsafeCallWhenOn(dist, toRun);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T unsafeCallWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
|
|
||||||
if (dist == FMLEnvironment.dist) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return toRun.get().call();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call the SafeCallable when on the correct {@link Dist}.
|
|
||||||
*
|
|
||||||
* <strong>The lambda supplied here is required to be a method reference to a method defined in
|
|
||||||
* another class, otherwise an invalid SafeReferent error will be thrown</strong>
|
|
||||||
* @param dist the dist which this will run on
|
|
||||||
* @param toRun the SafeCallable to run and return the result from
|
|
||||||
* @param <T> The type of the SafeCallable
|
|
||||||
* @return the result of the SafeCallable or null if on the wrong side
|
|
||||||
*/
|
|
||||||
public static <T> T safeCallWhenOn(Dist dist, Supplier<SafeCallable<T>> toRun) {
|
|
||||||
validateSafeReferent(toRun);
|
|
||||||
return callWhenOn(dist, toRun::get);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs the supplied Runnable on the speicified side. Same warnings apply as {@link #callWhenOn(Dist, Supplier)}.
|
|
||||||
*
|
|
||||||
* This method can cause unexpected ClassNotFound exceptions.
|
|
||||||
*
|
|
||||||
* @see #callWhenOn(Dist, Supplier)
|
|
||||||
* @param dist Dist to run this code on
|
|
||||||
* @param toRun The code to run
|
|
||||||
* @deprecated use {@link #safeRunWhenOn(Dist, Supplier)} where possible. Advanced uses only.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void runWhenOn(Dist dist, Supplier<Runnable> toRun) {
|
|
||||||
unsafeRunWhenOn(dist, toRun);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Runs the supplied Runnable on the speicified side. Same warnings apply as {@link #unsafeCallWhenOn(Dist, Supplier)}.
|
|
||||||
*
|
|
||||||
* This method can cause unexpected ClassNotFoundException problems in common scenarios. Understand the pitfalls of
|
|
||||||
* the way the class verifier works to load classes before using this.
|
|
||||||
*
|
|
||||||
* Use {@link #safeRunWhenOn(Dist, Supplier)} if you can.
|
|
||||||
*
|
|
||||||
* @see #unsafeCallWhenOn(Dist, Supplier)
|
|
||||||
* @param dist Dist to run this code on
|
|
||||||
* @param toRun The code to run
|
|
||||||
*/
|
|
||||||
public static void unsafeRunWhenOn(Dist dist, Supplier<Runnable> toRun) {
|
|
||||||
if (dist == FMLEnvironment.dist) {
|
|
||||||
toRun.get().run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call the supplied SafeRunnable when on the correct Dist.
|
|
||||||
* @param dist The dist to run on
|
|
||||||
* @param toRun The code to run
|
|
||||||
*/
|
|
||||||
public static void safeRunWhenOn(Dist dist, Supplier<SafeRunnable> toRun) {
|
|
||||||
validateSafeReferent(toRun);
|
|
||||||
if (dist == FMLEnvironment.dist) {
|
|
||||||
toRun.get().run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Executes one of the two suppliers, based on which side is active.
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Example (replacement for old SidedProxy):<br/>
|
|
||||||
* {@code Proxy p = DistExecutor.runForDist(()->ClientProxy::new, ()->ServerProxy::new);}
|
|
||||||
*
|
|
||||||
* NOTE: the double supplier is required to avoid classloading the secondary target.
|
|
||||||
*
|
|
||||||
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
|
||||||
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
|
||||||
* @param <T> The common type to return
|
|
||||||
* @return The returned instance
|
|
||||||
* @deprecated Use {@link #safeRunForDist(Supplier, Supplier)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static <T> T runForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
|
|
||||||
return unsafeRunForDist(clientTarget, serverTarget);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsafe version of {@link #safeRunForDist(Supplier, Supplier)}. Use only when you know what you're doing
|
|
||||||
* and understand why the verifier can cause unexpected ClassNotFoundException crashes even when code is apparently
|
|
||||||
* not sided. Ensure you test both sides fully to be confident in using this.
|
|
||||||
*
|
|
||||||
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
|
||||||
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
|
||||||
* @param <T> The common type to return
|
|
||||||
* @return The returned instance
|
|
||||||
*/
|
|
||||||
public static <T> T unsafeRunForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
|
|
||||||
switch (FMLEnvironment.dist)
|
|
||||||
{
|
|
||||||
case CLIENT:
|
|
||||||
return clientTarget.get().get();
|
|
||||||
case DEDICATED_SERVER:
|
|
||||||
return serverTarget.get().get();
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("UNSIDED?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Executes one of the two suppliers, based on which side is active.
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Example (replacement for old SidedProxy):<br/>
|
|
||||||
* {@code Proxy p = DistExecutor.safeRunForDist(()->ClientProxy::new, ()->ServerProxy::new);}
|
|
||||||
*
|
|
||||||
* NOTE: the double supplier is required to avoid classloading the secondary target.
|
|
||||||
*
|
|
||||||
* @param clientTarget The supplier supplier to run when on the {@link Dist#CLIENT}
|
|
||||||
* @param serverTarget The supplier supplier to run when on the {@link Dist#DEDICATED_SERVER}
|
|
||||||
* @param <T> The common type to return
|
|
||||||
* @return The returned instance
|
|
||||||
*/
|
|
||||||
public static <T> T safeRunForDist(Supplier<SafeSupplier<T>> clientTarget, Supplier<SafeSupplier<T>> serverTarget) {
|
|
||||||
validateSafeReferent(clientTarget);
|
|
||||||
validateSafeReferent(serverTarget);
|
|
||||||
switch (FMLEnvironment.dist)
|
|
||||||
{
|
|
||||||
case CLIENT:
|
|
||||||
return clientTarget.get().get();
|
|
||||||
case DEDICATED_SERVER:
|
|
||||||
return serverTarget.get().get();
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("UNSIDED?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A safe referent. This will assert that it is being called via a separated class method reference. This will
|
|
||||||
* avoid the common pitfalls of {@link #callWhenOn(Dist, Supplier)} above.
|
|
||||||
*
|
|
||||||
* SafeReferents assert that they are defined as a separate method outside the scope of the calling class.
|
|
||||||
*
|
|
||||||
* <strong>Implementations need to be defined in a separate class to the referring site, with appropriate
|
|
||||||
* visibility to be accessible at the callsite (generally, avoid private methods).</strong>
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Valid:<br/>
|
|
||||||
*
|
|
||||||
* {@code DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->AnotherClass::clientOnlyMethod);}
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Invalid:<br/>
|
|
||||||
*
|
|
||||||
* {@code DistExecutor.safeCallWhenOn(Dist.CLIENT, ()->()->Minecraft.getInstance().world);}
|
|
||||||
*/
|
|
||||||
public interface SafeReferent {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SafeCallable version of {@link SafeReferent}.
|
|
||||||
* @see SafeReferent
|
|
||||||
* @param <T> The return type of the Callable
|
|
||||||
*/
|
|
||||||
public interface SafeCallable<T> extends SafeReferent, Callable<T>, Serializable {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SafeSupplier version of {@link SafeReferent}
|
|
||||||
* @param <T> The return type of the Supplier
|
|
||||||
*/
|
|
||||||
public interface SafeSupplier<T> extends SafeReferent, Supplier<T>, Serializable {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SafeRunnable version of {@link SafeReferent}
|
|
||||||
*/
|
|
||||||
public interface SafeRunnable extends SafeReferent, Runnable, Serializable {}
|
|
||||||
|
|
||||||
private static final void validateSafeReferent(Supplier<? extends SafeReferent> safeReferentSupplier) {
|
|
||||||
if (FMLEnvironment.production) return;
|
|
||||||
final SafeReferent setter;
|
|
||||||
try {
|
|
||||||
setter = safeReferentSupplier.get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Typically a class cast exception, just return out, expected.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Class<?> cl = setter.getClass(); cl != null; cl = cl.getSuperclass()) {
|
|
||||||
try {
|
|
||||||
Method m = cl.getDeclaredMethod("writeReplace");
|
|
||||||
m.setAccessible(true);
|
|
||||||
Object replacement = m.invoke(setter);
|
|
||||||
if (!(replacement instanceof SerializedLambda))
|
|
||||||
break;// custom interface implementation
|
|
||||||
SerializedLambda l = (SerializedLambda) replacement;
|
|
||||||
if (Objects.equals(l.getCapturingClass(), l.getImplClass())) {
|
|
||||||
LOGGER.fatal("Detected unsafe referent usage, please view the code at {}",Thread.currentThread().getStackTrace()[3]);
|
|
||||||
throw new RuntimeException("Unsafe Referent usage found in safe referent method");
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
public interface I18NParser {
|
|
||||||
String parseMessage(String i18nMessage, Object... args);
|
|
||||||
String stripControlCodes(String toStrip);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.fml.config.IConfigEvent;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public interface IBindingsProvider {
|
|
||||||
Supplier<IEventBus> getForgeBusSupplier();
|
|
||||||
Supplier<I18NParser> getMessageParser();
|
|
||||||
Supplier<IConfigEvent.ConfigConfig> getConfigConfiguration();
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public interface IExtensionPoint<T extends Record>
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Compatibility display test for the mod.
|
|
||||||
* 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 network or writing to disk
|
|
||||||
* The predicate tests the version from a remote instance or save for acceptability (Boolean is true for network, false for local save)
|
|
||||||
* and returns true if the version is compatible.
|
|
||||||
*
|
|
||||||
* <p>Return {@link net.minecraftforge.fml.network.FMLNetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored
|
|
||||||
* as a server side only mod.</p>
|
|
||||||
* <p>Return true in the predicate for all values of the input string (when network boolean is true) if you are client side,
|
|
||||||
* and don't care about matching any potential server version.</p>
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Examples: A server only mod
|
|
||||||
*
|
|
||||||
* <code><pre>
|
|
||||||
* registerExtensionPoint(DISPLAYTEST, ()->Pair.of(
|
|
||||||
* ()->FMLNetworkConstants.IGNORESERVERONLY, // ignore me, I'm a server only mod
|
|
||||||
* (s,b)->true // i accept anything from the server or the save, if I'm asked
|
|
||||||
* )
|
|
||||||
* </pre></code>
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* Examples: A client only mod
|
|
||||||
* <code><pre>
|
|
||||||
* registerExtensionPoint(DISPLAYTEST, ()->Pair.of(
|
|
||||||
* ()->"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
|
|
||||||
* (remoteversionstring,networkbool)->networkbool // i accept anything from the server, by returning true if it's asking about the server
|
|
||||||
* )
|
|
||||||
* </pre></code>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
record DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) implements IExtensionPoint<DisplayTest> {}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public interface IModLoadingState {
|
|
||||||
String name();
|
|
||||||
String previous();
|
|
||||||
ModLoadingPhase phase();
|
|
||||||
Function<ModList, String> message();
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
<T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(Executor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask);
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IModStateProvider {
|
|
||||||
List<IModLoadingState> getAllStates();
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public interface IModStateTransition {
|
|
||||||
static IModStateTransition buildNoopTransition() {
|
|
||||||
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) {
|
|
||||||
List<CompletableFuture<List<Throwable>>> cfs = new ArrayList<>();
|
|
||||||
this.eventFunctionStream().get()
|
|
||||||
.map(f->(EventGenerator<T>)f)
|
|
||||||
.reduce((head, tail)-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, head, ModLoadingStage::currentState, tail))
|
|
||||||
.ifPresent(last-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, last, nextModLoadingStage(), null));
|
|
||||||
final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor);
|
|
||||||
final CompletableFuture<List<Throwable>> eventDispatchCF = ModList.gather(cfs).thenCompose(ModList::completableFutureFromExceptionList);
|
|
||||||
final CompletableFuture<List<Throwable>> postEventDispatchCF = preSyncTaskCF.thenComposeAsync(n -> eventDispatchCF, parallelExecutor).thenApply(r -> {
|
|
||||||
postSyncTask.apply(syncExecutor);
|
|
||||||
return r;
|
|
||||||
});
|
|
||||||
return this.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF);
|
|
||||||
}
|
|
||||||
|
|
||||||
default BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextModLoadingStage() {
|
|
||||||
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) {
|
|
||||||
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)preDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator));
|
|
||||||
completeableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector().apply(syncExecutor, parallelExecutor)));
|
|
||||||
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)postDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator));
|
|
||||||
return nextGenerator;
|
|
||||||
}
|
|
||||||
|
|
||||||
Supplier<Stream<EventGenerator<?>>> eventFunctionStream();
|
|
||||||
ThreadSelector threadSelector();
|
|
||||||
BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator();
|
|
||||||
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook();
|
|
||||||
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook();
|
|
||||||
|
|
||||||
interface EventGenerator<T extends Event & IModBusEvent> extends Function<ModContainer, T> {
|
|
||||||
static <FN extends Event & IModBusEvent> EventGenerator<FN> fromFunction(Function<ModContainer, FN> fn) {
|
|
||||||
return fn::apply;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
record NoopTransition() implements IModStateTransition {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Supplier<Stream<EventGenerator<?>>> eventFunctionStream() {
|
|
||||||
return Stream::of;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ThreadSelector threadSelector() {
|
|
||||||
return ThreadSelector.SYNC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator() {
|
|
||||||
return (e, t) -> t.thenApplyAsync(Function.identity(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook() {
|
|
||||||
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook() {
|
|
||||||
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,333 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.LoadingModList;
|
|
||||||
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.progress.StartupMessageManager;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.CompletionException;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.Logging.CORE;
|
|
||||||
import static net.minecraftforge.fml.Logging.LOADING;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads mods.
|
|
||||||
*
|
|
||||||
* Dispatch cycle is seen in {@link #loadMods()} and {@link #finishMods()}
|
|
||||||
*
|
|
||||||
* Overall sequence for loadMods is:
|
|
||||||
* <dl>
|
|
||||||
* <dt>CONSTRUCT</dt>
|
|
||||||
* <dd>Constructs the mod instance. Mods can typically setup basic environment such as Event listeners
|
|
||||||
* and Configuration specifications here.</dd>
|
|
||||||
* <dt>Automated dispatches</dt>
|
|
||||||
* <dd>Dispatches automated elements : {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber},
|
|
||||||
* {@link net.minecraftforge.event.RegistryEvent}, {@link net.minecraftforge.common.capabilities.CapabilityInject}
|
|
||||||
* and others</dd>
|
|
||||||
* <dt>CONFIG_LOAD</dt>
|
|
||||||
* <dd>Dispatches ConfigLoadEvent to mods</dd>
|
|
||||||
* <dt>COMMON_SETUP</dt>
|
|
||||||
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent} to mods</dd>
|
|
||||||
* <dt>SIDED_SETUP</dt>
|
|
||||||
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent} or
|
|
||||||
* {@link net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent} to mods</dd>
|
|
||||||
* </dl>
|
|
||||||
*
|
|
||||||
* Overall sequence for finishMods is:
|
|
||||||
* <dl>
|
|
||||||
* <dt>ENQUEUE_IMC</dt>
|
|
||||||
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent} to mods,
|
|
||||||
* for enqueuing {@link InterModComms} messages for other mods to receive subsequently</dd>
|
|
||||||
* <dt>PROCESS_IMC</dt>
|
|
||||||
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.InterModProcessEvent} to mods,
|
|
||||||
* for processing {@link InterModComms} messages received from other mods prior to this event</dd>
|
|
||||||
* <dt>COMPLETE</dt>
|
|
||||||
* <dd>Dispatches {@link net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent} to mods,
|
|
||||||
* and completes the mod loading sequence.</dd>
|
|
||||||
* </dl>
|
|
||||||
*/
|
|
||||||
public class ModLoader
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private static ModLoader INSTANCE;
|
|
||||||
private final LoadingModList loadingModList;
|
|
||||||
|
|
||||||
private final List<ModLoadingException> loadingExceptions;
|
|
||||||
private final List<ModLoadingWarning> loadingWarnings;
|
|
||||||
private final ModStateManager stateManager;
|
|
||||||
private boolean loadingStateValid;
|
|
||||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
|
||||||
private final Optional<Consumer<String>> statusConsumer = StartupMessageManager.modLoaderConsumer();
|
|
||||||
private ModList modList;
|
|
||||||
|
|
||||||
private ModLoader()
|
|
||||||
{
|
|
||||||
INSTANCE = this;
|
|
||||||
this.loadingModList = FMLLoader.getLoadingModList();
|
|
||||||
this.loadingExceptions = FMLLoader.getLoadingModList().getErrors().stream()
|
|
||||||
.flatMap(ModLoadingException::fromEarlyException)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
this.loadingWarnings = FMLLoader.getLoadingModList().getBrokenFiles().stream()
|
|
||||||
.map(file -> new ModLoadingWarning(null, ModLoadingStage.VALIDATE, InvalidModIdentifier.identifyJarProblem(file.getFilePath()).orElse("fml.modloading.brokenfile"), file.getFileName()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
FMLLoader.getLoadingModList().getModFiles().stream()
|
|
||||||
.filter(ModFileInfo::missingLicense) //Search for files with missing licenses
|
|
||||||
.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()))
|
|
||||||
.forEach(this.loadingExceptions::add);
|
|
||||||
this.stateManager = new ModStateManager();
|
|
||||||
CrashReportCallables.registerCrashCallable("ModLauncher", FMLLoader::getLauncherInfo);
|
|
||||||
CrashReportCallables.registerCrashCallable("ModLauncher launch target", FMLLoader::launcherHandlerName);
|
|
||||||
CrashReportCallables.registerCrashCallable("ModLauncher naming", FMLLoader::getNaming);
|
|
||||||
CrashReportCallables.registerCrashCallable("ModLauncher services", this::computeModLauncherServiceList);
|
|
||||||
CrashReportCallables.registerCrashCallable("FML Language Providers", this::computeLanguageList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String computeLanguageList() {
|
|
||||||
return "\n"+FMLLoader.getLanguageLoadingProvider().applyForEach(lp->lp.name() +"@"+ lp.getClass().getPackage().getImplementationVersion()).collect(Collectors.joining("\n\t\t", "\t\t", ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String computeModLauncherServiceList() {
|
|
||||||
final List<Map<String, String>> mods = FMLLoader.modLauncherModList();
|
|
||||||
return "\n"+mods.stream().map(mod->mod.getOrDefault("file","nofile")+
|
|
||||||
" "+mod.getOrDefault("name", "missing")+
|
|
||||||
" "+mod.getOrDefault("type","NOTYPE")+
|
|
||||||
" "+mod.getOrDefault("description", "")).
|
|
||||||
collect(Collectors.joining("\n\t\t","\t\t",""));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModLoader get()
|
|
||||||
{
|
|
||||||
return INSTANCE == null ? INSTANCE = new ModLoader() : INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run on the primary starting thread by ClientModLoader and ServerModLoader
|
|
||||||
* @param syncExecutor An executor to run tasks on the main thread
|
|
||||||
* @param parallelExecutor An executor to run tasks on a parallel loading thread pool
|
|
||||||
* @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) {
|
|
||||||
loadingStateValid = true;
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Waiting for scan to complete"));
|
|
||||||
FMLLoader.backgroundScanHandler.waitForScanToComplete(periodicTask);
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Loading mods"));
|
|
||||||
final ModList modList = ModList.of(loadingModList.getModFiles().stream().map(ModFileInfo::getFile).toList(),
|
|
||||||
loadingModList.getMods());
|
|
||||||
if (!this.loadingExceptions.isEmpty()) {
|
|
||||||
LOGGER.fatal(CORE, "Error during pre-loading phase", loadingExceptions.get(0));
|
|
||||||
modList.setLoadedMods(Collections.emptyList());
|
|
||||||
loadingStateValid = false;
|
|
||||||
throw new LoadingFailedException(loadingExceptions);
|
|
||||||
}
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Building Mod List"));
|
|
||||||
final List<ModContainer> modContainers = loadingModList.getModFiles().stream()
|
|
||||||
.map(ModFileInfo::getFile)
|
|
||||||
.map(this::buildMods)
|
|
||||||
.<ModContainer>mapMulti(Iterable::forEach)
|
|
||||||
.toList();
|
|
||||||
if (!loadingExceptions.isEmpty()) {
|
|
||||||
LOGGER.fatal(CORE, "Failed to initialize mod containers", loadingExceptions.get(0));
|
|
||||||
modList.setLoadedMods(Collections.emptyList());
|
|
||||||
loadingStateValid = false;
|
|
||||||
throw new LoadingFailedException(loadingExceptions);
|
|
||||||
}
|
|
||||||
modList.setLoadedMods(modContainers);
|
|
||||||
this.modList = modList;
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Dispatching gathering events"));
|
|
||||||
stateManager.getStates(ModLoadingPhase.GATHER).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask));
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Gathering phase complete"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Performing load phase"));
|
|
||||||
stateManager.getStates(ModLoadingPhase.LOAD).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask));
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Mod setup complete"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishMods(final ModWorkManager.DrivenExecutor syncExecutor, final Executor parallelExecutor, final Runnable periodicTask) {
|
|
||||||
statusConsumer.ifPresent(c->c.accept("Performing completion phase"));
|
|
||||||
stateManager.getStates(ModLoadingPhase.COMPLETE).forEach(mls->dispatchAndHandleError(mls, syncExecutor, parallelExecutor, periodicTask));
|
|
||||||
statusConsumer.ifPresent(c->c.accept(String.format("Mod loading complete - %d mods loaded", this.modList.size())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker) {
|
|
||||||
if (!isLoadingStateValid()) {
|
|
||||||
LOGGER.error("Cowardly refusing to process mod state change request from {}", state);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
statusConsumer.ifPresent(c->c.accept(state.message().apply(this.modList)));
|
|
||||||
state.inlineRunnable().ifPresent(a->a.accept(this.modList));
|
|
||||||
state.buildTransition(syncExecutor, parallelExecutor).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dispatchAndHandleError(IModLoadingState state, ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor, final Runnable ticker, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) {
|
|
||||||
if (!isLoadingStateValid()) {
|
|
||||||
LOGGER.error("Cowardly refusing to process mod state change request from {}", state);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
statusConsumer.ifPresent(c->c.accept(state.message().apply(this.modList)));
|
|
||||||
state.inlineRunnable().ifPresent(a->a.accept(this.modList));
|
|
||||||
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) {
|
|
||||||
while (!transition.isDone()) {
|
|
||||||
syncExecutor.drive(ticker);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
transition.join();
|
|
||||||
} catch (CompletionException e) {
|
|
||||||
loadingStateValid = false;
|
|
||||||
Throwable t = e.getCause();
|
|
||||||
final List<Throwable> notModLoading = Arrays.stream(t.getSuppressed())
|
|
||||||
.filter(obj -> !(obj instanceof ModLoadingException))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (!notModLoading.isEmpty()) {
|
|
||||||
LOGGER.fatal("Encountered non-modloading exceptions!", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<ModLoadingException> modLoadingExceptions = Arrays.stream(t.getSuppressed())
|
|
||||||
.filter(ModLoadingException.class::isInstance)
|
|
||||||
.map(ModLoadingException.class::cast)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
LOGGER.fatal(LOADING,"Failed to complete lifecycle event {}, {} errors found", state.name(), modLoadingExceptions.size());
|
|
||||||
throw new LoadingFailedException(modLoadingExceptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ModContainer> buildMods(final ModFile modFile)
|
|
||||||
{
|
|
||||||
final Map<String, IModInfo> modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity()));
|
|
||||||
|
|
||||||
LOGGER.trace(LOADING, "ModContainer is {}", ModContainer.class.getClassLoader());
|
|
||||||
final List<ModContainer> containers = modFile.getScanResult().getTargets()
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.map(e -> buildModContainerFromTOML(modFile, modInfoMap, e))
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (containers.size() != modInfoMap.size()) {
|
|
||||||
LOGGER.fatal(LOADING,"File {} constructed {} mods: {}, but had {} mods specified: {}",
|
|
||||||
modFile.getFilePath(),
|
|
||||||
containers.size(), containers.stream().map(c -> c != null ? c.getModId() : "(null)").sorted().collect(Collectors.toList()),
|
|
||||||
modInfoMap.size(), modInfoMap.values().stream().map(IModInfo::getModId).sorted().collect(Collectors.toList()));
|
|
||||||
loadingExceptions.add(new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingclasses", null, modFile.getFilePath()));
|
|
||||||
}
|
|
||||||
// remove errored mod containers
|
|
||||||
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) {
|
|
||||||
try {
|
|
||||||
final String modId = idToProviderEntry.getKey();
|
|
||||||
final IModLanguageProvider.IModLanguageLoader languageLoader = idToProviderEntry.getValue();
|
|
||||||
IModInfo info = Optional.ofNullable(modInfoMap.get(modId)).
|
|
||||||
// throw a missing metadata error if there is no matching modid in the modInfoMap from the mods.toml file
|
|
||||||
orElseThrow(()->new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingmetadata", null, modId));
|
|
||||||
return languageLoader.loadMod(info, modFile.getScanResult(), FMLLoader.getGameLayer());
|
|
||||||
} catch (ModLoadingException mle) {
|
|
||||||
// exceptions are caught and added to the error list for later handling
|
|
||||||
loadingExceptions.add(mle);
|
|
||||||
// return an errored container instance here, because we tried and failed building a container.
|
|
||||||
return new ErroredModContainer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If the current mod loading state is valid. Use if you interact with vanilla systems directly during loading
|
|
||||||
* and don't want to cause extraneous crashes due to trying to do things that aren't possible in a "broken load"
|
|
||||||
*/
|
|
||||||
public static boolean isLoadingStateValid() {
|
|
||||||
return get().loadingStateValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends Event & IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) {
|
|
||||||
if (!loadingStateValid) {
|
|
||||||
LOGGER.error("Cowardly refusing to send event generator to a broken mod state");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ModList.get().forEachModContainer((id, mc) -> mc.acceptEvent(generator.apply(mc)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends Event & IModBusEvent> void postEvent(T e) {
|
|
||||||
if (!loadingStateValid) {
|
|
||||||
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ModList.get().forEachModContainer((id, mc) -> mc.acceptEvent(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ModLoadingWarning> getWarnings()
|
|
||||||
{
|
|
||||||
return ImmutableList.copyOf(this.loadingWarnings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addWarning(ModLoadingWarning warning)
|
|
||||||
{
|
|
||||||
this.loadingWarnings.add(warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean runningDataGen = false;
|
|
||||||
|
|
||||||
public static boolean isDataGenRunning () {
|
|
||||||
return runningDataGen;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ErroredModContainer extends ModContainer {
|
|
||||||
public ErroredModContainer() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(final Object mod) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getMod() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
public enum ModLoadingPhase {
|
|
||||||
ERROR, // Special state for error handling
|
|
||||||
GATHER,
|
|
||||||
LOAD,
|
|
||||||
COMPLETE,
|
|
||||||
DONE;
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
public enum ModLoadingStage
|
|
||||||
{
|
|
||||||
ERROR,
|
|
||||||
VALIDATE,
|
|
||||||
CONSTRUCT,
|
|
||||||
COMMON_SETUP,
|
|
||||||
SIDED_SETUP,
|
|
||||||
ENQUEUE_IMC,
|
|
||||||
PROCESS_IMC,
|
|
||||||
COMPLETE,
|
|
||||||
DONE;
|
|
||||||
|
|
||||||
private final DeferredWorkQueue deferredWorkQueue;
|
|
||||||
|
|
||||||
ModLoadingStage() {
|
|
||||||
deferredWorkQueue = new DeferredWorkQueue(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
ModLoadingStage nextState(Throwable exception) {
|
|
||||||
return exception != null ? ERROR : values()[this.ordinal()+1];
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModLoadingStage currentState(Throwable exception) {
|
|
||||||
return exception != null ? ERROR : this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeferredWorkQueue getDeferredWorkQueue() {
|
|
||||||
return deferredWorkQueue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
import net.minecraftforge.fml.event.IModBusEvent;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
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 {
|
|
||||||
@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) {
|
|
||||||
return transition.map(t->t.build(syncExecutor, parallelExecutor, preSyncTask, postSyncTask));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) {
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModLoadingState withTransition(final String name, final String previous, final Function<ModList, String> message, final ModLoadingPhase phase, IModStateTransition 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import com.google.common.graph.GraphBuilder;
|
|
||||||
import com.google.common.graph.MutableGraph;
|
|
||||||
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.toposort.TopologicalSort;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
|
||||||
public class ModStateManager {
|
|
||||||
static ModStateManager INSTANCE;
|
|
||||||
private final EnumMap<ModLoadingPhase, List<IModLoadingState>> stateMap;
|
|
||||||
|
|
||||||
public ModStateManager() {
|
|
||||||
INSTANCE = this;
|
|
||||||
final var sp = ServiceLoader.load(FMLLoader.getGameLayer(), IModStateProvider.class);
|
|
||||||
this.stateMap = ServiceLoaderUtils.streamWithErrorHandling(sp, sce->{})
|
|
||||||
.map(IModStateProvider::getAllStates)
|
|
||||||
.<IModLoadingState>mapMulti(Iterable::forEach)
|
|
||||||
.collect(Collectors.groupingBy(IModLoadingState::phase, ()->new EnumMap<>(ModLoadingPhase.class), Collectors.toUnmodifiableList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IModLoadingState> getStates(final ModLoadingPhase phase) {
|
|
||||||
var nodes = stateMap.get(phase);
|
|
||||||
var lookup = nodes.stream().collect(Collectors.toMap(IModLoadingState::name, Function.identity()));
|
|
||||||
|
|
||||||
var graph = GraphBuilder.directed().allowsSelfLoops(false).<IModLoadingState>build();
|
|
||||||
var dummy = ModLoadingState.empty("", "", phase);
|
|
||||||
nodes.forEach(graph::addNode);
|
|
||||||
graph.addNode(dummy);
|
|
||||||
nodes.forEach(n->graph.putEdge(lookup.getOrDefault(n.previous(), dummy), n));
|
|
||||||
return TopologicalSort.topologicalSort(graph, Comparator.comparingInt(nodes::indexOf)).stream().filter(st->st!=dummy).toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.FMLConfig;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
import java.util.concurrent.locks.LockSupport;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.Logging.LOADING;
|
|
||||||
|
|
||||||
public class ModWorkManager {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private static final long PARK_TIME = TimeUnit.MILLISECONDS.toNanos(1);
|
|
||||||
public interface DrivenExecutor extends Executor {
|
|
||||||
boolean selfDriven();
|
|
||||||
boolean driveOne();
|
|
||||||
|
|
||||||
default void drive(Runnable ticker) {
|
|
||||||
if (!selfDriven()) {
|
|
||||||
while (driveOne()) {
|
|
||||||
ticker.run();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// park for a bit so other threads can schedule
|
|
||||||
LockSupport.parkNanos(PARK_TIME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static class SyncExecutor implements DrivenExecutor {
|
|
||||||
private ConcurrentLinkedDeque<Runnable> tasks = new ConcurrentLinkedDeque<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean driveOne() {
|
|
||||||
final Runnable task = tasks.pollFirst();
|
|
||||||
if (task != null) {
|
|
||||||
task.run();
|
|
||||||
}
|
|
||||||
return task != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean selfDriven() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(final Runnable command) {
|
|
||||||
tasks.addLast(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class WrappingExecutor implements DrivenExecutor {
|
|
||||||
private final Executor wrapped;
|
|
||||||
|
|
||||||
public WrappingExecutor(final Executor executor) {
|
|
||||||
this.wrapped = executor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean selfDriven() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean driveOne() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(final Runnable command) {
|
|
||||||
wrapped.execute(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SyncExecutor syncExecutor;
|
|
||||||
|
|
||||||
public static DrivenExecutor syncExecutor() {
|
|
||||||
if (syncExecutor == null)
|
|
||||||
syncExecutor = new SyncExecutor();
|
|
||||||
return syncExecutor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DrivenExecutor wrappedExecutor(Executor executor) {
|
|
||||||
return new WrappingExecutor(executor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ForkJoinPool parallelThreadPool;
|
|
||||||
public static Executor parallelExecutor() {
|
|
||||||
if (parallelThreadPool == null) {
|
|
||||||
final int loadingThreadCount = FMLConfig.loadingThreadCount();
|
|
||||||
LOGGER.debug(LOADING, "Using {} threads for parallel mod-loading", loadingThreadCount);
|
|
||||||
parallelThreadPool = new ForkJoinPool(loadingThreadCount, ModWorkManager::newForkJoinWorkerThread, null, false);
|
|
||||||
}
|
|
||||||
return parallelThreadPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ForkJoinWorkerThread newForkJoinWorkerThread(ForkJoinPool pool) {
|
|
||||||
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
|
|
||||||
thread.setName("modloading-worker-" + thread.getPoolIndex());
|
|
||||||
// The default sets it to the SystemClassloader, so copy the current one.
|
|
||||||
thread.setContextClassLoader(Thread.currentThread().getContextClassLoader());
|
|
||||||
return thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class StartupMessageManager {
|
|
||||||
public static void addModMessage(final String message) {
|
|
||||||
net.minecraftforge.fml.loading.progress.StartupMessageManager.addModMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<Consumer<String>> modLoaderConsumer() {
|
|
||||||
return net.minecraftforge.fml.loading.progress.StartupMessageManager.modLoaderConsumer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<Consumer<String>> mcLoaderConsumer() {
|
|
||||||
return net.minecraftforge.fml.loading.progress.StartupMessageManager.mcLoaderConsumer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package net.minecraftforge.fml;
|
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.function.BinaryOperator;
|
|
||||||
|
|
||||||
public enum ThreadSelector implements BinaryOperator<Executor> {
|
|
||||||
SYNC((sync, parallel) -> sync),
|
|
||||||
PARALLEL((sync, parallel) -> parallel);
|
|
||||||
|
|
||||||
private final BinaryOperator<Executor> selector;
|
|
||||||
|
|
||||||
ThreadSelector(final BinaryOperator<Executor> selector) {
|
|
||||||
this.selector = selector;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Executor apply(final Executor sync, final Executor parallel) {
|
|
||||||
return this.selector.apply(sync, parallel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package net.minecraftforge.fml.config;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
import net.minecraftforge.fml.Bindings;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public interface IConfigEvent {
|
|
||||||
record ConfigConfig(Function<ModConfig, IConfigEvent> loading, Function<ModConfig, IConfigEvent> reloading) {}
|
|
||||||
ConfigConfig CONFIGCONFIG = Bindings.getConfigConfiguration().get();
|
|
||||||
|
|
||||||
static IConfigEvent reloading(ModConfig modConfig) {
|
|
||||||
return CONFIGCONFIG.reloading().apply(modConfig);
|
|
||||||
}
|
|
||||||
static IConfigEvent loading(ModConfig modConfig) {
|
|
||||||
return CONFIGCONFIG.loading().apply(modConfig);
|
|
||||||
}
|
|
||||||
ModConfig getConfig();
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
default <T extends Event & IConfigEvent> T self() {
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package net.minecraftforge.fml.config;
|
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
|
||||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
|
||||||
|
|
||||||
public interface IConfigSpec<T extends IConfigSpec<T>> extends UnmodifiableConfig {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
default T self() {
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void acceptConfig(CommentedConfig data);
|
|
||||||
|
|
||||||
boolean isCorrecting();
|
|
||||||
|
|
||||||
boolean isCorrect(CommentedConfig commentedFileConfig);
|
|
||||||
|
|
||||||
int correct(CommentedConfig commentedFileConfig);
|
|
||||||
|
|
||||||
void afterReload();
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'com.github.ben-manes.versions'
|
|
||||||
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
|
||||||
}
|
|
||||||
apply plugin: 'java-library'
|
|
||||||
apply plugin: 'jacoco'
|
|
||||||
apply plugin: 'org.javamodularity.moduleplugin'
|
|
||||||
|
|
||||||
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
|
||||||
configurations.forEach{ it.transitive = false }
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4')
|
|
||||||
compileOnly('org.jetbrains:annotations:21.0.0')
|
|
||||||
api("org.ow2.asm:asm:${ASM_VERSION}")
|
|
||||||
api("org.ow2.asm:asm-tree:${ASM_VERSION}")
|
|
||||||
api("org.ow2.asm:asm-commons:${ASM_VERSION}")
|
|
||||||
api('net.minecraftforge:forgespi:4.0.+')
|
|
||||||
api('org.apache.logging.log4j:log4j-api:2.14.1')
|
|
||||||
api('com.google.guava:guava:21.0')
|
|
||||||
api('com.google.code.gson:gson:2.8.0')
|
|
||||||
api('org.apache.maven:maven-artifact:3.8.1')
|
|
||||||
api('org.apache.commons:commons-lang3:3.8.1')
|
|
||||||
api('com.electronwill.night-config:core:3.6.3')
|
|
||||||
api('com.electronwill.night-config:toml:3.6.3')
|
|
||||||
api('cpw.mods:modlauncher:9.0.+')
|
|
||||||
api('net.minecraftforge:coremods:5.0.+')
|
|
||||||
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
|
|
||||||
implementation('org.apache.logging.log4j:log4j-core:2.14.1')
|
|
||||||
annotationProcessor('org.apache.logging.log4j:log4j-core:2.14.1')
|
|
||||||
implementation('net.minecraftforge:accesstransformers:8.0.4')
|
|
||||||
implementation('net.minecrell:terminalconsoleappender:1.2.0')
|
|
||||||
// implementation('org.jline:jline:3.12.+')
|
|
||||||
testCompileOnly('org.jetbrains:annotations:21.0.0')
|
|
||||||
testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}")
|
|
||||||
}
|
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
|
||||||
archiveClassifier = 'sources'
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
ext {
|
|
||||||
MANIFESTS = [
|
|
||||||
'/': [
|
|
||||||
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
||||||
'Git-Commit': GIT_INFO.abbreviatedId,
|
|
||||||
'Git-Branch': GIT_INFO.branch,
|
|
||||||
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
|
|
||||||
] as LinkedHashMap,
|
|
||||||
'net/minecraftforge/fml/loading/': [
|
|
||||||
'Specification-Title': 'FMLLoader',
|
|
||||||
'Specification-Vendor': 'Forge Development LLC',
|
|
||||||
'Specification-Version': '1',
|
|
||||||
'Implementation-Title': 'FML Loader',
|
|
||||||
'Implementation-Version': '1.0',
|
|
||||||
'Implementation-Vendor': 'Forge'
|
|
||||||
] as LinkedHashMap
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
jar.doFirst {
|
|
||||||
MANIFESTS.each { pkg, values ->
|
|
||||||
manifest.attributes(values, pkg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.compilerArgs << '-Xlint:unchecked'
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives jar
|
|
||||||
archives sourcesJar
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing.publications.mavenJava(MavenPublication) {
|
|
||||||
from components.java
|
|
||||||
artifact sourcesJar
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
public class BackgroundWaiter {
|
|
||||||
private static ExecutorService runner = Executors.newSingleThreadExecutor();
|
|
||||||
|
|
||||||
public static void runAndTick(Runnable r, Runnable tick) {
|
|
||||||
final Future<?> work = runner.submit(r);
|
|
||||||
do {
|
|
||||||
tick.run();
|
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
}
|
|
||||||
} while (!work.isDone());
|
|
||||||
try {
|
|
||||||
runner.shutdown();
|
|
||||||
work.get();
|
|
||||||
} catch (ExecutionException ee) {
|
|
||||||
throw new RuntimeException(ee.getCause());
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public record VersionInfo(String forgeVersion, String mcVersion, String mcpVersion, String forgeGroup) {
|
|
||||||
VersionInfo(Map<String, ?> arguments) {
|
|
||||||
this((String) arguments.get("forgeVersion"), (String) arguments.get("mcVersion"), (String) arguments.get("mcpVersion"), (String) arguments.get("forgeGroup"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String mcAndForgeVersion() {
|
|
||||||
return mcVersion+"-"+forgeVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String mcAndMCPVersion() {
|
|
||||||
return mcVersion + "-" + mcpVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading;
|
|
||||||
|
|
||||||
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
|
|
||||||
public class VersionSupportMatrix {
|
|
||||||
private static final HashMap<String, List<ArtifactVersion>> overrideVersions = new HashMap<>();
|
|
||||||
static {
|
|
||||||
final ArtifactVersion version = new DefaultArtifactVersion(FMLLoader.versionInfo().mcVersion());
|
|
||||||
// if (MavenVersionAdapter.createFromVersionSpec("[1.16.4,1.16.5]").containsVersion(version)) {
|
|
||||||
// // 1.16.4 is Compatible with 1.16.3
|
|
||||||
// add("languageloader.javafml", "34");
|
|
||||||
// add("mod.minecraft", "1.16.3");
|
|
||||||
// add("mod.forge", "34.1.42");
|
|
||||||
// // 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) {
|
|
||||||
overrideVersions.computeIfAbsent(key, k -> new ArrayList<>()).add(new DefaultArtifactVersion(value));
|
|
||||||
}
|
|
||||||
public static <T> boolean testVersionSupportMatrix(VersionRange declaredRange, String lookupId, String type, BiPredicate<String, VersionRange> standardLookup) {
|
|
||||||
if (standardLookup.test(lookupId, declaredRange)) return true;
|
|
||||||
List<ArtifactVersion> custom = overrideVersions.get(type +"." +lookupId);
|
|
||||||
return custom == null ? false : custom.stream().anyMatch(declaredRange::containsVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.log4j;
|
|
||||||
|
|
||||||
import net.minecrell.terminalconsole.HighlightErrorConverter;
|
|
||||||
import net.minecrell.terminalconsole.TerminalConsoleAppender;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.logging.log4j.core.config.Configuration;
|
|
||||||
import org.apache.logging.log4j.core.config.plugins.Plugin;
|
|
||||||
import org.apache.logging.log4j.core.pattern.ConverterKeys;
|
|
||||||
import org.apache.logging.log4j.core.pattern.HighlightConverter;
|
|
||||||
import org.apache.logging.log4j.core.pattern.PatternConverter;
|
|
||||||
import org.apache.logging.log4j.status.StatusLogger;
|
|
||||||
import org.apache.logging.log4j.util.PerformanceSensitive;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A wrapper for {@link HighlightConverter} that auto-disables ANSI when the terminal doesn't support it.
|
|
||||||
* Ansi support is determined by TerminalConsoleAppender
|
|
||||||
*/
|
|
||||||
@Plugin(name = "highlightForge", category = PatternConverter.CATEGORY)
|
|
||||||
@ConverterKeys("highlightForge")
|
|
||||||
@PerformanceSensitive("allocation")
|
|
||||||
public class ForgeHighlight {
|
|
||||||
protected static final Logger LOGGER = StatusLogger.getLogger();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a new instance of the {@link HighlightErrorConverter} with the
|
|
||||||
* specified options.
|
|
||||||
*
|
|
||||||
* @param config The current configuration
|
|
||||||
* @param options The pattern options
|
|
||||||
* @return The new instance
|
|
||||||
*/
|
|
||||||
public static @Nullable HighlightConverter newInstance(Configuration config, String[] options) {
|
|
||||||
try {
|
|
||||||
Method method = TerminalConsoleAppender.class.getDeclaredMethod("initializeTerminal");
|
|
||||||
method.setAccessible(true);
|
|
||||||
method.invoke(null);
|
|
||||||
} catch (ReflectiveOperationException e) {
|
|
||||||
LOGGER.warn("Failed to invoke initializeTerminal on TCA", e);
|
|
||||||
}
|
|
||||||
if (!TerminalConsoleAppender.isAnsiSupported() && Arrays.stream(options).noneMatch(s -> s.equals("disableAnsi=true"))) {
|
|
||||||
List<String> optionList = new ArrayList<>();
|
|
||||||
optionList.add(options[0]);
|
|
||||||
optionList.add("disableAnsi=true");
|
|
||||||
options = optionList.toArray(new String[0]);
|
|
||||||
}
|
|
||||||
return HighlightConverter.newInstance(config, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
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.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
|
||||||
|
|
||||||
public abstract class AbstractJarFileLocator implements IModLocator {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void scanFile(final IModFile file, final Consumer<Path> pathConsumer) {
|
|
||||||
LOGGER.debug(SCAN,"Scan started: {}", file);
|
|
||||||
final Function<Path, SecureJar.Status> status = p->file.getSecureJar().verifyPath(p);
|
|
||||||
try (Stream<Path> files = Files.find(file.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) {
|
|
||||||
file.setSecurityStatus(files.peek(pathConsumer).map(status).reduce((s1, s2)-> SecureJar.Status.values()[Math.min(s1.ordinal(), s2.ordinal())]).orElse(SecureJar.Status.INVALID));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
LOGGER.debug(SCAN,"Scan finished: {}", file);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IModFile> scanMods() {
|
|
||||||
return scanCandidates()
|
|
||||||
.map(mc -> ModFile.newFMLInstance(this, mc))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Stream<Path> scanCandidates();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(final IModFile modFile) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-90
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
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.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
|
||||||
|
|
||||||
public class ExplodedDirectoryLocator implements IModLocator {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
public record ExplodedMod(String modid, List<Path> paths) {}
|
|
||||||
|
|
||||||
private final List<ExplodedMod> explodedMods = new ArrayList<>();
|
|
||||||
private final Map<ExplodedMod, IModFile> mods = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IModFile> scanMods() {
|
|
||||||
explodedMods.forEach(explodedMod -> ModJarMetadata.buildFile(this, jar ->jar.findFile("/META-INF/mods.toml").isPresent(), explodedMod.paths().toArray(Path[]::new))
|
|
||||||
.ifPresentOrElse(f->mods.put(explodedMod, f), () -> LOGGER.warn(LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString())));
|
|
||||||
return List.copyOf(mods.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return "exploded directory";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void scanFile(final IModFile file, final Consumer<Path> pathConsumer) {
|
|
||||||
LOGGER.debug(SCAN,"Scanning exploded directory {}", file.getFilePath().toString());
|
|
||||||
try (Stream<Path> files = Files.find(file.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) {
|
|
||||||
files.forEach(pathConsumer);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
LOGGER.debug(SCAN,"Exploded directory scan complete {}", file.getFilePath().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "{ExplodedDir locator}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void initArguments(final Map<String, ?> arguments) {
|
|
||||||
final var explodedTargets = ((Map<String, List<ExplodedMod>>) arguments).get("explodedTargets");
|
|
||||||
if (explodedTargets != null && !explodedTargets.isEmpty()) {
|
|
||||||
explodedMods.addAll(explodedTargets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(final IModFile modFile) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-118
@@ -1,118 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.Config;
|
|
||||||
import com.electronwill.nightconfig.core.file.FileConfig;
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
|
||||||
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
|
||||||
|
|
||||||
public class MinecraftLocator implements IModLocator {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IModFile> scanMods() {
|
|
||||||
final var launchHandler = FMLLoader.getLaunchHandler();
|
|
||||||
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 artifacts = baseMC.otherArtifacts().stream().map(SecureJar::from).map(sj->ModFile.newFMLInstance(this, sj)).collect(Collectors.<IModFile>toList());
|
|
||||||
var othermods = baseMC.otherModPaths().stream().map(p->ModJarMetadata.buildFile(this, p.toArray(Path[]::new))).toList();
|
|
||||||
artifacts.add(mcjar);
|
|
||||||
artifacts.addAll(othermods);
|
|
||||||
return artifacts;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IModFileInfo buildMinecraftTOML(final IModFile iModFile) {
|
|
||||||
final ModFile modFile = (ModFile) iModFile;
|
|
||||||
/*
|
|
||||||
final Path mcmodtoml = modFile.findResource("META-INF", "minecraftmod.toml");
|
|
||||||
if (Files.notExists(mcmodtoml)) {
|
|
||||||
LOGGER.fatal(LOADING, "Mod file {} is missing minecraftmod.toml file", modFile.getFilePath());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final FileConfig mcmodstomlfile = FileConfig.builder(mcmodtoml).build();
|
|
||||||
mcmodstomlfile.load();
|
|
||||||
mcmodstomlfile.close();
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// We haven't changed this in years, and I can't be asked right now to special case this one file in the path.
|
|
||||||
final var conf = Config.inMemory();
|
|
||||||
conf.set("modLoader", "minecraft");
|
|
||||||
conf.set("loaderVersion", "1");
|
|
||||||
conf.set("license", "Mojang Studios, All Rights Reserved");
|
|
||||||
final var mods = Config.inMemory();
|
|
||||||
mods.set("modId", "minecraft");
|
|
||||||
mods.set("version", FMLLoader.versionInfo().mcVersion());
|
|
||||||
mods.set("displayName", "Minecraft");
|
|
||||||
mods.set("logoFile", "mcplogo.png");
|
|
||||||
mods.set("credits", "Mojang, deobfuscated by MCP");
|
|
||||||
mods.set("authors", "MCP: Searge,ProfMobius,IngisKahn,Fesh0r,ZeuX,R4wk,LexManos,Bspkrs");
|
|
||||||
mods.set("description", "Minecraft, decompiled and deobfuscated with MCP technology");
|
|
||||||
conf.set("mods", List.of(mods));
|
|
||||||
/*
|
|
||||||
conf.putAll(mcmodstomlfile);
|
|
||||||
|
|
||||||
final var extralangs = Stream.<IModFileInfo.LanguageSpec>builder();
|
|
||||||
final Path forgemodtoml = modFile.findResource("META-INF", "mods.toml");
|
|
||||||
if (Files.notExists(forgemodtoml)) {
|
|
||||||
LOGGER.info("No forge mods.toml file found, not loading forge mod");
|
|
||||||
} else {
|
|
||||||
final FileConfig forgemodstomlfile = FileConfig.builder(forgemodtoml).build();
|
|
||||||
forgemodstomlfile.load();
|
|
||||||
forgemodstomlfile.close();
|
|
||||||
conf.putAll(forgemodstomlfile);
|
|
||||||
conf.<List<Object>>get("mods").add(0, mcmodstomlfile.<List<Object>>get("mods").get(0)); // Add MC as a sub-mod
|
|
||||||
extralangs.add(new IModFileInfo.LanguageSpec(mcmodstomlfile.get("modLoader"), MavenVersionAdapter.createFromVersionSpec(mcmodstomlfile.get("loaderVersion"))));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
final NightConfigWrapper configWrapper = new NightConfigWrapper(conf);
|
|
||||||
//final ModFileInfo modFileInfo = new ModFileInfo(modFile, configWrapper, extralangs.build().toList());
|
|
||||||
final ModFileInfo modFileInfo = new ModFileInfo(modFile, configWrapper, List.of());
|
|
||||||
configWrapper.setFile(modFileInfo);
|
|
||||||
return modFileInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return "minecraft";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void scanFile(final IModFile modFile, final Consumer<Path> pathConsumer) {
|
|
||||||
LOGGER.debug(SCAN, "Scan started: {}", modFile);
|
|
||||||
try (Stream<Path> files = Files.find(modFile.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) {
|
|
||||||
files.forEach(pathConsumer);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
LOGGER.debug(SCAN, "Scan finished: {}", modFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initArguments(final Map<String, ?> arguments) {
|
|
||||||
// no op
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(final IModFile modFile) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.Launcher;
|
|
||||||
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
|
||||||
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
|
||||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
|
||||||
import net.minecraftforge.forgespi.Environment;
|
|
||||||
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.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.ServiceLoader;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
|
||||||
|
|
||||||
public class ModDiscoverer {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private final ServiceLoader<IModLocator> locators;
|
|
||||||
private final List<IModLocator> locatorList;
|
|
||||||
|
|
||||||
public ModDiscoverer(Map<String, ?> arguments) {
|
|
||||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new);
|
|
||||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v->StartupMessageManager.locatorConsumer().orElseGet(()->s->{}));
|
|
||||||
final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow();
|
|
||||||
locators = 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());
|
|
||||||
locatorList.forEach(l->l.initArguments(arguments));
|
|
||||||
LOGGER.debug(CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
ModDiscoverer(List<IModLocator> locatorList) {
|
|
||||||
this.locatorList = locatorList;
|
|
||||||
this.locators = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModValidator discoverMods() {
|
|
||||||
LOGGER.debug(SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", locatorList.size());
|
|
||||||
final var modFiles = locatorList.stream()
|
|
||||||
.peek(loc -> LOGGER.debug(SCAN,"Trying locator {}", loc))
|
|
||||||
.map(IModLocator::scanMods)
|
|
||||||
.<IModFile>mapMulti(Iterable::forEach)
|
|
||||||
.peek(mf -> LOGGER.info(SCAN,"Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator()))
|
|
||||||
.peek(mf -> StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType())))
|
|
||||||
.map(ModFile.class::cast)
|
|
||||||
.collect(Collectors.groupingBy(IModFile::getType));
|
|
||||||
|
|
||||||
var validator = new ModValidator(modFiles);
|
|
||||||
validator.stage1Validation();
|
|
||||||
return validator;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,212 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
|
||||||
import cpw.mods.util.LambdaExceptionUtils;
|
|
||||||
import net.minecraftforge.fml.loading.StringUtils;
|
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
|
||||||
|
|
||||||
import javax.security.auth.x500.X500Principal;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.security.CodeSigner;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.NoSuchProviderException;
|
|
||||||
import java.security.SignatureException;
|
|
||||||
import java.security.cert.Certificate;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.jar.Manifest;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|
||||||
|
|
||||||
public class ModFileInfo implements IModFileInfo, IConfigurable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private final IConfigurable config;
|
|
||||||
private final ModFile modFile;
|
|
||||||
private final URL issueURL;
|
|
||||||
private final List<LanguageSpec> languageSpecs;
|
|
||||||
private final boolean showAsResourcePack;
|
|
||||||
private final List<IModInfo> mods;
|
|
||||||
private final Map<String,Object> properties;
|
|
||||||
private final String license;
|
|
||||||
private final List<String> usesServices;
|
|
||||||
|
|
||||||
ModFileInfo(final ModFile modFile, final IConfigurable config)
|
|
||||||
{
|
|
||||||
this.modFile = modFile;
|
|
||||||
this.config = config;
|
|
||||||
var modLoader = config.<String>getConfigElement("modLoader")
|
|
||||||
.orElseThrow(()->new InvalidModFileException("Missing ModLoader in file", this));
|
|
||||||
var modLoaderVersion = config.<String>getConfigElement("loaderVersion")
|
|
||||||
.map(MavenVersionAdapter::createFromVersionSpec)
|
|
||||||
.orElseThrow(()->new InvalidModFileException("Missing ModLoader version in file", this));
|
|
||||||
this.languageSpecs = new ArrayList<>(List.of(new LanguageSpec(modLoader, modLoaderVersion)));
|
|
||||||
this.license = config.<String>getConfigElement("license")
|
|
||||||
.orElse("");
|
|
||||||
this.showAsResourcePack = config.<Boolean>getConfigElement("showAsResourcePack").orElse(false);
|
|
||||||
this.usesServices = config.<List<String>>getConfigElement("services").orElse(List.of());
|
|
||||||
this.properties = config.<Map<String, Object>>getConfigElement("properties").orElse(Collections.emptyMap());
|
|
||||||
this.modFile.setFileProperties(this.properties);
|
|
||||||
this.issueURL = config.<String>getConfigElement("issueTrackerURL").map(StringUtils::toURL).orElse(null);
|
|
||||||
final List<? extends IConfigurable> modConfigs = config.getConfigList("mods");
|
|
||||||
if (modConfigs.isEmpty())
|
|
||||||
{
|
|
||||||
throw new InvalidModFileException("Missing mods list", this);
|
|
||||||
}
|
|
||||||
this.mods = modConfigs.stream()
|
|
||||||
.map(mi-> new ModInfo(this, mi))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
LOGGER.debug(LOADING, "Found valid mod file {} with {} mods - versions {}",
|
|
||||||
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) {
|
|
||||||
this(file, config);
|
|
||||||
this.languageSpecs.addAll(languageSpecs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IModInfo> getMods()
|
|
||||||
{
|
|
||||||
return mods;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModFile getFile()
|
|
||||||
{
|
|
||||||
return this.modFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LanguageSpec> requiredLanguageLoaders() {
|
|
||||||
return this.languageSpecs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getFileProperties()
|
|
||||||
{
|
|
||||||
return this.properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean showAsResourcePack()
|
|
||||||
{
|
|
||||||
return this.showAsResourcePack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Optional<T> getConfigElement(final String... key)
|
|
||||||
{
|
|
||||||
return this.config.getConfigElement(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends IConfigurable> getConfigList(final String... key)
|
|
||||||
{
|
|
||||||
return this.config.getConfigList(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLicense()
|
|
||||||
{
|
|
||||||
return license;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IConfigurable getConfig() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URL getIssueURL()
|
|
||||||
{
|
|
||||||
return issueURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean missingLicense()
|
|
||||||
{
|
|
||||||
return Strings.isNullOrEmpty(license);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<String> getCodeSigningFingerprint() {
|
|
||||||
var signers = this.modFile.getSecureJar().getManifestSigners();
|
|
||||||
return (signers == null ? Stream.<CodeSigner>of() : Arrays.stream(signers))
|
|
||||||
.flatMap(csa->csa.getSignerCertPath().getCertificates().stream())
|
|
||||||
.findFirst()
|
|
||||||
.map(LamdbaExceptionUtils.rethrowFunction(Certificate::getEncoded))
|
|
||||||
.map(bytes->LamdbaExceptionUtils.uncheck(()->MessageDigest.getInstance("SHA-256")).digest(bytes))
|
|
||||||
.map(StringUtils::binToHex)
|
|
||||||
.map(str-> String.join(":", str.split("(?<=\\G.{2})")));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<String> getTrustData() {
|
|
||||||
return Arrays.stream(this.modFile.getSecureJar().getManifestSigners())
|
|
||||||
.flatMap(csa->csa.getSignerCertPath().getCertificates().stream())
|
|
||||||
.findFirst()
|
|
||||||
.map(X509Certificate.class::cast)
|
|
||||||
.map(c->{
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
sb.append(c.getSubjectX500Principal().getName(X500Principal.RFC2253).split(",")[0]);
|
|
||||||
boolean selfSigned = false;
|
|
||||||
try {
|
|
||||||
c.verify(c.getPublicKey());
|
|
||||||
selfSigned = true;
|
|
||||||
} catch (CertificateException | NoSuchAlgorithmException | InvalidKeyException | SignatureException | NoSuchProviderException e) {
|
|
||||||
// not self signed
|
|
||||||
}
|
|
||||||
if (selfSigned) {
|
|
||||||
sb.append(" self-signed");
|
|
||||||
} else {
|
|
||||||
sb.append(" signed by ").append(c.getIssuerX500Principal().getName(X500Principal.RFC2253).split(",")[0]);
|
|
||||||
};
|
|
||||||
return sb.toString();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String moduleName() {
|
|
||||||
return getMods().get(0).getModId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String versionString() {
|
|
||||||
return getMods().get(0).getVersion().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> usesServices() {
|
|
||||||
return usesServices;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.StringSubstitutor;
|
|
||||||
import net.minecraftforge.fml.loading.StringUtils;
|
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.MavenVersionAdapter;
|
|
||||||
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.DefaultArtifactVersion;
|
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ModInfo implements IModInfo, IConfigurable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1");
|
|
||||||
private static final Pattern VALID_LABEL = Pattern.compile("^[a-z][a-z0-9_-]{1,63}$");
|
|
||||||
|
|
||||||
private final ModFileInfo owningFile;
|
|
||||||
private final String modId;
|
|
||||||
private final String namespace;
|
|
||||||
private final ArtifactVersion version;
|
|
||||||
private final String displayName;
|
|
||||||
private final String description;
|
|
||||||
private final Optional<String> logoFile;
|
|
||||||
private final boolean logoBlur;
|
|
||||||
private final Optional<URL> updateJSONURL;
|
|
||||||
private final List<? extends IModInfo.ModVersion> dependencies;
|
|
||||||
private final Map<String,Object> properties;
|
|
||||||
private final IConfigurable config;
|
|
||||||
|
|
||||||
public ModInfo(final ModFileInfo owningFile, final IConfigurable config)
|
|
||||||
{
|
|
||||||
Optional<ModFileInfo> ownFile = Optional.ofNullable(owningFile);
|
|
||||||
this.owningFile = owningFile;
|
|
||||||
this.config = config;
|
|
||||||
this.modId = config.<String>getConfigElement("modId")
|
|
||||||
.orElseThrow(() -> new InvalidModFileException("Missing modId", owningFile));
|
|
||||||
if (!VALID_LABEL.matcher(this.modId).matches()) {
|
|
||||||
LOGGER.fatal("Invalid modId found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.modId, VALID_LABEL.pattern());
|
|
||||||
throw new InvalidModFileException("Invalid modId found : " + this.modId, owningFile);
|
|
||||||
}
|
|
||||||
this.namespace = config.<String>getConfigElement("namespace").orElse(this.modId);
|
|
||||||
if (!VALID_LABEL.matcher(this.namespace).matches()) {
|
|
||||||
LOGGER.fatal("Invalid override namespace found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.namespace, VALID_LABEL.pattern());
|
|
||||||
throw new InvalidModFileException("Invalid override namespace found : " + this.namespace, owningFile);
|
|
||||||
}
|
|
||||||
this.version = config.<String>getConfigElement("version")
|
|
||||||
.map(s -> StringSubstitutor.replace(s, ownFile.map(ModFileInfo::getFile).orElse(null)))
|
|
||||||
.map(DefaultArtifactVersion::new).orElse(DEFAULT_VERSION);
|
|
||||||
this.displayName = config.<String>getConfigElement("displayName").orElse(this.modId);
|
|
||||||
this.description = config.<String>getConfigElement("description").orElse("MISSING DESCRIPTION");
|
|
||||||
|
|
||||||
this.logoFile = Optional.ofNullable(config.<String>getConfigElement("logoFile")
|
|
||||||
.orElseGet(() -> ownFile.flatMap(mf -> mf.<String>getConfigElement("logoFile")).orElse(null)));
|
|
||||||
this.logoBlur = config.<Boolean>getConfigElement("logoBlur")
|
|
||||||
.orElseGet(() -> ownFile.flatMap(f -> f.<Boolean>getConfigElement("logoBlur"))
|
|
||||||
.orElse(true));
|
|
||||||
|
|
||||||
this.updateJSONURL = config.<String>getConfigElement("updateJSONURL")
|
|
||||||
.map(StringUtils::toURL);
|
|
||||||
|
|
||||||
this.dependencies = ownFile.map(mfi -> mfi.getConfigList("dependencies", this.modId)
|
|
||||||
.stream()
|
|
||||||
.map(dep -> new ModVersion(this, dep))
|
|
||||||
.collect(Collectors.toList()))
|
|
||||||
.orElse(Collections.emptyList());
|
|
||||||
|
|
||||||
this.properties = ownFile.map(mfi -> mfi.<Map<String, Object>>getConfigElement("modproperties", this.modId)
|
|
||||||
.orElse(Collections.emptyMap()))
|
|
||||||
.orElse(Collections.emptyMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModFileInfo getOwningFile() {
|
|
||||||
return owningFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModId() {
|
|
||||||
return modId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName()
|
|
||||||
{
|
|
||||||
return this.displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription()
|
|
||||||
{
|
|
||||||
return this.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArtifactVersion getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends IModInfo.ModVersion> getDependencies() {
|
|
||||||
return this.dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNamespace() {
|
|
||||||
return this.namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getModProperties() {
|
|
||||||
return this.properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<URL> getUpdateURL() {
|
|
||||||
return this.updateJSONURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<String> getLogoFile()
|
|
||||||
{
|
|
||||||
return this.logoFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getLogoBlur()
|
|
||||||
{
|
|
||||||
return this.logoBlur;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IConfigurable getConfig() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Optional<T> getConfigElement(final String... key) {
|
|
||||||
return this.config.getConfigElement(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends IConfigurable> getConfigList(final String... key) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ModVersion implements net.minecraftforge.forgespi.language.IModInfo.ModVersion {
|
|
||||||
private IModInfo owner;
|
|
||||||
private final String modId;
|
|
||||||
private final VersionRange versionRange;
|
|
||||||
private final boolean mandatory;
|
|
||||||
private final Ordering ordering;
|
|
||||||
private final DependencySide side;
|
|
||||||
|
|
||||||
public ModVersion(final IModInfo owner, final IConfigurable config) {
|
|
||||||
this.owner = owner;
|
|
||||||
this.modId = config.<String>getConfigElement("modId")
|
|
||||||
.orElseThrow(()->new InvalidModFileException("Missing required field modid in dependency", getOwningFile()));
|
|
||||||
this.mandatory = config.<Boolean>getConfigElement("mandatory")
|
|
||||||
.orElseThrow(()->new InvalidModFileException("Missing required field mandatory in dependency", getOwningFile()));
|
|
||||||
this.versionRange = config.<String>getConfigElement("versionRange")
|
|
||||||
.map(MavenVersionAdapter::createFromVersionSpec)
|
|
||||||
.orElse(UNBOUNDED);
|
|
||||||
this.ordering = config.<String>getConfigElement("ordering")
|
|
||||||
.map(Ordering::valueOf)
|
|
||||||
.orElse(Ordering.NONE);
|
|
||||||
this.side = config.<String>getConfigElement("side")
|
|
||||||
.map(DependencySide::valueOf)
|
|
||||||
.orElse(DependencySide.BOTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModId()
|
|
||||||
{
|
|
||||||
return modId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VersionRange getVersionRange()
|
|
||||||
{
|
|
||||||
return versionRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMandatory()
|
|
||||||
{
|
|
||||||
return mandatory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Ordering getOrdering()
|
|
||||||
{
|
|
||||||
return ordering;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DependencySide getSide()
|
|
||||||
{
|
|
||||||
return side;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setOwner(final IModInfo owner)
|
|
||||||
{
|
|
||||||
this.owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IModInfo getOwner()
|
|
||||||
{
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-96
@@ -1,96 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import cpw.mods.jarhandling.JarMetadata;
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
|
||||||
|
|
||||||
import java.lang.module.ModuleDescriptor;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public final class ModJarMetadata implements JarMetadata {
|
|
||||||
private IModFile modFile;
|
|
||||||
private ModuleDescriptor descriptor;
|
|
||||||
|
|
||||||
static Optional<IModFile> buildFile(IModLocator locator, Predicate<SecureJar> jarTest, Path... files) {
|
|
||||||
return buildFile(locator, jarTest, (a,b) -> true, files);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Optional<IModFile> buildFile(IModLocator locator, Predicate<SecureJar> jarTest, BiPredicate<String, String> filter, Path... files) {
|
|
||||||
return buildFile(j->ModFile.newFMLInstance(locator, j), jarTest, filter, files);
|
|
||||||
}
|
|
||||||
|
|
||||||
static IModFile buildFile(IModLocator locator, Path... files) {
|
|
||||||
return buildFile(locator, j->true, files).orElseThrow(()->new IllegalArgumentException("Failed to find valid JAR file"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static Optional<IModFile> buildFile(Function<SecureJar, IModFile> mfConstructor, Predicate<SecureJar> jarTest, BiPredicate<String, String> filter, Path... files) {
|
|
||||||
var mjm = new ModJarMetadata();
|
|
||||||
var sj = SecureJar.from(()->ModFile.DEFAULTMANIFEST, j->mjm, filter, files);
|
|
||||||
if (jarTest.test(sj)) {
|
|
||||||
var mf = mfConstructor.apply(sj);
|
|
||||||
mjm.setModFile(mf);
|
|
||||||
return Optional.of(mf);
|
|
||||||
} else {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ModJarMetadata() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModFile(IModFile file) {
|
|
||||||
this.modFile = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return modFile.getModFileInfo().moduleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String version() {
|
|
||||||
return modFile.getModFileInfo().versionString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModuleDescriptor descriptor() {
|
|
||||||
if (descriptor != null) return descriptor;
|
|
||||||
var bld = ModuleDescriptor.newAutomaticModule(name())
|
|
||||||
.version(version())
|
|
||||||
.packages(modFile.getSecureJar().getPackages());
|
|
||||||
modFile.getSecureJar().getProviders().stream()
|
|
||||||
.filter(p -> !p.providers().isEmpty())
|
|
||||||
.forEach(p -> bld.provides(p.serviceName(), p.providers()));
|
|
||||||
modFile.getModFileInfo().usesServices().forEach(bld::uses);
|
|
||||||
descriptor = bld.build();
|
|
||||||
return descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IModFile modFile() {
|
|
||||||
return modFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == this) return true;
|
|
||||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
|
||||||
var that = (ModJarMetadata) obj;
|
|
||||||
return Objects.equals(this.modFile, that.modFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(modFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ModJarMetadata[" +"modFile=" + modFile + ']';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
|
||||||
import cpw.mods.modlauncher.api.ITransformationService;
|
|
||||||
import net.minecraftforge.fml.loading.*;
|
|
||||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
|
||||||
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
|
||||||
|
|
||||||
public class ModValidator {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private final Map<IModFile.Type, List<ModFile>> modFiles;
|
|
||||||
private final List<ModFile> candidatePlugins;
|
|
||||||
private final List<ModFile> candidateMods;
|
|
||||||
private LoadingModList loadingModList;
|
|
||||||
private List<ModFile> brokenFiles;
|
|
||||||
|
|
||||||
public ModValidator(final Map<IModFile.Type, List<ModFile>> modFiles) {
|
|
||||||
this.modFiles = modFiles;
|
|
||||||
this.candidateMods = new ArrayList<>(modFiles.getOrDefault(IModFile.Type.MOD, List.of()));
|
|
||||||
this.candidatePlugins = new ArrayList<>(modFiles.getOrDefault(IModFile.Type.LANGPROVIDER, List.of()));
|
|
||||||
this.candidatePlugins.addAll(modFiles.getOrDefault(IModFile.Type.LIBRARY, List.of()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stage1Validation() {
|
|
||||||
brokenFiles = validateFiles(candidateMods);
|
|
||||||
LOGGER.debug(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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private List<ModFile> validateFiles(final List<ModFile> mods) {
|
|
||||||
final List<ModFile> brokenFiles = new ArrayList<>();
|
|
||||||
for (Iterator<ModFile> iterator = mods.iterator(); iterator.hasNext(); )
|
|
||||||
{
|
|
||||||
ModFile mod = iterator.next();
|
|
||||||
if (!mod.getLocator().isValid(mod) || !mod.identifyMods()) {
|
|
||||||
LOGGER.warn(SCAN, "File {} has been ignored - it is invalid", mod.getFilePath());
|
|
||||||
iterator.remove();
|
|
||||||
brokenFiles.add(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return brokenFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITransformationService.Resource getPluginResources() {
|
|
||||||
return new ITransformationService.Resource(IModuleLayerManager.Layer.PLUGIN, this.candidatePlugins.stream().map(ModFile::getSecureJar).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITransformationService.Resource getModResources() {
|
|
||||||
return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().map(ModFile::getSecureJar).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<EarlyLoadingException.ExceptionData> validateLanguages() {
|
|
||||||
List<EarlyLoadingException.ExceptionData> errorData = new ArrayList<>();
|
|
||||||
for (Iterator<ModFile> iterator = this.candidateMods.iterator(); iterator.hasNext(); ) {
|
|
||||||
final ModFile modFile = iterator.next();
|
|
||||||
try {
|
|
||||||
modFile.identifyLanguage();
|
|
||||||
} catch (EarlyLoadingException e) {
|
|
||||||
errorData.addAll(e.getAllData());
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return errorData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BackgroundScanHandler stage2Validation() {
|
|
||||||
var errors = validateLanguages();
|
|
||||||
loadingModList = ModSorter.sort(candidateMods, errors);
|
|
||||||
loadingModList.addCoreMods();
|
|
||||||
loadingModList.addAccessTransformers();
|
|
||||||
loadingModList.setBrokenFiles(brokenFiles);
|
|
||||||
BackgroundScanHandler backgroundScanHandler = new BackgroundScanHandler(candidateMods);
|
|
||||||
loadingModList.addForScanning(backgroundScanHandler);
|
|
||||||
return backgroundScanHandler;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-70
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
public class NightConfigWrapper implements IConfigurable {
|
|
||||||
private final UnmodifiableConfig config;
|
|
||||||
private IModFileInfo file;
|
|
||||||
|
|
||||||
public NightConfigWrapper(final UnmodifiableConfig config) {
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
NightConfigWrapper setFile(IModFileInfo file) {
|
|
||||||
this.file = file;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T> Optional<T> getConfigElement(final String... key) {
|
|
||||||
return this.config.getOptional(asList(key)).map(value -> {
|
|
||||||
if (value instanceof UnmodifiableConfig) {
|
|
||||||
return (T) ((UnmodifiableConfig) value).valueMap();
|
|
||||||
}
|
|
||||||
return (T) value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends IConfigurable> getConfigList(final String... key) {
|
|
||||||
final List<String> path = asList(key);
|
|
||||||
if (this.config.contains(path) && !(this.config.get(path) instanceof Collection)) {
|
|
||||||
throw new InvalidModFileException("The configuration path "+path+" is invalid. Expecting a collection!", file);
|
|
||||||
}
|
|
||||||
final Collection<UnmodifiableConfig> nestedConfigs = this.config.getOrElse(path, ArrayList::new);
|
|
||||||
return nestedConfigs.stream()
|
|
||||||
.map(NightConfigWrapper::new)
|
|
||||||
.map(cw->cw.setFile(file))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-372
@@ -1,372 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*//*
|
|
||||||
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.progress;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.lwjgl.PointerBuffer;
|
|
||||||
import org.lwjgl.glfw.*;
|
|
||||||
import org.lwjgl.opengl.GL;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL14;
|
|
||||||
import org.lwjgl.stb.STBEasyFont;
|
|
||||||
import org.lwjgl.stb.STBImage;
|
|
||||||
import org.lwjgl.system.MemoryStack;
|
|
||||||
import org.lwjgl.system.MemoryUtil;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.lang.management.MemoryUsage;
|
|
||||||
import java.nio.Buffer;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.IntBuffer;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.IntConsumer;
|
|
||||||
import java.util.function.IntSupplier;
|
|
||||||
import java.util.function.LongSupplier;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import static org.lwjgl.glfw.GLFW.*;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
|
||||||
import static org.lwjgl.system.MemoryStack.stackPush;
|
|
||||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
|
||||||
|
|
||||||
|
|
||||||
class ClientVisualization implements EarlyProgressVisualization.Visualization {
|
|
||||||
private final int screenWidth = 854;
|
|
||||||
private final int screenHeight = 480;
|
|
||||||
private long window;
|
|
||||||
private Thread renderThread = new Thread(this::renderThreadFunc);
|
|
||||||
|
|
||||||
private boolean running = true;
|
|
||||||
private GLFWFramebufferSizeCallback framebufferSizeCallback;
|
|
||||||
private int[] fbSize;
|
|
||||||
|
|
||||||
private void initWindow(@Nullable String mcVersion) {
|
|
||||||
GLFWErrorCallback.createPrint(System.err).set();
|
|
||||||
|
|
||||||
long glfwInitBegin = System.nanoTime();
|
|
||||||
if (!glfwInit()) {
|
|
||||||
throw new IllegalStateException("Unable to initialize GLFW");
|
|
||||||
}
|
|
||||||
long glfwInitEnd = System.nanoTime();
|
|
||||||
|
|
||||||
if (glfwInitEnd - glfwInitBegin > 1e9) {
|
|
||||||
LogManager.getLogger().fatal("WARNING : glfwInit took {} seconds to start.", (glfwInitEnd-glfwInitBegin) / 1.0e9);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the Last Exception (#7285 - Prevent Vanilla throwing an IllegalStateException due to invalid controller mappings)
|
|
||||||
handleLastGLFWError((error, description) -> LogManager.getLogger().error(String.format("Suppressing Last GLFW error: [0x%X]%s", error, description)));
|
|
||||||
|
|
||||||
glfwDefaultWindowHints();
|
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
|
||||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
|
||||||
|
|
||||||
if (mcVersion != null)
|
|
||||||
{
|
|
||||||
// this emulates what we would get without early progress window
|
|
||||||
// as vanilla never sets these, so GLFW uses the first window title
|
|
||||||
// set them explicitly to avoid it using "FML early loading progress" as the class
|
|
||||||
String vanillaWindowTitle = "Minecraft* " + mcVersion;
|
|
||||||
glfwWindowHintString(GLFW_X11_CLASS_NAME, vanillaWindowTitle);
|
|
||||||
glfwWindowHintString(GLFW_X11_INSTANCE_NAME, vanillaWindowTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
window = glfwCreateWindow(screenWidth, screenHeight, "FML early loading progress", NULL, NULL);
|
|
||||||
if (window == NULL) {
|
|
||||||
throw new RuntimeException("Failed to create the GLFW window"); // ignore it and make the GUI optional?
|
|
||||||
}
|
|
||||||
framebufferSizeCallback = GLFWFramebufferSizeCallback.create(this::fbResize);
|
|
||||||
|
|
||||||
try (MemoryStack stack = stackPush()) {
|
|
||||||
IntBuffer pWidth = stack.mallocInt(1);
|
|
||||||
IntBuffer pHeight = stack.mallocInt(1);
|
|
||||||
IntBuffer monPosLeft = stack.mallocInt(1);
|
|
||||||
IntBuffer monPosTop = stack.mallocInt(1);
|
|
||||||
glfwGetWindowSize(window, pWidth, pHeight);
|
|
||||||
|
|
||||||
// try to center the window, this is a best-effort as there may not be
|
|
||||||
// a primary monitor and we might not even be on the primary monitor...
|
|
||||||
long primaryMonitor = glfwGetPrimaryMonitor();
|
|
||||||
if (primaryMonitor != NULL)
|
|
||||||
{
|
|
||||||
GLFWVidMode vidmode = glfwGetVideoMode(primaryMonitor);
|
|
||||||
glfwGetMonitorPos(primaryMonitor, monPosLeft, monPosTop);
|
|
||||||
glfwSetWindowPos(
|
|
||||||
window,
|
|
||||||
(vidmode.width() - pWidth.get(0)) / 2 + monPosLeft.get(0),
|
|
||||||
(vidmode.height() - pHeight.get(0)) / 2 + monPosTop.get(0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
IntBuffer iconWidth = stack.mallocInt(1);
|
|
||||||
IntBuffer iconHeight = stack.mallocInt(1);
|
|
||||||
IntBuffer iconChannels = stack.mallocInt(1);
|
|
||||||
final GLFWImage.Buffer glfwImages = GLFWImage.mallocStack(1, stack);
|
|
||||||
byte[] icon;
|
|
||||||
try {
|
|
||||||
icon = ByteStreams.toByteArray(getClass().getClassLoader().getResourceAsStream("forge_icon.png"));
|
|
||||||
final ByteBuffer iconBuf = stack.malloc(icon.length);
|
|
||||||
iconBuf.put(icon);
|
|
||||||
((Buffer)iconBuf).position(0);
|
|
||||||
final ByteBuffer imgBuffer = STBImage.stbi_load_from_memory(iconBuf, iconWidth, iconHeight, iconChannels, 4);
|
|
||||||
if (imgBuffer == null) {
|
|
||||||
throw new NullPointerException("Failed to load window icon"); // fall down to catch block
|
|
||||||
}
|
|
||||||
glfwImages.position(0);
|
|
||||||
glfwImages.width(iconWidth.get(0));
|
|
||||||
glfwImages.height(iconHeight.get(0));
|
|
||||||
((Buffer)imgBuffer).position(0);
|
|
||||||
glfwImages.pixels(imgBuffer);
|
|
||||||
glfwImages.position(0);
|
|
||||||
glfwSetWindowIcon(window, glfwImages);
|
|
||||||
STBImage.stbi_image_free(imgBuffer);
|
|
||||||
} catch (NullPointerException | IOException e) {
|
|
||||||
System.err.println("Failed to load forge logo");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int[] w = new int[1];
|
|
||||||
int[] h = new int[1];
|
|
||||||
glfwGetFramebufferSize(window, w, h);
|
|
||||||
fbSize = new int[] {w[0], h[0]};
|
|
||||||
glfwSetFramebufferSizeCallback(window, framebufferSizeCallback);
|
|
||||||
glfwShowWindow(window);
|
|
||||||
glfwPollEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderProgress() {
|
|
||||||
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
// glMatrixMode(GL_PROJECTION);
|
|
||||||
// glLoadIdentity();
|
|
||||||
// glOrtho(0.0D, screenWidth, screenHeight, 0.0D, -1000.0D, 1000.0D);
|
|
||||||
// glMatrixMode(GL_MODELVIEW);
|
|
||||||
// glLoadIdentity();
|
|
||||||
//
|
|
||||||
// glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
|
||||||
// glEnable(GL_BLEND);
|
|
||||||
// renderBackground();
|
|
||||||
// renderMessages();
|
|
||||||
// glfwSwapBuffers(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static float clamp(float num, float min, float max) {
|
|
||||||
if (num < min) {
|
|
||||||
return min;
|
|
||||||
} else {
|
|
||||||
return num > max ? max : num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int clamp(int num, int min, int max) {
|
|
||||||
if (num < min) {
|
|
||||||
return min;
|
|
||||||
} else {
|
|
||||||
return num > max ? max : num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int hsvToRGB(float hue, float saturation, float value) {
|
|
||||||
int i = (int)(hue * 6.0F) % 6;
|
|
||||||
float f = hue * 6.0F - (float)i;
|
|
||||||
float f1 = value * (1.0F - saturation);
|
|
||||||
float f2 = value * (1.0F - f * saturation);
|
|
||||||
float f3 = value * (1.0F - (1.0F - f) * saturation);
|
|
||||||
float f4;
|
|
||||||
float f5;
|
|
||||||
float f6;
|
|
||||||
switch(i) {
|
|
||||||
case 0:
|
|
||||||
f4 = value;
|
|
||||||
f5 = f3;
|
|
||||||
f6 = f1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
f4 = f2;
|
|
||||||
f5 = value;
|
|
||||||
f6 = f1;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
f4 = f1;
|
|
||||||
f5 = value;
|
|
||||||
f6 = f3;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
f4 = f1;
|
|
||||||
f5 = f2;
|
|
||||||
f6 = value;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
f4 = f3;
|
|
||||||
f5 = f1;
|
|
||||||
f6 = value;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
f4 = value;
|
|
||||||
f5 = f1;
|
|
||||||
f6 = f2;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + hue + ", " + saturation + ", " + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int j = clamp((int)(f4 * 255.0F), 0, 255);
|
|
||||||
int k = clamp((int)(f5 * 255.0F), 0, 255);
|
|
||||||
int l = clamp((int)(f6 * 255.0F), 0, 255);
|
|
||||||
return j << 16 | k << 8 | l;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderBackground() {
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glColor4f(239F / 255F, 50F / 255F, 61F / 255F, 255F / 255F); //Color from ResourceLoadProgressGui
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glVertex2f(0, screenHeight);
|
|
||||||
glVertex2f(screenWidth, screenHeight);
|
|
||||||
glVertex2f(screenWidth, 0);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fbResize(long window, int width, int height) {
|
|
||||||
if (window == this.window && width != 0 && height != 0) {
|
|
||||||
fbSize = new int[] {width, height};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleLastGLFWError(BiConsumer<Integer, String> handler) {
|
|
||||||
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
|
||||||
PointerBuffer pointerbuffer = memorystack.mallocPointer(1);
|
|
||||||
int error = GLFW.glfwGetError(pointerbuffer);
|
|
||||||
if (error != GLFW_NO_ERROR) {
|
|
||||||
long pDescription = pointerbuffer.get();
|
|
||||||
String description = pDescription == 0L ? "" : MemoryUtil.memUTF8(pDescription);
|
|
||||||
handler.accept(error, description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderMessages() {
|
|
||||||
List<Pair<Integer, StartupMessageManager.Message>> messages = StartupMessageManager.getMessages();
|
|
||||||
for (int i = 0; i < messages.size(); i++) {
|
|
||||||
final Pair<Integer, StartupMessageManager.Message> pair = messages.get(i);
|
|
||||||
final float fade = clamp((4000.0f - (float) pair.getLeft() - ( i - 4 ) * 1000.0f) / 5000.0f, 0.0f, 1.0f);
|
|
||||||
if (fade <0.01f) continue;
|
|
||||||
StartupMessageManager.Message msg = pair.getRight();
|
|
||||||
renderMessage(msg.getText(), msg.getTypeColour(), ((screenHeight - 15) / 20) - i, fade);
|
|
||||||
}
|
|
||||||
renderMemoryInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateFBSize(final IntConsumer width, final IntConsumer height) {
|
|
||||||
width.accept(this.fbSize[0]);
|
|
||||||
height.accept(this.fbSize[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final float[] memorycolour = new float[] { 0.0f, 0.0f, 0.0f};
|
|
||||||
|
|
||||||
private void renderMemoryInfo() {
|
|
||||||
final MemoryUsage heapusage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
|
||||||
final MemoryUsage offheapusage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
|
|
||||||
final float pctmemory = (float) heapusage.getUsed() / heapusage.getMax();
|
|
||||||
String memory = String.format("Memory Heap: %d / %d MB (%.1f%%) OffHeap: %d MB", heapusage.getUsed() >> 20, heapusage.getMax() >> 20, pctmemory * 100.0, offheapusage.getUsed() >> 20);
|
|
||||||
|
|
||||||
final int i = hsvToRGB((1.0f - (float)Math.pow(pctmemory, 1.5f)) / 3f, 1.0f, 0.5f);
|
|
||||||
memorycolour[2] = ((i) & 0xFF) / 255.0f;
|
|
||||||
memorycolour[1] = ((i >> 8 ) & 0xFF) / 255.0f;
|
|
||||||
memorycolour[0] = ((i >> 16 ) & 0xFF) / 255.0f;
|
|
||||||
renderMessage(memory, memorycolour, 1, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderMessage(final String message, final float[] colour, int row, float alpha) {
|
|
||||||
ByteBuffer charBuffer = MemoryUtil.memAlloc(message.length() * 270);
|
|
||||||
int quads = STBEasyFont.stb_easy_font_print(0, 0, message, null, charBuffer);
|
|
||||||
|
|
||||||
glVertexPointer(3, GL11.GL_FLOAT, 16, charBuffer);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
GL14.glBlendColor(0,0,0, alpha);
|
|
||||||
glBlendFunc(GL14.GL_CONSTANT_ALPHA, GL14.GL_ONE_MINUS_CONSTANT_ALPHA);
|
|
||||||
glColor3f(colour[0], colour[1], colour[2]);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(10, row * 20, 0);
|
|
||||||
glScalef(2, 2, 1);
|
|
||||||
glDrawArrays(GL11.GL_QUADS, 0, quads * 4);
|
|
||||||
glPopMatrix();
|
|
||||||
MemoryUtil.memFree(charBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderThreadFunc() {
|
|
||||||
glfwMakeContextCurrent(window);
|
|
||||||
glfwSwapInterval(1);
|
|
||||||
GL.createCapabilities();
|
|
||||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
while (running) {
|
|
||||||
renderProgress();
|
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glfwMakeContextCurrent(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Runnable start(@Nullable String mcVersion) {
|
|
||||||
initWindow(mcVersion);
|
|
||||||
renderThread.setDaemon(true); // Don't hang the game if it terminates before handoff (i.e. datagen)
|
|
||||||
renderThread.start();
|
|
||||||
return org.lwjgl.glfw.GLFW::glfwPollEvents;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long handOffWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitorSupplier) {
|
|
||||||
running = false;
|
|
||||||
try {
|
|
||||||
renderThread.join();
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
}
|
|
||||||
glfwSetWindowTitle(window, title.get());
|
|
||||||
glfwSetWindowSize(window, width.getAsInt(), height.getAsInt());
|
|
||||||
if (monitorSupplier.getAsLong() != 0L)
|
|
||||||
glfwSetWindowMonitor(window, monitorSupplier.getAsLong(), 0, 0, width.getAsInt(), height.getAsInt(), GLFW_DONT_CARE);
|
|
||||||
glfwMakeContextCurrent(window);
|
|
||||||
GL.createCapabilities();
|
|
||||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
renderProgress();
|
|
||||||
glfwSwapInterval(0);
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
glfwSwapInterval(1);
|
|
||||||
final GLFWFramebufferSizeCallback previous = glfwSetFramebufferSizeCallback(window, null);
|
|
||||||
previous.free();
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
-80
@@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.progress;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.function.IntConsumer;
|
|
||||||
import java.util.function.IntSupplier;
|
|
||||||
import java.util.function.LongSupplier;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public enum EarlyProgressVisualization {
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
private Visualization visualization;
|
|
||||||
|
|
||||||
public Runnable accept(Dist dist, boolean isData)
|
|
||||||
{
|
|
||||||
return accept(dist, isData, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Runnable accept(final Dist dist, final boolean isData, @Nullable String mcVersion) {
|
|
||||||
// visualization = !isData && dist.isClient() && Boolean.parseBoolean(System.getProperty("fml.earlyprogresswindow", "true")) ? new ClientVisualization() : new NoVisualization();
|
|
||||||
visualization = new NoVisualization();
|
|
||||||
return visualization.start(mcVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long handOffWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitor) {
|
|
||||||
return visualization.handOffWindow(width, height, title, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateFBSize(IntConsumer width, IntConsumer height) {
|
|
||||||
visualization.updateFBSize(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Visualization {
|
|
||||||
Runnable start(@Nullable String mcVersion);
|
|
||||||
|
|
||||||
default long handOffWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, LongSupplier monitorSupplier) {
|
|
||||||
return FMLLoader.getGameLayer().findModule("forge")
|
|
||||||
.map(l->Class.forName(l, "net.minecraftforge.fmllegacy.NoVizFallback"))
|
|
||||||
.map(LamdbaExceptionUtils.rethrowFunction(c->c.getMethod("fallback", IntSupplier.class, IntSupplier.class, Supplier.class, LongSupplier.class)))
|
|
||||||
.map(LamdbaExceptionUtils.rethrowFunction(m->(LongSupplier)m.invoke(null, width, height, title, monitorSupplier)))
|
|
||||||
.map(LongSupplier::getAsLong)
|
|
||||||
.orElseThrow(()->new IllegalStateException("Why are you here?"));
|
|
||||||
}
|
|
||||||
|
|
||||||
default void updateFBSize(IntConsumer width, IntConsumer height) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class NoVisualization implements Visualization {
|
|
||||||
@Override
|
|
||||||
public Runnable start(@Nullable String mcVersion) {
|
|
||||||
return () -> {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
-68
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonClientLaunchHandler extends CommonLaunchHandler {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
@Override public String getNaming() { return "srg"; }
|
|
||||||
@Override public boolean isProduction() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
final var vers = FMLLoader.versionInfo();
|
|
||||||
var mc = LibraryFinder.findPathForMaven("net.minecraft", "client", "", "srg", vers.mcAndMCPVersion());
|
|
||||||
var mcextra = LibraryFinder.findPathForMaven("net.minecraft", "client", "", "extra", vers.mcAndMCPVersion());
|
|
||||||
var mcstream = Stream.<Path>builder().add(mc).add(mcextra);
|
|
||||||
var modstream = Stream.<List<Path>>builder();
|
|
||||||
|
|
||||||
processMCStream(vers, mcstream, modstream);
|
|
||||||
|
|
||||||
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
|
||||||
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), (a,b) -> true, modstream.build().toList(), List.of(fmlcore, javafmllang, mclang));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods);
|
|
||||||
}
|
|
||||||
-150
@@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
|
||||||
@Override public String getNaming() { return "mcp"; }
|
|
||||||
@Override public boolean isProduction() { return false; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
// Minecraft is extra jar {resources} + our exploded directories in dev
|
|
||||||
final var mcstream = Stream.<Path>builder();
|
|
||||||
|
|
||||||
// The extra jar is on the classpath, so try and pull it out of the legacy classpath
|
|
||||||
var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find client-extra").split(File.pathSeparator);
|
|
||||||
var extra = Paths.get(Arrays.stream(legacyCP).filter(e -> e.contains("client-extra")).findFirst().orElseThrow(() -> new IllegalStateException("Could not find client-extra in legacy classpath")));
|
|
||||||
mcstream.add(extra);
|
|
||||||
|
|
||||||
// The MC code/Patcher edits are in exploded directories
|
|
||||||
final var modstream = Stream.<List<Path>>builder();
|
|
||||||
final var mods = getModClasses();
|
|
||||||
final var minecraft = mods.remove("minecraft");
|
|
||||||
if (minecraft == null)
|
|
||||||
throw new IllegalStateException("Could not find 'minecraft' mod paths.");
|
|
||||||
minecraft.stream().distinct().forEach(mcstream::add);
|
|
||||||
mods.values().forEach(modstream::add);
|
|
||||||
|
|
||||||
var mcFilter = getMcFilter(extra, minecraft, modstream);
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), mcFilter, modstream.build().toList(), getFmlStuff(legacyCP));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String[] preLaunch(String[] arguments, ModuleLayer layer) {
|
|
||||||
if (getDist().isDedicatedServer())
|
|
||||||
return arguments;
|
|
||||||
|
|
||||||
fixNatives();
|
|
||||||
|
|
||||||
if (isData())
|
|
||||||
return arguments;
|
|
||||||
|
|
||||||
var args = ArgumentList.from(arguments);
|
|
||||||
|
|
||||||
String username = args.get("username");
|
|
||||||
if (username != null) { // Replace '#' placeholders with random numbers
|
|
||||||
Matcher m = Pattern.compile("#+").matcher(username);
|
|
||||||
StringBuffer replaced = new StringBuffer();
|
|
||||||
while (m.find()) {
|
|
||||||
m.appendReplacement(replaced, getRandomNumbers(m.group().length()));
|
|
||||||
}
|
|
||||||
m.appendTail(replaced);
|
|
||||||
args.put("username", replaced.toString());
|
|
||||||
} else {
|
|
||||||
args.putLazy("username", "Dev");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args.hasValue("accessToken")) {
|
|
||||||
args.put("accessToken", "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
return args.getArguments();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<Path> getFmlStuff(String[] classpath) {
|
|
||||||
// We also want the FML things, fmlcore, javafmllanguage, mclanguage, I don't like hard coding these, but hey whatever works for now.
|
|
||||||
return Arrays.stream(classpath)
|
|
||||||
.filter(e -> e.contains("fmlcore") || e.contains("javafmllanguage") || e.contains("mclanguage"))
|
|
||||||
.map(Paths::get)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BiPredicate<String, String> getMcFilter(Path extra, List<Path> minecraft, Stream.Builder<List<Path>> mods) {
|
|
||||||
final var packages = getPackages();
|
|
||||||
final var extraPath = extra.toString().replace('\\', '/');
|
|
||||||
|
|
||||||
// We serve everything, except for things in the forge packages.
|
|
||||||
BiPredicate<String, String> mcFilter = (path, base) -> {
|
|
||||||
if (base.equals(extraPath) ||
|
|
||||||
path.endsWith("/")) return true;
|
|
||||||
for (var pkg : packages)
|
|
||||||
if (path.startsWith(pkg)) return false;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// We need to separate out our resources/code so that we can show up as a different data pack.
|
|
||||||
var modJar = SecureJar.from((path, base) -> {
|
|
||||||
if (!path.endsWith(".class")) return true;
|
|
||||||
for (var pkg : packages)
|
|
||||||
if (path.startsWith(pkg)) return true;
|
|
||||||
return false;
|
|
||||||
}, minecraft.stream().distinct().toArray(Path[]::new));
|
|
||||||
//modJar.getPackages().stream().sorted().forEach(System.out::println);
|
|
||||||
mods.add(List.of(modJar.getRootPath()));
|
|
||||||
|
|
||||||
return mcFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String[] getPackages() {
|
|
||||||
return new String[]{ "net/minecraftforge/", "META-INF/services/", "META-INF/coremods.json", "META-INF/mods.toml" };
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getRandomNumbers(int length) {
|
|
||||||
// Generate a time-based random number, to mimic how n.m.client.Main works
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-81
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
|
||||||
import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
|
||||||
|
|
||||||
public abstract class CommonLaunchHandler implements ILaunchHandlerService {
|
|
||||||
public record LocatedPaths(List<Path> minecraftPaths, BiPredicate<String, String> minecraftFilter, List<List<Path>> otherModPaths, List<Path> otherArtifacts) {}
|
|
||||||
|
|
||||||
protected static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
public abstract Dist getDist();
|
|
||||||
|
|
||||||
public abstract String getNaming();
|
|
||||||
|
|
||||||
public boolean isProduction() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isData() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract LocatedPaths getMinecraftPaths();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureTransformationClassLoader(final ITransformingClassLoaderBuilder builder) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final Map<String, List<Path>> getModClasses() {
|
|
||||||
final String modClasses = Optional.ofNullable(System.getenv("MOD_CLASSES")).orElse("");
|
|
||||||
LOGGER.debug(CORE, "Got mod coordinates {} from env", modClasses);
|
|
||||||
|
|
||||||
record ExplodedModPath(String modid, Path path) {}
|
|
||||||
// "a/b/;c/d/;" -> "modid%%c:\fish\pepper;modid%%c:\fish2\pepper2\;modid2%%c:\fishy\bums;modid2%%c:\hmm"
|
|
||||||
final var modClassPaths = Arrays.stream(modClasses.split(File.pathSeparator))
|
|
||||||
.map(inp -> inp.split("%%", 2))
|
|
||||||
.map(splitString -> new ExplodedModPath(splitString.length == 1 ? "defaultmodid" : splitString[0], Paths.get(splitString[splitString.length - 1])))
|
|
||||||
.collect(Collectors.groupingBy(ExplodedModPath::modid, Collectors.mapping(ExplodedModPath::path, Collectors.toList())));
|
|
||||||
|
|
||||||
LOGGER.debug(CORE, "Found supplied mod coordinates [{}]", modClassPaths);
|
|
||||||
|
|
||||||
//final var explodedTargets = ((Map<String, List<ExplodedDirectoryLocator.ExplodedMod>>)arguments).computeIfAbsent("explodedTargets", a -> new ArrayList<>());
|
|
||||||
//modClassPaths.forEach((modlabel,paths) -> explodedTargets.add(new ExplodedDirectoryLocator.ExplodedMod(modlabel, paths)));
|
|
||||||
return modClassPaths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonServerLaunchHandler extends CommonLaunchHandler {
|
|
||||||
protected static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
@Override public String getNaming() { return "srg"; }
|
|
||||||
@Override public boolean isProduction() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)arguments);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
final var vers = FMLLoader.versionInfo();
|
|
||||||
var mc = LibraryFinder.findPathForMaven("net.minecraft", "server", "", "srg", vers.mcAndMCPVersion());
|
|
||||||
var mcextra = LibraryFinder.findPathForMaven("net.minecraft", "server", "", "extra", vers.mcAndMCPVersion());
|
|
||||||
var mcextra_filtered = SecureJar.from( // We only want it for it's resources. So filter everything else out.
|
|
||||||
(path, base) -> {
|
|
||||||
return path.equals("META-INF/versions/") || // This is required because it bypasses our filter for the manifest, and it's a multi-release jar.
|
|
||||||
(!path.endsWith(".class") &&
|
|
||||||
!path.startsWith("META-INF/"));
|
|
||||||
}, mcextra
|
|
||||||
);
|
|
||||||
BiPredicate<String, String> filter = (path, base) -> true;
|
|
||||||
|
|
||||||
var mcstream = Stream.<Path>builder().add(mc).add(mcextra_filtered.getRootPath());
|
|
||||||
var modstream = Stream.<List<Path>>builder();
|
|
||||||
|
|
||||||
filter = processMCStream(vers, mcstream, filter, modstream);
|
|
||||||
|
|
||||||
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
|
||||||
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
|
||||||
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), filter, modstream.build().toList(), List.of(fmlcore, javafmllang, mclang));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract BiPredicate<String, String> processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, BiPredicate<String, String> filter, Stream.Builder<List<Path>> mods);
|
|
||||||
}
|
|
||||||
-62
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommonUserdevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public LocatedPaths getMinecraftPaths() {
|
|
||||||
final var vers = FMLLoader.versionInfo();
|
|
||||||
|
|
||||||
// Minecraft is extra jar {resources} + forge jar {patches}
|
|
||||||
final var mcstream = Stream.<Path>builder();
|
|
||||||
// Mod code is in exploded directories
|
|
||||||
final var modstream = Stream.<List<Path>>builder();
|
|
||||||
|
|
||||||
// The MC extra and forge jars are on the classpath, so try and pull them out
|
|
||||||
var legacyCP = Objects.requireNonNull(System.getProperty("legacyClassPath"), "Missing legacyClassPath, cannot find userdev jars").split(File.pathSeparator);
|
|
||||||
var extra = findJarOnClasspath(legacyCP, "client-extra");
|
|
||||||
|
|
||||||
processStreams(legacyCP, vers, mcstream, modstream);
|
|
||||||
getModClasses().forEach((modid, paths) -> modstream.add(paths));
|
|
||||||
|
|
||||||
var minecraft = mcstream.build().collect(Collectors.toList());
|
|
||||||
var mcFilter = getMcFilter(extra, minecraft, modstream);
|
|
||||||
minecraft.add(extra); // Add extra late so the filter is made correctly
|
|
||||||
return new LocatedPaths(minecraft, mcFilter, modstream.build().toList(), getFmlStuff(legacyCP));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods);
|
|
||||||
|
|
||||||
protected static Path findJarOnClasspath(String[] classpath, String match) {
|
|
||||||
return Paths.get(Arrays.stream(classpath).filter(e -> e.contains(match)).findFirst().orElseThrow(() -> new IllegalStateException("Could not find " + match + " in classpath")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class FMLClientDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "fmlclientdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
public class FMLClientLaunchHandler extends CommonClientLaunchHandler {
|
|
||||||
@Override public String name() { return "fmlclient"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods) {
|
|
||||||
var fmlonly = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "fmlonly", "", "universal", versionInfo.mcAndForgeVersion());
|
|
||||||
mods.add(List.of(fmlonly));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class FMLClientUserdevLaunchHandler extends FMLUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public String name() { return "fmlclientuserdev"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class FMLDataUserdevLaunchHandler extends FMLUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public String name() { return "fmldatauserdev"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isData() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class FMLServerDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "fmlserverdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class FMLServerLaunchHandler extends CommonServerLaunchHandler implements ILaunchHandlerService {
|
|
||||||
@Override public String name() { return "fmlserver"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BiPredicate<String, String> processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, BiPredicate<String, String> filter, Stream.Builder<List<Path>> mods) {
|
|
||||||
var fmlonly = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "fmlonly", "", "universal", versionInfo.mcAndForgeVersion());
|
|
||||||
mods.add(List.of(fmlonly));
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class FMLServerUserdevLaunchHandler extends FMLUserdevLaunchHandler {
|
|
||||||
@Override public String name() { return "fmlserveruserdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class FMLUserdevLaunchHandler extends CommonUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
protected void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods) {
|
|
||||||
var fmlonly = findJarOnClasspath(classpath, "fmlonly-" + versionInfo.mcAndForgeVersion());
|
|
||||||
mc.add(fmlonly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class ForgeClientDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeclientdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
public class ForgeClientLaunchHandler extends CommonClientLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeclient"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods) {
|
|
||||||
var forgepatches = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "client", versionInfo.mcAndForgeVersion());
|
|
||||||
var forgejar = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "universal", versionInfo.mcAndForgeVersion());
|
|
||||||
mc.add(forgepatches);
|
|
||||||
mods.add(List.of(forgejar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class ForgeClientUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public String name() { return "forgeclientuserdev"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.client.main.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class ForgeDataDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgedatadev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
@Override public boolean isData() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class ForgeDataUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
public String name() { return "forgedatauserdev"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dist getDist() { return Dist.CLIENT; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isData() { return true; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(), "net.minecraft.data.Main").getMethod("main", String[].class).invoke(null, (Object) args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class ForgeServerDevLaunchHandler extends CommonDevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeserverdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
|
||||||
import net.minecraftforge.fml.loading.LibraryFinder;
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiPredicate;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class ForgeServerLaunchHandler extends CommonServerLaunchHandler implements ILaunchHandlerService {
|
|
||||||
@Override public String name() { return "forgeserver"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BiPredicate<String, String> processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, BiPredicate<String, String> filter, Stream.Builder<List<Path>> mods) {
|
|
||||||
var forgepatches = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "server", versionInfo.mcAndForgeVersion());
|
|
||||||
var forgejar = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "forge", "", "universal", versionInfo.mcAndForgeVersion());
|
|
||||||
mc.add(forgepatches);
|
|
||||||
mods.add(List.of(forgejar));
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class ForgeServerUserdevLaunchHandler extends ForgeUserdevLaunchHandler {
|
|
||||||
@Override public String name() { return "forgeserveruserdev"; }
|
|
||||||
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Callable<Void> launchService(String[] arguments, ModuleLayer layer) {
|
|
||||||
return () -> {
|
|
||||||
var args = preLaunch(arguments, layer);
|
|
||||||
|
|
||||||
Class.forName(layer.findModule("minecraft").orElseThrow(),"net.minecraft.server.Main").getMethod("main", String[].class).invoke(null, (Object)args);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fml.loading.targets;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.VersionInfo;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class ForgeUserdevLaunchHandler extends CommonUserdevLaunchHandler {
|
|
||||||
@Override
|
|
||||||
protected void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods) {
|
|
||||||
var forge = findJarOnClasspath(classpath, "forge-" + versionInfo.mcAndForgeVersion());
|
|
||||||
mc.add(forge);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Whitespace-only changes.
-16
@@ -1,16 +0,0 @@
|
|||||||
net.minecraftforge.fml.loading.targets.FMLClientLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.FMLClientDevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.FMLClientUserdevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.FMLServerLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.FMLServerDevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.FMLServerUserdevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.FMLDataUserdevLaunchHandler
|
|
||||||
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeClientLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeClientDevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeServerLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeServerDevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeServerUserdevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeDataDevLaunchHandler
|
|
||||||
net.minecraftforge.fml.loading.targets.ForgeDataUserdevLaunchHandler
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
net.minecraftforge.fml.loading.MCPNamingService
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Configuration status="warn" shutdownHook="disable">
|
|
||||||
<filters>
|
|
||||||
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="${sys:forge.logging.marker.networking:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="CLASSLOADING" onMatch="${sys:forge.logging.marker.classloading:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="LAUNCHPLUGIN" onMatch="${sys:forge.logging.marker.launchplugin:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="CLASSDUMP" onMatch="${sys:forge.logging.marker.classdump:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="AXFORM" onMatch="${sys:forge.logging.marker.axform:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="EVENTBUS" onMatch="${sys:forge.logging.marker.eventbus:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="DISTXFORM" onMatch="${sys:forge.logging.marker.distxform:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="SCAN" onMatch="${sys:forge.logging.marker.scan:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="REGISTRIES" onMatch="${sys:forge.logging.marker.registries:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="REGISTRYDUMP" onMatch="${sys:forge.logging.marker.registrydump:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="SPLASH" onMatch="${sys:forge.logging.marker.splash:-DENY}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="FORGEMOD" onMatch="${sys:forge.logging.marker.forgemod:-ACCEPT}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="LOADING" onMatch="${sys:forge.logging.marker.loading:-ACCEPT}" onMismatch="NEUTRAL"/>
|
|
||||||
<MarkerFilter marker="CORE" onMatch="${sys:forge.logging.marker.core:-ACCEPT}" onMismatch="NEUTRAL"/>
|
|
||||||
</filters>
|
|
||||||
<Appenders>
|
|
||||||
<TerminalConsole name="Console">
|
|
||||||
<PatternLayout>
|
|
||||||
<LoggerNamePatternSelector defaultPattern="%highlightForge{[%d{HH:mm:ss}] [%t/%level] [%c{2.}/%markerSimpleName]: %minecraftFormatting{%msg}%n%tEx}">
|
|
||||||
<!-- don't include the full logger name for Mojang's logs since they use full class names and it's very verbose -->
|
|
||||||
<PatternMatch key="net.minecraft." pattern="%highlightForge{[%d{HH:mm:ss}] [%t/%level] [minecraft/%logger{1}]: %minecraftFormatting{%msg}%n%tEx}"/>
|
|
||||||
<PatternMatch key="com.mojang." pattern="%highlightForge{[%d{HH:mm:ss}] [%t/%level] [mojang/%logger{1}]: %minecraftFormatting{%msg}%n%tEx}"/>
|
|
||||||
</LoggerNamePatternSelector>
|
|
||||||
</PatternLayout>
|
|
||||||
</TerminalConsole>
|
|
||||||
<Queue name="ServerGuiConsole" ignoreExceptions="true">
|
|
||||||
<PatternLayout>
|
|
||||||
<LoggerNamePatternSelector defaultPattern="[%d{HH:mm:ss}] [%t/%level] [%c{2.}/%markerSimpleName]: %minecraftFormatting{%msg}{strip}%n">
|
|
||||||
<!-- don't include the full logger name for Mojang's logs since they use full class names and it's very verbose -->
|
|
||||||
<PatternMatch key="net.minecraft." pattern="[%d{HH:mm:ss}] [%t/%level] [minecraft/%logger{1}]: %minecraftFormatting{%msg}{strip}%n"/>
|
|
||||||
<PatternMatch key="com.mojang." pattern="[%d{HH:mm:ss}] [%t/%level] [mojang/%logger{1}]: %minecraftFormatting{%msg}{strip}%n"/>
|
|
||||||
</LoggerNamePatternSelector>
|
|
||||||
</PatternLayout>
|
|
||||||
</Queue>
|
|
||||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
|
||||||
<PatternLayout pattern="[%d{ddMMMyyyy HH:mm:ss.SSS}] [%t/%level] [%logger/%markerSimpleName]: %minecraftFormatting{%msg}{strip}%n%xEx"/>
|
|
||||||
<Policies>
|
|
||||||
<TimeBasedTriggeringPolicy/>
|
|
||||||
<OnStartupTriggeringPolicy/>
|
|
||||||
</Policies>
|
|
||||||
<DefaultRolloverStrategy max="99" fileIndex="min"/>
|
|
||||||
</RollingRandomAccessFile>
|
|
||||||
<RollingRandomAccessFile name="DebugFile" fileName="logs/debug.log" filePattern="logs/debug-%i.log.gz">
|
|
||||||
<PatternLayout pattern="[%d{ddMMMyyyy HH:mm:ss.SSS}] [%t/%level] [%logger/%markerSimpleName]: %minecraftFormatting{%msg}{strip}%n%xEx"/>
|
|
||||||
<Policies>
|
|
||||||
<OnStartupTriggeringPolicy/>
|
|
||||||
<SizeBasedTriggeringPolicy size="200MB"/>
|
|
||||||
</Policies>
|
|
||||||
<DefaultRolloverStrategy max="5" fileIndex="min"/>
|
|
||||||
</RollingRandomAccessFile>
|
|
||||||
</Appenders>
|
|
||||||
<Loggers>
|
|
||||||
<!-- make sure mojang's logging is set to 'info' so that their LOGGER.isDebugEnabled() behavior isn't active -->
|
|
||||||
<Logger level="${sys:forge.logging.mojang.level:-info}" name="com.mojang"/>
|
|
||||||
<Logger level="${sys:forge.logging.mojang.level:-info}" name="net.minecraft"/>
|
|
||||||
<Logger level="${sys:forge.logging.classtransformer.level:-info}" name="cpw.mods.modlauncher.ClassTransformer"/>
|
|
||||||
<Root level="all">
|
|
||||||
<AppenderRef ref="Console" level="${sys:forge.logging.console.level:-info}"/>
|
|
||||||
<AppenderRef ref="ServerGuiConsole" level="${sys:forge.logging.console.level:-info}"/>
|
|
||||||
<AppenderRef ref="File" level="${sys:forge.logging.file.level:-info}"/>
|
|
||||||
<AppenderRef ref="DebugFile" level="${sys:forge.logging.debugFile.level:-debug}"/>
|
|
||||||
</Root>
|
|
||||||
</Loggers>
|
|
||||||
</Configuration>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../src/fmlcommon/
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package net.minecraftforge.fmlonly;
|
|
||||||
|
|
||||||
import net.minecraftforge.eventbus.api.BusBuilder;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.fml.I18NParser;
|
|
||||||
import net.minecraftforge.fml.IBindingsProvider;
|
|
||||||
import net.minecraftforge.fml.config.IConfigEvent;
|
|
||||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class FMLOnlyBindings implements IBindingsProvider {
|
|
||||||
private static final IEventBus DUMMYFORGEBUS = BusBuilder.builder().build();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Supplier<IEventBus> getForgeBusSupplier() {
|
|
||||||
return ()->DUMMYFORGEBUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Supplier<I18NParser> getMessageParser() {
|
|
||||||
return ()->new I18NParser() {
|
|
||||||
@Override
|
|
||||||
public String parseMessage(final String i18nMessage, final Object... args) {
|
|
||||||
return i18nMessage + Arrays.stream(args).map(Objects::toString).collect(Collectors.joining(",", "[", "]"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String stripControlCodes(final String toStrip) {
|
|
||||||
return toStrip;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Supplier<IConfigEvent.ConfigConfig> getConfigConfiguration() {
|
|
||||||
return ()->new IConfigEvent.ConfigConfig(ModConfigEvent.Loading::new, ModConfigEvent.Reloading::new);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,205 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2021.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.fmlonlyclient;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.resources.ClientPackSource;
|
|
||||||
import net.minecraft.server.packs.repository.PackRepository;
|
|
||||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
|
||||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.fml.LoadingFailedException;
|
|
||||||
import net.minecraftforge.fml.ModLoader;
|
|
||||||
import net.minecraftforge.fml.ModWorkManager;
|
|
||||||
import net.minecraftforge.fml.VersionChecker;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public class ClientModLoader
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private static boolean loading;
|
|
||||||
private static Minecraft mc;
|
|
||||||
private static boolean loadingComplete;
|
|
||||||
private static LoadingFailedException error;
|
|
||||||
// private static EarlyLoaderGUI earlyLoaderGUI;
|
|
||||||
|
|
||||||
private static class SpacedRunnable implements Runnable {
|
|
||||||
static final long NANO_SLEEP_TIME = TimeUnit.MILLISECONDS.toNanos(50);
|
|
||||||
private final Runnable wrapped;
|
|
||||||
private long lastRun;
|
|
||||||
|
|
||||||
private SpacedRunnable(final Runnable wrapped) {
|
|
||||||
this.wrapped = wrapped;
|
|
||||||
this.lastRun = System.nanoTime() - NANO_SLEEP_TIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (System.nanoTime() - this.lastRun > NANO_SLEEP_TIME) {
|
|
||||||
wrapped.run();
|
|
||||||
this.lastRun = System.nanoTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void begin(final Minecraft minecraft, final PackRepository defaultResourcePacks, final ReloadableResourceManager mcResourceManager, ClientPackSource metadataSerializer)
|
|
||||||
{
|
|
||||||
// force log4j to shutdown logging in a shutdown hook. This is because we disable default shutdown hook so the server properly logs it's shutdown
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown));
|
|
||||||
loading = true;
|
|
||||||
ClientModLoader.mc = minecraft;
|
|
||||||
// LogicalSidedProvider.setClient(()->minecraft);
|
|
||||||
// LanguageHook.loadForgeAndMCLangs();
|
|
||||||
// earlyLoaderGUI = new EarlyLoaderGUI(minecraft.getWindow());
|
|
||||||
createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{})).run();
|
|
||||||
mcResourceManager.registerReloadListener(ClientModLoader::onResourceReload);
|
|
||||||
// if (error == null) {
|
|
||||||
//// ResourcePackLoader.loadResourcePacks(defaultResourcePacks, ClientModLoader::buildPackFinder);
|
|
||||||
//// DatapackCodec.DEFAULT.addModPacks(ResourcePackLoader.getPackNames());
|
|
||||||
//// mcResourceManager.registerReloadListener(BrandingControl.resourceManagerReloadListener());
|
|
||||||
//// ModelLoaderRegistry.init();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CompletableFuture<Void> onResourceReload(final PreparableReloadListener.PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller prepareProfiler, final ProfilerFiller executeProfiler, final Executor asyncExecutor, final Executor syncExecutor) {
|
|
||||||
return CompletableFuture.runAsync(createRunnableWithCatch(() -> startModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor)), ModWorkManager.parallelExecutor())
|
|
||||||
.thenCompose(stage::wait)
|
|
||||||
.thenRunAsync(() -> finishModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor), ModWorkManager.parallelExecutor());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Runnable createRunnableWithCatch(Runnable r) {
|
|
||||||
return ()-> {
|
|
||||||
if (loadingComplete) return;
|
|
||||||
try {
|
|
||||||
r.run();
|
|
||||||
} catch (LoadingFailedException e) {
|
|
||||||
if (error == null) error = e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void startModLoading(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor) {
|
|
||||||
if (error!=null) throw error;
|
|
||||||
// earlyLoaderGUI.handleElsewhere();
|
|
||||||
createRunnableWithCatch(() -> ModLoader.get().loadMods(syncExecutor, parallelExecutor, ()->{})).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void postSidedRunnable() {
|
|
||||||
// LOGGER.debug(LOADING, "Running post client event work");
|
|
||||||
// RenderingRegistry.loadEntityRenderers(mc.getEntityRenderDispatcher());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void finishModLoading(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor)
|
|
||||||
{
|
|
||||||
if (error!=null) throw error;
|
|
||||||
createRunnableWithCatch(() -> ModLoader.get().finishMods(syncExecutor, parallelExecutor, ()->{})).run();
|
|
||||||
loading = false;
|
|
||||||
loadingComplete = true;
|
|
||||||
// reload game settings on main thread
|
|
||||||
syncExecutor.execute(()->mc.options.load());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean completeModLoading()
|
|
||||||
{
|
|
||||||
// RenderSystem.disableTexture();
|
|
||||||
// RenderSystem.enableTexture();
|
|
||||||
// List<ModLoadingWarning> warnings = ModLoader.get().getWarnings();
|
|
||||||
// boolean showWarnings = true;
|
|
||||||
// try {
|
|
||||||
// showWarnings = ForgeConfig.CLIENT.showLoadWarnings.get();
|
|
||||||
// } catch (NullPointerException e) {
|
|
||||||
// // We're in an early error state, config is not available. Assume true.
|
|
||||||
// }
|
|
||||||
// if (!showWarnings) {
|
|
||||||
// //User disabled warning screen, as least log them
|
|
||||||
// if (!warnings.isEmpty()) {
|
|
||||||
// LOGGER.warn(LOADING, "Mods loaded with {} warning(s)", warnings.size());
|
|
||||||
// warnings.forEach(warning -> LOGGER.warn(LOADING, warning.formatToString()));
|
|
||||||
// }
|
|
||||||
// warnings = Collections.emptyList(); //Clear warnings, as the user does not want to see them
|
|
||||||
// }
|
|
||||||
// File dumpedLocation = null;
|
|
||||||
// if (error == null) {
|
|
||||||
// // We can finally start the forge eventbus up
|
|
||||||
// MinecraftForge.EVENT_BUS.start();
|
|
||||||
// } else {
|
|
||||||
// // Double check we have the langs loaded for forge
|
|
||||||
// LanguageHook.loadForgeAndMCLangs();
|
|
||||||
// dumpedLocation = CrashReportExtender.dumpModLoadingCrashReport(LOGGER, error, mc.gameDirectory);
|
|
||||||
// }
|
|
||||||
// if (error != null || !warnings.isEmpty()) {
|
|
||||||
// mc.setScreen(new LoadingErrorScreen(error, warnings, dumpedLocation));
|
|
||||||
// return true;
|
|
||||||
// } else {
|
|
||||||
// ClientHooks.logMissingTextureErrors();
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renderProgressText() {
|
|
||||||
// earlyLoaderGUI.renderFromGUI();
|
|
||||||
}
|
|
||||||
public static boolean isLoading()
|
|
||||||
{
|
|
||||||
return loading;
|
|
||||||
}
|
|
||||||
|
|
||||||
// private static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter) {
|
|
||||||
// return (packList, factory) -> clientPackFinder(modResourcePacks, packSetter, packList, factory);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static void clientPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter, Consumer<ResourcePackInfo> consumer, ResourcePackInfo.IFactory factory) {
|
|
||||||
// List<ModFileResourcePack> hiddenPacks = new ArrayList<>();
|
|
||||||
// for (Entry<ModFile, ? extends ModFileResourcePack> e : modResourcePacks.entrySet())
|
|
||||||
// {
|
|
||||||
// IModInfo mod = e.getKey().getModInfos().get(0);
|
|
||||||
// if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
|
|
||||||
// final String name = "mod:" + mod.getModId();
|
|
||||||
// final ResourcePackInfo packInfo = ResourcePackInfo.create(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT);
|
|
||||||
// if (packInfo == null) {
|
|
||||||
// // Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
|
|
||||||
// ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// packSetter.accept(e.getValue(), packInfo);
|
|
||||||
// LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath());
|
|
||||||
// if (mod.getOwningFile().showAsResourcePack()) {
|
|
||||||
// consumer.accept(packInfo);
|
|
||||||
// } else {
|
|
||||||
// hiddenPacks.add(e.getValue());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// final ResourcePackInfo packInfo = ResourcePackInfo.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
|
|
||||||
// new PackMetadataSection(new TranslationTextComponent("fml.resources.modresources", hiddenPacks.size()), 6),
|
|
||||||
// hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT);
|
|
||||||
// consumer.accept(packInfo);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"load_fml_client": "coremods/load_fml_client.js"
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
net.minecraftforge.fmlonly.FMLOnlyBindings
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
net.minecraftforge.fml.core.ModStateProvider
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI')
|
|
||||||
var Opcodes = Java.type('org.objectweb.asm.Opcodes')
|
|
||||||
|
|
||||||
function initializeCoreMod() {
|
|
||||||
return {
|
|
||||||
'minecraft': {
|
|
||||||
'target': {
|
|
||||||
'type': 'METHOD',
|
|
||||||
'class': 'net.minecraft.client.Minecraft',
|
|
||||||
'methodName': '<init>',
|
|
||||||
'methodDesc': '(Lnet/minecraft/client/main/GameConfig;)V'
|
|
||||||
},
|
|
||||||
'transformer': function(methodNode) {
|
|
||||||
//print(ASMAPI.methodNodeToString(methodNode))
|
|
||||||
var meth = ASMAPI.getMethodNode();
|
|
||||||
var resourcePackRepository = ASMAPI.mapField("f_91038_")
|
|
||||||
var resourceManager = ASMAPI.mapField("f_91036_")
|
|
||||||
var clientPackSource = ASMAPI.mapField("f_91037_")
|
|
||||||
|
|
||||||
meth.visitVarInsn(Opcodes.ALOAD, 0);
|
|
||||||
meth.visitVarInsn(Opcodes.ALOAD, 0);
|
|
||||||
meth.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", resourcePackRepository, "Lnet/minecraft/server/packs/repository/PackRepository;");
|
|
||||||
meth.visitVarInsn(Opcodes.ALOAD, 0);
|
|
||||||
meth.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", resourceManager, "Lnet/minecraft/server/packs/resources/ReloadableResourceManager;");
|
|
||||||
meth.visitVarInsn(Opcodes.ALOAD, 0);
|
|
||||||
meth.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", clientPackSource, "Lnet/minecraft/client/resources/ClientPackSource;");
|
|
||||||
meth.visitMethodInsn(Opcodes.INVOKESTATIC, "net/minecraftforge/fmlonlyclient/ClientModLoader", "begin", "(Lnet/minecraft/client/Minecraft;Lnet/minecraft/server/packs/repository/PackRepository;Lnet/minecraft/server/packs/resources/ReloadableResourceManager;Lnet/minecraft/client/resources/ClientPackSource;)V", false)
|
|
||||||
for (var i=0; i<methodNode.instructions.size(); i++) {
|
|
||||||
var ain = methodNode.instructions.get(i);
|
|
||||||
if (ain.getOpcode() == Opcodes.PUTFIELD && ain.name.equals(resourceManager)) {
|
|
||||||
methodNode.instructions.insert(ain, meth.instructions);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return methodNode;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB |
@@ -1,4 +0,0 @@
|
|||||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
|
||||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
|
||||||
org.gradle.jvmargs=-Xmx3G
|
|
||||||
org.gradle.daemon=false
|
|
||||||
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-snapshots/gradle-7.2-20210702220150+0000-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
||||||
@@ -1,21 +1,5 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright 2015 the original author or authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
## Gradle start up script for UN*X
|
## Gradle start up script for UN*X
|
||||||
@@ -44,7 +28,7 @@ APP_NAME="Gradle"
|
|||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
@@ -72,7 +56,7 @@ case "`uname`" in
|
|||||||
Darwin* )
|
Darwin* )
|
||||||
darwin=true
|
darwin=true
|
||||||
;;
|
;;
|
||||||
MSYS* | MINGW* )
|
MINGW* )
|
||||||
msys=true
|
msys=true
|
||||||
;;
|
;;
|
||||||
NONSTOP* )
|
NONSTOP* )
|
||||||
@@ -82,7 +66,6 @@ esac
|
|||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
@@ -126,11 +109,10 @@ if $darwin; then
|
|||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
if $cygwin ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
@@ -156,19 +138,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=`expr $i + 1`
|
i=$((i+1))
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
0) set -- ;;
|
(0) set -- ;;
|
||||||
1) set -- "$args0" ;;
|
(1) set -- "$args0" ;;
|
||||||
2) set -- "$args0" "$args1" ;;
|
(2) set -- "$args0" "$args1" ;;
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -177,9 +159,14 @@ save () {
|
|||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
echo " "
|
echo " "
|
||||||
}
|
}
|
||||||
APP_ARGS=`save "$@"`
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
Vendored
+19
-24
@@ -1,19 +1,3 @@
|
|||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -29,18 +13,15 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
|||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
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%" == "0" goto init
|
||||||
|
|
||||||
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.
|
||||||
@@ -54,7 +35,7 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -64,14 +45,28 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
Loaded 100 of 2492 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user