mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 09:05:17 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2106a3ced9 | ||
|
|
50b5414033 | ||
|
|
be0a6819ac | ||
|
|
82a7ee1416 | ||
|
|
b4feee8046 | ||
|
|
df8954869a | ||
|
|
8a552136a2 | ||
|
|
34ec627457 | ||
|
|
28dd76ebbf | ||
|
|
b639bcb5c7 | ||
|
|
7538cf5501 | ||
|
|
1112819fc8 | ||
|
|
cdd38270e9 | ||
|
|
20e309c339 | ||
|
|
5f87bde00e | ||
|
|
a4e574fa6b | ||
|
|
ec7cb00f86 | ||
|
|
ebe375dac0 | ||
|
|
4a2572d545 | ||
|
|
55db597baa | ||
|
|
c24d05173f | ||
|
|
d711982a1c | ||
|
|
8a38416e0f | ||
|
|
a784bdb0d0 | ||
|
|
dc9a7f6ad5 | ||
|
|
417798f2eb | ||
|
|
394e76eed3 | ||
|
|
9e476551be | ||
|
|
1dc421e6a4 | ||
|
|
e431bb1caa | ||
|
|
8bd517ca91 | ||
|
|
69ddf58600 | ||
|
|
1e040c9f1f | ||
|
|
11bdf592c8 | ||
|
|
f4a827ab01 | ||
|
|
827ca83cfd | ||
|
|
e9f8acd191 | ||
|
|
febfd5ab62 | ||
|
|
4ca2a8058f | ||
|
|
4acafcccfd | ||
|
|
937b719e24 | ||
|
|
2b5bfd923c | ||
|
|
249aaa5806 | ||
|
|
46f57e6a9a | ||
|
|
cfd79130de | ||
|
|
6a25c99097 | ||
|
|
95be0d87d9 | ||
|
|
6125ec3bc8 | ||
|
|
9944a8252a | ||
|
|
fd544dd414 | ||
|
|
c00777e6ea | ||
|
|
b2cea78006 | ||
|
|
79272361f0 | ||
|
|
fe4be54774 | ||
|
|
eecb8cc783 | ||
|
|
5e2e404828 | ||
|
|
96303f6570 | ||
|
|
166feefc02 | ||
|
|
cd67762bee | ||
|
|
347a0b3c0d | ||
|
|
be1698bb15 | ||
|
|
a3e9d7a397 | ||
|
|
b2dbe9de51 | ||
|
|
a31adc2823 | ||
|
|
30a33f5c3e | ||
|
|
b01a217f45 | ||
|
|
69136fce19 | ||
|
|
ee21224fff | ||
|
|
804f390064 | ||
|
|
ca2023fa80 | ||
|
|
4e562664f4 | ||
|
|
c8d3ad1d1c | ||
|
|
b7379953d5 | ||
|
|
9d7f5dd32a | ||
|
|
049ed79e7b | ||
|
|
675bf8bde2 | ||
|
|
8dc58ad469 | ||
|
|
827c963d7e | ||
|
|
2ac616b293 | ||
|
|
dcfbc08504 | ||
|
|
19f470ee8c | ||
|
|
a96d078a7a | ||
|
|
b375da6962 | ||
|
|
d17f10d80c | ||
|
|
a336e443f7 | ||
|
|
c5a1c90366 | ||
|
|
95c0aa1e98 | ||
|
|
559b801cc4 | ||
|
|
aa97ddad8b | ||
|
|
d612dc3a6d | ||
|
|
9165d4c3a1 | ||
|
|
12d0f96fc2 | ||
|
|
bec9d6f534 | ||
|
|
892c3669e0 | ||
|
|
ce13efbac9 | ||
|
|
1018b077dc | ||
|
|
9746db5129 | ||
|
|
c4de1f33ba | ||
|
|
a8a4623d24 | ||
|
|
10b51f257f | ||
|
|
52d7df06da | ||
|
|
fcc819584a | ||
|
|
4721d4c461 | ||
|
|
dbdc345d4a | ||
|
|
14c6fc3388 | ||
|
|
33419ed5b1 | ||
|
|
9ec1e24dc5 | ||
|
|
06804675be | ||
|
|
2f43f9910d | ||
|
|
ea9a72af85 | ||
|
|
9a92363e15 | ||
|
|
94389d0efd | ||
|
|
9080886c1a | ||
|
|
13ca55f34d | ||
|
|
5dbea18e30 | ||
|
|
30cfd848d8 | ||
|
|
80d08dbf3a | ||
|
|
7d4c238165 | ||
|
|
0ea9401d90 | ||
|
|
4bdfd8674d | ||
|
|
3e9e0a6447 | ||
|
|
76da41dd46 | ||
|
|
6ddf56ef15 | ||
|
|
eeec737188 | ||
|
|
119ac8f4ab | ||
|
|
bdf0d9cf22 | ||
|
|
bd58ced0e4 | ||
|
|
5af6649435 | ||
|
|
695e1fbb94 | ||
|
|
b027a92dd2 |
No files matched your search
Vendored
+185
@@ -0,0 +1,185 @@
|
||||
import jetbrains.buildServer.configs.kotlin.v2019_2.*
|
||||
import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues
|
||||
import jetbrains.buildServer.configs.kotlin.*
|
||||
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle
|
||||
|
||||
/*
|
||||
The settings script is an entry point for defining a TeamCity
|
||||
project hierarchy. The script should contain a single call to the
|
||||
project() function with a Project instance or an init function as
|
||||
an argument.
|
||||
|
||||
VcsRoots, BuildTypes, Templates, and subprojects can be
|
||||
registered inside the project using the vcsRoot(), buildType(),
|
||||
template(), and subProject() methods respectively.
|
||||
|
||||
To debug settings scripts in command-line, run the
|
||||
|
||||
mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate
|
||||
|
||||
command and attach your debugger to the port 8000.
|
||||
|
||||
To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
|
||||
-> Tool Windows -> Maven Projects), find the generate task node
|
||||
(Plugins -> teamcity-configs -> teamcity-configs:generate), the
|
||||
'Debug' option is available in the context menu for the task.
|
||||
*/
|
||||
|
||||
version = "2021.2"
|
||||
|
||||
project {
|
||||
|
||||
buildType(Build)
|
||||
buildType(BuildSecondaryBranches)
|
||||
buildType(PullRequests)
|
||||
buildType(PullRequestChecks)
|
||||
buildType(PullRequestCompatibility)
|
||||
|
||||
params {
|
||||
text("docker_jdk_version", "17", label = "Gradle version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("docker_gradle_version", "7.3.3", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("git_main_branch", "1.20.x", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("git_branch_spec", """
|
||||
+:refs/heads/(main*)
|
||||
+:refs/heads/(master*)
|
||||
+:refs/heads/(develop|release|staging|main|master)
|
||||
+:refs/heads/(1.*)
|
||||
""".trimIndent(), label = "The branch specification of the repository", description = "By default all main branches are build by the configuration. Modify this value to adapt the branches build.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
|
||||
text("github_repository_name", "MinecraftForge", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `MinecraftForge` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("env.PUBLISHED_JAVA_ARTIFACT_ID", "forge", label = "Published artifact id", description = "The maven coordinate artifact id that has been published by this build. Can not be empty.", allowEmpty = false)
|
||||
text("env.PUBLISHED_JAVA_GROUP", "net.minecraftforge", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false)
|
||||
//These are references and not actually keys
|
||||
password("env.CROWDIN_KEY", "credentialsJSON:a3102dbe-805d-4177-9f54-3d2c2eb08fd5", display = ParameterDisplay.HIDDEN)
|
||||
password("env.LEGACY_KEYSTORE_URL", "credentialsJSON:a2d2efc7-4492-47b6-9826-d14b2c1243a0", display = ParameterDisplay.HIDDEN)
|
||||
password("env.LEGACY_KEYSTORE_PASSWORD", "credentialsJSON:9f9a1a9e-f91b-40d5-b888-8ebc79a99ded", display = ParameterDisplay.HIDDEN)
|
||||
text("additional_publishing_gradle_parameters", "-PcrowdinKey=%env.CROWDIN_KEY% -PkeystoreKeyPass=%env.LEGACY_KEYSTORE_PASSWORD% -PkeystoreStorePass=%env.LEGACY_KEYSTORE_PASSWORD% -Pkeystore=%env.LEGACY_KEYSTORE_URL%", label = "Additional gradle parameters for publish", description = "Contains the additional gradle parameters used during publishing.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
|
||||
|
||||
checkbox("should_execute_build", "false", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
|
||||
checked = "true", unchecked = "false")
|
||||
checkbox("should_execute_test", "false", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
|
||||
checked = "true", unchecked = "false")
|
||||
}
|
||||
|
||||
features {
|
||||
githubIssues {
|
||||
id = "MinecraftForge_MinecraftForge__IssueTracker"
|
||||
displayName = "MinecraftForge/MinecraftForge"
|
||||
repositoryURL = "https://github.com/MinecraftForge/MinecraftForge"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Build : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"), AbsoluteId("MinecraftForge_PublishProjectUsingGradle"), AbsoluteId("MinecraftForge_TriggersStaticFilesWebpageGenerator"))
|
||||
id("MinecraftForge_MinecraftForge__Build")
|
||||
name = "Build"
|
||||
description = "Builds and Publishes the main branches of the project."
|
||||
})
|
||||
|
||||
object BuildSecondaryBranches : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_ExcludesBuildingDefaultBranch"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__BuildSecondaryBranches")
|
||||
name = "Build - Secondary Branches"
|
||||
description = "Builds and Publishes the secondary branches of the project."
|
||||
params {
|
||||
text("git_branch_spec", """
|
||||
+:refs/heads/(*)
|
||||
-:refs/heads/noci*
|
||||
""".trimIndent(), label = "The branch specification of the repository", description = "By default all main branches are build by the configuration. Modify this value to adapt the branches build.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
|
||||
}
|
||||
vcs {
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:1.*
|
||||
-:<default>
|
||||
""".trimIndent()
|
||||
}
|
||||
})
|
||||
|
||||
object PullRequests : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__PullRequests")
|
||||
name = "Pull Requests"
|
||||
description = "Builds pull requests for the project"
|
||||
|
||||
params {
|
||||
checkbox("should_execute_build", "true", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
|
||||
checked = "true", unchecked = "false")
|
||||
text(
|
||||
"gradle_build_task",
|
||||
"assemble",
|
||||
label = "Gradle build task to execute during build",
|
||||
description = "Determines the build task that is executed to build the project.",
|
||||
display = ParameterDisplay.HIDDEN,
|
||||
allowEmpty = false
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
object PullRequestChecks : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__PullRequestChecks")
|
||||
name = "Pull Requests (Checks)"
|
||||
description = "Checks pull requests for the project"
|
||||
|
||||
steps {
|
||||
gradle {
|
||||
name = "Check"
|
||||
id = "RUNNER_10_Check"
|
||||
|
||||
tasks = "checkAll"
|
||||
gradleParams = "--continue %gradle_custom_args%"
|
||||
enableStacktrace = true
|
||||
dockerImage = "%docker_gradle_image%"
|
||||
dockerRunParameters = """
|
||||
-v "/opt/cache/agent/gradle:/home/gradle/.gradle"
|
||||
-v "/opt/cache/shared/gradle:/home/gradle/rocache:ro"
|
||||
--network=host
|
||||
-u 1000:1000
|
||||
%docker_additional_args%
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
||||
vcs {
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:1.*
|
||||
-:<default>
|
||||
""".trimIndent()
|
||||
}
|
||||
})
|
||||
|
||||
object PullRequestCompatibility : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__PullRequestCompatibility")
|
||||
name = "Pull Requests (Compatibility)"
|
||||
description = "Validates binary compatibility for pull requests made to the project"
|
||||
|
||||
steps {
|
||||
gradle {
|
||||
name = "Validate"
|
||||
id = "RUNNER_10_Compatibility"
|
||||
|
||||
tasks = "checkJarCompatibility"
|
||||
gradleParams = "--continue %gradle_custom_args%"
|
||||
enableStacktrace = true
|
||||
dockerImage = "%docker_gradle_image%"
|
||||
dockerRunParameters = """
|
||||
-v "/opt/cache/agent/gradle:/home/gradle/.gradle"
|
||||
-v "/opt/cache/shared/gradle:/home/gradle/rocache:ro"
|
||||
--network=host
|
||||
-u 1000:1000
|
||||
%docker_additional_args%
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
||||
vcs {
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:1.*
|
||||
-:<default>
|
||||
""".trimIndent()
|
||||
}
|
||||
})
|
||||
Vendored
+12
-1
@@ -7,7 +7,7 @@ pipeline {
|
||||
agent {
|
||||
docker {
|
||||
image 'gradle:7-jdk16'
|
||||
args '-v forgegc:/home/gradle/.gradle/'
|
||||
//args '-v forgegc:/home/gradle/.gradle_cache/'
|
||||
}
|
||||
}
|
||||
environment {
|
||||
@@ -34,6 +34,15 @@ pipeline {
|
||||
)
|
||||
}
|
||||
}
|
||||
/*
|
||||
stage('pull_cache') {
|
||||
steps {
|
||||
sh 'cp -r /home/gradle/.gradle_cache/jdks/ /home/gradle/.gradle/jdks/'
|
||||
sh 'cp -r /home/gradle/.gradle_cache/wrapper/ /home/gradle/.gradle/wrapper/'
|
||||
sh 'cp -r /home/gradle/.gradle_cache/caches/ /home/gradle/.gradle/caches/'
|
||||
}
|
||||
}
|
||||
*/
|
||||
stage('setup') {
|
||||
steps {
|
||||
withGradle {
|
||||
@@ -41,6 +50,7 @@ pipeline {
|
||||
}
|
||||
script {
|
||||
env.MYVERSION = sh(returnStdout: true, script: './gradlew :forge:properties -q | grep "^version:" | cut -d" " -f2').trim()
|
||||
env.FMLONLY_VERSION = sh(returnStdout: true, script: './gradlew :fmlonly:properties -q | grep "^version:" | cut -d" " -f2').trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +86,7 @@ pipeline {
|
||||
post {
|
||||
success {
|
||||
build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote net.minecraftforge:forge ${env.MYVERSION} latest")], propagate: false, wait: false
|
||||
build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote net.minecraftforge:fmlonly ${env.FMLONLY_VERSION} latest")], propagate: false, wait: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-16
@@ -1,16 +1,2 @@
|
||||
Minecraft Forge
|
||||
Copyright (c) 2016-${year}.
|
||||
|
||||
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
|
||||
Copyright (c) Forge Development LLC and contributors
|
||||
SPDX-License-Identifier: LGPL-2.1-only
|
||||
+146
-49
@@ -5,11 +5,18 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:[5.1.39,5.2.0)'
|
||||
}
|
||||
}
|
||||
|
||||
import groovy.json.JsonBuilder
|
||||
import de.undercouch.gradle.tasks.download.Download
|
||||
import net.minecraftforge.forge.tasks.checks.CheckATs
|
||||
import net.minecraftforge.forge.tasks.checks.CheckExcs
|
||||
import net.minecraftforge.forge.tasks.checks.CheckPatches
|
||||
import net.minecraftforge.forge.tasks.checks.CheckSAS
|
||||
import net.minecraftforge.forge.tasks.checks.CheckTask
|
||||
import net.minecraftforge.forge.tasks.checks.CheckMode
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.util.Date
|
||||
@@ -17,6 +24,8 @@ import java.util.LinkedHashMap
|
||||
import net.minecraftforge.forge.tasks.*
|
||||
import static net.minecraftforge.forge.tasks.Util.*
|
||||
import net.minecraftforge.gradle.common.tasks.ApplyBinPatches
|
||||
import net.minecraftforge.gradle.common.tasks.CheckJarCompatibility
|
||||
import net.minecraftforge.gradle.common.tasks.ApplyBinPatches
|
||||
import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact
|
||||
import net.minecraftforge.gradle.common.tasks.ExtractInheritance
|
||||
import net.minecraftforge.gradle.common.tasks.SignJar
|
||||
@@ -27,8 +36,9 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
||||
plugins {
|
||||
id 'org.cadixdev.licenser' version '0.6.1'
|
||||
id 'com.github.ben-manes.versions' version '0.36.0'
|
||||
id 'net.minecraftforge.gradleutils' version '1.+'
|
||||
id 'net.minecraftforge.gradleutils' version '[2.2,2.3)'
|
||||
id 'eclipse'
|
||||
id 'de.undercouch.download' version '5.1.3'
|
||||
}
|
||||
|
||||
Util.init() //Init all our extension methods!
|
||||
@@ -46,25 +56,28 @@ ext {
|
||||
MAPPING_VERSION = '1.17.1'
|
||||
MC_VERSION = '1.17.1'
|
||||
MCP_VERSION = '20210706.113038'
|
||||
SPI_VERSION = '4.0.9'
|
||||
SPI_VERSION = '4.0.10'
|
||||
ACCESSTRANSFORMERS_VERSION = '8.0.4'
|
||||
COREMODS_VERSION = '5.0.1'
|
||||
EVENTBUS_VERSION = '5.0.3'
|
||||
COREMODS_VERSION = '5.0.3'
|
||||
EVENTBUS_VERSION = '5.0.7'
|
||||
MODLAUNCHER_VERSION = '9.0.7'
|
||||
SECUREJARHANDLER_VERSION = '0.9.44'
|
||||
BOOTSTRAPLAUNCHER_VERSION = '0.1.15'
|
||||
ASM_VERSION = '9.1'
|
||||
INSTALLER_VERSION = '2.1.4'
|
||||
SECUREJARHANDLER_VERSION = '0.9.54'
|
||||
BOOTSTRAPLAUNCHER_VERSION = '0.1.17'
|
||||
ASM_VERSION = '9.6'
|
||||
INSTALLER_VERSION = '2.2.+'
|
||||
MIXIN_VERSION = '0.8.5'
|
||||
|
||||
GIT_INFO = gradleutils.gitInfo
|
||||
VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION)
|
||||
GIT_INFO = gradleutils.gitInfo
|
||||
LAST_RB = GIT_INFO.tag.rsplit('.', 1)[1] as int >= 1 ? GIT_INFO.tag + '.0' : null
|
||||
// FML_VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, 'FML', MC_VERSION)
|
||||
FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1)
|
||||
MIN_TAG_FOR_CHANGELOG = "37.0"
|
||||
|
||||
SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0'
|
||||
VIGNETTE = 'net.minecraftforge.lex:vignette:0.2.0.16'
|
||||
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar'
|
||||
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.2.7'
|
||||
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.4.1'
|
||||
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
|
||||
}
|
||||
|
||||
@@ -73,6 +86,10 @@ println('Version: ' + VERSION +
|
||||
' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ')' +
|
||||
' Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
changelog {
|
||||
fromTag MIN_TAG_FOR_CHANGELOG
|
||||
}
|
||||
|
||||
def extraTxts = [
|
||||
rootProject.file('CREDITS.txt'),
|
||||
rootProject.file('LICENSE.txt')
|
||||
@@ -110,6 +127,15 @@ subprojects {
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
|
||||
|
||||
tasks.withType(Javadoc).configureEach {
|
||||
options.tags = [
|
||||
'apiNote:a:<em>API Note:</em>',
|
||||
'implSpec:a:<em>Implementation Requirements:</em>',
|
||||
'implNote:a:<em>Implementation Note:</em>'
|
||||
]
|
||||
options.addStringOption('Xdoclint:all,-missing', '-public')
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
@@ -242,14 +268,15 @@ def sharedDeps = {
|
||||
installer 'org.apache.maven:maven-artifact:3.6.3'
|
||||
installer 'org.apache.commons:commons-lang3:3.8.1'
|
||||
installer 'net.jodah:typetools:0.8.3'
|
||||
installer 'org.apache.logging.log4j:log4j-api:2.14.1'
|
||||
installer 'org.apache.logging.log4j:log4j-core:2.14.1'
|
||||
installer 'org.apache.logging.log4j:log4j-api:2.15.0' //TODO: Unpin in 1.18.1 or when Mojang bumps the Log4J version
|
||||
installer 'org.apache.logging.log4j:log4j-core:2.15.0' //TODO: Unpin in 1.18.1 or when Mojang bumps the Log4J version
|
||||
installer 'org.apache.logging.log4j:log4j-slf4j18-impl:2.15.0' //TODO: Unpin in 1.18.1 or when Mojang bumps the Log4J version
|
||||
installer 'net.minecrell:terminalconsoleappender:1.2.0'
|
||||
installer 'org.jline:jline-reader:3.12.+' //Dep of TerminaalConsoleeAppender
|
||||
installer 'org.jline:jline-terminal:3.12.+' //Dep of TerminaalConsoleeAppender
|
||||
installer 'net.sf.jopt-simple:jopt-simple:5.0.4'
|
||||
// installer 'org.spongepowered:mixin:0.8.3'
|
||||
installer 'org.openjdk.nashorn:nashorn-core:15.1.1'
|
||||
installer "org.spongepowered:mixin:${MIXIN_VERSION}"
|
||||
installer 'org.openjdk.nashorn:nashorn-core:15.3'
|
||||
installer 'com.google.guava:guava:21.0'
|
||||
installer 'com.google.code.gson:gson:2.8.0'
|
||||
|
||||
@@ -304,7 +331,7 @@ def sharedFmlonlyForge = { Project prj ->
|
||||
}
|
||||
|
||||
prj.task([type: DownloadMavenArtifact], 'downloadInstaller') {
|
||||
artifact = "net.minecraftforge:installer:${INSTALLER_VERSION}:shrunk"
|
||||
artifact = "net.minecraftforge:installer:${INSTALLER_VERSION}:fatjar"
|
||||
changing = true
|
||||
}
|
||||
|
||||
@@ -391,12 +418,13 @@ def sharedFmlonlyForge = { Project prj ->
|
||||
}
|
||||
|
||||
// SecureJarHandler bootstrap values.
|
||||
run.property 'legacyClassPath', '{runtime_classpath}'
|
||||
run.property 'ignoreList', prj.configurations.moduleonly.files.collect {it.name}.join(',') + ",client-extra,fmlcore,javafmllanguage,mclanguage,${prj.name}-${prj.version},${prj.rootProject.ext.MC_VERSION}-${prj.name}${prj.version.substring(prj.rootProject.ext.MC_VERSION.length())}"
|
||||
run.property 'ignoreList', prj.configurations.moduleonly.files.collect {it.name.replaceAll(/([-_]([.\d]*\d+)|\.jar$)/, '') }.join(',') + ",client-extra,fmlcore,javafmllanguage,mclanguage,${prj.name}-"
|
||||
run.property 'mergeModules', 'jna-5.8.0.jar,jna-platform-58.0.jar,java-objc-bridge-1.0.0.jar'
|
||||
if (userdevRuns.contains(run)) {
|
||||
run.property 'legacyClassPath.file', '{minecraft_classpath_file}'
|
||||
run.jvmArgs '-p', '{modules}'
|
||||
} else {
|
||||
run.property 'legacyClassPath.file', '{runtime_classpath_file}'
|
||||
run.jvmArgs '-p', prj.configurations.moduleonly.files.collect { it.path }.join(File.pathSeparator)
|
||||
}
|
||||
run.jvmArgs '--add-modules', 'ALL-MODULE-PATH'
|
||||
@@ -570,8 +598,7 @@ project(':fmlonly') {
|
||||
'--fml.mcVersion', MC_VERSION,
|
||||
'--fml.forgeGroup', project.group,
|
||||
'--fml.mcpVersion', MCP_VERSION],
|
||||
jvm: ['-DlegacyClassPath=${classpath}',
|
||||
"-DignoreList=${fmlonly_client.properties.ignoreList}",
|
||||
jvm: ["-DignoreList=${fmlonly_client.properties.ignoreList},\${version_name}.jar",
|
||||
"-DmergeModules=${fmlonly_client.properties.mergeModules}",
|
||||
'-DlibraryDirectory=${library_directory}',
|
||||
'-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{"\${library_directory}/${it.downloads.artifact.path}"}.join('${classpath_separator}'),
|
||||
@@ -586,7 +613,7 @@ project(':fmlonly') {
|
||||
}
|
||||
}
|
||||
|
||||
task installerJson(type: InstallerJson) {
|
||||
task installerJson(type: InstallerJson, dependsOn: 'signUniversalJar') {
|
||||
icon = rootProject.file('icon.ico')
|
||||
packedDependencies = PACKED_DEPS
|
||||
|
||||
@@ -812,11 +839,13 @@ project(':forge') {
|
||||
}
|
||||
|
||||
configurations {
|
||||
internalProject
|
||||
installer {
|
||||
// Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it.
|
||||
transitive = false
|
||||
}
|
||||
moduleonly
|
||||
implementation.extendsFrom(internalProject)
|
||||
api.extendsFrom(installer)
|
||||
}
|
||||
|
||||
@@ -825,10 +854,10 @@ project(':forge') {
|
||||
testImplementation 'org.junit.vintage:junit-vintage-engine:5.+'
|
||||
testImplementation 'org.opentest4j:opentest4j:1.2.0' // needed for junit 5
|
||||
testImplementation 'org.hamcrest:hamcrest-all:1.3' // needs advanced matching for list order
|
||||
implementation project(':fmlcore')
|
||||
implementation project(':fmlloader')
|
||||
implementation project(':javafmllanguage')
|
||||
implementation project(':mclanguage')
|
||||
internalProject project(':fmlcore')
|
||||
internalProject project(':fmlloader')
|
||||
internalProject project(':javafmllanguage')
|
||||
internalProject project(':mclanguage')
|
||||
}
|
||||
dependencies sharedDeps
|
||||
|
||||
@@ -930,6 +959,7 @@ project(':forge') {
|
||||
'--mod', 'scaffolding_test',
|
||||
'--mod', 'custom_tag_types_test',
|
||||
'--mod', 'new_model_loader_test',
|
||||
'--mod', 'remove_tag_datagen_test',
|
||||
'--output', rootProject.file('src/generated_test/resources/'),
|
||||
'--existing', sourceSets.main.resources.srcDirs[0],
|
||||
'--existing', sourceSets.test.resources.srcDirs[0]
|
||||
@@ -988,9 +1018,12 @@ project(':forge') {
|
||||
]
|
||||
}
|
||||
|
||||
task crowdin(type: Crowdin) {
|
||||
key = project.hasProperty('crowdinKey') ? project.crowdinKey : null
|
||||
//TODO: Merge our english.json?
|
||||
tasks.register('downloadCrowdin', Download) {
|
||||
src 'https://files.minecraftforge.net/crowdin.zip'
|
||||
dest file('build/crowdin.zip')
|
||||
useETag 'all'
|
||||
onlyIfModified true
|
||||
quiet true
|
||||
}
|
||||
|
||||
sharedFmlonlyForge.call(project)
|
||||
@@ -1002,6 +1035,7 @@ project(':forge') {
|
||||
|
||||
task extractInheritance(type: ExtractInheritance, dependsOn: [genJoinedBinPatches, downloadLibraries]) {
|
||||
tool = INSTALLER_TOOLS + ':fatjar'
|
||||
args.add '--annotations'
|
||||
input = genJoinedBinPatches.cleanJar
|
||||
libraries.addAll downloadLibraries.librariesOutput.map { rf -> Files.readAllLines(rf.asFile.toPath()).stream().map(File::new).collect(java.util.stream.Collectors.toList()) }
|
||||
}
|
||||
@@ -1025,40 +1059,101 @@ project(':forge') {
|
||||
}
|
||||
}
|
||||
|
||||
task checkATs(type: CheckATs, dependsOn: [extractInheritance, createSrg2Mcp]) {
|
||||
inheritance = extractInheritance.output
|
||||
tasks.register('checkAll') {
|
||||
dependsOn 'checkLicenses'
|
||||
group = 'checks'
|
||||
}
|
||||
tasks.register('checkAllAndFix') {
|
||||
dependsOn 'findFieldInstanceChecks', 'checkLicenses'
|
||||
group = 'checks'
|
||||
}
|
||||
|
||||
CheckTask.registerTask(tasks, 'ATs', CheckATs) {
|
||||
dependsOn extractInheritance, createSrg2Mcp
|
||||
ats.from patcher.accessTransformers
|
||||
inheritance = extractInheritance.output
|
||||
mappings = createSrg2Mcp.output
|
||||
}
|
||||
|
||||
task checkSAS(type: CheckSAS, dependsOn: extractInheritance) {
|
||||
inheritance = extractInheritance.output
|
||||
CheckTask.registerTask(tasks, 'SAS', CheckSAS) {
|
||||
dependsOn extractInheritance
|
||||
sass.from patcher.sideAnnotationStrippers
|
||||
inheritance = extractInheritance.output
|
||||
}
|
||||
|
||||
task checkExcs(type: CheckExcs, dependsOn: jar) {
|
||||
CheckTask.registerTask(tasks, 'Excs', CheckExcs) {
|
||||
dependsOn jar
|
||||
binary = jar.archiveFile.get().asFile
|
||||
excs.from patcher.excs
|
||||
}
|
||||
|
||||
task checkAll(dependsOn: [checkATs, checkSAS, checkExcs, findFieldInstanceChecks]){}
|
||||
|
||||
task checkPatchesAndFix(type: CheckPatches, dependsOn: genPatches) {
|
||||
CheckTask.registerTask(tasks, 'Patches', CheckPatches) {
|
||||
dependsOn genPatches
|
||||
patchDir = file("$rootDir/patches")
|
||||
autoFix = true
|
||||
}
|
||||
|
||||
task checkPatches(type: CheckPatches, dependsOn: genPatches) {
|
||||
patchDir = file("$rootDir/patches")
|
||||
autoFix = false
|
||||
patchesWithS2SArtifact = [
|
||||
'minecraft/net/minecraft/client/renderer/ViewFrustum.java.patch',
|
||||
'minecraft/net/minecraft/data/BlockModelDefinition.java.patch',
|
||||
]
|
||||
}
|
||||
|
||||
genPatches {
|
||||
finalizedBy checkPatches
|
||||
finalizedBy checkAndFixPatches
|
||||
autoHeader true
|
||||
lineEnding = '\n'
|
||||
}
|
||||
|
||||
def baseForgeVersionProperty = project.objects.property(String)
|
||||
baseForgeVersionProperty.set(project.provider { getLatestForgeVersion(MC_VERSION) }.map { MC_VERSION + '-' + it })
|
||||
baseForgeVersionProperty.finalizeValueOnRead()
|
||||
def jarCompatibilityTaskSetup = { task ->
|
||||
task.group = 'jar compatibility'
|
||||
task.onlyIf {
|
||||
baseForgeVersionProperty.getOrNull() != null
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('setupCheckJarCompatibility', SetupCheckJarCompatibility) {
|
||||
inputVersion = baseForgeVersionProperty
|
||||
}
|
||||
|
||||
tasks.register('applyBaseCompatibilityJarBinPatches', ApplyBinPatches) {
|
||||
jarCompatibilityTaskSetup(it)
|
||||
|
||||
clean = project.tasks.createJoinedSRG.output
|
||||
patch = project.tasks.named('setupCheckJarCompatibility').flatMap { it.baseBinPatchesOutput }
|
||||
output = project.layout.buildDirectory.dir(name).map { it.file('output.jar') }
|
||||
}
|
||||
|
||||
tasks.register('mergeBaseForgeJar', MergeJars) {
|
||||
jarCompatibilityTaskSetup(it)
|
||||
|
||||
inputJars.from(project.tasks.named('applyBaseCompatibilityJarBinPatches').flatMap { it.output })
|
||||
inputJars.from(baseForgeVersionProperty.map { inputVersion ->
|
||||
def output = project.layout.buildDirectory.dir(name).map { it.file("forge-${inputVersion}-universal.jar") }.get().asFile
|
||||
project.rootProject.extensions.download.run {
|
||||
src "https://maven.minecraftforge.net/net/minecraftforge/forge/${inputVersion}/forge-${inputVersion}-universal.jar"
|
||||
dest output
|
||||
}
|
||||
return output
|
||||
})
|
||||
}
|
||||
|
||||
tasks.register('checkJarCompatibility', CheckJarCompatibility) {
|
||||
jarCompatibilityTaskSetup(it)
|
||||
dependsOn 'setupCheckJarCompatibility'
|
||||
|
||||
baseJar = project.tasks.named('mergeBaseForgeJar').flatMap { it.output }
|
||||
baseLibraries.from(project.tasks.named('createJoinedSRG').flatMap { it.output })
|
||||
|
||||
inputJar = project.tasks.named('reobfJar').flatMap { it.output }
|
||||
|
||||
commonLibraries.from(configurations.minecraftImplementation)
|
||||
commonLibraries.from(configurations.installer)
|
||||
commonLibraries.from(configurations.moduleonly)
|
||||
commonLibraries.from(configurations.internalProject)
|
||||
}
|
||||
|
||||
|
||||
task launcherJson(type: LauncherJson) {
|
||||
packedDependencies = [':fmlloader:jar']
|
||||
doFirst {
|
||||
@@ -1078,8 +1173,7 @@ project(':forge') {
|
||||
'--fml.mcVersion', MC_VERSION,
|
||||
'--fml.forgeGroup', project.group,
|
||||
'--fml.mcpVersion', MCP_VERSION],
|
||||
jvm: ['-DlegacyClassPath=${classpath}',
|
||||
"-DignoreList=${forge_client.properties.ignoreList}",
|
||||
jvm: ["-DignoreList=${forge_client.properties.ignoreList},\${version_name}.jar",
|
||||
"-DmergeModules=${forge_client.properties.mergeModules}",
|
||||
'-DlibraryDirectory=${library_directory}',
|
||||
'-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{'${library_directory}/' + it.downloads.artifact.path}.join('${classpath_separator}'),
|
||||
@@ -1094,7 +1188,7 @@ project(':forge') {
|
||||
}
|
||||
}
|
||||
|
||||
task installerJson(type: InstallerJson, dependsOn: [launcherJson, genClientBinPatches, applyClientBinPatches, applyServerBinPatches]) {
|
||||
task installerJson(type: InstallerJson, dependsOn: [launcherJson, genClientBinPatches, applyClientBinPatches, applyServerBinPatches, 'signUniversalJar']) {
|
||||
ext {
|
||||
// remove :fatjar
|
||||
BIN_PATCHER = BINPATCH_TOOL.substring(0, BINPATCH_TOOL.length() - 1 - BINPATCH_TOOL.split(':')[3].length())
|
||||
@@ -1277,9 +1371,12 @@ project(':forge') {
|
||||
from extraTxts
|
||||
|
||||
// add crowdin locales
|
||||
from { crowdin.output.present && crowdin.output.get().asFile.exists() ? zipTree(crowdin.output) : null}
|
||||
dependsOn crowdin
|
||||
duplicatesStrategy = 'exclude'
|
||||
from zipTree(downloadCrowdin.dest).matching {
|
||||
include 'assets/forge/lang/*.json'
|
||||
}
|
||||
|
||||
dependsOn downloadCrowdin
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
doFirst {
|
||||
MANIFESTS.each{ pkg, values ->
|
||||
|
||||
@@ -6,4 +6,6 @@ dependencies {
|
||||
implementation 'org.ow2.asm:asm:9.1'
|
||||
implementation 'org.ow2.asm:asm-tree:9.1'
|
||||
implementation 'net.minecraftforge:srgutils:0.4.+'
|
||||
implementation 'commons-io:commons-io:2.8.0'
|
||||
implementation 'com.google.code.gson:gson:2.10'
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.TupleConstructor
|
||||
|
||||
@CompileStatic
|
||||
@TupleConstructor
|
||||
final class InheritanceData implements Annotatable {
|
||||
String name
|
||||
int access
|
||||
String superName
|
||||
List<String> interfaces = []
|
||||
Map<String, Method> methods = [:]
|
||||
Map<String, Field> fields = [:]
|
||||
List<Annotation> annotations = []
|
||||
|
||||
@TupleConstructor
|
||||
static final class Method implements Annotatable {
|
||||
int access
|
||||
String override
|
||||
List<Annotation> annotations = []
|
||||
}
|
||||
|
||||
@TupleConstructor
|
||||
static final class Field implements Annotatable {
|
||||
int access
|
||||
String desc
|
||||
List<Annotation> annotations = []
|
||||
}
|
||||
|
||||
@TupleConstructor
|
||||
static final class Annotation {
|
||||
String desc
|
||||
}
|
||||
|
||||
private static final Gson GSON = new Gson()
|
||||
static Map<String, InheritanceData> parse(File file) {
|
||||
try (final reader = file.newReader()) {
|
||||
return GSON.fromJson(reader, new TypeToken<Map<String, InheritanceData>>() {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CompileStatic
|
||||
interface Annotatable {
|
||||
List<InheritanceData.Annotation> getAnnotations()
|
||||
}
|
||||
@@ -48,14 +48,16 @@ abstract class LauncherJson extends DefaultTask {
|
||||
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) }
|
||||
def libs = [:]
|
||||
getArtifacts(project, project.configurations.installer, false).each { key, lib -> libs[key] = lib }
|
||||
getArtifacts(project, project.configurations.moduleonly, false).each { key, lib -> libs[key] = lib }
|
||||
|
||||
packedDependencies.get().collect{ project.rootProject.tasks.findByPath(it) }.forEach {
|
||||
def path = Util.getMavenPath(it)
|
||||
def key = Util.getMavenDep(it)
|
||||
|
||||
json.libraries.add([
|
||||
name: Util.getMavenDep(it),
|
||||
libs[key] = [
|
||||
name: key,
|
||||
downloads: [
|
||||
artifact: [
|
||||
path: path,
|
||||
@@ -64,8 +66,9 @@ abstract class LauncherJson extends DefaultTask {
|
||||
size: it.archiveFile.get().asFile.length()
|
||||
]
|
||||
]
|
||||
])
|
||||
]
|
||||
}
|
||||
libs.each { key, lib -> json.libraries.add(lib) }
|
||||
Files.writeString(output.get().asFile.toPath(), new JsonBuilder(json).toPrettyString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
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 MergeJars extends DefaultTask {
|
||||
MergeJars() {
|
||||
output.convention(project.layout.buildDirectory.dir(name).map { it.file('output.jar') })
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void run() {
|
||||
def jars = inputJars.files
|
||||
|
||||
try (ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(output.get().asFile))) {
|
||||
for (def jar : jars) {
|
||||
try (ZipInputStream zin = new ZipInputStream(new FileInputStream(jar))) {
|
||||
def entry
|
||||
while ((entry = zin.getNextEntry()) != null) {
|
||||
ZipEntry _new = new ZipEntry(entry.getName())
|
||||
_new.setTime(0) //SHOULD be the same time as the main entry, but NOOOO _new.setTime(entry.getTime()) throws DateTimeException, so you get 0, screw you!
|
||||
zout.putNextEntry(_new)
|
||||
IOUtils.copy(zin, zout)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@InputFiles
|
||||
abstract ConfigurableFileCollection getInputJars()
|
||||
|
||||
@OutputFile
|
||||
abstract RegularFileProperty getOutput()
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
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.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
abstract class SetupCheckJarCompatibility extends DefaultTask {
|
||||
SetupCheckJarCompatibility() {
|
||||
group = 'jar compatibility'
|
||||
onlyIf {
|
||||
inputVersion.getOrNull() != null
|
||||
}
|
||||
outputs.upToDateWhen { false } // Never up to date, because this setup task should always run
|
||||
|
||||
baseBinPatchesOutput.convention(project.layout.buildDirectory.dir(name).map { it.file('joined.lzma') })
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void run() {
|
||||
def inputVersion = inputVersion.get()
|
||||
|
||||
def baseForgeUserdev = project.layout.buildDirectory.dir(name).map { it.file("forge-${inputVersion}-userdev.jar") }.get().asFile
|
||||
project.rootProject.extensions.download.run {
|
||||
src "https://maven.minecraftforge.net/net/minecraftforge/forge/${inputVersion}/forge-${inputVersion}-userdev.jar"
|
||||
dest baseForgeUserdev
|
||||
}
|
||||
|
||||
def joinedLzma = project.zipTree(baseForgeUserdev).matching { it.include('joined.lzma') }.singleFile
|
||||
|
||||
Files.copy(joinedLzma.toPath(), baseBinPatchesOutput.get().asFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
abstract Property<String> getInputVersion()
|
||||
|
||||
@OutputFile
|
||||
abstract RegularFileProperty getBaseBinPatchesOutput()
|
||||
}
|
||||
@@ -138,4 +138,9 @@ public class Util {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLatestForgeVersion(mcVersion) {
|
||||
def json = new JsonSlurper().parseText(new URL("https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json").getText("UTF-8"))
|
||||
return json.promos["$mcVersion-latest"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
package net.minecraftforge.forge.tasks.checks
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.TupleConstructor
|
||||
import net.minecraftforge.forge.tasks.InheritanceData
|
||||
import net.minecraftforge.srgutils.IMappingFile
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.RegularFile
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.Optional
|
||||
import org.objectweb.asm.Opcodes
|
||||
|
||||
@CompileStatic
|
||||
abstract class CheckATs extends CheckTask {
|
||||
|
||||
@InputFile abstract RegularFileProperty getInheritance()
|
||||
@InputFiles abstract ConfigurableFileCollection getAts()
|
||||
@InputFile @Optional abstract RegularFileProperty getMappings()
|
||||
|
||||
@Override
|
||||
void check(Reporter reporter, boolean fix) {
|
||||
final IMappingFile mappings = mappings.map { RegularFile it -> IMappingFile.load(it.asFile) }.getOrNull()
|
||||
final inheritance = InheritanceData.parse(this.inheritance.get().asFile)
|
||||
|
||||
ats.each {
|
||||
final lines = process(it, reporter, inheritance)
|
||||
if (fix) {
|
||||
it.text = joinBack(lines, inheritance, mappings).join('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static TreeMap<String, ATParser.Entry> process(File file, Reporter reporter, Map<String, InheritanceData> inheritance) {
|
||||
final TreeMap<String, ATParser.Entry> lines = ATParser.parse(file.readLines(), reporter)
|
||||
final Map<String, ATParser.Entry> constructorGroups = [:]
|
||||
|
||||
final itr = lines.entrySet().iterator()
|
||||
final toRemove = []
|
||||
while (itr.hasNext()) {
|
||||
final next = itr.next()
|
||||
String key = next.key
|
||||
final entry = next.value
|
||||
if (entry === null) continue
|
||||
|
||||
final binaryName = entry.cls.replaceAll('\\.', '/')
|
||||
|
||||
// Process Groups, this will remove any entries outside the group that is covered by the group
|
||||
if (entry.group) {
|
||||
final jcls = inheritance[binaryName]
|
||||
if (jcls === null) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid group: $key")
|
||||
} else if ('*' == entry.desc) {
|
||||
if (!jcls.fields) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid group, class has no fields: $key")
|
||||
} else {
|
||||
jcls.fields.each { field, value ->
|
||||
final fkey = entry.cls + ' ' + field
|
||||
if (accessLevel(value.access) < accessStr(entry.modifier)) {
|
||||
if (lines.containsKey(fkey)) {
|
||||
toRemove.add(fkey)
|
||||
} else if (!entry.existing.contains(fkey)) {
|
||||
reporter.report("Missing group entry: $fkey")
|
||||
}
|
||||
entry.children.add(fkey)
|
||||
} else if (lines.containsKey(fkey)) {
|
||||
toRemove.add(fkey)
|
||||
reporter.report("Found invalid group entry: $fkey")
|
||||
}
|
||||
}
|
||||
entry.existing.findAll { it !in entry.children }.each { println('Removed: ' + it) }
|
||||
}
|
||||
} else if ('*()' == entry.desc) {
|
||||
if (!jcls.methods) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid group, class has no methods: $key")
|
||||
} else {
|
||||
jcls.methods.each { mtd, value ->
|
||||
if (mtd.startsWith('<clinit>') || mtd.startsWith('lambda$')) return
|
||||
key = entry.cls + ' ' + mtd.replace(' ', '')
|
||||
if (accessLevel(value.access) < accessStr(entry.modifier)) {
|
||||
if (lines.containsKey(key)) {
|
||||
toRemove.add(key)
|
||||
} else if (!entry.existing.contains(key)) {
|
||||
reporter.report("Missing group entry: $key")
|
||||
}
|
||||
entry.children.add(key)
|
||||
} else if (lines.containsKey(key)) {
|
||||
toRemove.add(key)
|
||||
reporter.report("Found invalid group entry: $key")
|
||||
}
|
||||
}
|
||||
entry.existing.findAll { it !in entry.children }.each { println('Removed: ' + it) }
|
||||
}
|
||||
} else if ('<init>' == entry.desc) { //Make all public non-abstract subclasses
|
||||
constructorGroups.put(binaryName, entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Process normal lines, remove invalid and remove narrowing
|
||||
else {
|
||||
def jcls = inheritance.get(binaryName)
|
||||
if (jcls === null) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid: $key")
|
||||
} else if (entry.desc == '') {
|
||||
if (accessLevel(jcls.access) > accessStr(entry.modifier) && (entry.comment === null || !entry.comment.startsWith('#force '))) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid Narrowing: $key")
|
||||
}
|
||||
} else if (!entry.desc.contains('(')) {
|
||||
if (!jcls.fields || !jcls.fields.containsKey(entry.desc)) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid: $key")
|
||||
} else {
|
||||
final value = jcls.fields[entry.desc]
|
||||
if (accessLevel(value.access) > accessStr(entry.modifier) && (entry.comment === null || !entry.comment.startsWith('#force '))) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid Narrowing: $key - ${entry.comment}")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final jdesc = entry.desc.replace('(', ' (')
|
||||
if (!jcls.methods || !jcls.methods.containsKey(jdesc)) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid: $key")
|
||||
} else {
|
||||
final value = jcls.methods[jdesc]
|
||||
if (accessLevel(value.access) > accessStr(entry.modifier) && (entry.comment === null || !entry.comment.startsWith('#force '))) {
|
||||
itr.remove()
|
||||
reporter.report("Invalid Narrowing: $key")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inheritance.each { tcls, value ->
|
||||
if (!value.methods || ((value.access & Opcodes.ACC_ABSTRACT) !== 0)) return
|
||||
String parent = tcls
|
||||
while (parent !== null) {
|
||||
constructorGroups[parent]?.tap { entry ->
|
||||
value.methods.each { mtd, v ->
|
||||
if (mtd.startsWith('<init>')) {
|
||||
final child = tcls.replaceAll('/', '\\.') + ' ' + mtd.replace(' ', '')
|
||||
if (accessLevel(v.access) < 3) {
|
||||
if (lines.containsKey(child)) {
|
||||
toRemove.add(child)
|
||||
} else if (child !in entry.existing) {
|
||||
reporter.report("Missing group entry: $child")
|
||||
}
|
||||
entry.children.add(child)
|
||||
} else if (lines.containsKey(child)) {
|
||||
toRemove.add(child)
|
||||
reporter.report("Found invalid group entry: $child")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parent = inheritance[parent]?.superName
|
||||
}
|
||||
}
|
||||
constructorGroups.values().each { entry -> entry.existing.findAll { it !in entry.children }.each{ reporter.report("Found invalid group entry: $it") } }
|
||||
|
||||
toRemove.each(lines.&remove)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
private static List<String> joinBack(TreeMap<String, ATParser.Entry> lines, Map<String, InheritanceData> inheritance, IMappingFile mappings) {
|
||||
final data = []
|
||||
final remapComment = { ATParser.Entry entry ->
|
||||
if (!mappings || !entry || !entry.desc) return null
|
||||
final comment = entry.comment?.substring(1)?.trim()
|
||||
final jsonCls = inheritance.get(entry.cls.replaceAll('\\.', '/'))
|
||||
final mappingsClass = mappings?.getClass(jsonCls.name)
|
||||
if (mappingsClass === null) return entry.comment
|
||||
final idx = entry.desc.indexOf('(')
|
||||
|
||||
String 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 ?: '')).trim())
|
||||
value.children.each {
|
||||
final line = value.modifier + ' ' + it
|
||||
final entry = ATParser.parseEntry(line)
|
||||
final comment = remapComment(entry)
|
||||
data.add(line + (comment ? ' ' + comment : ''))
|
||||
}
|
||||
data.add('#endgroup')
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
static int accessStr(String 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
|
||||
}
|
||||
}
|
||||
|
||||
static int accessLevel(int 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
|
||||
}
|
||||
}
|
||||
|
||||
@CompileStatic
|
||||
class ATParser {
|
||||
static TreeMap<String, Entry> parse(List<String> lines, CheckTask.Reporter reporter) {
|
||||
TreeMap<String, Entry> outLines = new TreeMap<>()
|
||||
Entry group = null
|
||||
for (final line : lines) {
|
||||
if (line.isEmpty()) continue
|
||||
if (line.startsWith('#group ')) {
|
||||
final entry = parseEntry(line.substring(7))
|
||||
|
||||
if (entry.desc != '*' && entry.desc != '*()' && entry.desc != '<init>') {
|
||||
reporter.report("Invalid group: $line", false)
|
||||
}
|
||||
|
||||
entry.group = true
|
||||
entry.children = []
|
||||
entry.existing = []
|
||||
|
||||
group = entry
|
||||
|
||||
if (outLines.containsKey(entry.key)) {
|
||||
reporter.report("Duplicate group: $line", false)
|
||||
}
|
||||
|
||||
outLines[entry.key] = group
|
||||
} else if (group !== null) {
|
||||
if (line.startsWith('#endgroup')) {
|
||||
group = null
|
||||
} else {
|
||||
final key = parseEntry(line).key
|
||||
group.existing.add(key)
|
||||
}
|
||||
} else if (line.startsWith('#endgroup')) {
|
||||
reporter.report("Invalid group ending: $line", false)
|
||||
} else if (line.startsWith('#')) {
|
||||
//Nom
|
||||
} else {
|
||||
final entry = parseEntry(line)
|
||||
if (outLines.containsKey(entry.key)) {
|
||||
reporter.report("Found duplicate: $line")
|
||||
continue
|
||||
}
|
||||
outLines[entry.key] = entry
|
||||
}
|
||||
}
|
||||
return outLines
|
||||
}
|
||||
|
||||
static Entry parseEntry(String line) {
|
||||
final idx = line.indexOf('#')
|
||||
final String comment = idx === -1 ? null : line.substring(idx)
|
||||
if (idx !== -1) line = line.substring(0, idx - 1)
|
||||
final data = (line.trim() + ' ').split(' ', -1)
|
||||
new Entry(data[0], data[1], data[2], comment)
|
||||
}
|
||||
|
||||
@TupleConstructor
|
||||
static final class Entry {
|
||||
String modifier, cls, desc, comment
|
||||
|
||||
Set<String> existing
|
||||
TreeSet<String> children
|
||||
boolean group = false
|
||||
|
||||
@Lazy
|
||||
String key = {cls + (desc.isEmpty() ? '' : ' ' + desc)}()
|
||||
|
||||
Object getAt(String key) {
|
||||
return getProperty(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package net.minecraftforge.forge.tasks.checks
|
||||
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
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 CheckTask {
|
||||
|
||||
@InputFile abstract RegularFileProperty getBinary()
|
||||
@InputFiles abstract ConfigurableFileCollection getExcs()
|
||||
|
||||
@Override
|
||||
void check(Reporter reporter, boolean fix) {
|
||||
final Set<String> known = []
|
||||
collectKnown(known)
|
||||
|
||||
excs.each { f ->
|
||||
final lines = []
|
||||
f.eachLine { line ->
|
||||
def idx = line.indexOf('#')
|
||||
if (idx == 0 || line.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (idx != -1) line = line.substring(0, idx - 1)
|
||||
|
||||
if (!line.contains('=')) {
|
||||
reporter.report("Invalid: $line")
|
||||
return
|
||||
}
|
||||
|
||||
def (String key, String value) = line.split('=', 2)
|
||||
if (!known.contains(key)) {
|
||||
reporter.report("Unknown: $line")
|
||||
return
|
||||
}
|
||||
|
||||
String desc = key.split('\\.', 2)[1]
|
||||
if (!desc.contains('(')) {
|
||||
reporter.report("Invalid: $line")
|
||||
return
|
||||
}
|
||||
desc = '(' + desc.split('\\(', 2)[1]
|
||||
|
||||
def (exceptions, String args) = value.contains('|') ? value.split('|', 2) : [value, '']
|
||||
|
||||
if (args.split(',').length !== Type.getArgumentTypes(desc).length) {
|
||||
reporter.report("Invalid: $line")
|
||||
return
|
||||
}
|
||||
lines.add(line)
|
||||
}
|
||||
|
||||
if (fix) f.text = lines.sort().join('\n')
|
||||
}
|
||||
}
|
||||
|
||||
private void collectKnown(Collection<String> known) {
|
||||
binary.get().asFile.withInputStream { i ->
|
||||
new ZipInputStream(i).withCloseable { zin ->
|
||||
final visitor = new ClassVisitor(Opcodes.ASM9) {
|
||||
private String cls
|
||||
@Override
|
||||
void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
this.cls = name
|
||||
}
|
||||
|
||||
@Override
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.minecraftforge.forge.tasks.checks
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
@CompileStatic
|
||||
enum CheckMode {
|
||||
CHECK,
|
||||
FIX
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package net.minecraftforge.forge.tasks.checks
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.Optional
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@CompileStatic
|
||||
abstract class CheckPatches extends CheckTask {
|
||||
|
||||
private static final Pattern HUNK_START_PATTERN = Pattern.compile('^@@ -[0-9,]* \\+[0-9,_]* @@$')
|
||||
private static final Pattern WHITESPACE_PATTERN = Pattern.compile('^[+\\-]\\s*$')
|
||||
private static final Pattern IMPORT_PATTERN = Pattern.compile('^[+\\-]\\s*import.*')
|
||||
private static final Pattern FIELD_PATTERN = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^=;]*)(=.*)?;\\s*$')
|
||||
private static final Pattern METHOD_PATTERN = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^(]*)[(]([^)]*)?[)]\\s*[{]\\s*$')
|
||||
private static final Pattern CLASS_PATTERN = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final[\\s]*)?(class|interface)([^{]*)[{]\\s*$')
|
||||
private static final Map<String, Integer> ACCESS_MAP = [private: 0, protected: 2, public: 3].tap { it.put(null, 1) }
|
||||
|
||||
@InputDirectory abstract DirectoryProperty getPatchDir()
|
||||
@Input @Optional abstract ListProperty<String> getPatchesWithS2SArtifact()
|
||||
|
||||
@Override
|
||||
void check(Reporter reporter, boolean fix) {
|
||||
final patchDir = getPatchDir().get().asFile.toPath()
|
||||
Files.walk(patchDir).withCloseable {
|
||||
it.filter(Files.&isRegularFile).forEach { path ->
|
||||
final String relativeName = patchDir.relativize(path).toString()
|
||||
verifyPatch(path, reporter, fix, relativeName, patchesWithS2SArtifact.get().contains(relativeName.replace('\\', '/')))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void verifyPatch(Path patch, Reporter reporter, boolean fix, String patchPath, boolean hasS2SArtifact) {
|
||||
final oldFixedErrors = reporter.fixed.size()
|
||||
|
||||
final lines = Files.readAllLines(patch)
|
||||
|
||||
int hunksStart = 0
|
||||
boolean onlyWhiteSpace = false
|
||||
|
||||
final List<String> newLines = []
|
||||
|
||||
// First two lines are file name ++/-- and we do not care
|
||||
newLines.add(lines[0] + '\n')
|
||||
newLines.add(lines[1] + '\n')
|
||||
|
||||
int i
|
||||
for (i = 2; i < lines.size(); ++i) {
|
||||
def line = lines[i]
|
||||
newLines.add(line + '\n')
|
||||
|
||||
if (HUNK_START_PATTERN.matcher(line).find()) {
|
||||
if (onlyWhiteSpace) {
|
||||
if (!hasS2SArtifact)
|
||||
reporter.report("Patch contains only white space hunk starting at line ${hunksStart + 1}, file: $patchPath")
|
||||
int toRemove = i - hunksStart
|
||||
while (toRemove-- > 0)
|
||||
newLines.remove(newLines.size() - 1)
|
||||
}
|
||||
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 == 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
|
||||
(ACCESS_MAP[pMatcher.group(2)] < ACCESS_MAP[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||
reporter.report("Patch contains access changes or final removal at line ${i + 1}, file: $patchPath", false)
|
||||
}
|
||||
|
||||
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
|
||||
(ACCESS_MAP[pMatcher.group(2)] < ACCESS_MAP[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||
reporter.report("Patch contains access changes or final removal at line ${i + 1}, file: $patchPath", false)
|
||||
}
|
||||
|
||||
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
|
||||
(ACCESS_MAP[pMatcher.group(2)] < ACCESS_MAP[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||
reporter.report("Patch contains access changes or final removal at line ${i + 1}, file: $patchPath", false)
|
||||
}
|
||||
}
|
||||
|
||||
if (line.charAt(0) == (char)'-' && i + 1 < lines.size()) {
|
||||
final nextLine = lines[i + 1]
|
||||
if (nextLine.charAt(0) == (char)'+') {
|
||||
final nextTrim = nextLine.substring(1).replaceAll("\\s", "")
|
||||
final currTrim = line.substring(1).replaceAll("\\s", "")
|
||||
|
||||
if (nextTrim == currTrim) {
|
||||
prefixChange = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final isWhiteSpaceChange = WHITESPACE_PATTERN.matcher(line).find()
|
||||
|
||||
if (!prefixChange && !isWhiteSpaceChange) {
|
||||
onlyWhiteSpace = hasS2SArtifact && IMPORT_PATTERN.matcher(line).find()
|
||||
} else if (isWhiteSpaceChange) {
|
||||
final prevLineChange = prevLine.startsWithAny('+','-')
|
||||
final nextLineChange = i + 1 < lines.size() && lines[i + 1].startsWithAny('+','-')
|
||||
|
||||
if (!prevLineChange && !nextLineChange) {
|
||||
reporter.report("Patch contains white space change in valid hunk at line ${i + 1}, file: $patchPath", false)
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains('\t')) {
|
||||
reporter.report("Patch contains tabs on line ${i + 1}, file: $patchPath")
|
||||
line = line.replaceAll('\t', ' ')
|
||||
newLines.remove(newLines.size() - 1)
|
||||
newLines.add(line + '\n')
|
||||
}
|
||||
|
||||
if (IMPORT_PATTERN.matcher(line).find() && !hasS2SArtifact) {
|
||||
reporter.report("Patch contains import change on line ${i + 1}, file: $patchPath", false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (onlyWhiteSpace) {
|
||||
if (!hasS2SArtifact)
|
||||
reporter.report("Patch contains only white space hunk starting at line ${hunksStart + 1}, file: $patchPath")
|
||||
def toRemove = i - hunksStart;
|
||||
while (toRemove-- > 0)
|
||||
newLines.remove(newLines.size() - 1)
|
||||
}
|
||||
|
||||
if ((reporter.fixed.size() > oldFixedErrors && fix) || hasS2SArtifact) {
|
||||
if (newLines.size() <= 2) {
|
||||
logger.lifecycle("Patch is now empty removing, file: {}", patchPath)
|
||||
Files.delete(patch)
|
||||
}
|
||||
else {
|
||||
if (!hasS2SArtifact)
|
||||
logger.lifecycle("*** Updating patch file. Please run setup then genPatches again. ***")
|
||||
Files.newBufferedWriter(patch).withCloseable {
|
||||
newLines.each { l -> it.write(l) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package net.minecraftforge.forge.tasks.checks
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import net.minecraftforge.forge.tasks.Annotatable
|
||||
import net.minecraftforge.forge.tasks.InheritanceData
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
|
||||
@CompileStatic
|
||||
abstract class CheckSAS extends CheckTask {
|
||||
|
||||
@InputFile abstract RegularFileProperty getInheritance()
|
||||
@InputFiles abstract ConfigurableFileCollection getSass()
|
||||
|
||||
@Override
|
||||
void check(Reporter reporter, boolean fix) {
|
||||
final inheritance = InheritanceData.parse(this.inheritance.get().asFile)
|
||||
|
||||
sass.each { f ->
|
||||
final lines = []
|
||||
f.eachLine { line ->
|
||||
if (line[0] == '\t') return // Skip any tabbed lines, those are ones we add
|
||||
final 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)
|
||||
final spl = (line.trim().replace('(', ' (') + ' ').split(' ', -1)
|
||||
def (String cls, String name, String desc) = [spl[0], spl[1], spl[2]]
|
||||
cls = cls.replaceAll('\\.', '/')
|
||||
|
||||
if (inheritance[cls] === null) {
|
||||
reporter.report("Invalid: $line")
|
||||
} else if (name.isEmpty()) { //Class SAS
|
||||
final toAdd = []
|
||||
final clsSided = isSided(inheritance[cls])
|
||||
boolean sided = clsSided
|
||||
|
||||
/* TODO: MergeTool doesn't do fields
|
||||
if (json[cls]['fields'] != null) {
|
||||
for (entry in json[cls]['fields']) {
|
||||
if (isSided(entry.value)) {
|
||||
sided = true
|
||||
toAdd.add('\t' + cls + ' ' + entry.key)
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
final clsInh = inheritance[cls]
|
||||
if (clsInh.methods) {
|
||||
for (entry in clsInh.methods) {
|
||||
if (isSided(entry.value)) {
|
||||
sided = true
|
||||
toAdd.add('\t' + cls + ' ' + entry.key.replaceAll(' ', ''))
|
||||
findChildMethods(inheritance, cls, entry.key).each { lines.add('\t' + it) }
|
||||
findChildMethods(inheritance, cls, entry.key).each { println(line + ' -- ' + it) }
|
||||
} else if (clsSided) {
|
||||
findChildMethods(inheritance, cls, entry.key).each { lines.add('\t' + it) }
|
||||
findChildMethods(inheritance, cls, entry.key).each { println(line + ' -- ' + it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sided) {
|
||||
lines.add(cls + (comment == null ? '' : ' ' + comment))
|
||||
lines.addAll(toAdd.sort())
|
||||
} else {
|
||||
reporter.report("Invalid: $line")
|
||||
}
|
||||
|
||||
} else if (desc.isEmpty()) { // Fields
|
||||
/* TODO: MergeTool doesn't do fields
|
||||
if (json[cls]['fields'] != null && isSided(json[cls]['fields'][name]))
|
||||
lines.add(cls + ' ' + name + (comment == null ? '' : ' ' + comment))
|
||||
else */
|
||||
reporter.report("Invalid: $line")
|
||||
} else { // Methods
|
||||
final clsInh = inheritance[cls]
|
||||
if (clsInh.methods === null || !isSided(clsInh.methods[name + ' ' + desc]))
|
||||
reporter.report("Invalid: $line")
|
||||
else {
|
||||
lines.add(cls + ' ' + name + desc + (comment == null ? '' : ' ' + comment))
|
||||
findChildMethods(inheritance, cls, name + ' ' + desc).each { println(line + ' -- ' + it) }
|
||||
findChildMethods(inheritance, cls, name + ' ' + desc).each { lines.add('\t' + it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fix) f.text = lines.join('\n')
|
||||
}
|
||||
}
|
||||
|
||||
protected static isSided(Annotatable annotatable) {
|
||||
if (annotatable === null) return false
|
||||
for (ann in annotatable.annotations) {
|
||||
if ('Lnet/minecraftforge/api/distmarker/OnlyIn;' == ann.desc)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
protected static findChildMethods(Map<String, InheritanceData> json, String cls, String desc) {
|
||||
return json.values().findAll{ it.methods != null && it.methods[desc] != null && it.methods[desc].override == cls && isSided(it.methods[desc]) }
|
||||
.collect { it.name + ' ' + desc.replace(' ', '') } as TreeSet
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package net.minecraftforge.forge.tasks.checks
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import net.minecraftforge.forge.tasks.Util
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.TaskContainer
|
||||
import org.gradle.api.tasks.VerificationTask
|
||||
|
||||
@CompileStatic
|
||||
abstract class CheckTask extends DefaultTask implements VerificationTask {
|
||||
@Input
|
||||
abstract Property<CheckMode> getMode()
|
||||
|
||||
private boolean ignoreFailures = false
|
||||
|
||||
@Input
|
||||
@Override
|
||||
boolean getIgnoreFailures() {
|
||||
return ignoreFailures
|
||||
}
|
||||
|
||||
@Override
|
||||
void setIgnoreFailures(boolean ignoreFailures) {
|
||||
this.ignoreFailures = ignoreFailures
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void run() {
|
||||
Util.init()
|
||||
|
||||
final doFix = getMode().get() === CheckMode.FIX
|
||||
final Reporter reporter = new Reporter(doFix)
|
||||
check(reporter, doFix)
|
||||
|
||||
if (reporter.messages) {
|
||||
if (getMode().get() === CheckMode.CHECK) {
|
||||
logger.error("Check task '{}' found errors:\n{}", name, reporter.messages.join('\n'))
|
||||
if (!ignoreFailures) {
|
||||
throw new IllegalArgumentException("${reporter.messages.size()} errors were found!")
|
||||
}
|
||||
} else {
|
||||
if (logger.isEnabled(LogLevel.DEBUG)) {
|
||||
logger.warn("Check task '{}' found {} errors and fixed {}:\n{}", name, reporter.messages.size(), reporter.fixed.size(), reporter.fixed.join('\n'))
|
||||
} else {
|
||||
logger.warn("Check task '{}' found {} errors and fixed {}.", name, reporter.messages.size(), reporter.fixed.size())
|
||||
}
|
||||
|
||||
if (reporter.notFixed) {
|
||||
logger.error('{} errors could not be fixed:\n{}', reporter.notFixed.size(), reporter.notFixed.join('\n'))
|
||||
if (!ignoreFailures) {
|
||||
throw new IllegalArgumentException("${reporter.notFixed.size()} errors which cannot be fixed were found!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract void check(Reporter reporter, boolean fix)
|
||||
|
||||
@CompileStatic
|
||||
static final class Reporter {
|
||||
final boolean trackFixed
|
||||
Reporter(boolean trackFixed) {
|
||||
this.trackFixed = trackFixed
|
||||
}
|
||||
|
||||
public final List<String> messages = []
|
||||
|
||||
public final List<String> fixed = []
|
||||
public final List<String> notFixed = []
|
||||
|
||||
void report(String message, boolean canBeFixed = true) {
|
||||
messages.add(message)
|
||||
|
||||
if (trackFixed) {
|
||||
if (canBeFixed) {
|
||||
fixed.add(message)
|
||||
} else {
|
||||
notFixed.add(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static <T extends CheckTask> void registerTask(TaskContainer tasks, String taskName, @DelegatesTo.Target('type') Class<T> clazz,
|
||||
@DelegatesTo(genericTypeIndex = 0, target = 'type') Closure configuration) {
|
||||
taskName = taskName.capitalize()
|
||||
tasks.register("check$taskName", clazz) { CheckTask task ->
|
||||
configuration.setDelegate((T) task)
|
||||
configuration.call(task)
|
||||
task.mode.set(CheckMode.CHECK)
|
||||
task.group = 'checks'
|
||||
}
|
||||
tasks.named('checkAll').configure { it.dependsOn("check$taskName") }
|
||||
|
||||
tasks.register("checkAndFix$taskName", clazz) { CheckTask task ->
|
||||
configuration.setDelegate((T) task)
|
||||
configuration.call(task)
|
||||
task.mode.set(CheckMode.FIX)
|
||||
task.group = 'checks'
|
||||
}
|
||||
tasks.named('checkAllAndFix').configure { it.dependsOn("checkAndFix$taskName") }
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,4 @@ Contributor License Agreement
|
||||
- You grant Forge a license to use your code contributed to the primary codebase (everything **not** under patches) in Forge, under the LGPLv2.1 license.
|
||||
- You assign copyright ownership of your contributions to the patches codebase (everything under patches) to Forge, where it will be licensed under the LGPLv2.1 license.
|
||||
|
||||
Additionally, while 1.9.4 is being maintained, you will be asked to acknowledge these two additional clauses.
|
||||
- You grant Forge a license to use your code contributed to the primary codebase (everything **not** under patches) in Forge, under the MinecraftForge license.
|
||||
- You grant assign copyright ownership of your contributions to the patches codebase (everything under patches) to Forge, where it will be licensed under the MinecraftForge license.
|
||||
|
||||
"Forge" is Forge Development LLC, a legally incorporated entity in Oregon, USA.
|
||||
+5
-5
@@ -2,16 +2,16 @@
|
||||
|
||||
MinecraftForge
|
||||
=============
|
||||
[](https://files.minecraftforge.net)
|
||||
[](https://files.minecraftforge.net)
|
||||
[](https://files.minecraftforge.net) [](https://discord.gg/UvedJ9m) [](https://www.patreon.com/LexManos)
|
||||
|
||||
Forge is a free, open-source modding API all of your favourite mods use!
|
||||
|
||||
| Version | Support |
|
||||
| Version | Support |
|
||||
| ------------- | ------------- |
|
||||
| 1.16.x | Active |
|
||||
| 1.15.x | LTS |
|
||||
| 1.17.x | Active |
|
||||
| 1.16.x | LTS |
|
||||
|
||||
* [Download]
|
||||
* [Forum]
|
||||
|
||||
@@ -34,15 +34,13 @@ 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.
|
||||
* point, {@code ReentrantBlockableEventLoop} 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.
|
||||
@@ -78,7 +76,12 @@ public class DeferredWorkQueue
|
||||
private static void makeRunnable(TaskInfo ti, Executor executor) {
|
||||
executor.execute(() -> {
|
||||
Stopwatch timer = Stopwatch.createStarted();
|
||||
ti.task.run();
|
||||
ModLoadingContext.get().setActiveContainer(ti.owner);
|
||||
try {
|
||||
ti.task.run();
|
||||
} finally {
|
||||
ModLoadingContext.get().setActiveContainer(null);
|
||||
}
|
||||
timer.stop();
|
||||
if (timer.elapsed(TimeUnit.SECONDS) >= 1) {
|
||||
LOGGER.warn(LOADING, "Mod '{}' took {} to run a deferred task.", ti.owner.getModId(), timer);
|
||||
@@ -86,13 +89,13 @@ public class DeferredWorkQueue
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> enqueueWork(final IModInfo modInfo, final Runnable work) {
|
||||
public CompletableFuture<Void> enqueueWork(final ModContainer 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) {
|
||||
public <T> CompletableFuture<T> enqueueWork(final ModContainer modInfo, final Supplier<T> work) {
|
||||
return CompletableFuture.supplyAsync(work, r->tasks.add(new TaskInfo(modInfo, r)));
|
||||
}
|
||||
|
||||
record TaskInfo(IModInfo owner, Runnable task) {}
|
||||
record TaskInfo(ModContainer owner, Runnable task) {}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public final class DistExecutor
|
||||
private DistExecutor() {}
|
||||
|
||||
/**
|
||||
* Run the callable in the supplier only on the specified {@link Side}.
|
||||
* Run the callable in the supplier only on the specified {@link Dist}.
|
||||
* 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.
|
||||
*
|
||||
|
||||
@@ -32,30 +32,30 @@ public interface IExtensionPoint<T extends Record>
|
||||
* 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
|
||||
* <p>Return {@code net.minecraftforge.fmllegacy.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>
|
||||
* </p>
|
||||
* <pre>{@code
|
||||
* 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>
|
||||
* }</pre>
|
||||
*
|
||||
* <p>
|
||||
* Examples: A client only mod
|
||||
* <code><pre>
|
||||
* </p>
|
||||
* <pre>{@code
|
||||
* 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>
|
||||
* }</pre>
|
||||
*
|
||||
*/
|
||||
record DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) implements IExtensionPoint<DisplayTest> {}
|
||||
|
||||
@@ -116,13 +116,13 @@ public abstract class ModContainer
|
||||
final Executor executor) {
|
||||
return CompletableFuture
|
||||
.runAsync(() -> {
|
||||
ModLoadingContext.get().setActiveContainer(target, target.contextExtension.get());
|
||||
ModLoadingContext.get().setActiveContainer(target);
|
||||
target.activityMap.getOrDefault(target.modLoadingStage, ()->{}).run();
|
||||
target.acceptEvent(eventGenerator.apply(target));
|
||||
}, executor)
|
||||
.whenComplete((mc, exception) -> {
|
||||
target.modLoadingStage = stateChangeHandler.apply(target.modLoadingStage, exception);
|
||||
ModLoadingContext.get().setActiveContainer(null, null);
|
||||
ModLoadingContext.get().setActiveContainer(null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import static net.minecraftforge.fml.Logging.LOADING;
|
||||
/**
|
||||
* Loads mods.
|
||||
*
|
||||
* Dispatch cycle is seen in {@link #loadMods()} and {@link #finishMods()}
|
||||
* Dispatch cycle is seen in {@code #loadMods()} and {@code #finishMods()}
|
||||
*
|
||||
* Overall sequence for loadMods is:
|
||||
* <dl>
|
||||
@@ -61,28 +61,28 @@ import static net.minecraftforge.fml.Logging.LOADING;
|
||||
* <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}
|
||||
* <dd>Dispatches automated elements : {@code net.minecraftforge.fml.common.Mod.EventBusSubscriber},
|
||||
* {@code net.minecraftforge.event.RegistryEvent}, {@code 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>
|
||||
* <dd>Dispatches {@code 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>
|
||||
* <dd>Dispatches {@code net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent} or
|
||||
* {@code 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,
|
||||
* <dd>Dispatches {@code 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,
|
||||
* <dd>Dispatches {@code 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,
|
||||
* <dd>Dispatches {@code net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent} to mods,
|
||||
* and completes the mod loading sequence.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
@@ -36,9 +36,9 @@ public class ModLoadingContext
|
||||
|
||||
private ModContainer activeContainer;
|
||||
|
||||
public void setActiveContainer(final ModContainer container, final Object languageExtension) {
|
||||
public void setActiveContainer(final ModContainer container) {
|
||||
this.activeContainer = container;
|
||||
this.languageExtension = languageExtension;
|
||||
this.languageExtension = container == null ? null : container.contextExtension.get();
|
||||
}
|
||||
|
||||
public ModContainer getActiveContainer() {
|
||||
|
||||
@@ -19,29 +19,34 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.gson.Gson;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.maven.artifact.versioning.ComparableVersion;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.http.HttpClient;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import static net.minecraftforge.fml.VersionChecker.Status.*;
|
||||
|
||||
@@ -49,6 +54,7 @@ public class VersionChecker
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final int MAX_HTTP_REDIRECTS = Integer.getInteger("http.maxRedirects", 20);
|
||||
private static final int HTTP_TIMEOUT_SECS = Integer.getInteger("http.timeoutSecs", 15);
|
||||
|
||||
public enum Status
|
||||
{
|
||||
@@ -108,6 +114,8 @@ public class VersionChecker
|
||||
{
|
||||
new Thread("Forge Version Check")
|
||||
{
|
||||
private HttpClient client;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -117,46 +125,52 @@ public class VersionChecker
|
||||
return;
|
||||
}
|
||||
|
||||
client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS)).build();
|
||||
gatherMods().forEach(this::process);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens stream for given URL while following redirects
|
||||
* Returns the response body as a String for the given URL while following redirects
|
||||
*/
|
||||
private InputStream openUrlStream(URL url) throws IOException
|
||||
{
|
||||
private String openUrlString(URL url) throws IOException, URISyntaxException, InterruptedException {
|
||||
URL currentUrl = url;
|
||||
for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++)
|
||||
{
|
||||
URLConnection c = currentUrl.openConnection();
|
||||
if (c instanceof HttpURLConnection)
|
||||
var request = HttpRequest.newBuilder()
|
||||
.uri(currentUrl.toURI())
|
||||
.timeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS))
|
||||
.setHeader("Accept-Encoding", "gzip")
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
final HttpResponse<InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
|
||||
|
||||
int responseCode = response.statusCode();
|
||||
if (responseCode >= 300 && responseCode <= 399)
|
||||
{
|
||||
HttpURLConnection huc = (HttpURLConnection) c;
|
||||
huc.setInstanceFollowRedirects(false);
|
||||
int responseCode = huc.getResponseCode();
|
||||
if (responseCode >= 300 && responseCode <= 399)
|
||||
{
|
||||
try
|
||||
{
|
||||
String loc = huc.getHeaderField("Location");
|
||||
currentUrl = new URL(currentUrl, loc);
|
||||
continue;
|
||||
}
|
||||
finally
|
||||
{
|
||||
huc.disconnect();
|
||||
}
|
||||
}
|
||||
String newLocation = response.headers().firstValue("Location")
|
||||
.orElseThrow(() -> new IOException("Got a 3xx response code but Location header was null while trying to fetch " + url));
|
||||
currentUrl = new URL(currentUrl, newLocation);
|
||||
continue;
|
||||
}
|
||||
|
||||
return c.getInputStream();
|
||||
final boolean isGzipEncoded = response.headers().firstValue("Content-Encoding").orElse("").equals("gzip");
|
||||
|
||||
final String bodyStr;
|
||||
try (InputStream inStream = isGzipEncoded ? new GZIPInputStream(response.body()) : response.body())
|
||||
{
|
||||
try (var bufferedReader = new BufferedReader(new InputStreamReader(inStream)))
|
||||
{
|
||||
bodyStr = bufferedReader.lines().collect(Collectors.joining("\n"));
|
||||
}
|
||||
}
|
||||
return bodyStr;
|
||||
}
|
||||
throw new IOException("Too many redirects while trying to fetch " + url);
|
||||
}
|
||||
|
||||
private void process(IModInfo mod)
|
||||
{
|
||||
// HttpClient.newBuilder().build();
|
||||
Status status = PENDING;
|
||||
ComparableVersion target = null;
|
||||
Map<ComparableVersion, String> changes = null;
|
||||
@@ -167,9 +181,7 @@ public class VersionChecker
|
||||
URL url = mod.getUpdateURL().get();
|
||||
LOGGER.info("[{}] Starting version check at {}", mod.getModId(), url.toString());
|
||||
|
||||
InputStream con = openUrlStream(url);
|
||||
String data = new String(ByteStreams.toByteArray(con), StandardCharsets.UTF_8);
|
||||
con.close();
|
||||
String data = openUrlString(url);
|
||||
|
||||
LOGGER.debug("[{}] Received version check data:\n{}", mod.getModId(), data);
|
||||
|
||||
@@ -180,8 +192,7 @@ public class VersionChecker
|
||||
Map<String, String> promos = (Map<String, String>)json.get("promos");
|
||||
display_url = (String)json.get("homepage");
|
||||
|
||||
// String mcVersion = MCPVersion.getMCVersion();
|
||||
var mcVersion = "1.17";
|
||||
var mcVersion = FMLLoader.versionInfo().mcVersion();
|
||||
String rec = promos.get(mcVersion + "-recommended");
|
||||
String lat = promos.get(mcVersion + "-latest");
|
||||
ComparableVersion current = new ComparableVersion(mod.getVersion().toString());
|
||||
|
||||
+1
-1
@@ -19,7 +19,6 @@
|
||||
|
||||
package net.minecraftforge.common.asm;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -33,6 +32,7 @@ import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||
/**
|
||||
* Removes the final modifier from fields with the @CapabilityInject annotation, prevents the JITer from in lining them so our runtime replacements can work.
|
||||
*/
|
||||
@Deprecated(since = "1.18", forRemoval = true)
|
||||
public class CapabilityInjectDefinalize implements ILaunchPluginService {
|
||||
|
||||
private final String CAP = "Lnet/minecraftforge/common/capabilities/Capability;"; //Don't directly reference this to prevent class loading.
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.common.asm;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.signature.SignatureReader;
|
||||
import org.objectweb.asm.signature.SignatureVisitor;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||
|
||||
/**
|
||||
* Implements getType() in CapabilityToken subclasses.
|
||||
*
|
||||
* Using the class's signature to determine the generic type of TypeToken, and then implements getType() using that value.
|
||||
* <pre>
|
||||
* Example:
|
||||
*
|
||||
* <code>new CapabilityToken<String>(){}</code>
|
||||
* Has the signature <code>"CapabilityToken<Ljava/lang/String;>"</code>
|
||||
*
|
||||
* Implements the method:
|
||||
* <code>public String getType() {
|
||||
* return "java/lang/String";
|
||||
* }</code>
|
||||
* </pre>
|
||||
*/
|
||||
public class CapabilityTokenSubclass implements ILaunchPluginService {
|
||||
|
||||
private final String FUNC_NAME = "getType";
|
||||
private final String FUNC_DESC = "()Ljava/lang/String;";
|
||||
private final String CAP_INJECT = "net/minecraftforge/common/capabilities/CapabilityToken"; //Don't directly reference this to prevent class loading.
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "capability_token_subclass";
|
||||
}
|
||||
|
||||
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
|
||||
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||
|
||||
@Override
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||
{
|
||||
return isEmpty ? NAY : YAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason)
|
||||
{
|
||||
if (CAP_INJECT.equals(classNode.name))
|
||||
{
|
||||
for (MethodNode mtd : classNode.methods)
|
||||
{
|
||||
if (FUNC_NAME.equals(mtd.name) && FUNC_DESC.equals(mtd.desc))
|
||||
{
|
||||
mtd.access &= ~Opcodes.ACC_FINAL; // We have it final in code so people don't override it, cuz that'd be stupid, and make our transformer more complicated.
|
||||
}
|
||||
}
|
||||
return ComputeFlags.SIMPLE_REWRITE;
|
||||
}
|
||||
else if (CAP_INJECT.equals(classNode.superName))
|
||||
{
|
||||
Holder cls = new Holder();
|
||||
|
||||
SignatureReader reader = new SignatureReader(classNode.signature); // Having a node version of this would probably be useful.
|
||||
reader.accept(new SignatureVisitor(Opcodes.ASM9)
|
||||
{
|
||||
Deque<String> stack = new ArrayDeque<>();
|
||||
|
||||
@Override
|
||||
public void visitClassType(final String name)
|
||||
{
|
||||
stack.push(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInnerClassType(final String name)
|
||||
{
|
||||
stack.push(stack.pop() + '$' + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnd()
|
||||
{
|
||||
var val = stack.pop();
|
||||
if (!stack.isEmpty() && CAP_INJECT.equals(stack.peek()))
|
||||
cls.value = val;
|
||||
}
|
||||
});
|
||||
|
||||
if (cls.value == null)
|
||||
throw new IllegalStateException("Could not find signature for CapabilityToken on " + classNode.name + " from " + classNode.signature);
|
||||
|
||||
var mtd = classNode.visitMethod(Opcodes.ACC_PUBLIC, FUNC_NAME, FUNC_DESC, null, new String[0]);
|
||||
mtd.visitLdcInsn(cls.value);
|
||||
mtd.visitInsn(Opcodes.ARETURN);
|
||||
mtd.visitEnd();
|
||||
return ComputeFlags.COMPUTE_MAXS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ComputeFlags.NO_REWRITE;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Holder {
|
||||
String value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -138,9 +138,10 @@ public class FMLLoader
|
||||
}
|
||||
}
|
||||
|
||||
static void setupLaunchHandler(final IEnvironment environment, final Map<String, ?> arguments)
|
||||
static void setupLaunchHandler(final IEnvironment environment, final Map<String, Object> arguments)
|
||||
{
|
||||
final String launchTarget = environment.getProperty(IEnvironment.Keys.LAUNCHTARGET.get()).orElse("MISSING");
|
||||
arguments.put("launchTarget", launchTarget);
|
||||
final Optional<ILaunchHandlerService> launchHandler = environment.findLaunchHandler(launchTarget);
|
||||
LOGGER.debug(CORE, "Using {} as launch service", launchTarget);
|
||||
if (launchHandler.isEmpty()) {
|
||||
|
||||
@@ -19,30 +19,23 @@
|
||||
|
||||
package net.minecraftforge.fml.loading;
|
||||
|
||||
import cpw.mods.jarhandling.SecureJar;
|
||||
import cpw.mods.modlauncher.api.*;
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.OptionSpecBuilder;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.forgespi.Environment;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||
|
||||
public class FMLServiceProvider implements ITransformationService
|
||||
|
||||
@@ -44,11 +44,18 @@ public class LibraryFinder {
|
||||
return libsPath;
|
||||
}
|
||||
|
||||
// Not used anywhere in Forge's codebase, scheduled for deletion unless a good need is expressed.
|
||||
@Deprecated(forRemoval = true, since = "1.17.1")
|
||||
public static Path findJarPathFor(final String className, final String jarName) {
|
||||
final URL resource = LibraryFinder.class.getClassLoader().getResource(className);
|
||||
return findJarPathFor(className, jarName, resource);
|
||||
}
|
||||
|
||||
/*
|
||||
* Only used in ClasspathLocator now, so moved too a private method and depreciated this.
|
||||
* Scheduled for deletion unless a good need is expressed.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.17.1")
|
||||
public static Path findJarPathFor(final String resourceName, final String jarName, final URL resource) {
|
||||
try {
|
||||
Path path;
|
||||
@@ -93,7 +100,4 @@ public class LibraryFinder {
|
||||
public static Path findPathForMaven(final String maven) {
|
||||
return findLibsPath().resolve(MavenCoordinateResolver.get(maven));
|
||||
}
|
||||
public static Path getFMLCorePath() {
|
||||
return findLibsPath().resolve(MavenCoordinateResolver.get("net.minecraftforge:fmlcore:1.0"));
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ public class ModSorter
|
||||
AtomicInteger counter = new AtomicInteger();
|
||||
Map<IModFileInfo, Integer> infos = modFiles.stream()
|
||||
.map(ModFile::getModFileInfo)
|
||||
.filter(ModFileInfo.class::isInstance)
|
||||
.collect(toMap(Function.identity(), e -> counter.incrementAndGet()));
|
||||
infos.keySet().forEach(i -> graph.addNode((ModFileInfo) i));
|
||||
modFiles.stream()
|
||||
@@ -150,9 +151,9 @@ public class ModSorter
|
||||
|
||||
private void buildUniqueList()
|
||||
{
|
||||
// Collect mod files by first modid in the file. This will be used for deduping purposes
|
||||
// Collect mod files by module name. This will be used for deduping purposes
|
||||
final Map<String, List<IModFile>> modFilesByFirstId = modFiles.stream()
|
||||
.collect(groupingBy(mf -> mf.getModInfos().get(0).getModId()));
|
||||
.collect(groupingBy(mf -> mf.getModFileInfo().moduleName()));
|
||||
|
||||
// Capture forge and MC here, so we can keep them for later
|
||||
forgeAndMC = new ArrayList<>();
|
||||
@@ -161,6 +162,10 @@ public class ModSorter
|
||||
forgeAndMC.add((ModFile) mc.get(0));
|
||||
else
|
||||
throw new IllegalStateException("Failed to find minecraft somehow?");
|
||||
// TODO: remove this hardcoding and make it more flexible
|
||||
var forge = modFilesByFirstId.get("forge");
|
||||
if (forge != null && !forge.isEmpty())
|
||||
forgeAndMC.add((ModFile) forge.get(0)); // Silently ignore if Forge isn't present
|
||||
|
||||
// Select the newest by artifact version sorting of non-unique files thus identified
|
||||
this.modFiles = modFilesByFirstId.entrySet().stream()
|
||||
@@ -242,6 +247,6 @@ public class ModSorter
|
||||
private boolean modVersionNotContained(final IModInfo.ModVersion mv, final Map<String, ArtifactVersion> modVersions)
|
||||
{
|
||||
return !(VersionSupportMatrix.testVersionSupportMatrix(mv.getVersionRange(), mv.getModId(), "mod", (modId, range) -> modVersions.containsKey(modId) &&
|
||||
(range.containsVersion(modVersions.get(modId)) || modVersions.get(modId).toString().equals("NONE"))));
|
||||
(range.containsVersion(modVersions.get(modId)) || modVersions.get(modId).toString().equals("0.0NONE"))));
|
||||
}
|
||||
}
|
||||
+73
-1
@@ -20,6 +20,10 @@
|
||||
package net.minecraftforge.fml.loading.moddiscovery;
|
||||
|
||||
import cpw.mods.jarhandling.SecureJar;
|
||||
import cpw.mods.jarhandling.JarMetadata;
|
||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -28,9 +32,13 @@ import org.apache.logging.log4j.Logger;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -38,6 +46,8 @@ import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
||||
|
||||
public abstract class AbstractJarFileLocator implements IModLocator {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
protected static final String MODS_TOML = "META-INF/mods.toml";
|
||||
protected static final String MANIFEST = "META-INF/MANIFEST.MF";
|
||||
|
||||
@Override
|
||||
public void scanFile(final IModFile file, final Consumer<Path> pathConsumer) {
|
||||
@@ -54,7 +64,9 @@ public abstract class AbstractJarFileLocator implements IModLocator {
|
||||
@Override
|
||||
public List<IModFile> scanMods() {
|
||||
return scanCandidates()
|
||||
.map(mc -> ModFile.newFMLInstance(this, mc))
|
||||
.map(this::createMod)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -64,4 +76,64 @@ public abstract class AbstractJarFileLocator implements IModLocator {
|
||||
public boolean isValid(final IModFile modFile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Optional<IModFile> createMod(Path path) {
|
||||
var mjm = new ModJarMetadata();
|
||||
var sj = SecureJar.from(
|
||||
Manifest::new,
|
||||
jar -> jar.findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path),
|
||||
(root, p) -> true,
|
||||
path
|
||||
);
|
||||
|
||||
IModFile mod = null;
|
||||
var type = sj.getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
||||
if (sj.findFile(MODS_TOML).isPresent()) {
|
||||
LOGGER.debug(SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
||||
mod = ModFile.newFMLInstance(this, sj);
|
||||
} else if (type != null) {
|
||||
LOGGER.debug(SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path);
|
||||
mod = new ModFile(sj, this, this::manifestParser);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
mjm.setModFile(mod);
|
||||
return Optional.ofNullable(mod);
|
||||
}
|
||||
|
||||
private IModFileInfo manifestParser(final IModFile mod) {
|
||||
Function<String, Optional<String>> cfg = name -> Optional.ofNullable(mod.getSecureJar().getManifest().getMainAttributes().getValue(name));
|
||||
var license = cfg.apply("LICENSE").orElse("");
|
||||
var dummy = new IConfigurable() {
|
||||
@Override
|
||||
public <T> Optional<T> getConfigElement(String... key) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@Override
|
||||
public List<? extends IConfigurable> getConfigList(String... key) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
|
||||
return new IModFileInfo() {
|
||||
@Override public List<IModInfo> getMods() { return Collections.emptyList(); }
|
||||
@Override public List<LanguageSpec> requiredLanguageLoaders() { return Collections.emptyList(); }
|
||||
@Override public boolean showAsResourcePack() { return false; }
|
||||
@Override public Map<String, Object> getFileProperties() { return Collections.emptyMap(); }
|
||||
@Override public String getLicense() { return license; }
|
||||
@Override public IModFile getFile() { return mod; }
|
||||
@Override public IConfigurable getConfig() { return dummy; }
|
||||
|
||||
// These Should never be called as it's only called from ModJarMetadata.version and we bypass that
|
||||
@Override public String moduleName() { return mod.getSecureJar().name(); }
|
||||
@Override public String versionString() { return null; }
|
||||
@Override public List<String> usesServices() { return null; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IModFileInfo(" + mod.getFilePath() + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+24
-7
@@ -24,6 +24,8 @@ import net.minecraftforge.fml.loading.LoadingModList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
@@ -32,12 +34,22 @@ import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
||||
|
||||
public class BackgroundScanHandler
|
||||
{
|
||||
private enum ScanStatus {
|
||||
NOT_STARTED,
|
||||
RUNNING,
|
||||
COMPLETE,
|
||||
TIMED_OUT,
|
||||
INTERRUPTED,
|
||||
ERRORED
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final ExecutorService modContentScanner;
|
||||
private final List<ModFile> pendingFiles;
|
||||
private final List<ModFile> scannedFiles;
|
||||
private final List<ModFile> allFiles;
|
||||
private final List<ModFile> modFiles;
|
||||
private ScanStatus status;
|
||||
private LoadingModList loadingModList;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
@@ -51,6 +63,7 @@ public class BackgroundScanHandler
|
||||
scannedFiles = new ArrayList<>();
|
||||
pendingFiles = new ArrayList<>();
|
||||
allFiles = new ArrayList<>();
|
||||
status = ScanStatus.NOT_STARTED;
|
||||
}
|
||||
|
||||
public List<ModFile> getModFiles() {
|
||||
@@ -59,8 +72,10 @@ public class BackgroundScanHandler
|
||||
|
||||
public void submitForScanning(final ModFile file) {
|
||||
if (modContentScanner.isShutdown()) {
|
||||
status = ScanStatus.ERRORED;
|
||||
throw new IllegalStateException("Scanner has shutdown");
|
||||
}
|
||||
status = ScanStatus.RUNNING;
|
||||
allFiles.add(file);
|
||||
pendingFiles.add(file);
|
||||
final CompletableFuture<ModFileScanData> future = CompletableFuture.supplyAsync(file::compileContent, modContentScanner)
|
||||
@@ -71,6 +86,7 @@ public class BackgroundScanHandler
|
||||
|
||||
private void addCompletedFile(final ModFile file, final ModFileScanData modFileScanData, final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
status = ScanStatus.ERRORED;
|
||||
LOGGER.error(SCAN,"An error occurred scanning file {}", file, throwable);
|
||||
}
|
||||
pendingFiles.remove(file);
|
||||
@@ -88,18 +104,19 @@ public class BackgroundScanHandler
|
||||
}
|
||||
|
||||
public void waitForScanToComplete(final Runnable ticker) {
|
||||
boolean interrupted = false;
|
||||
boolean succeeded = false;
|
||||
boolean timeoutActive = System.getProperty("fml.disableScanTimeout") == null;
|
||||
Instant deadline = Instant.now().plus(Duration.ofMinutes(10));
|
||||
modContentScanner.shutdown();
|
||||
do {
|
||||
ticker.run();
|
||||
try {
|
||||
succeeded = modContentScanner.awaitTermination(50, TimeUnit.MILLISECONDS);
|
||||
status = modContentScanner.awaitTermination(50, TimeUnit.MILLISECONDS) ? ScanStatus.COMPLETE : ScanStatus.RUNNING;
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
status = ScanStatus.INTERRUPTED;
|
||||
}
|
||||
} while (!modContentScanner.isShutdown());
|
||||
if (interrupted) Thread.currentThread().interrupt();
|
||||
if (!succeeded) throw new IllegalStateException("Failed to complete mod scan");
|
||||
if (timeoutActive && Instant.now().isAfter(deadline)) status = ScanStatus.TIMED_OUT;
|
||||
} while (status == ScanStatus.RUNNING);
|
||||
if (status == ScanStatus.INTERRUPTED) Thread.currentThread().interrupt();
|
||||
if (status != ScanStatus.COMPLETE) throw new IllegalStateException("Failed to complete mod scan");
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
|
||||
|
||||
public class ClasspathLocator extends AbstractJarFileLocator {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
|
||||
private boolean enabled = false;
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "userdev classpath";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Path> scanCandidates() {
|
||||
if (!enabled)
|
||||
return Stream.of();
|
||||
|
||||
try {
|
||||
var claimed = new ArrayList<>(legacyClasspath);
|
||||
var paths = Stream.<Path>builder();
|
||||
|
||||
findPaths(claimed, MODS_TOML).forEach(paths::add);
|
||||
findPaths(claimed, MANIFEST).forEach(paths::add);
|
||||
|
||||
return paths.build();
|
||||
} catch (IOException e) {
|
||||
LOGGER.fatal(SCAN, "Error trying to find resources", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Path> findPaths(List<Path> claimed, String resource) throws IOException {
|
||||
var ret = new ArrayList<Path>();
|
||||
final Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(resource);
|
||||
while (resources.hasMoreElements()) {
|
||||
URL url = resources.nextElement();
|
||||
Path path = findJarPathFor(resource, resource, url);
|
||||
if (claimed.stream().anyMatch(path::equals) || !Files.exists(path) || Files.isDirectory(path))
|
||||
continue;
|
||||
ret.add(path);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArguments(Map<String, ?> arguments) {
|
||||
var launchTarget = (String) arguments.get("launchTarget");
|
||||
enabled = launchTarget != null && launchTarget.contains("dev");
|
||||
}
|
||||
|
||||
private Path findJarPathFor(final String resourceName, final String jarName, final URL resource) {
|
||||
try {
|
||||
Path path;
|
||||
final URI uri = resource.toURI();
|
||||
if (uri.getScheme().equals("jar") && uri.getRawSchemeSpecificPart().contains("!/")) {
|
||||
int lastExcl = uri.getRawSchemeSpecificPart().lastIndexOf("!/");
|
||||
path = Paths.get(new URI(uri.getRawSchemeSpecificPart().substring(0, lastExcl)));
|
||||
} else {
|
||||
path = Paths.get(new URI("file://"+uri.getRawSchemeSpecificPart().substring(0, uri.getRawSchemeSpecificPart().length()-resourceName.length())));
|
||||
}
|
||||
//LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
|
||||
return path;
|
||||
} catch (NullPointerException | URISyntaxException e) {
|
||||
LOGGER.fatal(SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName);
|
||||
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-9
@@ -29,9 +29,8 @@ 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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -61,16 +60,21 @@ public class ModDiscoverer {
|
||||
|
||||
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())))
|
||||
var loadedFiles = new ArrayList<>();
|
||||
for (IModLocator locator : locatorList) {
|
||||
LOGGER.debug(SCAN,"Trying locator {}", locator);
|
||||
var modFiles = locator.scanMods();
|
||||
for (IModFile mf : modFiles) {
|
||||
LOGGER.info(SCAN, "Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator());
|
||||
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType()));
|
||||
}
|
||||
loadedFiles.addAll(modFiles);
|
||||
}
|
||||
final var modFilesMap = loadedFiles.stream()
|
||||
.map(ModFile.class::cast)
|
||||
.collect(Collectors.groupingBy(IModFile::getType));
|
||||
|
||||
var validator = new ModValidator(modFiles);
|
||||
var validator = new ModValidator(modFilesMap);
|
||||
validator.stage1Validation();
|
||||
return validator;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ import java.util.jar.Manifest;
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
||||
|
||||
public class ModFile implements IModFile {
|
||||
// Mods either must have a mods.toml or a manifest. We can no longer just put any jar on the classpath.
|
||||
@Deprecated(forRemoval = true, since = "1.17.1")
|
||||
public static final Manifest DEFAULTMANIFEST;
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@@ -72,6 +74,7 @@ public class ModFile implements IModFile {
|
||||
private List<CoreModFile> coreMods;
|
||||
private Path accessTransformer;
|
||||
|
||||
//TODO: Make package private in 1.18+
|
||||
public static final Attributes.Name TYPE = new Attributes.Name("FMLModType");
|
||||
private SecureJar.Status securityStatus;
|
||||
|
||||
@@ -116,7 +119,7 @@ public class ModFile implements IModFile {
|
||||
|
||||
public boolean identifyMods() {
|
||||
this.modFileInfo = ModFileParser.readModList(this, this.parser);
|
||||
if (this.modFileInfo == null) return false;
|
||||
if (this.modFileInfo == null) return this.getType() != Type.MOD;
|
||||
LOGGER.debug(LOADING,"Loading mod file {} with languages {}", this.getFilePath(), this.modFileInfo.requiredLanguageLoaders());
|
||||
this.coreMods = ModFileParser.getCoreMods(this);
|
||||
this.coreMods.forEach(mi-> LOGGER.debug(LOADING,"Found coremod {}", mi.getPath()));
|
||||
@@ -139,8 +142,7 @@ public class ModFile implements IModFile {
|
||||
locator.scanFile(this, pathConsumer);
|
||||
}
|
||||
|
||||
public void setFutureScanResult(CompletableFuture<ModFileScanData> future)
|
||||
{
|
||||
public void setFutureScanResult(CompletableFuture<ModFileScanData> future) {
|
||||
this.futureScanResult = future;
|
||||
}
|
||||
|
||||
@@ -168,20 +170,17 @@ public class ModFile implements IModFile {
|
||||
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Completed deep scan of "+this.getFileName()));
|
||||
}
|
||||
|
||||
public void setFileProperties(Map<String, Object> fileProperties)
|
||||
{
|
||||
public void setFileProperties(Map<String, Object> fileProperties) {
|
||||
this.fileProperties = fileProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IModLanguageProvider> getLoaders()
|
||||
{
|
||||
public List<IModLanguageProvider> getLoaders() {
|
||||
return loaders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path findResource(String... path)
|
||||
{
|
||||
public Path findResource(String... path) {
|
||||
if (path.length < 1) {
|
||||
throw new IllegalArgumentException("Missing path");
|
||||
}
|
||||
@@ -214,17 +213,24 @@ public class ModFile implements IModFile {
|
||||
return modFileInfo;
|
||||
}
|
||||
|
||||
// TODO: Remove concept of factory from forgeapi.. Why expose this?
|
||||
@Deprecated(forRemoval = true, since="1.17.1")
|
||||
public static ModFileFactory buildFactory() {
|
||||
return ModFile::new;
|
||||
}
|
||||
|
||||
// TODO: Remove helper functions to cleanup api
|
||||
@Deprecated(forRemoval = true, since="1.17.1")
|
||||
public static ModFile newFMLInstance(final IModLocator locator, final SecureJar jar) {
|
||||
return (ModFile) ModFileFactory.FACTORY.build(jar, locator, ModFileParser::modsTomlParser);
|
||||
}
|
||||
|
||||
// TODO: Remove helper functions to cleanup api
|
||||
@Deprecated(forRemoval = true, since="1.17.1")
|
||||
public static ModFile newFMLInstance(final IModLocator locator, final Path... paths) {
|
||||
return (ModFile) ModJarMetadata.buildFile(locator, paths);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityStatus(final SecureJar.Status status) {
|
||||
this.securityStatus = status;
|
||||
|
||||
@@ -21,17 +21,13 @@ 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;
|
||||
@@ -44,7 +40,6 @@ 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;
|
||||
|
||||
|
||||
+9
-1
@@ -17,18 +17,26 @@ public final class ModJarMetadata implements JarMetadata {
|
||||
private IModFile modFile;
|
||||
private ModuleDescriptor descriptor;
|
||||
|
||||
// TODO: Remove helper functions to cleanup api
|
||||
@Deprecated(forRemoval = true, since="1.17.1")
|
||||
static Optional<IModFile> buildFile(IModLocator locator, Predicate<SecureJar> jarTest, Path... files) {
|
||||
return buildFile(locator, jarTest, (a,b) -> true, files);
|
||||
}
|
||||
|
||||
// TODO: Remove helper functions to cleanup api
|
||||
@Deprecated(forRemoval = true, since="1.17.1")
|
||||
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);
|
||||
}
|
||||
|
||||
// TODO: Remove helper functions to cleanup api
|
||||
@Deprecated(forRemoval = true, since="1.17.1")
|
||||
static IModFile buildFile(IModLocator locator, Path... files) {
|
||||
return buildFile(locator, j->true, files).orElseThrow(()->new IllegalArgumentException("Failed to find valid JAR file"));
|
||||
}
|
||||
|
||||
// TODO: Remove helper functions to cleanup api
|
||||
@Deprecated(forRemoval = true, since="1.17.1")
|
||||
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);
|
||||
@@ -41,7 +49,7 @@ public final class ModJarMetadata implements JarMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
private ModJarMetadata() {
|
||||
ModJarMetadata() {
|
||||
}
|
||||
|
||||
public void setModFile(IModFile file) {
|
||||
|
||||
+8
-8
@@ -1,20 +1,15 @@
|
||||
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 {
|
||||
@@ -27,9 +22,14 @@ public class ModValidator {
|
||||
|
||||
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()));
|
||||
this.candidateMods = lst(modFiles.get(IModFile.Type.MOD));
|
||||
this.candidateMods.addAll(lst(modFiles.get(IModFile.Type.GAMELIBRARY)));
|
||||
this.candidatePlugins = lst(modFiles.get(IModFile.Type.LANGPROVIDER));
|
||||
this.candidatePlugins.addAll(lst(modFiles.get(IModFile.Type.LIBRARY)));
|
||||
}
|
||||
|
||||
private static List<ModFile> lst(List<ModFile> files) {
|
||||
return files == null ? new ArrayList<>() : new ArrayList<>(files);
|
||||
}
|
||||
|
||||
public void stage1Validation() {
|
||||
|
||||
-3
@@ -22,16 +22,13 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
|
||||
import net.minecraftforge.fml.loading.StringUtils;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck;
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
net.minecraftforge.fml.loading.RuntimeDistCleaner
|
||||
net.minecraftforge.common.asm.RuntimeEnumExtender
|
||||
net.minecraftforge.common.asm.ObjectHolderDefinalize
|
||||
net.minecraftforge.common.asm.CapabilityInjectDefinalize
|
||||
net.minecraftforge.common.asm.CapabilityInjectDefinalize
|
||||
net.minecraftforge.common.asm.CapabilityTokenSubclass
|
||||
+1
@@ -2,3 +2,4 @@ net.minecraftforge.fml.loading.moddiscovery.ModsFolderLocator
|
||||
net.minecraftforge.fml.loading.moddiscovery.MavenDirectoryLocator
|
||||
net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator
|
||||
net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator
|
||||
net.minecraftforge.fml.loading.moddiscovery.ClasspathLocator
|
||||
@@ -20,24 +20,24 @@
|
||||
<Appenders>
|
||||
<TerminalConsole name="Console">
|
||||
<PatternLayout>
|
||||
<LoggerNamePatternSelector defaultPattern="%highlightForge{[%d{HH:mm:ss}] [%t/%level] [%c{2.}/%markerSimpleName]: %minecraftFormatting{%msg}%n%tEx}">
|
||||
<LoggerNamePatternSelector defaultPattern="%highlightForge{[%d{HH:mm:ss}] [%t/%level] [%c{2.}/%markerSimpleName]: %minecraftFormatting{%msg{nolookup}}%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}"/>
|
||||
<PatternMatch key="net.minecraft." pattern="%highlightForge{[%d{HH:mm:ss}] [%t/%level] [minecraft/%logger{1}]: %minecraftFormatting{%msg{nolookup}}%n%tEx}"/>
|
||||
<PatternMatch key="com.mojang." pattern="%highlightForge{[%d{HH:mm:ss}] [%t/%level] [mojang/%logger{1}]: %minecraftFormatting{%msg{nolookup}}%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">
|
||||
<LoggerNamePatternSelector defaultPattern="[%d{HH:mm:ss}] [%t/%level] [%c{2.}/%markerSimpleName]: %minecraftFormatting{%msg{nolookup}}{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"/>
|
||||
<PatternMatch key="net.minecraft." pattern="[%d{HH:mm:ss}] [%t/%level] [minecraft/%logger{1}]: %minecraftFormatting{%msg{nolookup}}{strip}%n"/>
|
||||
<PatternMatch key="com.mojang." pattern="[%d{HH:mm:ss}] [%t/%level] [mojang/%logger{1}]: %minecraftFormatting{%msg{nolookup}}{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"/>
|
||||
<PatternLayout pattern="[%d{ddMMMyyyy HH:mm:ss.SSS}] [%t/%level] [%logger/%markerSimpleName]: %minecraftFormatting{%msg{nolookup}}{strip}%n%xEx"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy/>
|
||||
<OnStartupTriggeringPolicy/>
|
||||
@@ -45,7 +45,7 @@
|
||||
<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"/>
|
||||
<PatternLayout pattern="[%d{ddMMMyyyy HH:mm:ss.SSS}] [%t/%level] [%logger/%markerSimpleName]: %minecraftFormatting{%msg{nolookup}}{strip}%n%xEx"/>
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy/>
|
||||
<SizeBasedTriggeringPolicy size="200MB"/>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-7.2-20210702220150+0000-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,67 +17,101 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MSYS* | MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# 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"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -33,7 +33,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
/**
|
||||
* This defines a Mod to FML.
|
||||
* Any class found with this annotation applied will be loaded as a Mod. The instance that is loaded will
|
||||
* represent the mod to other Mods in the system. It will be sent various subclasses of {@link ModLifecycleEvent}
|
||||
* represent the mod to other Mods in the system. It will be sent various subclasses of {@code ModLifecycleEvent}
|
||||
* at pre-defined times during the loading of the game.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -51,7 +51,7 @@ public @interface Mod
|
||||
|
||||
/**
|
||||
* Annotate a class which will be subscribed to an Event Bus at mod construction time.
|
||||
* Defaults to subscribing the current modid to the {@link MinecraftForge#EVENT_BUS}
|
||||
* Defaults to subscribing the current modid to the {@code MinecraftForge#EVENT_BUS}
|
||||
* on both sides.
|
||||
*
|
||||
* @see Bus
|
||||
@@ -84,7 +84,8 @@ public @interface Mod
|
||||
enum Bus {
|
||||
/**
|
||||
* The main Forge Event Bus.
|
||||
* @see MinecraftForge#EVENT_BUS
|
||||
*
|
||||
* <p>See {@code MinecraftForge#EVENT_BUS}</p>
|
||||
*/
|
||||
FORGE(Bindings.getForgeBus()),
|
||||
/**
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ import static net.minecraftforge.fml.Logging.LOADING;
|
||||
/**
|
||||
* Automatic eventbus subscriber - reads {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber}
|
||||
* annotations and passes the class instances to the {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus}
|
||||
* defined by the annotation. Defaults to {@link MinecraftForge#EVENT_BUS}
|
||||
* defined by the annotation. Defaults to {@code MinecraftForge#EVENT_BUS}
|
||||
*/
|
||||
public class AutomaticEventSubscriber
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "examplemod resources",
|
||||
"pack_format": 6,
|
||||
"_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods."
|
||||
"pack_format": 7
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
--- a/com/mojang/math/Vector3f.java
|
||||
+++ b/com/mojang/math/Vector3f.java
|
||||
@@ -138,7 +_,7 @@
|
||||
|
||||
public boolean m_122278_() {
|
||||
float f = this.f_122228_ * this.f_122228_ + this.f_122229_ * this.f_122229_ + this.f_122230_ * this.f_122230_;
|
||||
- if ((double)f < 1.0E-5D) {
|
||||
+ if (f < Float.MIN_NORMAL) { //Forge: Fix MC-239212
|
||||
return false;
|
||||
} else {
|
||||
float f1 = Mth.m_14195_(f);
|
||||
@@ -207,4 +_,16 @@
|
||||
public String toString() {
|
||||
return "[" + this.f_122228_ + ", " + this.f_122229_ + ", " + this.f_122230_ + "]";
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
--- a/net/minecraft/advancements/Advancement.java
|
||||
+++ b/net/minecraft/advancements/Advancement.java
|
||||
@@ -127,7 +_,7 @@
|
||||
return this.f_138305_;
|
||||
}
|
||||
|
||||
- public static class Builder {
|
||||
+ public static class Builder implements net.minecraftforge.common.extensions.IForgeAdvancementBuilder {
|
||||
private ResourceLocation f_138332_;
|
||||
private Advancement f_138333_;
|
||||
private DisplayInfo f_138334_;
|
||||
@@ -311,6 +_,7 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
--- a/net/minecraft/client/Minecraft.java
|
||||
+++ b/net/minecraft/client/Minecraft.java
|
||||
@@ -390,6 +_,7 @@
|
||||
public Minecraft(GameConfig p_91084_) {
|
||||
super("Client");
|
||||
f_90981_ = this;
|
||||
+ net.minecraftforge.client.ForgeHooksClient.invalidateLog4jThreadCache();
|
||||
this.f_91069_ = p_91084_.f_101907_.f_101916_;
|
||||
File file1 = p_91084_.f_101907_.f_101918_;
|
||||
this.f_90985_ = p_91084_.f_101907_.f_101917_;
|
||||
@@ -257,7 +_,7 @@
|
||||
import org.lwjgl.util.tinyfd.TinyFileDialogs;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements SnooperPopulator, WindowEventHandler {
|
||||
+public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements SnooperPopulator, WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft {
|
||||
private static Minecraft f_90981_;
|
||||
private static final Logger f_90982_ = LogManager.getLogger();
|
||||
public static final boolean f_91002_ = Util.m_137581_() == Util.OS.OSX;
|
||||
@@ -397,14 +_,13 @@
|
||||
this.f_91029_ = p_91084_.f_101908_.f_101928_;
|
||||
this.f_90986_ = p_91084_.f_101905_.f_101944_;
|
||||
@@ -24,6 +25,14 @@
|
||||
this.f_91033_ = p_91084_.f_101908_.f_101926_;
|
||||
this.f_91034_ = !p_91084_.f_101908_.f_101929_;
|
||||
this.f_91035_ = !p_91084_.f_101908_.f_101930_;
|
||||
@@ -436,6 +_,7 @@
|
||||
}
|
||||
|
||||
Util.f_137440_ = RenderSystem.m_69576_();
|
||||
+ if (net.minecraftforge.common.ForgeConfig.CLIENT.forceSystemNanoTime.get()) Util.f_137440_ = System::nanoTime;
|
||||
this.f_90989_ = new VirtualScreen(this);
|
||||
this.f_90990_ = this.f_90989_.m_110872_(displaydata, this.f_91066_.f_92123_, this.m_91270_());
|
||||
this.m_7440_(true);
|
||||
@@ -450,7 +_,6 @@
|
||||
|
||||
this.f_90990_.m_85380_(this.f_91066_.f_92113_);
|
||||
@@ -58,6 +67,17 @@
|
||||
this.f_91064_ = new DebugRenderer(this);
|
||||
RenderSystem.m_69900_(this::m_91113_);
|
||||
if (this.f_91042_.f_83915_ == this.f_90990_.m_85441_() && this.f_91042_.f_83916_ == this.f_90990_.m_85442_()) {
|
||||
@@ -531,6 +_,10 @@
|
||||
TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false);
|
||||
}
|
||||
|
||||
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RegisterClientReloadListenersEvent(this.f_91036_));
|
||||
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterLayerDefinitions());
|
||||
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers());
|
||||
+
|
||||
this.f_90990_.m_85409_(this.f_91066_.f_92041_);
|
||||
this.f_90990_.m_85424_(this.f_91066_.f_92034_);
|
||||
this.f_90990_.m_85426_();
|
||||
@@ -546,13 +_,16 @@
|
||||
}
|
||||
|
||||
@@ -124,14 +144,6 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -779,6 +_,7 @@
|
||||
return this.m_168019_(false);
|
||||
}
|
||||
|
||||
+ @Deprecated // Forge: Use selective refreshResources method in FMLClientHandler
|
||||
private CompletableFuture<Void> m_168019_(boolean p_168020_) {
|
||||
if (this.f_91024_ != null) {
|
||||
return this.f_91024_;
|
||||
@@ -876,10 +_,6 @@
|
||||
f_90982_.error("setScreen called from non-game thread");
|
||||
}
|
||||
@@ -143,10 +155,11 @@
|
||||
if (p_91153_ == null && this.f_91073_ == null) {
|
||||
p_91153_ = new TitleScreen();
|
||||
} else if (p_91153_ == null && this.f_91074_.m_21224_()) {
|
||||
@@ -890,6 +_,14 @@
|
||||
@@ -890,6 +_,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this);
|
||||
+ Screen old = this.f_91080_;
|
||||
+ net.minecraftforge.client.event.GuiOpenEvent event = new net.minecraftforge.client.event.GuiOpenEvent(p_91153_);
|
||||
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return;
|
||||
@@ -172,7 +185,12 @@
|
||||
}
|
||||
|
||||
if (this.f_91056_ != null) {
|
||||
@@ -1136,6 +_,7 @@
|
||||
@@ -1132,10 +_,12 @@
|
||||
this.f_90990_.m_85378_((double)i);
|
||||
if (this.f_91080_ != null) {
|
||||
this.f_91080_.m_6574_(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_());
|
||||
+ net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_());
|
||||
}
|
||||
|
||||
RenderTarget rendertarget = this.m_91385_();
|
||||
rendertarget.m_83941_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_(), f_91002_);
|
||||
@@ -385,7 +403,7 @@
|
||||
IntegratedServer integratedserver = this.f_91007_;
|
||||
this.f_91007_ = null;
|
||||
this.f_91063_.m_109150_();
|
||||
+ net.minecraftforge.fmlclient.ClientHooks.firePlayerLogout(this.f_91072_, this.f_91074_);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.firePlayerLogout(this.f_91072_, this.f_91074_);
|
||||
this.f_91072_ = null;
|
||||
NarratorChatListener.f_93311_.m_93328_();
|
||||
this.m_91362_(p_91321_);
|
||||
@@ -398,7 +416,7 @@
|
||||
this.f_91065_.m_93089_();
|
||||
this.f_91008_ = null;
|
||||
this.f_91010_ = false;
|
||||
+ net.minecraftforge.fmlclient.ClientHooks.handleClientWorldClosing(f_91073_);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.handleClientWorldClosing(f_91073_);
|
||||
this.f_91004_.m_90740_();
|
||||
}
|
||||
|
||||
@@ -480,14 +498,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2318,6 +_,7 @@
|
||||
return f_90981_;
|
||||
}
|
||||
|
||||
+ @Deprecated // Forge: Use selective scheduleResourceRefresh method in FMLClientHandler
|
||||
public CompletableFuture<Void> m_91088_() {
|
||||
return this.m_18691_(() -> this.m_91391_()).thenCompose((p_167945_) -> {
|
||||
return p_167945_;
|
||||
@@ -2768,7 +_,7 @@
|
||||
return this.f_90993_;
|
||||
}
|
||||
|
||||
Regular → Executable
+9
-5
@@ -8,21 +8,25 @@
|
||||
boolean[] aboolean = new boolean[]{false};
|
||||
if (this.f_91503_.m_91265_() == null) {
|
||||
if (this.f_91503_.f_91080_ == null) {
|
||||
@@ -82,11 +_,15 @@
|
||||
@@ -82,11 +_,19 @@
|
||||
if (flag) {
|
||||
screen.m_169415_();
|
||||
Screen.m_96579_(() -> {
|
||||
- aboolean[0] = screen.m_6375_(d0, d1, i);
|
||||
+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPre(this.f_91503_.f_91080_, d0, d1, i);
|
||||
+ if (!aboolean[0]) aboolean[0] = this.f_91503_.f_91080_.m_6375_(d0, d1, i);
|
||||
+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPost(this.f_91503_.f_91080_, d0, d1, i);
|
||||
+ if (!aboolean[0]) {
|
||||
+ aboolean[0] = this.f_91503_.f_91080_.m_6375_(d0, d1, i);
|
||||
+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPost(this.f_91503_.f_91080_, d0, d1, i, aboolean[0]);
|
||||
+ }
|
||||
}, "mouseClicked event handler", screen.getClass().getCanonicalName());
|
||||
} else {
|
||||
Screen.m_96579_(() -> {
|
||||
- aboolean[0] = screen.m_6348_(d0, d1, i);
|
||||
+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPre(this.f_91503_.f_91080_, d0, d1, i);
|
||||
+ if (!aboolean[0]) aboolean[0] = this.f_91503_.f_91080_.m_6348_(d0, d1, i);
|
||||
+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPost(this.f_91503_.f_91080_, d0, d1, i);
|
||||
+ if (!aboolean[0]) {
|
||||
+ aboolean[0] = this.f_91503_.f_91080_.m_6348_(d0, d1, i);
|
||||
+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPost(this.f_91503_.f_91080_, d0, d1, i, aboolean[0]);
|
||||
+ }
|
||||
}, "mouseReleased event handler", screen.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/client/gui/screens/LanguageSelectScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/LanguageSelectScreen.java
|
||||
@@ -36,7 +_,7 @@
|
||||
if (languageselectscreen$languageselectionlist$entry != null && !languageselectscreen$languageselectionlist$entry.f_96116_.getCode().equals(this.f_96080_.m_118983_().getCode())) {
|
||||
this.f_96080_.m_118974_(languageselectscreen$languageselectionlist$entry.f_96116_);
|
||||
this.f_96282_.f_92075_ = languageselectscreen$languageselectionlist$entry.f_96116_.getCode();
|
||||
- this.f_96541_.m_91391_();
|
||||
+ net.minecraftforge.client.ForgeHooksClient.refreshResources(this.f_96541_, net.minecraftforge.resource.VanillaResourceType.LANGUAGES);
|
||||
this.f_96282_.m_92169_();
|
||||
}
|
||||
|
||||
@@ -1,68 +1,142 @@
|
||||
--- a/net/minecraft/client/gui/screens/Screen.java
|
||||
+++ b/net/minecraft/client/gui/screens/Screen.java
|
||||
@@ -163,7 +_,10 @@
|
||||
@@ -125,7 +_,7 @@
|
||||
}
|
||||
|
||||
public void m_7379_() {
|
||||
- this.f_96541_.m_91152_((Screen)null);
|
||||
+ this.f_96541_.popGuiLayer();
|
||||
}
|
||||
|
||||
protected <T extends GuiEventListener & Widget & NarratableEntry> T m_142416_(T p_169406_) {
|
||||
@@ -162,15 +_,29 @@
|
||||
this.f_169368_.clear();
|
||||
}
|
||||
|
||||
+ private Font tooltipFont = null;
|
||||
+ private ItemStack tooltipStack = ItemStack.f_41583_;
|
||||
protected void m_6057_(PoseStack p_96566_, ItemStack p_96567_, int p_96568_, int p_96569_) {
|
||||
- this.m_169388_(p_96566_, this.m_96555_(p_96567_), p_96567_.m_150921_(), p_96568_, p_96569_);
|
||||
+ Font font = net.minecraftforge.client.RenderProperties.get(p_96567_).getFont(p_96567_);
|
||||
+ net.minecraftforge.fmlclient.gui.GuiUtils.preItemToolTip(p_96567_);
|
||||
+ this.renderComponentToolTip(p_96566_, this.m_96555_(p_96567_), p_96568_, p_96569_, (font == null ? this.f_96547_ : font));
|
||||
+ net.minecraftforge.fmlclient.gui.GuiUtils.postItemToolTip();
|
||||
+ tooltipStack = p_96567_;
|
||||
this.m_169388_(p_96566_, this.m_96555_(p_96567_), p_96567_.m_150921_(), p_96568_, p_96569_);
|
||||
+ tooltipStack = ItemStack.f_41583_;
|
||||
}
|
||||
|
||||
+ public void renderTooltip(PoseStack poseStack, List<Component> textComponents, Optional<TooltipComponent> tooltipComponent, int x, int y, ItemStack stack) {
|
||||
+ this.renderTooltip(poseStack, textComponents, tooltipComponent, x, y, null, stack);
|
||||
+ }
|
||||
+ public void renderTooltip(PoseStack poseStack, List<Component> textComponents, Optional<TooltipComponent> tooltipComponent, int x, int y, @Nullable Font font) {
|
||||
+ this.renderTooltip(poseStack, textComponents, tooltipComponent, x, y, font, ItemStack.f_41583_);
|
||||
+ }
|
||||
+ public void renderTooltip(PoseStack poseStack, List<Component> textComponents, Optional<TooltipComponent> tooltipComponent, int x, int y, @Nullable Font font, ItemStack stack) {
|
||||
+ this.tooltipFont = font;
|
||||
+ this.tooltipStack = stack;
|
||||
+ this.m_169388_(poseStack, textComponents, tooltipComponent, x, y);
|
||||
+ this.tooltipFont = null;
|
||||
+ this.tooltipStack = ItemStack.f_41583_;
|
||||
+ }
|
||||
public void m_169388_(PoseStack p_169389_, List<Component> p_169390_, Optional<TooltipComponent> p_169391_, int p_169392_, int p_169393_) {
|
||||
@@ -171,7 +_,7 @@
|
||||
p_169391_.ifPresent((p_169399_) -> {
|
||||
list.add(1, ClientTooltipComponent.m_169950_(p_169399_));
|
||||
});
|
||||
- this.m_169383_(p_169389_, list, p_169392_, p_169393_);
|
||||
+ this.renderTooltipInternal(p_169389_, list, p_169392_, p_169393_, f_96547_);
|
||||
- List<ClientTooltipComponent> list = p_169390_.stream().map(Component::m_7532_).map(ClientTooltipComponent::m_169948_).collect(Collectors.toList());
|
||||
- p_169391_.ifPresent((p_169399_) -> {
|
||||
- list.add(1, ClientTooltipComponent.m_169950_(p_169399_));
|
||||
- });
|
||||
+ List<ClientTooltipComponent> list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_169390_, p_169391_, p_169392_, f_96543_, f_96544_, this.tooltipFont, this.f_96547_);
|
||||
this.m_169383_(p_169389_, list, p_169392_, p_169393_);
|
||||
}
|
||||
|
||||
public List<Component> m_96555_(ItemStack p_96556_) {
|
||||
@@ -179,24 +_,30 @@
|
||||
}
|
||||
|
||||
public void m_96602_(PoseStack p_96603_, Component p_96604_, int p_96605_, int p_96606_) {
|
||||
- this.m_96617_(p_96603_, Arrays.asList(p_96604_.m_7532_()), p_96605_, p_96606_);
|
||||
+ this.m_96597_(p_96603_, Arrays.asList(p_96604_), p_96605_, p_96606_);
|
||||
@@ -183,20 +_,48 @@
|
||||
}
|
||||
|
||||
public void m_96597_(PoseStack p_96598_, List<Component> p_96599_, int p_96600_, int p_96601_) {
|
||||
- this.m_96617_(p_96598_, Lists.transform(p_96599_, Component::m_7532_), p_96600_, p_96601_);
|
||||
+ this.renderComponentToolTip(p_96598_, p_96599_, p_96600_, p_96601_, f_96547_);
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, p_96599_, p_96600_, f_96543_, f_96544_, this.tooltipFont, this.f_96547_);
|
||||
+ this.m_169383_(p_96598_, components, p_96600_, p_96601_);
|
||||
+ }
|
||||
+ public void renderComponentToolTip(PoseStack matrixStack, List<? extends net.minecraft.network.chat.FormattedText> tooltips, int mouseX, int mouseY, Font font) {
|
||||
+ net.minecraftforge.fmlclient.gui.GuiUtils.drawHoveringText(matrixStack, tooltips, mouseX, mouseY, f_96543_, f_96544_, -1, font);
|
||||
+ public void renderComponentTooltip(PoseStack poseStack, List<? extends net.minecraft.network.chat.FormattedText> tooltips, int mouseX, int mouseY, ItemStack stack) {
|
||||
+ this.renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, null, stack);
|
||||
+ }
|
||||
+ public void renderComponentTooltip(PoseStack poseStack, List<? extends net.minecraft.network.chat.FormattedText> tooltips, int mouseX, int mouseY, @Nullable Font font) {
|
||||
+ this.renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, font, ItemStack.f_41583_);
|
||||
+ }
|
||||
+ @Deprecated(forRemoval = true, since = "1.17.1") public void renderComponentToolTip(PoseStack poseStack, List<? extends net.minecraft.network.chat.FormattedText> tooltips, int mouseX, int mouseY, @Nullable Font font) {
|
||||
+ renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, font);
|
||||
+ }
|
||||
+ public void renderComponentTooltip(PoseStack poseStack, List<? extends net.minecraft.network.chat.FormattedText> tooltips, int mouseX, int mouseY, @Nullable Font font, ItemStack stack) {
|
||||
+ this.tooltipFont = font;
|
||||
+ this.tooltipStack = stack;
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, tooltips, mouseX, f_96543_, f_96544_, this.tooltipFont, this.f_96547_);
|
||||
+ this.m_169383_(poseStack, components, mouseX, mouseY);
|
||||
+ this.tooltipFont = null;
|
||||
+ this.tooltipStack = ItemStack.f_41583_;
|
||||
}
|
||||
|
||||
public void m_96617_(PoseStack p_96618_, List<? extends FormattedCharSequence> p_96619_, int p_96620_, int p_96621_) {
|
||||
- this.m_169383_(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_);
|
||||
+ this.renderToolTip(p_96618_, p_96619_, p_96620_, p_96621_, f_96547_);
|
||||
+ }
|
||||
+ public void renderToolTip(PoseStack p_96618_, List<? extends FormattedCharSequence> p_96619_, int p_96620_, int p_96621_, Font font) {
|
||||
+ this.renderTooltipInternal(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_, font);
|
||||
this.m_169383_(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_);
|
||||
}
|
||||
+ @Deprecated(forRemoval = true, since = "1.17.1") public void renderToolTip(PoseStack p_96618_, List<? extends FormattedCharSequence> p_96619_, int p_96620_, int p_96621_, Font font) {
|
||||
+ renderTooltip(p_96618_, p_96619_, p_96620_, p_96621_, font);
|
||||
+ }
|
||||
+ public void renderTooltip(PoseStack poseStack, List<? extends FormattedCharSequence> lines, int x, int y, Font font) {
|
||||
+ this.tooltipFont = font;
|
||||
+ this.m_96617_(poseStack, lines, x, y);
|
||||
+ this.tooltipFont = null;
|
||||
+ }
|
||||
|
||||
- private void m_169383_(PoseStack p_169384_, List<ClientTooltipComponent> p_169385_, int p_169386_, int p_169387_) {
|
||||
+ private void renderTooltipInternal(PoseStack p_169384_, List<ClientTooltipComponent> p_169385_, int p_169386_, int p_169387_, Font font) {
|
||||
private void m_169383_(PoseStack p_169384_, List<ClientTooltipComponent> p_169385_, int p_169386_, int p_169387_) {
|
||||
if (!p_169385_.isEmpty()) {
|
||||
+ net.minecraftforge.client.event.RenderTooltipEvent.Pre preEvent = net.minecraftforge.client.ForgeHooksClient.preTooltipEvent(this.tooltipStack, p_169384_, p_169386_, p_169387_, f_96543_, f_96544_, p_169385_, this.tooltipFont, this.f_96547_);
|
||||
+ if (preEvent.isCanceled()) return;
|
||||
int i = 0;
|
||||
int j = p_169385_.size() == 1 ? -2 : 0;
|
||||
|
||||
for(ClientTooltipComponent clienttooltipcomponent : p_169385_) {
|
||||
- int k = clienttooltipcomponent.m_142069_(this.f_96547_);
|
||||
+ int k = clienttooltipcomponent.m_142069_(font);
|
||||
+ int k = clienttooltipcomponent.m_142069_(preEvent.getFontRenderer());
|
||||
if (k > i) {
|
||||
i = k;
|
||||
}
|
||||
@@ -204,8 +_,8 @@
|
||||
j += clienttooltipcomponent.m_142103_();
|
||||
}
|
||||
|
||||
- int j2 = p_169386_ + 12;
|
||||
- int k2 = p_169387_ - 12;
|
||||
+ int j2 = preEvent.getX() + 12;
|
||||
+ int k2 = preEvent.getY() - 12;
|
||||
if (j2 + i > this.f_96543_) {
|
||||
j2 -= 28 + i;
|
||||
}
|
||||
@@ -226,15 +_,16 @@
|
||||
RenderSystem.m_157427_(GameRenderer::m_172811_);
|
||||
bufferbuilder.m_166779_(VertexFormat.Mode.QUADS, DefaultVertexFormat.f_85815_);
|
||||
Matrix4f matrix4f = p_169384_.m_85850_().m_85861_();
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, -267386864, -267386864);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, -267386864, -267386864);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, -267386864, -267386864);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, -267386864, -267386864);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, -267386864, -267386864);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, 1347420415, 1344798847);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, 1347420415, 1344798847);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, 1347420415, 1347420415);
|
||||
- m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, 1344798847, 1344798847);
|
||||
+ net.minecraftforge.client.event.RenderTooltipEvent.Color colorEvent = net.minecraftforge.client.ForgeHooksClient.colorTooltipEvent(this.tooltipStack, p_169384_, j2, k2, preEvent.getFontRenderer(), p_169385_);
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundStart());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, colorEvent.getBackgroundEnd(), colorEvent.getBackgroundEnd());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 - 4, k2 - 3, j2 - 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 + i + 3, k2 - 3, j2 + i + 4, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderEnd());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, colorEvent.getBorderStart(), colorEvent.getBorderStart());
|
||||
+ m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBorderEnd(), colorEvent.getBorderEnd());
|
||||
RenderSystem.m_69482_();
|
||||
RenderSystem.m_69472_();
|
||||
RenderSystem.m_69478_();
|
||||
@@ -249,7 +_,7 @@
|
||||
|
||||
for(int i2 = 0; i2 < p_169385_.size(); ++i2) {
|
||||
ClientTooltipComponent clienttooltipcomponent1 = p_169385_.get(i2);
|
||||
- clienttooltipcomponent1.m_142440_(this.f_96547_, j2, l1, matrix4f, multibuffersource$buffersource);
|
||||
+ clienttooltipcomponent1.m_142440_(font, j2, l1, matrix4f, multibuffersource$buffersource);
|
||||
+ clienttooltipcomponent1.m_142440_(preEvent.getFontRenderer(), j2, l1, matrix4f, multibuffersource$buffersource);
|
||||
l1 += clienttooltipcomponent1.m_142103_() + (i2 == 0 ? 2 : 0);
|
||||
}
|
||||
|
||||
@@ -71,7 +145,7 @@
|
||||
for(int l2 = 0; l2 < p_169385_.size(); ++l2) {
|
||||
ClientTooltipComponent clienttooltipcomponent2 = p_169385_.get(l2);
|
||||
- clienttooltipcomponent2.m_142162_(this.f_96547_, j2, l1, p_169384_, this.f_96542_, 400, this.f_96541_.m_91097_());
|
||||
+ clienttooltipcomponent2.m_142162_(font, j2, l1, p_169384_, this.f_96542_, 400, this.f_96541_.m_91097_());
|
||||
+ clienttooltipcomponent2.m_142162_(preEvent.getFontRenderer(), j2, l1, p_169384_, this.f_96542_, 400, this.f_96541_.m_91097_());
|
||||
l1 += clienttooltipcomponent2.m_142103_() + (l2 == 0 ? 2 : 0);
|
||||
}
|
||||
|
||||
@@ -88,19 +162,16 @@
|
||||
|
||||
this.f_96541_.f_91074_.m_108739_(p_96613_);
|
||||
}
|
||||
@@ -366,11 +_,24 @@
|
||||
@@ -366,11 +_,21 @@
|
||||
this.f_96547_ = p_96607_.f_91062_;
|
||||
this.f_96543_ = p_96608_;
|
||||
this.f_96544_ = p_96609_;
|
||||
+ java.util.function.Consumer<GuiEventListener> add = (b) -> {
|
||||
+ if (b instanceof Widget) {
|
||||
+ this.f_169369_.add((Widget)b);
|
||||
+ }
|
||||
+
|
||||
+ if (b instanceof NarratableEntry) {
|
||||
+ this.f_169368_.add((NarratableEntry)b);
|
||||
+ }
|
||||
+ f_96540_.remove(b);
|
||||
+ if (b instanceof Widget w)
|
||||
+ this.f_169369_.add(w);
|
||||
+ if (b instanceof NarratableEntry ne)
|
||||
+ this.f_169368_.add(ne);
|
||||
+ f_96540_.add(b);
|
||||
+ };
|
||||
+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Pre(this, this.f_96540_, add, this::m_169411_))) {
|
||||
this.m_169413_();
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
int l = slot.f_40220_;
|
||||
int i1 = slot.f_40221_;
|
||||
- m_169606_(p_97795_, l, i1, this.m_93252_());
|
||||
+ renderSlotHighlight(p_97795_, l, i1, this.m_93252_(), this.getSlotColor(i1));
|
||||
+ renderSlotHighlight(p_97795_, l, i1, this.m_93252_(), this.getSlotColor(k));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -173,15 +173,12 @@
|
||||
RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.m_7025_(p_98577_, p_98578_, p_98579_);
|
||||
}
|
||||
@@ -620,7 +_,10 @@
|
||||
@@ -620,7 +_,7 @@
|
||||
list1.add(1, creativemodetab.m_40786_().m_6881_().m_130940_(ChatFormatting.BLUE));
|
||||
}
|
||||
|
||||
- this.m_169388_(p_98590_, list1, p_98591_.m_150921_(), p_98592_, p_98593_);
|
||||
+ net.minecraft.client.gui.Font font = net.minecraftforge.client.RenderProperties.get(p_98591_).getFont(p_98591_);
|
||||
+ net.minecraftforge.fmlclient.gui.GuiUtils.preItemToolTip(p_98591_);
|
||||
+ this.renderComponentToolTip(p_98590_, list1, p_98592_, p_98593_, (font == null ? this.f_96547_ : font));
|
||||
+ net.minecraftforge.fmlclient.gui.GuiUtils.postItemToolTip();
|
||||
+ this.renderTooltip(p_98590_, list1, p_98591_.m_150921_(), p_98592_, p_98593_, p_98591_);
|
||||
} else {
|
||||
super.m_6057_(p_98590_, p_98591_, p_98592_, p_98593_);
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
|
||||
+++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
|
||||
@@ -22,6 +_,8 @@
|
||||
if (p_169951_ instanceof BundleTooltip) {
|
||||
return new ClientBundleTooltip((BundleTooltip)p_169951_);
|
||||
} else {
|
||||
+ ClientTooltipComponent result = net.minecraftforge.client.MinecraftForgeClient.getClientTooltipComponent(p_169951_);
|
||||
+ if (result != null) return result;
|
||||
throw new IllegalArgumentException("Unknown TooltipComponent");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
this.f_99855_.m_99707_(list1);
|
||||
}
|
||||
|
||||
+ net.minecraftforge.fmlclient.ClientHooks.drawForgePingInfo(this.f_99855_, f_99857_, p_99879_, p_99882_, p_99881_, p_99883_, i1, j1);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.f_99855_, f_99857_, p_99879_, p_99882_, p_99881_, p_99883_, i1, j1);
|
||||
+
|
||||
if (this.f_99856_.f_91066_.f_92051_ || p_99887_) {
|
||||
RenderSystem.m_157456_(0, ServerSelectionList.f_99759_);
|
||||
|
||||
+7
-7
@@ -9,12 +9,12 @@
|
||||
this.f_100279_.add(new RecipeBookTabButton(recipebookcategories));
|
||||
}
|
||||
|
||||
@@ -462,7 +_,7 @@
|
||||
|
||||
languagemanager.m_118974_(languageinfo);
|
||||
this.f_100272_.f_91066_.f_92075_ = languageinfo.getCode();
|
||||
- this.f_100272_.m_91391_();
|
||||
+ net.minecraftforge.client.ForgeHooksClient.refreshResources(this.f_100272_, net.minecraftforge.resource.VanillaResourceType.LANGUAGES);
|
||||
this.f_100272_.f_91066_.m_92169_();
|
||||
@@ -319,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (itemstack != null && this.f_100272_.f_91080_ != null) {
|
||||
- this.f_100272_.f_91080_.m_96597_(p_100375_, this.f_100272_.f_91080_.m_96555_(itemstack), p_100378_, p_100379_);
|
||||
+ this.f_100272_.f_91080_.renderComponentTooltip(p_100375_, this.f_100272_.f_91080_.m_96555_(itemstack), p_100378_, p_100379_, itemstack);
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/client/gui/screens/recipebook/RecipeBookPage.java
|
||||
+++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookPage.java
|
||||
@@ -115,7 +_,7 @@
|
||||
|
||||
public void m_100417_(PoseStack p_100418_, int p_100419_, int p_100420_) {
|
||||
if (this.f_100397_.f_91080_ != null && this.f_100395_ != null && !this.f_100396_.m_100212_()) {
|
||||
- this.f_100397_.f_91080_.m_96597_(p_100418_, this.f_100395_.m_100477_(this.f_100397_.f_91080_), p_100419_, p_100420_);
|
||||
+ this.f_100397_.f_91080_.renderComponentTooltip(p_100418_, this.f_100395_.m_100477_(this.f_100397_.f_91080_), p_100419_, p_100420_, this.f_100395_.m_100488_().m_8043_());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
File file1 = path.toFile();
|
||||
if (this.f_100832_ == null) {
|
||||
this.f_100832_ = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(file1, PackSource.f_10527_));
|
||||
+ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinder);
|
||||
+ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinderNew);
|
||||
this.f_100832_.m_10506_();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
WoodType.m_61843_().forEach((p_171114_) -> {
|
||||
builder.put(ModelLayers.m_171291_(p_171114_), layerdefinition19);
|
||||
});
|
||||
+ net.minecraftforge.fmlclient.registry.RenderingRegistry.loadLayerDefinitions(builder);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder);
|
||||
ImmutableMap<ModelLayerLocation, LayerDefinition> immutablemap = builder.build();
|
||||
List<ModelLayerLocation> list = ModelLayers.m_171288_().filter((p_171117_) -> {
|
||||
return !immutablemap.containsKey(p_171117_);
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/client/model/geom/ModelLayers.java
|
||||
+++ b/net/minecraft/client/model/geom/ModelLayers.java
|
||||
@@ -199,7 +_,8 @@
|
||||
}
|
||||
|
||||
public static ModelLayerLocation m_171291_(WoodType p_171292_) {
|
||||
- return m_171300_("sign/" + p_171292_.m_61846_(), "main");
|
||||
+ ResourceLocation location = new ResourceLocation(p_171292_.m_61846_());
|
||||
+ return new ModelLayerLocation(new ResourceLocation(location.m_135827_(), "sign/" + location.m_135815_()), "main");
|
||||
}
|
||||
|
||||
public static Stream<ModelLayerLocation> m_171288_() {
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
this.f_104888_.f_91064_.m_113434_();
|
||||
this.f_104888_.f_91074_.m_172530_();
|
||||
+ net.minecraftforge.fmlclient.ClientHooks.firePlayerLogin(this.f_104888_.f_91072_, this.f_104888_.f_91074_, this.f_104888_.m_91403_().m_6198_());
|
||||
+ net.minecraftforge.client.ForgeHooksClient.firePlayerLogin(this.f_104888_.f_91072_, this.f_104888_.f_91074_, this.f_104888_.m_91403_().m_6198_());
|
||||
int i = p_105030_.m_132398_();
|
||||
this.f_104888_.f_91074_.m_20234_(i);
|
||||
this.f_104889_.m_104630_(i, this.f_104888_.f_91074_);
|
||||
@@ -43,7 +43,7 @@
|
||||
+ localplayer1.updateSyncFields(localplayer); // Forge: fix MC-10657
|
||||
localplayer1.m_172530_();
|
||||
localplayer1.m_108748_(s);
|
||||
+ net.minecraftforge.fmlclient.ClientHooks.firePlayerRespawn(this.f_104888_.f_91072_, localplayer, localplayer1, localplayer1.f_108617_.m_6198_());
|
||||
+ net.minecraftforge.client.ForgeHooksClient.firePlayerRespawn(this.f_104888_.f_91072_, localplayer, localplayer1, localplayer1.f_108617_.m_6198_());
|
||||
this.f_104889_.m_104630_(i, localplayer1);
|
||||
localplayer1.m_146922_(-180.0F);
|
||||
localplayer1.f_108618_ = new KeyboardInput(this.f_104888_.f_91066_);
|
||||
@@ -77,23 +77,15 @@
|
||||
if (mobeffect != null) {
|
||||
MobEffectInstance mobeffectinstance = new MobEffectInstance(mobeffect, p_105130_.m_133625_(), p_105130_.m_133624_(), p_105130_.m_133627_(), p_105130_.m_133626_(), p_105130_.m_133628_());
|
||||
mobeffectinstance.m_19562_(p_105130_.m_133619_());
|
||||
@@ -1228,11 +_,14 @@
|
||||
public void m_5859_(ClientboundUpdateTagsPacket p_105134_) {
|
||||
PacketUtils.m_131363_(p_105134_, this, this.f_104888_);
|
||||
TagContainer tagcontainer = TagContainer.m_144449_(this.f_104903_, p_105134_.m_179482_());
|
||||
- Multimap<ResourceKey<? extends Registry<?>>, ResourceLocation> multimap = StaticTags.m_13283_(tagcontainer);
|
||||
+ boolean vanillaConnection = net.minecraftforge.fmllegacy.network.NetworkHooks.isVanillaConnection(f_104885_);
|
||||
+ Multimap<ResourceKey<? extends Registry<?>>, ResourceLocation> multimap = vanillaConnection ? StaticTags.m_13283_(net.minecraftforge.common.ForgeTagHandler.withNoCustom(tagcontainer)) : StaticTags.validateVanillaTags(tagcontainer);//Forge: If we are connecting to vanilla validate all tags to properly validate custom tags the client may "require", and if we are connecting to forge only validate the vanilla tag types as the custom tag types get synced in a separate packet so may still arrive
|
||||
if (!multimap.isEmpty()) {
|
||||
@@ -1233,6 +_,7 @@
|
||||
f_104883_.warn("Incomplete server tags, disconnecting. Missing: {}", (Object)multimap);
|
||||
this.f_104885_.m_129507_(new TranslatableComponent("multiplayer.disconnect.missing_tags"));
|
||||
} else {
|
||||
+ net.minecraftforge.common.ForgeTagHandler.resetCachedTagCollections(true, vanillaConnection);
|
||||
+ tagcontainer = TagContainer.reinjectOptionalTags(tagcontainer);
|
||||
+ tagcontainer = net.minecraftforge.common.ForgeTagHandler.reinjectOptionalTags(tagcontainer);
|
||||
this.f_104895_ = tagcontainer;
|
||||
if (!this.f_104885_.m_129531_()) {
|
||||
tagcontainer.m_13431_();
|
||||
@@ -1780,10 +_,12 @@
|
||||
@@ -1780,7 +_,8 @@
|
||||
int i5 = friendlybytebuf.m_130242_();
|
||||
this.f_104888_.f_91064_.f_173815_.m_173830_(positionsource, i5);
|
||||
} else {
|
||||
@@ -103,7 +95,3 @@
|
||||
}
|
||||
} finally {
|
||||
if (friendlybytebuf != null) {
|
||||
+ if (false) // Forge: let packet handle releasing buffer
|
||||
friendlybytebuf.release();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
p_105461_.run();
|
||||
}
|
||||
|
||||
+ net.minecraftforge.fmlclient.ClientHooks.processForgeListPingData(serverstatus, p_105460_);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.processForgeListPingData(serverstatus, p_105460_);
|
||||
this.f_105477_ = Util.m_137550_();
|
||||
connection.m_129512_(new ServerboundPingRequestPacket(this.f_105477_));
|
||||
this.f_105475_ = true;
|
||||
@@ -75,7 +75,23 @@
|
||||
VoxelShape voxelshape = p_107357_.m_60808_(this.f_107287_, p_107356_);
|
||||
double d0 = 0.25D;
|
||||
voxelshape.m_83286_((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> {
|
||||
@@ -500,6 +_,12 @@
|
||||
@@ -450,7 +_,7 @@
|
||||
double d7 = d4 * d1 + p_172273_;
|
||||
double d8 = d5 * d2 + p_172274_;
|
||||
double d9 = d6 * d3 + p_172275_;
|
||||
- this.m_107344_(new TerrainParticle(this.f_107287_, (double)p_107356_.m_123341_() + d7, (double)p_107356_.m_123342_() + d8, (double)p_107356_.m_123343_() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, p_107357_, p_107356_));
|
||||
+ this.m_107344_(new TerrainParticle(this.f_107287_, (double)p_107356_.m_123341_() + d7, (double)p_107356_.m_123342_() + d8, (double)p_107356_.m_123343_() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, p_107357_, p_107356_).updateSprite(p_107357_, p_107356_));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,12 +_,18 @@
|
||||
d0 = (double)i + aabb.f_82291_ + (double)0.1F;
|
||||
}
|
||||
|
||||
- this.m_107344_((new TerrainParticle(this.f_107287_, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockstate, p_107368_)).m_107268_(0.2F).m_6569_(0.6F));
|
||||
+ this.m_107344_((new TerrainParticle(this.f_107287_, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockstate, p_107368_).updateSprite(blockstate, p_107368_)).m_107268_(0.2F).m_6569_(0.6F));
|
||||
}
|
||||
}
|
||||
|
||||
public String m_107403_() {
|
||||
return String.valueOf(this.f_107289_.values().stream().mapToInt(Collection::size).sum());
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ private Particle updateSprite(BlockState state, BlockPos pos) { //FORGE: we cannot assume that the x y z of the particles match the block pos of the block.
|
||||
+ public Particle updateSprite(BlockState state, BlockPos pos) { //FORGE: we cannot assume that the x y z of the particles match the block pos of the block.
|
||||
+ if (pos != null) // There are cases where we are not able to obtain the correct source pos, and need to fallback to the non-model data version
|
||||
+ this.m_108337_(Minecraft.m_91087_().m_91289_().m_110907_().getTexture(state, f_107208_, pos));
|
||||
+ return this;
|
||||
|
||||
@@ -37,6 +37,14 @@
|
||||
this.f_108617_.m_104955_(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
|
||||
}
|
||||
}
|
||||
@@ -807,6 +_,7 @@
|
||||
|
||||
public void m_6083_() {
|
||||
super.m_6083_();
|
||||
+ if (this.m_36342_() && this.m_20159_()) this.f_108618_.f_108573_ = false;
|
||||
this.f_108611_ = false;
|
||||
if (this.m_20202_() instanceof Boat) {
|
||||
Boat boat = (Boat)this.m_20202_();
|
||||
@@ -1004,6 +_,18 @@
|
||||
} else {
|
||||
return super.m_7398_(p_108758_);
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -541,6 +_,7 @@
|
||||
list1.add(Pair.of(new ShaderInstance(p_172768_, "rendertype_crumbling", DefaultVertexFormat.f_85811_), (p_172733_) -> {
|
||||
f_172607_ = p_172733_;
|
||||
}));
|
||||
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RegisterShadersEvent(p_172768_, list1));
|
||||
} catch (IOException ioexception) {
|
||||
list1.forEach((p_172772_) -> {
|
||||
p_172772_.getFirst().close();
|
||||
@@ -703,7 +_,7 @@
|
||||
d0 *= (double)Mth.m_14179_(this.f_109059_.f_91066_.f_92070_, 1.0F, 0.85714287F);
|
||||
}
|
||||
@@ -18,6 +26,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -840,11 +_,11 @@
|
||||
|
||||
Window window = this.f_109059_.m_91268_();
|
||||
RenderSystem.m_69421_(256, Minecraft.f_91002_);
|
||||
- Matrix4f matrix4f = Matrix4f.m_162203_(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), 0.0F, (float)((double)window.m_85442_() / window.m_85449_()), 1000.0F, 3000.0F);
|
||||
+ Matrix4f matrix4f = Matrix4f.m_162203_(0.0F, (float)((double)window.m_85441_() / window.m_85449_()), 0.0F, (float)((double)window.m_85442_() / window.m_85449_()), 1000.0F, net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane());
|
||||
RenderSystem.m_157425_(matrix4f);
|
||||
PoseStack posestack = RenderSystem.m_157191_();
|
||||
posestack.m_166856_();
|
||||
- posestack.m_85837_(0.0D, 0.0D, -2000.0D);
|
||||
+ posestack.m_85837_(0.0D, 0.0D, 1000F-net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane());
|
||||
RenderSystem.m_157182_();
|
||||
Lighting.m_84931_();
|
||||
PoseStack posestack1 = new PoseStack();
|
||||
@@ -879,7 +_,7 @@
|
||||
}
|
||||
} else if (this.f_109059_.f_91080_ != null) {
|
||||
@@ -45,15 +67,3 @@
|
||||
this.f_109059_.m_91307_().m_6182_("hand");
|
||||
if (this.f_109070_) {
|
||||
RenderSystem.m_69421_(256, Minecraft.f_91002_);
|
||||
@@ -1151,6 +_,11 @@
|
||||
|
||||
public OverlayTexture m_109155_() {
|
||||
return this.f_109075_;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraftforge.resource.IResourceType getResourceType() {
|
||||
+ return net.minecraftforge.resource.VanillaResourceType.SHADERS;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -4,7 +4,7 @@
|
||||
if (iteminhandrenderer$handrenderselection.f_172921_) {
|
||||
float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F;
|
||||
float f5 = 1.0F - Mth.m_14179_(p_109315_, this.f_109303_, this.f_109302_);
|
||||
+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f5, f2, this.f_109300_))
|
||||
+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, p_109316_, p_109317_, p_109319_, p_109315_, f1, f4, f5, this.f_109300_))
|
||||
this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.MAIN_HAND, f4, this.f_109300_, f5, p_109316_, p_109317_, p_109319_);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,15 +198,3 @@
|
||||
if (j < k) {
|
||||
j = k;
|
||||
}
|
||||
@@ -2748,6 +_,11 @@
|
||||
@Nullable
|
||||
public RenderTarget m_109832_() {
|
||||
return this.f_109417_;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraftforge.resource.IResourceType getResourceType() {
|
||||
+ return net.minecraftforge.resource.VanillaResourceType.MODELS;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -10,3 +10,11 @@
|
||||
Resource resource = null;
|
||||
|
||||
try {
|
||||
@@ -278,6 +_,7 @@
|
||||
public void m_110038_(String p_110039_, int p_110040_, int p_110041_) {
|
||||
RenderTarget rendertarget = new TextureTarget(p_110040_, p_110041_, true, Minecraft.f_91002_);
|
||||
rendertarget.m_83931_(0.0F, 0.0F, 0.0F, 0.0F);
|
||||
+ if (f_110006_.isStencilEnabled()) { rendertarget.enableStencil(); }
|
||||
this.f_110010_.put(p_110039_, rendertarget);
|
||||
if (p_110040_ == this.f_110013_ && p_110041_ == this.f_110014_) {
|
||||
this.f_110011_.add(rendertarget);
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/client/renderer/RenderType.java
|
||||
+++ b/net/minecraft/client/renderer/RenderType.java
|
||||
@@ -288,27 +_,27 @@
|
||||
}
|
||||
|
||||
public static RenderType m_110497_(ResourceLocation p_110498_) {
|
||||
- return f_173173_.apply(p_110498_);
|
||||
+ return net.minecraftforge.client.ForgeRenderTypes.getText(p_110498_);
|
||||
}
|
||||
|
||||
public static RenderType m_173237_(ResourceLocation p_173238_) {
|
||||
- return f_173174_.apply(p_173238_);
|
||||
+ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensity(p_173238_);
|
||||
}
|
||||
|
||||
public static RenderType m_181444_(ResourceLocation p_181445_) {
|
||||
- return f_181442_.apply(p_181445_);
|
||||
+ return net.minecraftforge.client.ForgeRenderTypes.getTextPolygonOffset(p_181445_);
|
||||
}
|
||||
|
||||
public static RenderType m_181446_(ResourceLocation p_181447_) {
|
||||
- return f_181443_.apply(p_181447_);
|
||||
+ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensityPolygonOffset(p_181447_);
|
||||
}
|
||||
|
||||
public static RenderType m_110500_(ResourceLocation p_110501_) {
|
||||
- return f_173175_.apply(p_110501_);
|
||||
+ return net.minecraftforge.client.ForgeRenderTypes.getTextSeeThrough(p_110501_);
|
||||
}
|
||||
|
||||
public static RenderType m_173240_(ResourceLocation p_173241_) {
|
||||
- return f_173176_.apply(p_173241_);
|
||||
+ return net.minecraftforge.client.ForgeRenderTypes.getTextIntensitySeeThrough(p_173241_);
|
||||
}
|
||||
|
||||
public static RenderType m_110502_() {
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/client/renderer/ShaderInstance.java
|
||||
+++ b/net/minecraft/client/renderer/ShaderInstance.java
|
||||
@@ -91,10 +_,14 @@
|
||||
@Nullable
|
||||
public final Uniform f_173320_;
|
||||
|
||||
+ @Deprecated // FORGE: Use the ResourceLocation variant below
|
||||
public ShaderInstance(ResourceProvider p_173336_, String p_173337_, VertexFormat p_173338_) throws IOException {
|
||||
- this.f_173300_ = p_173337_;
|
||||
+ this(p_173336_, new ResourceLocation(p_173337_), p_173338_);
|
||||
+ }
|
||||
+ public ShaderInstance(ResourceProvider p_173336_, ResourceLocation shaderLocation, VertexFormat p_173338_) throws IOException {
|
||||
+ this.f_173300_ = shaderLocation.m_135827_().equals("minecraft") ? shaderLocation.m_135815_() : shaderLocation.toString();
|
||||
this.f_173307_ = p_173338_;
|
||||
- ResourceLocation resourcelocation = new ResourceLocation("shaders/core/" + p_173337_ + ".json");
|
||||
+ ResourceLocation resourcelocation = new ResourceLocation(shaderLocation.m_135827_(), "shaders/core/" + shaderLocation.m_135815_() + ".json");
|
||||
Resource resource = null;
|
||||
|
||||
try {
|
||||
@@ -202,8 +_,9 @@
|
||||
Program program1 = p_173342_.m_85570_().get(p_173343_);
|
||||
Program program;
|
||||
if (program1 == null) {
|
||||
- String s = "shaders/core/" + p_173343_ + p_173342_.m_85569_();
|
||||
- ResourceLocation resourcelocation = new ResourceLocation(s);
|
||||
+ ResourceLocation loc = new ResourceLocation(p_173343_);
|
||||
+ String s = "shaders/core/" + loc.m_135815_() + p_173342_.m_85569_();
|
||||
+ ResourceLocation resourcelocation = new ResourceLocation(loc.m_135827_(), s);
|
||||
Resource resource = p_173341_.m_142591_(resourcelocation);
|
||||
final String s1 = FileUtil.m_179922_(s);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/renderer/block/BlockModelShaper.java
|
||||
+++ b/net/minecraft/client/renderer/block/BlockModelShaper.java
|
||||
@@ -24,8 +_,14 @@
|
||||
@@ -24,8 +_,15 @@
|
||||
this.f_110878_ = p_110880_;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
+
|
||||
+ public TextureAtlasSprite getTexture(BlockState p_110883_, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) {
|
||||
+ net.minecraftforge.client.model.data.IModelData data = net.minecraftforge.client.model.ModelDataManager.getModelData(level, pos);
|
||||
+ return this.m_110893_(p_110883_).getParticleIcon(data == null ? net.minecraftforge.client.model.data.EmptyModelData.INSTANCE : data);
|
||||
+ BakedModel model = this.m_110893_(p_110883_);
|
||||
+ return model.getParticleIcon(model.getModelData(level, pos, p_110883_, data == null ? net.minecraftforge.client.model.data.EmptyModelData.INSTANCE : data));
|
||||
}
|
||||
|
||||
public BakedModel m_110893_(BlockState p_110894_) {
|
||||
-11
@@ -64,14 +64,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -105,5 +_,10 @@
|
||||
|
||||
public void m_6213_(ResourceManager p_110909_) {
|
||||
this.f_110901_.m_110944_();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraftforge.resource.IResourceType getResourceType() {
|
||||
+ return net.minecraftforge.resource.VanillaResourceType.MODELS;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
+/**
|
||||
+ * @deprecated use {@link net.minecraft.util.math.vector.TransformationMatrix} through {@link net.minecraftforge.client.extensions.IForgeBakedModel#handlePerspective}
|
||||
+ * @deprecated use {@link com.mojang.math.Transformation} through {@link net.minecraftforge.client.extensions.IForgeBakedModel#handlePerspective}
|
||||
+ */
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
+@Deprecated
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/client/renderer/entity/BoatRenderer.java
|
||||
+++ b/net/minecraft/client/renderer/entity/BoatRenderer.java
|
||||
@@ -52,7 +_,7 @@
|
||||
p_113932_.m_85845_(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), p_113929_.m_38352_(p_113931_), true));
|
||||
}
|
||||
|
||||
- Pair<ResourceLocation, BoatModel> pair = this.f_173934_.get(p_113929_.m_38387_());
|
||||
+ Pair<ResourceLocation, BoatModel> pair = getModelWithLocation(p_113929_);
|
||||
ResourceLocation resourcelocation = pair.getFirst();
|
||||
BoatModel boatmodel = pair.getSecond();
|
||||
p_113932_.m_85841_(-1.0F, -1.0F, 1.0F);
|
||||
@@ -69,7 +_,10 @@
|
||||
super.m_7392_(p_113929_, p_113930_, p_113931_, p_113932_, p_113933_, p_113934_);
|
||||
}
|
||||
|
||||
+ @Deprecated // forge: override getModelWithLocation to change the texture / model
|
||||
public ResourceLocation m_5478_(Boat p_113927_) {
|
||||
- return this.f_173934_.get(p_113927_.m_38387_()).getFirst();
|
||||
+ return getModelWithLocation(p_113927_).getFirst();
|
||||
}
|
||||
+
|
||||
+ public Pair<ResourceLocation, BoatModel> getModelWithLocation(Boat boat) { return this.f_173934_.get(boat.m_38387_()); }
|
||||
}
|
||||
+11
-7
@@ -15,14 +15,18 @@
|
||||
p_114442_.m_85836_();
|
||||
double d3 = d0 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19790_, enderdragonpart.m_20185_());
|
||||
double d4 = d1 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19791_, enderdragonpart.m_20186_());
|
||||
@@ -322,6 +_,10 @@
|
||||
|
||||
public Quaternion m_114470_() {
|
||||
@@ -324,9 +_,14 @@
|
||||
return this.f_114367_;
|
||||
+ }
|
||||
+
|
||||
+ public Map<String, EntityRenderer<? extends Player>> getSkinMap() {
|
||||
+ return java.util.Collections.unmodifiableMap(f_114363_);
|
||||
}
|
||||
|
||||
+ public Map<String, EntityRenderer<? extends Player>> getSkinMap() {
|
||||
+ return java.util.Collections.unmodifiableMap(f_114363_);
|
||||
+ }
|
||||
+
|
||||
public void m_6213_(ResourceManager p_174004_) {
|
||||
EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context(this, this.f_173995_, p_174004_, this.f_173996_, this.f_114365_);
|
||||
this.f_114362_ = EntityRenderers.m_174049_(entityrendererprovider$context);
|
||||
this.f_114363_ = EntityRenderers.m_174051_(entityrendererprovider$context);
|
||||
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.AddLayers(f_114362_, f_114363_));
|
||||
}
|
||||
}
|
||||
@@ -57,26 +57,7 @@
|
||||
crashreportcategory.m_128165_("Item Damage", () -> {
|
||||
return String.valueOf(p_174237_.m_41773_());
|
||||
});
|
||||
@@ -332,14 +_,15 @@
|
||||
multibuffersource$buffersource.m_109911_();
|
||||
}
|
||||
|
||||
- if (p_115176_.m_150947_()) {
|
||||
+ if (p_115176_.m_41720_().showDurabilityBar(p_115176_)) {
|
||||
RenderSystem.m_69465_();
|
||||
RenderSystem.m_69472_();
|
||||
RenderSystem.m_69461_();
|
||||
Tesselator tesselator = Tesselator.m_85913_();
|
||||
BufferBuilder bufferbuilder = tesselator.m_85915_();
|
||||
- int i = p_115176_.m_150948_();
|
||||
- int j = p_115176_.m_150949_();
|
||||
+ double health = p_115176_.m_41720_().getDurabilityForDisplay(p_115176_);
|
||||
+ int i = Math.round(13.0F - (float)health * 13.0F);
|
||||
+ int j = p_115176_.m_41720_().getRGBDurabilityForDisplay(p_115176_);
|
||||
this.m_115152_(bufferbuilder, p_115177_ + 2, p_115178_ + 13, 13, 2, 0, 0, 0, 255);
|
||||
this.m_115152_(bufferbuilder, p_115177_ + 2, p_115178_ + 13, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255);
|
||||
RenderSystem.m_69478_();
|
||||
@@ -377,5 +_,14 @@
|
||||
@@ -377,5 +_,9 @@
|
||||
|
||||
public void m_6213_(ResourceManager p_115105_) {
|
||||
this.f_115095_.m_109403_();
|
||||
@@ -84,10 +65,5 @@
|
||||
+
|
||||
+ public BlockEntityWithoutLevelRenderer getBlockEntityRenderer() {
|
||||
+ return f_174223_;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraftforge.resource.IResourceType getResourceType() {
|
||||
+ return net.minecraftforge.resource.VanillaResourceType.MODELS;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
--- a/net/minecraft/client/resources/language/LanguageManager.java
|
||||
+++ b/net/minecraft/client/resources/language/LanguageManager.java
|
||||
@@ -80,4 +_,9 @@
|
||||
public LanguageInfo m_118976_(String p_118977_) {
|
||||
return this.f_118966_.get(p_118977_);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraftforge.resource.IResourceType getResourceType() {
|
||||
+ return net.minecraftforge.resource.VanillaResourceType.LANGUAGES;
|
||||
+ }
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
--- a/net/minecraft/client/searchtree/SearchRegistry.java
|
||||
+++ b/net/minecraft/client/searchtree/SearchRegistry.java
|
||||
@@ -31,6 +_,11 @@
|
||||
return (MutableSearchTree<T>)this.f_119944_.get(p_119950_);
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public net.minecraftforge.resource.IResourceType getResourceType() {
|
||||
+ return net.minecraftforge.resource.VanillaResourceType.LANGUAGES;
|
||||
+ }
|
||||
+
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Key<T> {
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/data/advancements/AdvancementProvider.java
|
||||
+++ b/net/minecraft/data/advancements/AdvancementProvider.java
|
||||
@@ -22,11 +_,18 @@
|
||||
private static final Gson f_123961_ = (new GsonBuilder()).setPrettyPrinting().create();
|
||||
private final DataGenerator f_123962_;
|
||||
private final List<Consumer<Consumer<Advancement>>> f_123963_ = ImmutableList.of(new TheEndAdvancements(), new HusbandryAdvancements(), new AdventureAdvancements(), new NetherAdvancements(), new StoryAdvancements());
|
||||
+ protected net.minecraftforge.common.data.ExistingFileHelper fileHelper;
|
||||
|
||||
+ @Deprecated
|
||||
public AdvancementProvider(DataGenerator p_123966_) {
|
||||
this.f_123962_ = p_123966_;
|
||||
}
|
||||
|
||||
+ public AdvancementProvider(DataGenerator generatorIn, net.minecraftforge.common.data.ExistingFileHelper fileHelperIn) {
|
||||
+ this.f_123962_ = generatorIn;
|
||||
+ this.fileHelper = fileHelperIn;
|
||||
+ }
|
||||
+
|
||||
public void m_6865_(HashCache p_123969_) {
|
||||
Path path = this.f_123962_.m_123916_();
|
||||
Set<ResourceLocation> set = Sets.newHashSet();
|
||||
@@ -45,6 +_,16 @@
|
||||
}
|
||||
};
|
||||
|
||||
+ registerAdvancements(consumer, fileHelper);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Override this method for registering and generating custom {@link Advancement}s. <br>
|
||||
+ * Just use {@link Advancement.Builder} to build your Advancements, you don't need an extra consumer like the vanilla classes.
|
||||
+ * @param consumer used for the register function from {@link Advancement.Builder}
|
||||
+ * @param fileHelper used for the register function from {@link Advancement.Builder}
|
||||
+ */
|
||||
+ protected void registerAdvancements(Consumer<Advancement> consumer, net.minecraftforge.common.data.ExistingFileHelper fileHelper) {
|
||||
for(Consumer<Consumer<Advancement>> consumer1 : this.f_123963_) {
|
||||
consumer1.accept(consumer);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/data/tags/GameEventTagsProvider.java
|
||||
+++ b/net/minecraft/data/tags/GameEventTagsProvider.java
|
||||
@@ -8,8 +_,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
public class GameEventTagsProvider extends TagsProvider<GameEvent> {
|
||||
+ @Deprecated
|
||||
public GameEventTagsProvider(DataGenerator p_176826_) {
|
||||
super(p_176826_, Registry.f_175412_);
|
||||
+ }
|
||||
+ public GameEventTagsProvider(DataGenerator p_126517_, String modId, @javax.annotation.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) {
|
||||
+ super(p_126517_, Registry.f_175412_, modId, existingFileHelper);
|
||||
}
|
||||
|
||||
protected void m_6577_() {
|
||||
@@ -77,7 +77,7 @@
|
||||
- protected static class TagAppender<T> {
|
||||
+ public static class TagAppender<T> implements net.minecraftforge.common.extensions.IForgeTagAppender<T> {
|
||||
private final Tag.Builder f_126568_;
|
||||
private final Registry<T> f_126569_;
|
||||
public final Registry<T> f_126569_;
|
||||
private final String f_126570_;
|
||||
@@ -114,7 +_,7 @@
|
||||
return this;
|
||||
|
||||
+8
@@ -9,3 +9,11 @@
|
||||
private static final int f_178834_ = 1048576;
|
||||
public static final ResourceLocation f_132012_ = new ResourceLocation("brand");
|
||||
public static final ResourceLocation f_132013_ = new ResourceLocation("debug/path");
|
||||
@@ -52,6 +_,7 @@
|
||||
|
||||
public void m_5797_(ClientGamePacketListener p_132041_) {
|
||||
p_132041_.m_7413_(this);
|
||||
+ this.f_132030_.release(); // FORGE: Fix network buffer leaks (MC-121884)
|
||||
}
|
||||
|
||||
public ResourceLocation m_132042_() {
|
||||
@@ -9,14 +9,22 @@
|
||||
atomicreference.get().m_130011_();
|
||||
}, "Server thread");
|
||||
thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> {
|
||||
@@ -402,6 +_,7 @@
|
||||
@@ -365,6 +_,7 @@
|
||||
this.f_129732_ = new CommandStorage(dimensiondatastorage);
|
||||
WorldBorder worldborder = serverlevel.m_6857_();
|
||||
worldborder.m_61931_(serverleveldata.m_5813_());
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(f_129762_.get(Level.f_46428_)));
|
||||
if (!serverleveldata.m_6535_()) {
|
||||
try {
|
||||
m_177896_(serverlevel, serverleveldata, worldgensettings.m_64660_(), flag);
|
||||
@@ -401,6 +_,7 @@
|
||||
ServerLevel serverlevel1 = new ServerLevel(this, this.f_129738_, this.f_129744_, derivedleveldata, resourcekey1, dimensiontype1, p_129816_, chunkgenerator1, flag, j, ImmutableList.of(), false);
|
||||
worldborder.m_61929_(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.m_6857_()));
|
||||
this.f_129762_.put(resourcekey1, serverlevel1);
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(f_129762_.get(resourcekey)));
|
||||
}
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(f_129762_.get(resourcekey)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -411,6 +_,7 @@
|
||||
p_177898_.m_7250_(BlockPos.f_121853_.m_6630_(80), 0.0F);
|
||||
} else {
|
||||
@@ -167,7 +175,7 @@
|
||||
}
|
||||
|
||||
public static DataPackConfig m_129819_(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) {
|
||||
+ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(p_129820_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinder);
|
||||
+ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(p_129820_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinderNew);
|
||||
p_129820_.m_10506_();
|
||||
+ DataPackConfig.f_45842_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks());
|
||||
+ p_129821_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks());
|
||||
|
||||
@@ -8,11 +8,3 @@
|
||||
}
|
||||
|
||||
public ServerFunctionLibrary m_136157_() {
|
||||
@@ -94,6 +_,7 @@
|
||||
|
||||
public void m_136179_() {
|
||||
this.f_136148_.m_13480_().m_13431_();
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent.CustomTagTypes(f_136148_.m_13480_()));
|
||||
}
|
||||
|
||||
public void close() {
|
||||
@@ -1,7 +1,11 @@
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -173,6 +_,7 @@
|
||||
final Int2ObjectMap<EnderDragonPart> f_143247_ = new Int2ObjectOpenHashMap<>();
|
||||
@@ -170,9 +_,10 @@
|
||||
private final List<CustomSpawner> f_8558_;
|
||||
@Nullable
|
||||
private final EndDragonFight f_8559_;
|
||||
- final Int2ObjectMap<EnderDragonPart> f_143247_ = new Int2ObjectOpenHashMap<>();
|
||||
+ final Int2ObjectMap<net.minecraftforge.entity.PartEntity<?>> f_143247_ = new Int2ObjectOpenHashMap<>();
|
||||
private final StructureFeatureManager f_8560_;
|
||||
private final boolean f_8561_;
|
||||
+ private net.minecraftforge.common.util.WorldCapabilityData capabilityData;
|
||||
@@ -102,14 +106,14 @@
|
||||
}
|
||||
|
||||
+ public void removePlayer(ServerPlayer p_8850_, boolean keepData) {
|
||||
+ p_8850_.remove(keepData);
|
||||
+ p_8850_.m_146870_();
|
||||
+ this.removeEntity(p_8850_, keepData);
|
||||
+ }
|
||||
+
|
||||
+ public void removeEntityComplete(Entity p_8865_, boolean keepData) {
|
||||
+ if(p_8865_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> parts : p_8865_.getParts()) {
|
||||
+ parts.remove(keepData);
|
||||
+ parts.m_146870_();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -125,7 +129,7 @@
|
||||
+ }
|
||||
+
|
||||
+ p_8865_.onRemovedFromWorld();
|
||||
+ p_8865_.remove(keepData);
|
||||
+ p_8865_.m_146870_();
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_8865_, this));
|
||||
+ }
|
||||
+
|
||||
@@ -146,30 +150,30 @@
|
||||
Entity entity = this.m_142646_().m_142694_(p_8854_.m_142081_());
|
||||
if (entity != null) {
|
||||
f_8566_.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.m_142081_().toString());
|
||||
@@ -747,6 +_,7 @@
|
||||
@@ -746,7 +_,8 @@
|
||||
this.m_143261_((ServerPlayer)entity, Entity.RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
this.f_143244_.m_157533_(p_8854_);
|
||||
- this.f_143244_.m_157533_(p_8854_);
|
||||
+ this.f_143244_.addNewEntityWithoutEvent(p_8854_);
|
||||
+ p_8854_.onAddedToWorld();
|
||||
}
|
||||
|
||||
private boolean m_8872_(Entity p_8873_) {
|
||||
@@ -754,6 +_,7 @@
|
||||
@@ -754,7 +_,12 @@
|
||||
f_8566_.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.m_20613_(p_8873_.m_6095_()));
|
||||
return false;
|
||||
} else {
|
||||
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_8873_, this))) return false;
|
||||
return this.f_143244_.m_157533_(p_8873_);
|
||||
- return this.f_143244_.m_157533_(p_8873_);
|
||||
+ if (this.f_143244_.m_157533_(p_8873_)) {
|
||||
+ p_8873_.onAddedToWorld();
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
@@ -762,6 +_,7 @@
|
||||
if (p_8861_.m_142428_().map(Entity::m_142081_).anyMatch(this.f_143244_::m_157550_)) {
|
||||
return false;
|
||||
} else {
|
||||
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_8861_, this))) return false;
|
||||
this.m_47205_(p_8861_);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -790,10 +_,20 @@
|
||||
}
|
||||
|
||||
@@ -199,16 +203,38 @@
|
||||
explosion.m_46061_();
|
||||
explosion.m_46075_(false);
|
||||
if (p_8661_ == Explosion.BlockInteraction.NONE) {
|
||||
@@ -1355,6 +_,12 @@
|
||||
BlockPos.m_121976_(i - 2, j, k - 2, i + 2, j, k + 2).forEach((p_143260_) -> {
|
||||
p_8618_.m_46597_(p_143260_, Blocks.f_50080_.m_49966_());
|
||||
@@ -1357,6 +_,12 @@
|
||||
});
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ protected void initCapabilities() {
|
||||
+ this.gatherCapabilities();
|
||||
+ capabilityData = this.m_8895_().m_164861_(e -> net.minecraftforge.common.util.WorldCapabilityData.load(e, getCapabilities()), () -> new net.minecraftforge.common.util.WorldCapabilityData(getCapabilities()), net.minecraftforge.common.util.WorldCapabilityData.ID);
|
||||
+ capabilityData.setCapabilities(getCapabilities());
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
public LevelEntityGetter<Entity> m_142646_() {
|
||||
return this.f_143244_.m_157567_();
|
||||
}
|
||||
@@ -1422,8 +_,8 @@
|
||||
ServerLevel.this.f_143246_.add((Mob)p_143371_);
|
||||
}
|
||||
|
||||
- if (p_143371_ instanceof EnderDragon) {
|
||||
- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_143371_).m_31156_()) {
|
||||
+ if (p_143371_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> enderdragonpart : p_143371_.getParts()) {
|
||||
ServerLevel.this.f_143247_.put(enderdragonpart.m_142049_(), enderdragonpart);
|
||||
}
|
||||
}
|
||||
@@ -1442,8 +_,8 @@
|
||||
ServerLevel.this.f_143246_.remove(p_143375_);
|
||||
}
|
||||
|
||||
- if (p_143375_ instanceof EnderDragon) {
|
||||
- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_143375_).m_31156_()) {
|
||||
+ if (p_143375_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> enderdragonpart : p_143375_.getParts()) {
|
||||
ServerLevel.this.f_143247_.remove(enderdragonpart.m_142049_());
|
||||
}
|
||||
}
|
||||
@@ -150,6 +150,14 @@
|
||||
}
|
||||
|
||||
public boolean m_143432_() {
|
||||
@@ -1265,6 +_,7 @@
|
||||
public void m_9213_(Entity p_9214_) {
|
||||
Entity entity = this.m_8954_();
|
||||
this.f_8926_ = (Entity)(p_9214_ == null ? this : p_9214_);
|
||||
+ while (this.f_8926_ instanceof net.minecraftforge.entity.PartEntity<?> partEntity) this.f_8926_ = partEntity.getParent(); // FORGE: fix MC-46486
|
||||
if (entity != this.f_8926_) {
|
||||
this.f_8906_.m_141995_(new ClientboundSetCameraPacket(this.f_8926_));
|
||||
this.m_6021_(this.f_8926_.m_20185_(), this.f_8926_.m_20186_(), this.f_8926_.m_20189_());
|
||||
@@ -1294,7 +_,11 @@
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@
|
||||
private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) {
|
||||
ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_).m_41777_();
|
||||
InteractionResult interactionresult = p_143680_.m_143694_(ServerGamePacketListenerImpl.this.f_9743_, entity, p_143679_);
|
||||
+ // TODO: if (net.minecraftforge.common.ForgeHooks.onInteractEntityAt(player, entity, entity.position(), p_143679_) != null) return;
|
||||
+ if (net.minecraftforge.common.ForgeHooks.onInteractEntityAt(f_9743_, entity, entity.m_20182_(), p_143679_) != null) return;
|
||||
if (interactionresult.m_19077_()) {
|
||||
CriteriaTriggers.f_10565_.m_61494_(ServerGamePacketListenerImpl.this.f_9743_, itemstack, entity);
|
||||
if (interactionresult.m_19080_()) {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
--- a/net/minecraft/server/packs/AbstractPackResources.java
|
||||
+++ b/net/minecraft/server/packs/AbstractPackResources.java
|
||||
@@ -120,4 +_,10 @@
|
||||
public String m_8017_() {
|
||||
return this.f_10203_.getName();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString()
|
||||
+ {
|
||||
+ return String.format("%s: %s", getClass().getName(), f_10203_.getPath());
|
||||
+ }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/packs/repository/PackRepository.java
|
||||
+++ b/net/minecraft/server/packs/repository/PackRepository.java
|
||||
@@ -24,12 +_,12 @@
|
||||
@@ -24,13 +_,14 @@
|
||||
|
||||
public PackRepository(Pack.PackConstructor p_10502_, RepositorySource... p_10503_) {
|
||||
this.f_10500_ = p_10502_;
|
||||
@@ -14,8 +14,10 @@
|
||||
+ this((p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143899_, p_143900_, hidden) -> {
|
||||
+ return new Pack(p_143894_, p_143895_, p_143896_, p_143897_, p_143898_, p_143890_, p_143899_, p_143900_, hidden);
|
||||
}, p_143891_);
|
||||
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(p_143890_, f_10497_::add));
|
||||
}
|
||||
|
||||
public void m_10506_() {
|
||||
@@ -91,6 +_,10 @@
|
||||
@Nullable
|
||||
public Pack m_10507_(String p_10508_) {
|
||||
|
||||
+3
-13
@@ -1,22 +1,12 @@
|
||||
--- a/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java
|
||||
+++ b/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java
|
||||
@@ -5,6 +_,11 @@
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
|
||||
+/**
|
||||
+ * @deprecated Forge: {@link net.minecraftforge.resource.ISelectiveResourceReloadListener}, which selectively allows
|
||||
+ * individual resource types being reloaded should rather be used where possible.
|
||||
+ */
|
||||
+@Deprecated
|
||||
public interface ResourceManagerReloadListener extends PreparableReloadListener {
|
||||
default CompletableFuture<Void> m_5540_(PreparableReloadListener.PreparationBarrier p_10752_, ResourceManager p_10753_, ProfilerFiller p_10754_, ProfilerFiller p_10755_, Executor p_10756_, Executor p_10757_) {
|
||||
return p_10752_.m_6769_(Unit.INSTANCE).thenRunAsync(() -> {
|
||||
@@ -17,4 +_,9 @@
|
||||
@@ -17,4 +_,11 @@
|
||||
}
|
||||
|
||||
void m_6213_(ResourceManager p_10758_);
|
||||
+
|
||||
+ /** @deprecated Selective reloading is no longer supported due to vanilla now reloading resources in parallel, so this is no longer needed */
|
||||
+ @Deprecated(since="1.17.1", forRemoval = true)
|
||||
+ @javax.annotation.Nullable
|
||||
+ default net.minecraftforge.resource.IResourceType getResourceType() {
|
||||
+ return null;
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
GameRules gamerules = serverlevel1.m_46469_();
|
||||
boolean flag = gamerules.m_46207_(GameRules.f_46156_);
|
||||
boolean flag1 = gamerules.m_46207_(GameRules.f_46145_);
|
||||
@@ -160,6 +_,7 @@
|
||||
@@ -158,6 +_,7 @@
|
||||
servergamepacketlistenerimpl.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_()));
|
||||
servergamepacketlistenerimpl.m_141995_(new ClientboundPlayerAbilitiesPacket(p_11263_.m_150110_()));
|
||||
servergamepacketlistenerimpl.m_141995_(new ClientboundSetCarriedItemPacket(p_11263_.m_150109_().f_35977_));
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, p_11263_));
|
||||
servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_()));
|
||||
servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateTagsPacket(this.f_11195_.m_129895_().m_144442_(this.f_11206_)));
|
||||
+ net.minecraftforge.fmllegacy.network.NetworkHooks.syncCustomTagTypes(p_11263_, this.f_11195_.m_129895_());
|
||||
this.m_11289_(p_11263_);
|
||||
p_11263_.m_8951_().m_12850_();
|
||||
p_11263_.m_8952_().m_12789_(p_11263_);
|
||||
@@ -174,7 +_,7 @@
|
||||
|
||||
this.m_11264_(mutablecomponent.m_130940_(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.f_137441_);
|
||||
@@ -65,34 +65,6 @@
|
||||
ServerLevel serverlevel = p_11287_.m_9236_();
|
||||
p_11287_.m_36220_(Stats.f_12989_);
|
||||
this.m_6765_(p_11287_);
|
||||
@@ -328,7 +_,7 @@
|
||||
p_11287_.m_19877_();
|
||||
serverlevel.m_143261_(p_11287_, Entity.RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
p_11287_.m_8960_().m_135978_();
|
||||
- this.f_11196_.remove(p_11287_);
|
||||
+ this.removePlayer(p_11287_);
|
||||
this.f_11195_.m_129901_().m_136305_(p_11287_);
|
||||
UUID uuid = p_11287_.m_142081_();
|
||||
ServerPlayer serverplayer = this.f_11197_.get(uuid);
|
||||
@@ -390,8 +_,8 @@
|
||||
}
|
||||
|
||||
public ServerPlayer m_11236_(ServerPlayer p_11237_, boolean p_11238_) {
|
||||
- this.f_11196_.remove(p_11237_);
|
||||
- p_11237_.m_9236_().m_143261_(p_11237_, Entity.RemovalReason.DISCARDED);
|
||||
+ this.removePlayer(p_11237_);
|
||||
+ p_11237_.m_9236_().removePlayer(p_11237_, true); // Forge: keep data until copyFrom called
|
||||
BlockPos blockpos = p_11237_.m_8961_();
|
||||
float f = p_11237_.m_8962_();
|
||||
boolean flag = p_11237_.m_8964_();
|
||||
@@ -407,6 +_,7 @@
|
||||
ServerPlayer serverplayer = new ServerPlayer(this.f_11195_, serverlevel1, p_11237_.m_36316_());
|
||||
serverplayer.f_8906_ = p_11237_.f_8906_;
|
||||
serverplayer.m_9015_(p_11237_, p_11238_);
|
||||
+ p_11237_.remove(false); // Forge: clone event had a chance to see old data, now discard it
|
||||
serverplayer.m_20234_(p_11237_.m_142049_());
|
||||
serverplayer.m_36163_(p_11237_.m_5737_());
|
||||
|
||||
@@ -447,10 +_,11 @@
|
||||
this.m_11229_(serverplayer, serverlevel1);
|
||||
this.m_11289_(serverplayer);
|
||||
@@ -106,6 +78,22 @@
|
||||
if (flag2) {
|
||||
serverplayer.f_8906_.m_141995_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)blockpos.m_123341_(), (double)blockpos.m_123342_(), (double)blockpos.m_123343_(), 1.0F, 1.0F));
|
||||
}
|
||||
@@ -535,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void m_5749_(GameProfile p_11254_) {
|
||||
+ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_11254_, this.f_11195_.m_7022_(), this)) return;
|
||||
this.f_11200_.m_11381_(new ServerOpListEntry(p_11254_, this.f_11195_.m_7022_(), this.f_11200_.m_11351_(p_11254_)));
|
||||
ServerPlayer serverplayer = this.m_11259_(p_11254_.getId());
|
||||
if (serverplayer != null) {
|
||||
@@ -544,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void m_5750_(GameProfile p_11281_) {
|
||||
+ if (net.minecraftforge.event.ForgeEventFactory.onPermissionChanged(p_11281_, 0, this)) return;
|
||||
this.f_11200_.m_11393_(p_11281_);
|
||||
ServerPlayer serverplayer = this.m_11259_(p_11281_.getId());
|
||||
if (serverplayer != null) {
|
||||
@@ -726,13 +_,6 @@
|
||||
if (serverstatscounter == null) {
|
||||
File file1 = this.f_11195_.m_129843_(LevelResource.f_78175_).toFile();
|
||||
@@ -138,14 +126,14 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -786,6 +_,7 @@
|
||||
@@ -785,6 +_,7 @@
|
||||
playeradvancements.m_135981_(this.f_11195_.m_129889_());
|
||||
}
|
||||
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, null));
|
||||
this.m_11268_(new ClientboundUpdateTagsPacket(this.f_11195_.m_129895_().m_144442_(this.f_11206_)));
|
||||
+ net.minecraftforge.fmllegacy.network.NetworkHooks.syncCustomTagTypes(this.f_11195_.m_129895_());
|
||||
ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_());
|
||||
|
||||
for(ServerPlayer serverplayer : this.f_11196_) {
|
||||
@@ -797,5 +_,13 @@
|
||||
|
||||
public boolean m_11316_() {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--- a/net/minecraft/tags/GameEventTags.java
|
||||
+++ b/net/minecraft/tags/GameEventTags.java
|
||||
@@ -12,6 +_,14 @@
|
||||
return f_144301_.m_13244_(p_144308_);
|
||||
}
|
||||
|
||||
+ public static net.minecraftforge.common.Tags.IOptionalNamedTag<GameEvent> createOptional(net.minecraft.resources.ResourceLocation name) {
|
||||
+ return createOptional(name, null);
|
||||
+ }
|
||||
+
|
||||
+ public static net.minecraftforge.common.Tags.IOptionalNamedTag<GameEvent> createOptional(net.minecraft.resources.ResourceLocation name, @javax.annotation.Nullable java.util.Set<java.util.function.Supplier<GameEvent>> defaults) {
|
||||
+ return f_144301_.createOptional(name, defaults);
|
||||
+ }
|
||||
+
|
||||
public static TagCollection<GameEvent> m_144306_() {
|
||||
return f_144301_.m_13246_();
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
private final String f_144327_;
|
||||
private TagCollection<T> f_13227_ = TagCollection.m_13410_();
|
||||
private final List<StaticTagHelper.Wrapper<T>> f_13228_ = Lists.newArrayList();
|
||||
+ private static java.util.Map<ResourceLocation, List<StaticTagHelper.Wrapper<?>>> toAdd = com.google.common.collect.Maps.newHashMap();
|
||||
+ @Nullable private static java.util.Map<ResourceLocation, List<StaticTagHelper.Wrapper<?>>> toAdd = com.google.common.collect.Maps.newHashMap();
|
||||
|
||||
public StaticTagHelper(ResourceKey<? extends Registry<T>> p_144329_, String p_144330_) {
|
||||
this.f_144326_ = p_144329_;
|
||||
@@ -24,9 +_,46 @@
|
||||
@@ -24,9 +_,60 @@
|
||||
}
|
||||
|
||||
public Tag.Named<T> m_13244_(String p_13245_) {
|
||||
@@ -55,13 +55,8 @@
|
||||
+ namedtag.m_13260_(f_13227_::m_13404_);
|
||||
+ this.f_13228_.add(namedtag);
|
||||
+ return namedtag;
|
||||
}
|
||||
|
||||
public void m_13232_() {
|
||||
@@ -47,13 +_,31 @@
|
||||
});
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public TagCollection<T> reinjectOptionalTags(TagCollection<T> tagCollection) {
|
||||
+ java.util.Map<ResourceLocation, Tag<T>> currentTags = tagCollection.m_5643_();
|
||||
+ java.util.Map<ResourceLocation, Tag<T>> missingOptionals = this.f_13228_.stream().filter(e -> e instanceof OptionalNamedTag && !currentTags.containsKey(e.m_6979_())).collect(Collectors.toMap(Wrapper::m_6979_, namedTag -> {
|
||||
@@ -74,16 +69,11 @@
|
||||
+ return TagCollection.m_13396_(missingOptionals);
|
||||
+ }
|
||||
+ return tagCollection;
|
||||
+ }
|
||||
+
|
||||
public TagCollection<T> m_13246_() {
|
||||
return this.f_13227_;
|
||||
}
|
||||
|
||||
+ public List<? extends Tag.Named<T>> getWrappers() {
|
||||
+ return this.f_13228_;
|
||||
+ }
|
||||
+
|
||||
public void m_13232_() {
|
||||
@@ -53,7 +_,7 @@
|
||||
|
||||
public Set<ResourceLocation> m_13247_(TagContainer p_13248_) {
|
||||
TagCollection<T> tagcollection = p_13248_.m_144452_(this.f_144326_);
|
||||
- Set<ResourceLocation> set = this.f_13228_.stream().map(StaticTagHelper.Wrapper::m_6979_).collect(Collectors.toSet());
|
||||
@@ -108,7 +98,7 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "NamedTag[" + m_6979_().toString() + ']';
|
||||
+ return "NamedTag[" + m_6979_() + ']';
|
||||
+ }
|
||||
+ @Override public boolean equals(Object o) { return (o == this) || (o instanceof Tag.Named && java.util.Objects.equals(this.m_6979_(), ((Tag.Named<T>)o).m_6979_())); }
|
||||
+ @Override public int hashCode() { return m_6979_().hashCode(); }
|
||||
@@ -138,7 +128,7 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "OptionalNamedTag[" + m_6979_().toString() + ']';
|
||||
+ return "OptionalNamedTag[" + m_6979_() + ']';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,42 +21,20 @@
|
||||
return statictaghelper;
|
||||
}
|
||||
}
|
||||
@@ -55,11 +_,29 @@
|
||||
|
||||
private static void m_144356_() {
|
||||
Set<ResourceKey<?>> set = m_144355_().stream().map(StaticTagHelper::m_144338_).collect(Collectors.toSet());
|
||||
- if (!Sets.difference(f_144340_, set).isEmpty()) {
|
||||
+ if (!Sets.difference(set, f_144340_).isEmpty()) { // Forge: Fix bug with extra tag collections crashing
|
||||
throw new IllegalStateException("Missing helper registrations");
|
||||
}
|
||||
@@ -54,10 +_,16 @@
|
||||
}
|
||||
|
||||
private static void m_144356_() {
|
||||
+ if (true) { m_144355_(); return; } //FORGE this check is unnecessary as the 2 collections are patched back into a map above. Still need to 'clinit' them though.
|
||||
Set<ResourceKey<?>> set = m_144355_().stream().map(StaticTagHelper::m_144338_).collect(Collectors.toSet());
|
||||
if (!Sets.difference(f_144340_, set).isEmpty()) {
|
||||
throw new IllegalStateException("Missing helper registrations");
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ @javax.annotation.Nullable
|
||||
+ public static StaticTagHelper<?> get(ResourceLocation rl) {
|
||||
+ return HELPER_MAP.get(ResourceKey.m_135788_(rl));
|
||||
+ }
|
||||
+
|
||||
+ public static Multimap<ResourceKey<? extends Registry<?>>, ResourceLocation> validateVanillaTags(TagContainer tagCollectionSupplier) {
|
||||
+ Multimap<ResourceKey<? extends Registry<?>>, ResourceLocation> multimap = HashMultimap.create();
|
||||
+ f_13264_.forEach((tagHelper) -> {
|
||||
+ if (!net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeNames().contains(tagHelper.m_144338_().m_135782_()))
|
||||
+ multimap.putAll(tagHelper.m_144338_(), tagHelper.m_13247_(tagCollectionSupplier));
|
||||
+ });
|
||||
+ return multimap;
|
||||
+ }
|
||||
+
|
||||
+ public static void fetchCustomTagTypes(TagContainer tagCollectionSupplier) {
|
||||
+ net.minecraftforge.common.ForgeTagHandler.getCustomTagTypeNames().forEach(tagRegistry -> HELPER_MAP.get(ResourceKey.m_135788_(tagRegistry)).m_13242_(tagCollectionSupplier));
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
public static void m_144349_(Consumer<StaticTagHelper<?>> p_144350_) {
|
||||
f_13264_.forEach(p_144350_);
|
||||
}
|
||||
@@ -70,6 +_,7 @@
|
||||
f_13264_.forEach((p_144344_) -> {
|
||||
p_144344_.m_144336_(tagcontainer$builder);
|
||||
});
|
||||
+ net.minecraftforge.common.ForgeTagHandler.populateTagCollectionManager();
|
||||
return tagcontainer$builder.m_144485_();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,18 @@
|
||||
--- a/net/minecraft/tags/Tag.java
|
||||
+++ b/net/minecraft/tags/Tag.java
|
||||
@@ -49,6 +_,7 @@
|
||||
@@ -47,8 +_,16 @@
|
||||
return SetTag.m_13222_(p_13301_);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
- public static class Builder {
|
||||
+ public static class Builder implements net.minecraftforge.common.extensions.IForgeRawTagBuilder {
|
||||
+ private final List<Tag.BuilderEntry> removeEntries = Lists.newArrayList(); // FORGE: internal field for tracking "remove" entries
|
||||
+ /** FORGE: Gets a view of this builder's "remove" entries (only used during datagen) **/
|
||||
+ public Stream<Tag.BuilderEntry> getRemoveEntries() { return this.removeEntries.stream(); }
|
||||
+ public Tag.Builder remove(final Tag.BuilderEntry proxy) { // internal forge method for adding remove entries
|
||||
+ this.removeEntries.add(proxy);
|
||||
+ return this;
|
||||
+ }
|
||||
private final List<Tag.BuilderEntry> f_13302_ = Lists.newArrayList();
|
||||
+ private boolean replace = false;
|
||||
|
||||
@@ -32,15 +42,17 @@
|
||||
list.forEach((p_13319_) -> {
|
||||
this.f_13302_.add(new Tag.BuilderEntry(p_13319_, p_13314_));
|
||||
});
|
||||
@@ -155,7 +_,7 @@
|
||||
@@ -155,8 +_,9 @@
|
||||
tag$builderentry.m_13347_().m_6383_(jsonarray);
|
||||
}
|
||||
|
||||
- jsonobject.addProperty("replace", false);
|
||||
+ jsonobject.addProperty("replace", replace);
|
||||
jsonobject.add("values", jsonarray);
|
||||
+ this.serializeTagAdditions(jsonobject);
|
||||
return jsonobject;
|
||||
}
|
||||
}
|
||||
@@ -211,6 +_,7 @@
|
||||
public String toString() {
|
||||
return this.f_13349_.toString();
|
||||
|
||||
@@ -1,33 +1,18 @@
|
||||
--- a/net/minecraft/tags/TagContainer.java
|
||||
+++ b/net/minecraft/tags/TagContainer.java
|
||||
@@ -15,7 +_,7 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
-public class TagContainer {
|
||||
+public class TagContainer implements net.minecraftforge.common.extensions.IForgeTagContainer {
|
||||
static final Logger f_144432_ = LogManager.getLogger();
|
||||
public static final TagContainer f_13420_ = new TagContainer(ImmutableMap.of());
|
||||
public final Map<ResourceKey<? extends Registry<?>>, TagCollection<?>> f_144433_;
|
||||
@@ -74,6 +_,7 @@
|
||||
public void m_13431_() {
|
||||
StaticTags.m_13269_(this);
|
||||
Blocks.m_50758_();
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent.VanillaTagTypes(this));
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this));
|
||||
}
|
||||
|
||||
public Map<ResourceKey<? extends Registry<?>>, TagCollection.NetworkPayload> m_144442_(final RegistryAccess p_144443_) {
|
||||
@@ -108,6 +_,13 @@
|
||||
f_144432_.error("Unknown registry {}", (Object)p_144447_);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public static TagContainer reinjectOptionalTags(TagContainer tagCollectionSupplier) {
|
||||
+ TagContainer.Builder builder = new TagContainer.Builder();
|
||||
+ //noinspection unchecked,rawtypes
|
||||
+ StaticTags.m_144349_(h -> builder.m_144486_(h.m_144338_(), h.reinjectOptionalTags(tagCollectionSupplier.m_144452_((ResourceKey) h.m_144338_()))));
|
||||
+ return builder.m_144485_();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@@ -81,6 +_,7 @@
|
||||
this.m_144436_(new TagContainer.CollectionConsumer() {
|
||||
public <T> void m_142574_(ResourceKey<? extends Registry<T>> p_144481_, TagCollection<T> p_144482_) {
|
||||
Optional<? extends Registry<T>> optional = p_144443_.m_6632_(p_144481_);
|
||||
+ optional = net.minecraftforge.common.ForgeTagHandler.getWrapperRegistry(p_144481_, optional);
|
||||
if (optional.isPresent()) {
|
||||
map.put(p_144481_, p_144482_.m_144411_(optional.get()));
|
||||
} else {
|
||||
Loaded 100 of 947 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user