mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa170facb7 | ||
|
|
9919e5c1d5 | ||
|
|
84a8997263 | ||
|
|
f7c4320b7f | ||
|
|
84b1a40fe2 | ||
|
|
03b75632d8 | ||
|
|
2c3cb2025e | ||
|
|
0ca10b5569 | ||
|
|
1087e265aa | ||
|
|
d3ca95aee2 | ||
|
|
c5f3f34c5a | ||
|
|
9ef5d545f8 | ||
|
|
1b0ffa2633 | ||
|
|
763523d1c0 | ||
|
|
24d3705e19 | ||
|
|
40bce4b498 | ||
|
|
845c5958e0 | ||
|
|
6faa5667d6 | ||
|
|
8ab5cbca26 | ||
|
|
6ff02a6ba9 | ||
|
|
4db9bc68d9 | ||
|
|
84d354a7dd | ||
|
|
4df024ef43 | ||
|
|
49c927a505 | ||
|
|
73a937e088 | ||
|
|
65e8de880d | ||
|
|
1dacb882e0 | ||
|
|
22a51250b8 | ||
|
|
d264674a85 | ||
|
|
af9b4c1fe5 | ||
|
|
5a6baccee5 | ||
|
|
6443adcb6f | ||
|
|
fc649f4e06 | ||
|
|
2886f3ca34 | ||
|
|
1af16d70cc | ||
|
|
87abbdb8ef | ||
|
|
1b25285462 | ||
|
|
0f4e3146e0 | ||
|
|
b46f7c0d85 | ||
|
|
28d71761cd | ||
|
|
dbf1c8f10f | ||
|
|
f7dd6396e4 | ||
|
|
1a46f205d6 | ||
|
|
be0facc2aa | ||
|
|
67d4a0163b | ||
|
|
0cc85bc314 | ||
|
|
270e778ac5 | ||
|
|
9528fd8bcc | ||
|
|
5a75314bb3 | ||
|
|
cceb8db74e | ||
|
|
8e7b08b96d | ||
|
|
194f11069f | ||
|
|
5ef0d667e0 | ||
|
|
8a1c1d7e53 | ||
|
|
1353c1d9fa | ||
|
|
70a8663605 | ||
|
|
f179eed971 | ||
|
|
d4c8708229 | ||
|
|
4008057803 | ||
|
|
997d8e0aa2 | ||
|
|
15bd5f0d30 | ||
|
|
ccaa20b006 | ||
|
|
c48698f680 | ||
|
|
4285c931e7 | ||
|
|
03c43cf3da | ||
|
|
8d14797416 | ||
|
|
e4837f65a3 | ||
|
|
ee46af66e5 | ||
|
|
2bec354317 | ||
|
|
727c7780b3 | ||
|
|
5410f9b532 | ||
|
|
4c09d8d774 | ||
|
|
aded6fb847 | ||
|
|
c2ad951336 | ||
|
|
7fb5dfa3e6 | ||
|
|
0f8c2fa454 | ||
|
|
dfc2aa9c6a | ||
|
|
8865092bb2 | ||
|
|
abc3353375 | ||
|
|
e7a8da4d0b | ||
|
|
f938051373 | ||
|
|
9db0d72232 | ||
|
|
9e6e789b73 | ||
|
|
bc0d7179cc | ||
|
|
aafa34439a | ||
|
|
168a3bc6fc | ||
|
|
2fb8b2eb18 | ||
|
|
da82705e86 | ||
|
|
a237a39d52 | ||
|
|
c042dc5542 | ||
|
|
1493d06b5a | ||
|
|
9a11201a9e | ||
|
|
c34094ea50 | ||
|
|
c531b2b5c7 |
No files matched your search
Vendored
+73
-1
@@ -1,5 +1,7 @@
|
|||||||
import jetbrains.buildServer.configs.kotlin.v2019_2.*
|
import jetbrains.buildServer.configs.kotlin.v2019_2.*
|
||||||
import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues
|
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
|
The settings script is an entry point for defining a TeamCity
|
||||||
@@ -30,11 +32,13 @@ project {
|
|||||||
buildType(Build)
|
buildType(Build)
|
||||||
buildType(BuildSecondaryBranches)
|
buildType(BuildSecondaryBranches)
|
||||||
buildType(PullRequests)
|
buildType(PullRequests)
|
||||||
|
buildType(PullRequestChecks)
|
||||||
|
buildType(PullRequestCompatibility)
|
||||||
|
|
||||||
params {
|
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_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.4", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
text("docker_gradle_version", "7.4", 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.18.x", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
text("git_main_branch", "1.19.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", """
|
text("git_branch_spec", """
|
||||||
+:refs/heads/(main*)
|
+:refs/heads/(main*)
|
||||||
+:refs/heads/(master*)
|
+:refs/heads/(master*)
|
||||||
@@ -134,3 +138,71 @@ object PullRequests : BuildType({
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
})
|
||||||
+104
-26
@@ -5,11 +5,17 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:[5.1.26,)'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:[5.1.39,)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
import groovy.json.JsonBuilder
|
import groovy.json.JsonBuilder
|
||||||
|
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.nio.file.Files
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -17,6 +23,7 @@ import java.util.LinkedHashMap
|
|||||||
import net.minecraftforge.forge.tasks.*
|
import net.minecraftforge.forge.tasks.*
|
||||||
import static net.minecraftforge.forge.tasks.Util.*
|
import static net.minecraftforge.forge.tasks.Util.*
|
||||||
import net.minecraftforge.gradle.common.tasks.ApplyBinPatches
|
import net.minecraftforge.gradle.common.tasks.ApplyBinPatches
|
||||||
|
import net.minecraftforge.gradle.common.tasks.CheckJarCompatibility
|
||||||
import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact
|
import net.minecraftforge.gradle.common.tasks.DownloadMavenArtifact
|
||||||
import net.minecraftforge.gradle.common.tasks.ExtractInheritance
|
import net.minecraftforge.gradle.common.tasks.ExtractInheritance
|
||||||
import net.minecraftforge.gradle.common.tasks.SignJar
|
import net.minecraftforge.gradle.common.tasks.SignJar
|
||||||
@@ -29,7 +36,7 @@ plugins {
|
|||||||
id 'com.github.ben-manes.versions' version '0.36.0'
|
id 'com.github.ben-manes.versions' version '0.36.0'
|
||||||
id 'net.minecraftforge.gradleutils' version '2.+'
|
id 'net.minecraftforge.gradleutils' version '2.+'
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'de.undercouch.download' version '4.1.2'
|
id 'de.undercouch.download' version '5.1.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.init() //Init all our extension methods!
|
Util.init() //Init all our extension methods!
|
||||||
@@ -47,7 +54,7 @@ ext {
|
|||||||
MAPPING_VERSION = '1.18.2'
|
MAPPING_VERSION = '1.18.2'
|
||||||
MC_VERSION = '1.18.2'
|
MC_VERSION = '1.18.2'
|
||||||
MCP_VERSION = '20220404.173914'
|
MCP_VERSION = '20220404.173914'
|
||||||
SPI_VERSION = '4.0.10'
|
SPI_VERSION = '4.0.15-4.x'
|
||||||
ACCESSTRANSFORMERS_VERSION = '8.0.4'
|
ACCESSTRANSFORMERS_VERSION = '8.0.4'
|
||||||
COREMODS_VERSION = '5.0.1'
|
COREMODS_VERSION = '5.0.1'
|
||||||
EVENTBUS_VERSION = '5.0.3'
|
EVENTBUS_VERSION = '5.0.3'
|
||||||
@@ -57,6 +64,7 @@ ext {
|
|||||||
ASM_VERSION = '9.2'
|
ASM_VERSION = '9.2'
|
||||||
INSTALLER_VERSION = '2.1.+'
|
INSTALLER_VERSION = '2.1.+'
|
||||||
MIXIN_VERSION = '0.8.5'
|
MIXIN_VERSION = '0.8.5'
|
||||||
|
JARJAR_VERSION = '0.3.0'
|
||||||
|
|
||||||
GIT_INFO = gradleutils.gitInfo
|
GIT_INFO = gradleutils.gitInfo
|
||||||
VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION)
|
VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION)
|
||||||
@@ -65,10 +73,11 @@ ext {
|
|||||||
|
|
||||||
SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0'
|
SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0'
|
||||||
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar'
|
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar'
|
||||||
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.2.10'
|
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.3.0'
|
||||||
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
|
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
|
||||||
FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all'
|
FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all'
|
||||||
MIN_TAG_FOR_CHANGELOG = "39.0"
|
MIN_TAG_FOR_CHANGELOG = "39.0"
|
||||||
|
LAST_RB = GIT_INFO.tag.rsplit('.', 1)[1] as int >= 1 ? GIT_INFO.tag + '.0' : null
|
||||||
}
|
}
|
||||||
|
|
||||||
println('Version: ' + VERSION +
|
println('Version: ' + VERSION +
|
||||||
@@ -272,6 +281,7 @@ def sharedDeps = {
|
|||||||
installer 'org.jline:jline-terminal:3.12.+' //Dep of TerminaalConsoleeAppender
|
installer 'org.jline:jline-terminal:3.12.+' //Dep of TerminaalConsoleeAppender
|
||||||
installer "org.spongepowered:mixin:${MIXIN_VERSION}"
|
installer "org.spongepowered:mixin:${MIXIN_VERSION}"
|
||||||
installer 'org.openjdk.nashorn:nashorn-core:15.3'
|
installer 'org.openjdk.nashorn:nashorn-core:15.3'
|
||||||
|
installer "net.minecraftforge:JarJar:${JARJAR_VERSION}"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
installer 'org.lwjgl:lwjgl:3.2.2'
|
installer 'org.lwjgl:lwjgl:3.2.2'
|
||||||
@@ -418,6 +428,8 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
run.args '--fml.forgeGroup', prj.group
|
run.args '--fml.forgeGroup', prj.group
|
||||||
run.args '--fml.mcpVersion', MCP_VERSION
|
run.args '--fml.mcpVersion', MCP_VERSION
|
||||||
|
|
||||||
|
run.jvmArgs '-Djava.net.preferIPv6Addresses=system'
|
||||||
|
|
||||||
if (run.name.contains('client')) {
|
if (run.name.contains('client')) {
|
||||||
run.client true
|
run.client true
|
||||||
} else {
|
} else {
|
||||||
@@ -425,7 +437,7 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SecureJarHandler bootstrap values.
|
// SecureJarHandler bootstrap values.
|
||||||
run.property 'ignoreList', prj.configurations.moduleonly.files.collect {it.name.replaceAll(/([-_]([.\d]*\d+)|\.jar$)/, '') }.join(',') + ",client-extra,fmlcore,javafmllanguage,mclanguage,${prj.name}-"
|
run.property 'ignoreList', prj.configurations.moduleonly.files.collect {it.name.replaceAll(/([-_]([.\d]*\d+)|\.jar$)/, '') }.join(',') + ",client-extra,fmlcore,javafmllanguage,lowcodelanguage,mclanguage,${prj.name}-"
|
||||||
// FIXME: Without this jna doesn't work at runtime. Someone figure out why please?
|
// FIXME: Without this jna doesn't work at runtime. Someone figure out why please?
|
||||||
run.property 'mergeModules', 'jna-5.10.0.jar,jna-platform-5.10.0.jar,java-objc-bridge-1.0.0.jar'
|
run.property 'mergeModules', 'jna-5.10.0.jar,jna-platform-5.10.0.jar,java-objc-bridge-1.0.0.jar'
|
||||||
if (userdevRuns.contains(run)) {
|
if (userdevRuns.contains(run)) {
|
||||||
@@ -486,7 +498,7 @@ def sharedFmlonlyForge = { Project prj ->
|
|||||||
IGNORE_LIST: Util.getArtifacts(prj, prj.configurations.moduleonly, false).values().collect{it.downloads.artifact.path.rsplit('/', 1)[1]}.join(','),
|
IGNORE_LIST: Util.getArtifacts(prj, prj.configurations.moduleonly, false).values().collect{it.downloads.artifact.path.rsplit('/', 1)[1]}.join(','),
|
||||||
MODULES: 'ALL-MODULE-PATH'
|
MODULES: 'ALL-MODULE-PATH'
|
||||||
]
|
]
|
||||||
|
|
||||||
prj.task([dependsOn: rootProject.downloadServerRaw], 'makeClasspathFiles') {
|
prj.task([dependsOn: rootProject.downloadServerRaw], 'makeClasspathFiles') {
|
||||||
doLast {
|
doLast {
|
||||||
def CLASS_PATH = Util.getArtifacts(prj, prj.configurations.installer, false).values().collect{"libraries/${it.downloads.artifact.path}"} +
|
def CLASS_PATH = Util.getArtifacts(prj, prj.configurations.installer, false).values().collect{"libraries/${it.downloads.artifact.path}"} +
|
||||||
@@ -539,7 +551,7 @@ project(':fmlonly') {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
MCP_ARTIFACT = project(':mcp').mcp.config.get()
|
MCP_ARTIFACT = project(':mcp').mcp.config.get()
|
||||||
PACKED_DEPS = [':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':mclanguage:jar']
|
PACKED_DEPS = [':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':lowcodelanguage:jar', ':mclanguage:jar']
|
||||||
MAVEN_PATH = "${group.replace('.', '/')}/${project.name}/${VERSION}"
|
MAVEN_PATH = "${group.replace('.', '/')}/${project.name}/${VERSION}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,6 +580,7 @@ project(':fmlonly') {
|
|||||||
implementation project(':fmlcore')
|
implementation project(':fmlcore')
|
||||||
implementation project(':fmlloader')
|
implementation project(':fmlloader')
|
||||||
implementation project(':javafmllanguage')
|
implementation project(':javafmllanguage')
|
||||||
|
implementation project(':lowcodelanguage')
|
||||||
implementation project(':mclanguage')
|
implementation project(':mclanguage')
|
||||||
runtimeOnly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
|
runtimeOnly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
|
||||||
}
|
}
|
||||||
@@ -845,7 +858,7 @@ project(':fmlonly') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Since we need the modules in the bootstrap, we need to make sure they are compiled before we do each run
|
// Since we need the modules in the bootstrap, we need to make sure they are compiled before we do each run
|
||||||
afterEvaluate { prepareRuns.dependsOn(':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':mclanguage:jar') }
|
afterEvaluate { prepareRuns.dependsOn(PACKED_DEPS) }
|
||||||
}
|
}
|
||||||
|
|
||||||
project(':forge') {
|
project(':forge') {
|
||||||
@@ -894,7 +907,7 @@ project(':forge') {
|
|||||||
// Essentially, the same as the old, except dropping the first number, and the builds are no longer unique.
|
// Essentially, the same as the old, except dropping the first number, and the builds are no longer unique.
|
||||||
MCP_ARTIFACT = project(':mcp').mcp.config.get()
|
MCP_ARTIFACT = project(':mcp').mcp.config.get()
|
||||||
VERSION_JSON = project(':mcp').file('build/mcp/downloadJson/version.json')
|
VERSION_JSON = project(':mcp').file('build/mcp/downloadJson/version.json')
|
||||||
PACKED_DEPS = [':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':mclanguage:jar']
|
PACKED_DEPS = [':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':lowcodelanguage:jar', ':mclanguage:jar']
|
||||||
MAVEN_PATH = "${group.replace('.', '/')}/${project.name}/${VERSION}"
|
MAVEN_PATH = "${group.replace('.', '/')}/${project.name}/${VERSION}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -915,6 +928,7 @@ project(':forge') {
|
|||||||
implementation project(':fmlcore')
|
implementation project(':fmlcore')
|
||||||
implementation project(':fmlloader')
|
implementation project(':fmlloader')
|
||||||
implementation project(':javafmllanguage')
|
implementation project(':javafmllanguage')
|
||||||
|
implementation project(':lowcodelanguage')
|
||||||
implementation project(':mclanguage')
|
implementation project(':mclanguage')
|
||||||
runtimeOnly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
|
runtimeOnly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}"
|
||||||
}
|
}
|
||||||
@@ -1043,6 +1057,8 @@ project(':forge') {
|
|||||||
'--mod', 'new_model_loader_test',
|
'--mod', 'new_model_loader_test',
|
||||||
'--mod', 'remove_tag_datagen_test',
|
'--mod', 'remove_tag_datagen_test',
|
||||||
'--mod', 'tag_based_tool_types',
|
'--mod', 'tag_based_tool_types',
|
||||||
|
'--mod', 'custom_transformtype_test',
|
||||||
|
'--mod', 'data_pack_registries_test',
|
||||||
'--output', rootProject.file('src/generated_test/resources/'),
|
'--output', rootProject.file('src/generated_test/resources/'),
|
||||||
'--existing', sourceSets.main.resources.srcDirs[0],
|
'--existing', sourceSets.main.resources.srcDirs[0],
|
||||||
'--existing', sourceSets.test.resources.srcDirs[0]
|
'--existing', sourceSets.test.resources.srcDirs[0]
|
||||||
@@ -1116,6 +1132,7 @@ project(':forge') {
|
|||||||
|
|
||||||
task extractInheritance(type: ExtractInheritance, dependsOn: [genJoinedBinPatches, downloadLibraries]) {
|
task extractInheritance(type: ExtractInheritance, dependsOn: [genJoinedBinPatches, downloadLibraries]) {
|
||||||
tool = INSTALLER_TOOLS + ':fatjar'
|
tool = INSTALLER_TOOLS + ':fatjar'
|
||||||
|
args.add '--annotations'
|
||||||
input = genJoinedBinPatches.cleanJar
|
input = genJoinedBinPatches.cleanJar
|
||||||
libraries.addAll downloadLibraries.librariesOutput.map { rf -> Files.readAllLines(rf.asFile.toPath()).stream().map(File::new).collect(java.util.stream.Collectors.toList()) }
|
libraries.addAll downloadLibraries.librariesOutput.map { rf -> Files.readAllLines(rf.asFile.toPath()).stream().map(File::new).collect(java.util.stream.Collectors.toList()) }
|
||||||
}
|
}
|
||||||
@@ -1139,40 +1156,100 @@ project(':forge') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task checkATs(type: CheckATs, dependsOn: [extractInheritance, createSrg2Mcp]) {
|
tasks.register('checkAll') {
|
||||||
inheritance = extractInheritance.output
|
dependsOn 'checkLicenses'
|
||||||
|
group = 'checks'
|
||||||
|
}
|
||||||
|
tasks.register('checkAllAndFix') {
|
||||||
|
dependsOn 'findFieldInstanceChecks', 'checkLicenses'
|
||||||
|
group = 'checks'
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckTask.registerTask(tasks, 'ATs', CheckATs) {
|
||||||
|
dependsOn extractInheritance, createSrg2Mcp
|
||||||
ats.from patcher.accessTransformers
|
ats.from patcher.accessTransformers
|
||||||
|
inheritance = extractInheritance.output
|
||||||
mappings = createSrg2Mcp.output
|
mappings = createSrg2Mcp.output
|
||||||
}
|
}
|
||||||
|
|
||||||
task checkSAS(type: CheckSAS, dependsOn: extractInheritance) {
|
CheckTask.registerTask(tasks, 'SAS', CheckSAS) {
|
||||||
inheritance = extractInheritance.output
|
dependsOn extractInheritance
|
||||||
sass.from patcher.sideAnnotationStrippers
|
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
|
binary = jar.archiveFile.get().asFile
|
||||||
excs.from patcher.excs
|
excs.from patcher.excs
|
||||||
}
|
}
|
||||||
|
|
||||||
task checkAll(dependsOn: [checkATs, checkSAS, checkExcs, findFieldInstanceChecks]){}
|
CheckTask.registerTask(tasks, 'Patches', CheckPatches) {
|
||||||
|
dependsOn genPatches
|
||||||
task checkPatchesAndFix(type: CheckPatches, dependsOn: genPatches) {
|
|
||||||
patchDir = file("$rootDir/patches")
|
patchDir = file("$rootDir/patches")
|
||||||
autoFix = true
|
patchesWithS2SArtifact = [
|
||||||
}
|
'minecraft/net/minecraft/client/renderer/ViewArea.java.patch',
|
||||||
|
'minecraft/net/minecraft/data/models/blockstates/Variant.java.patch',
|
||||||
task checkPatches(type: CheckPatches, dependsOn: genPatches) {
|
]
|
||||||
patchDir = file("$rootDir/patches")
|
|
||||||
autoFix = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
genPatches {
|
genPatches {
|
||||||
finalizedBy checkPatches
|
finalizedBy checkAndFixPatches
|
||||||
autoHeader true
|
autoHeader true
|
||||||
lineEnding = '\n'
|
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 }
|
||||||
|
concreteLibraries.from(project.PACKED_DEPS.collect { project.rootProject.tasks.getByPath(it).archiveFile })
|
||||||
|
|
||||||
|
commonLibraries.from(project.configurations.minecraftImplementation)
|
||||||
|
commonLibraries.from(project.configurations.installer)
|
||||||
|
commonLibraries.from(project.configurations.moduleonly)
|
||||||
|
}
|
||||||
|
|
||||||
task launcherJson(type: LauncherJson) {
|
task launcherJson(type: LauncherJson) {
|
||||||
packedDependencies = [':fmlloader:jar']
|
packedDependencies = [':fmlloader:jar']
|
||||||
doFirst {
|
doFirst {
|
||||||
@@ -1192,7 +1269,8 @@ project(':forge') {
|
|||||||
'--fml.mcVersion', MC_VERSION,
|
'--fml.mcVersion', MC_VERSION,
|
||||||
'--fml.forgeGroup', project.group,
|
'--fml.forgeGroup', project.group,
|
||||||
'--fml.mcpVersion', MCP_VERSION],
|
'--fml.mcpVersion', MCP_VERSION],
|
||||||
jvm: ["-DignoreList=${forge_client.properties.ignoreList},\${version_name}.jar",
|
jvm: ['-Djava.net.preferIPv6Addresses=system',
|
||||||
|
"-DignoreList=${forge_client.properties.ignoreList},\${version_name}.jar",
|
||||||
"-DmergeModules=${forge_client.properties.mergeModules}",
|
"-DmergeModules=${forge_client.properties.mergeModules}",
|
||||||
'-DlibraryDirectory=${library_directory}',
|
'-DlibraryDirectory=${library_directory}',
|
||||||
'-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{'${library_directory}/' + it.downloads.artifact.path}.join('${classpath_separator}'),
|
'-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{'${library_directory}/' + it.downloads.artifact.path}.join('${classpath_separator}'),
|
||||||
@@ -1536,7 +1614,7 @@ project(':forge') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Since we need the modules in the bootstrap, we need to make sure they are compiled before we do each run
|
// Since we need the modules in the bootstrap, we need to make sure they are compiled before we do each run
|
||||||
afterEvaluate { prepareRuns.dependsOn(':fmlcore:jar', ':fmlloader:jar', ':javafmllanguage:jar', ':mclanguage:jar') }
|
afterEvaluate { prepareRuns.dependsOn(PACKED_DEPS) }
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||||
|
|||||||
@@ -6,4 +6,6 @@ dependencies {
|
|||||||
implementation 'org.ow2.asm:asm:9.1'
|
implementation 'org.ow2.asm:asm:9.1'
|
||||||
implementation 'org.ow2.asm:asm-tree:9.1'
|
implementation 'org.ow2.asm:asm-tree:9.1'
|
||||||
implementation 'net.minecraftforge:srgutils:0.4.+'
|
implementation 'net.minecraftforge:srgutils:0.4.+'
|
||||||
|
implementation 'commons-io:commons-io:2.8.0'
|
||||||
|
implementation 'com.google.code.gson:gson:2.10'
|
||||||
}
|
}
|
||||||
@@ -1,267 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import net.minecraftforge.srgutils.IMappingFile
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.Optional
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import org.objectweb.asm.Opcodes
|
|
||||||
|
|
||||||
abstract class CheckATs extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getInheritance()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getAts()
|
|
||||||
@InputFile @Optional abstract RegularFileProperty getMappings()
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
def mappings = mappings.map { IMappingFile.load(it.asFile) }.getOrNull()
|
|
||||||
Util.init()
|
|
||||||
def parse = { line ->
|
|
||||||
def idx = line.indexOf('#')
|
|
||||||
def comment = idx == -1 ? null : line.substring(idx)
|
|
||||||
if (idx != -1) line = line.substring(0, idx - 1)
|
|
||||||
def (modifier, cls, desc) = (line.trim() + ' ').split(' ', -1)
|
|
||||||
def key = cls + (desc.isEmpty() ? '' : ' ' + desc)
|
|
||||||
return [modifier, cls, desc, comment, key]
|
|
||||||
}
|
|
||||||
def accessLevel = { access ->
|
|
||||||
if ((access & Opcodes.ACC_PUBLIC) != 0) return 3
|
|
||||||
if ((access & Opcodes.ACC_PROTECTED) != 0) return 2
|
|
||||||
if ((access & Opcodes.ACC_PRIVATE) != 0) return 0
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
def accessStr = { access ->
|
|
||||||
if (access.endsWith('-f') || access.endsWith('+f'))
|
|
||||||
return 4
|
|
||||||
switch (access.toLowerCase()) {
|
|
||||||
case 'public': return 3
|
|
||||||
case 'protected': return 2
|
|
||||||
case 'default': return 1
|
|
||||||
case 'private': return 0
|
|
||||||
default: return -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def json = inheritance.get().asFile.json()
|
|
||||||
|
|
||||||
ats.each { f ->
|
|
||||||
TreeMap lines = [:]
|
|
||||||
def group = null
|
|
||||||
for (def line : f.readLines()) {
|
|
||||||
if (line.isEmpty()) continue
|
|
||||||
if (line.startsWith('#group ')) {
|
|
||||||
def (modifier, cls, desc, comment, key) = parse.call(line.substring(7))
|
|
||||||
|
|
||||||
if (desc != '*' && desc != '*()' && desc != '<init>')
|
|
||||||
throw new IllegalStateException('Invalid group: ' + line)
|
|
||||||
|
|
||||||
group = [modifier: modifier, cls: cls, desc: desc, comment: comment,
|
|
||||||
existing: [] as Set,
|
|
||||||
children: [] as TreeSet,
|
|
||||||
group: true
|
|
||||||
]
|
|
||||||
if (lines.containsKey(key))
|
|
||||||
throw new IllegalStateException('Duplicate group: ' + line)
|
|
||||||
|
|
||||||
lines[key] = group
|
|
||||||
} else if (group != null) {
|
|
||||||
if (line.startsWith('#endgroup')) {
|
|
||||||
group = null
|
|
||||||
} else {
|
|
||||||
def (modifier, cls, desc, comment, key) = parse.call(line)
|
|
||||||
group['existing'].add(key)
|
|
||||||
}
|
|
||||||
} else if (line.startsWith('#endgroup')) {
|
|
||||||
throw new IllegalStateException('Invalid group ending: ' + line)
|
|
||||||
} else if (line.startsWith('#')) {
|
|
||||||
//Nom
|
|
||||||
} else {
|
|
||||||
def (modifier, cls, desc, comment, key) = parse.call(line)
|
|
||||||
if (lines.containsKey(key)) {
|
|
||||||
println('Duplicate: ' + line)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
lines[key] = [modifier: modifier, cls: cls, desc: desc, comment: comment, group: false]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process Groups, this will remove any entries outside the group that is covered by the group
|
|
||||||
for (def key : new ArrayList<>(lines.keySet())) {
|
|
||||||
def entry = lines.get(key)
|
|
||||||
if (entry != null && entry['group']) {
|
|
||||||
def cls = entry['cls']
|
|
||||||
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
|
||||||
if (jcls == null) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Group: ' + key)
|
|
||||||
} else if ('*' == entry['desc']) {
|
|
||||||
if (!jcls.containsKey('fields')) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Group, Class has no fields: ' + key)
|
|
||||||
} else {
|
|
||||||
jcls['fields'].each { field, value ->
|
|
||||||
def fkey = cls + ' ' + field
|
|
||||||
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
|
||||||
if (lines.containsKey(fkey)) {
|
|
||||||
lines.remove(fkey)
|
|
||||||
} else if (!entry['existing'].contains(fkey)) {
|
|
||||||
println('Added: ' + fkey)
|
|
||||||
}
|
|
||||||
entry['children'].add(fkey)
|
|
||||||
} else if (lines.containsKey(fkey)) {
|
|
||||||
lines.remove(fkey)
|
|
||||||
println('Removed: ' + fkey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
|
||||||
}
|
|
||||||
} else if ('*()' == entry['desc']) {
|
|
||||||
if (!jcls.containsKey('methods')) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Group, Class has no methods: ' + key)
|
|
||||||
} else {
|
|
||||||
jcls['methods'].each{ mtd, value ->
|
|
||||||
if (mtd.startsWith('<clinit>') || mtd.startsWith('lambda$'))
|
|
||||||
return
|
|
||||||
key = cls + ' ' + mtd.replace(' ', '')
|
|
||||||
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
|
||||||
if (lines.containsKey(key)) {
|
|
||||||
lines.remove(key)
|
|
||||||
} else if (!entry['existing'].contains(key)) {
|
|
||||||
println('Added: ' + key)
|
|
||||||
}
|
|
||||||
entry['children'].add(key)
|
|
||||||
} else if (lines.containsKey(key)) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Removed: ' + key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
|
||||||
}
|
|
||||||
} else if ('<init>' == entry['desc']) { //Make all public non-abstract subclasses
|
|
||||||
json.each{ tcls,value ->
|
|
||||||
if (!value.containsKey('methods') || ((value['access'] & Opcodes.ACC_ABSTRACT) != 0))
|
|
||||||
return
|
|
||||||
def parents = [] as Set
|
|
||||||
def parent = tcls
|
|
||||||
while (parent != null && json.containsKey(parent)) {
|
|
||||||
parents.add(parent)
|
|
||||||
def p = json[parent]
|
|
||||||
parent = p == null ? null : p['superName']
|
|
||||||
}
|
|
||||||
if (parents.contains(cls.replaceAll('\\.', '/'))) {
|
|
||||||
value['methods'].each{ mtd, v ->
|
|
||||||
if (mtd.startsWith('<init>')) {
|
|
||||||
def child = tcls.replaceAll('/', '\\.') + ' ' + mtd.replace(' ', '')
|
|
||||||
if (accessLevel.call(v['access']) < 3) {
|
|
||||||
if (lines.containsKey(child)) {
|
|
||||||
lines.remove(child)
|
|
||||||
} else if (!entry['existing'].contains(child)) {
|
|
||||||
println('Added: ' + child)
|
|
||||||
}
|
|
||||||
entry['children'].add(child)
|
|
||||||
} else if (lines.containsKey(child)) {
|
|
||||||
lines.remove(child)
|
|
||||||
println('Removed: ' + child)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process normal lines, remove invalid and remove narrowing
|
|
||||||
for (def key : new ArrayList<>(lines.keySet())) {
|
|
||||||
def entry = lines.get(key)
|
|
||||||
if (entry != null && !entry['group']) {
|
|
||||||
def cls = entry['cls']
|
|
||||||
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
|
||||||
if (jcls == null) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid: ' + key)
|
|
||||||
} else if (entry['desc'] == '') {
|
|
||||||
if (accessLevel.call(jcls['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Narrowing: ' + key)
|
|
||||||
}
|
|
||||||
} else if (!entry['desc'].contains('(')) {
|
|
||||||
if (!jcls.containsKey('fields') || !jcls['fields'].containsKey(entry['desc'])) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid: ' + key)
|
|
||||||
} else {
|
|
||||||
def value = jcls['fields'][entry['desc']]
|
|
||||||
if (accessLevel.call(value['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Narrowing: ' + key)
|
|
||||||
println(entry.comment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
def jdesc = entry['desc'].replace('(', ' (')
|
|
||||||
if (!jcls.containsKey('methods') || !jcls['methods'].containsKey(jdesc)) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid: ' + key)
|
|
||||||
} else {
|
|
||||||
def value = jcls['methods'][jdesc]
|
|
||||||
if (accessLevel.call(value['access']) > accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
|
||||||
lines.remove(key)
|
|
||||||
println('Invalid Narrowing: ' + key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def data = []
|
|
||||||
def remapComment = { entry ->
|
|
||||||
if (!mappings || !entry || !entry.desc) return null
|
|
||||||
def comment = entry.comment?.substring(1)?.trim()
|
|
||||||
def jsonCls = json.get(entry.cls.replaceAll('\\.', '/'))
|
|
||||||
def mappingsClass = mappings?.getClass(jsonCls.name)
|
|
||||||
if (!mappingsClass) return entry.comment
|
|
||||||
def idx = entry.desc.indexOf('(')
|
|
||||||
def mappedName = idx == -1
|
|
||||||
? mappingsClass.remapField(entry.desc)
|
|
||||||
: mappingsClass.remapMethod(entry.desc.substring(0, idx), entry.desc.substring(idx))
|
|
||||||
if (!mappedName) return entry.comment
|
|
||||||
if (mappedName == '<init>')
|
|
||||||
mappedName = 'constructor'
|
|
||||||
|
|
||||||
if (comment?.startsWith(mappedName))
|
|
||||||
return '# ' + comment
|
|
||||||
if (comment && comment.indexOf(' ') != -1) {
|
|
||||||
def split = comment.split(" - ").toList()
|
|
||||||
if (split[0].indexOf(' ') != -1)
|
|
||||||
// The first string is more than one word, so append before it
|
|
||||||
return "# ${mappedName} - ${comment}"
|
|
||||||
split.remove(0)
|
|
||||||
return "# ${mappedName} - ${String.join(' - ', split)}"
|
|
||||||
}
|
|
||||||
return '# ' + mappedName
|
|
||||||
}
|
|
||||||
lines.each { key,value ->
|
|
||||||
if (!value.group) {
|
|
||||||
def comment = remapComment.call(value)
|
|
||||||
data.add(value.modifier + ' ' + key + (comment ? ' ' + comment : ''))
|
|
||||||
} else {
|
|
||||||
data.add('#group ' + value.modifier + ' ' + key + (value.comment == null ? '' : ' ' + value.comment))
|
|
||||||
value.children.each {
|
|
||||||
def line = value.modifier + ' ' + it
|
|
||||||
def (modifier, cls, desc, comment) = parse.call(line)
|
|
||||||
comment = remapComment.call([modifier: modifier, cls: cls, desc: desc, comment: comment])
|
|
||||||
data.add(line + (comment ? ' ' + comment : ''))
|
|
||||||
}
|
|
||||||
data.add('#endgroup')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f.text = data.join('\n')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
import org.objectweb.asm.ClassReader
|
|
||||||
import org.objectweb.asm.ClassVisitor
|
|
||||||
import org.objectweb.asm.MethodVisitor
|
|
||||||
import org.objectweb.asm.Opcodes
|
|
||||||
import org.objectweb.asm.Type
|
|
||||||
|
|
||||||
import java.util.zip.ZipEntry
|
|
||||||
import java.util.zip.ZipInputStream
|
|
||||||
|
|
||||||
abstract class CheckExcs extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getBinary()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getExcs()
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
Util.init()
|
|
||||||
def known = []
|
|
||||||
binary.get().asFile.withInputStream { i ->
|
|
||||||
new ZipInputStream(i).withCloseable { zin ->
|
|
||||||
def visitor = new ClassVisitor(Opcodes.ASM9) {
|
|
||||||
private String cls
|
|
||||||
@Override
|
|
||||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
|
||||||
this.cls = name
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
|
||||||
known.add(this.cls + '.' + name + descriptor)
|
|
||||||
super.visitMethod(access, name, descriptor, signature, exceptions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ZipEntry zein
|
|
||||||
while ((zein = zin.nextEntry) != null) {
|
|
||||||
if (zein.name.endsWith('.class')) {
|
|
||||||
ClassReader reader = new ClassReader(zin)
|
|
||||||
reader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
excs.each { f ->
|
|
||||||
def lines = []
|
|
||||||
f.eachLine { line ->
|
|
||||||
def idx = line.indexOf('#')
|
|
||||||
if (idx == 0 || line.isEmpty()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def comment = idx == -1 ? null : line.substring(idx)
|
|
||||||
if (idx != -1) line = line.substring(0, idx - 1)
|
|
||||||
|
|
||||||
if (!line.contains('=')) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def (key, value) = line.split('=', 2)
|
|
||||||
if (!known.contains(key)) {
|
|
||||||
println('Unknown: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def (cls, desc) = key.split('\\.', 2)
|
|
||||||
if (!desc.contains('(')) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
def name = desc.split('\\(', 2)[0]
|
|
||||||
desc = '(' + desc.split('\\(', 2)[1]
|
|
||||||
|
|
||||||
def (exceptions, args) = value.contains('|') ? value.split('|', 2) : [value, '']
|
|
||||||
|
|
||||||
if (args.split(',').length != Type.getArgumentTypes(desc).length) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
lines.add(line)
|
|
||||||
}
|
|
||||||
f.text = lines.sort().join('\n')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.InputDirectory
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.Paths
|
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
abstract class CheckPatches extends DefaultTask {
|
|
||||||
@InputDirectory abstract DirectoryProperty getPatchDir()
|
|
||||||
@Input boolean autoFix = false
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
def hasS2SArtifact = [
|
|
||||||
Paths.get("patches/minecraft/net/minecraft/client/renderer/ViewArea.java.patch"),
|
|
||||||
Paths.get("patches/minecraft/net/minecraft/data/models/blockstates/Variant.java.patch")
|
|
||||||
]
|
|
||||||
|
|
||||||
def verified = true;
|
|
||||||
patchDir.get().asFileTree.each { patch ->
|
|
||||||
def patchPath = project.rootDir.toPath().relativize(patch.toPath())
|
|
||||||
verified &= verifyPatch(patch, autoFix, patchPath.toString(), hasS2SArtifact.contains(patchPath))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!verified)
|
|
||||||
throw new RuntimeException('One or more patches failed verification. Check the log for errors.')
|
|
||||||
}
|
|
||||||
|
|
||||||
def verifyPatch(patch, fix, patchPath, hasS2SArtifact) {
|
|
||||||
def hunk_start_pattern = Pattern.compile('^@@ -[0-9,]* \\+[0-9,_]* @@$')
|
|
||||||
def white_space_pattern = Pattern.compile('^[+\\-]\\s*$')
|
|
||||||
def import_pattern = Pattern.compile('^[+\\-]\\s*import.*')
|
|
||||||
def field_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^=;]*)(=.*)?;\\s*$')
|
|
||||||
def method_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^(]*)[(]([^)]*)?[)]\\s*[{]\\s*$')
|
|
||||||
def class_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final[\\s]*)?(class|interface)([^{]*)[{]\\s*$')
|
|
||||||
|
|
||||||
def accessMap = [("private"):0, (null):1, ("protected"):2, ("public"):3]
|
|
||||||
|
|
||||||
def hasProblem = false;
|
|
||||||
def lines = patch.readLines()
|
|
||||||
|
|
||||||
def hunksStart = 0
|
|
||||||
def onlyWhiteSpace = false
|
|
||||||
|
|
||||||
def didFix = false
|
|
||||||
def newLines = []
|
|
||||||
def whiteSpaceErrors = []
|
|
||||||
|
|
||||||
// First two lines are file name ++/-- and we do not care
|
|
||||||
newLines.add(lines[0] + '\n')
|
|
||||||
newLines.add(lines[1] + '\n')
|
|
||||||
|
|
||||||
int i = 2
|
|
||||||
for (; i < lines.size(); ++i) {
|
|
||||||
def line = lines[i]
|
|
||||||
newLines.add(line + '\n')
|
|
||||||
|
|
||||||
if (hunk_start_pattern.matcher(line).find()) {
|
|
||||||
if (onlyWhiteSpace) {
|
|
||||||
if (fix || hasS2SArtifact) {
|
|
||||||
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
def toRemove = i - hunksStart;
|
|
||||||
while (toRemove-- > 0)
|
|
||||||
newLines.remove(newLines.size() - 1)
|
|
||||||
didFix = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!whiteSpaceErrors.empty)
|
|
||||||
hasProblem = true
|
|
||||||
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
|
||||||
whiteSpaceErrors.clear()
|
|
||||||
}
|
|
||||||
hunksStart = i
|
|
||||||
onlyWhiteSpace = true
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.startsWithAny('+','-')) {
|
|
||||||
def prefixChange = false
|
|
||||||
def prevLine = lines[i - 1]
|
|
||||||
|
|
||||||
if (line.charAt(0) == (char)'+' && prevLine.charAt(0) == (char)'-') {
|
|
||||||
def prevTrim = prevLine.substring(1).replaceAll("\\s", "")
|
|
||||||
def currTrim = line.substring(1).replaceAll("\\s", "")
|
|
||||||
|
|
||||||
if (prevTrim.equals(currTrim)) {
|
|
||||||
prefixChange = true
|
|
||||||
}
|
|
||||||
|
|
||||||
def pMatcher = field_pattern.matcher(prevLine)
|
|
||||||
def cMatcher = field_pattern.matcher(line)
|
|
||||||
|
|
||||||
if (pMatcher.find() && cMatcher.find() &&
|
|
||||||
pMatcher.group(6) == cMatcher.group(6) && // = ...
|
|
||||||
pMatcher.group(5) == cMatcher.group(5) && // field name
|
|
||||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
|
||||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
|
||||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
|
|
||||||
pMatcher = method_pattern.matcher(prevLine)
|
|
||||||
cMatcher = method_pattern.matcher(line)
|
|
||||||
|
|
||||||
if (pMatcher.find() && cMatcher.find() &&
|
|
||||||
pMatcher.group(6) == cMatcher.group(6) && // params
|
|
||||||
pMatcher.group(5) == cMatcher.group(5) && // <T> void name
|
|
||||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
|
||||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
|
||||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
|
|
||||||
pMatcher = class_pattern.matcher(prevLine)
|
|
||||||
cMatcher = class_pattern.matcher(line)
|
|
||||||
|
|
||||||
if (pMatcher.find() && cMatcher.find() &&
|
|
||||||
pMatcher.group(6) == cMatcher.group(6) && // ClassName<> extends ...
|
|
||||||
pMatcher.group(5) == cMatcher.group(5) && // class | interface
|
|
||||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
|
||||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
|
||||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.charAt(0) == (char)'-' && i + 1 < lines.size()) {
|
|
||||||
def nextLine = lines[i + 1]
|
|
||||||
if (nextLine.charAt(0) == (char)'+') {
|
|
||||||
def nextTrim = nextLine.substring(1).replaceAll("\\s", "")
|
|
||||||
def currTrim = line.substring(1).replaceAll("\\s", "")
|
|
||||||
|
|
||||||
if (nextTrim.equals(currTrim)) {
|
|
||||||
prefixChange = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def isWhiteSpaceChange = white_space_pattern.matcher(line).find()
|
|
||||||
|
|
||||||
if (!prefixChange && !isWhiteSpaceChange) {
|
|
||||||
onlyWhiteSpace = hasS2SArtifact && import_pattern.matcher(line).find()
|
|
||||||
}
|
|
||||||
else if (isWhiteSpaceChange) {
|
|
||||||
def prevLineChange = prevLine.startsWithAny('+','-')
|
|
||||||
def nextLineChange = i + 1 < lines.size() && lines[i + 1].startsWithAny('+','-')
|
|
||||||
|
|
||||||
if (!prevLineChange && !nextLineChange) {
|
|
||||||
whiteSpaceErrors.add(String.format("Patch contains white space change in valid hunk at line %d (cannot auto fix), file: %s", i + 1, patchPath))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.contains("\t")) {
|
|
||||||
if (!fix) {
|
|
||||||
logger.lifecycle("Patch contains tabs on line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.lifecycle("Fixing tabs on line {}, file: {}", i + 1, patchPath)
|
|
||||||
line = line.replaceAll('\t', ' ')
|
|
||||||
newLines.remove(newLines.size() - 1)
|
|
||||||
newLines.add(line + '\n')
|
|
||||||
didFix = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (import_pattern.matcher(line).find() && !hasS2SArtifact) {
|
|
||||||
logger.lifecycle("Patch contains import change on line {}, file: {}", i + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onlyWhiteSpace) {
|
|
||||||
if (fix || hasS2SArtifact) {
|
|
||||||
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
def toRemove = i - hunksStart;
|
|
||||||
while (toRemove-- > 0)
|
|
||||||
newLines.remove(newLines.size() - 1)
|
|
||||||
didFix = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
|
||||||
hasProblem = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!whiteSpaceErrors.empty)
|
|
||||||
hasProblem = true
|
|
||||||
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (didFix) {
|
|
||||||
if (newLines.size() <= 2) {
|
|
||||||
logger.lifecycle("Patch is now empty removing, file: {}", patchPath)
|
|
||||||
Files.delete(patch.toPath())
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!hasS2SArtifact)
|
|
||||||
logger.lifecycle("*** Updating patch file. Please run setup then genPatches again. ***")
|
|
||||||
patch.withWriter('UTF-8') { writer ->
|
|
||||||
newLines.each { l -> writer.write(l) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !hasProblem
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package net.minecraftforge.forge.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.tasks.InputFile
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
abstract class CheckSAS extends DefaultTask {
|
|
||||||
@InputFile abstract RegularFileProperty getInheritance()
|
|
||||||
@InputFiles abstract ConfigurableFileCollection getSass()
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
protected void exec() {
|
|
||||||
Util.init()
|
|
||||||
def json = inheritance.get().asFile.json()
|
|
||||||
|
|
||||||
sass.each { f ->
|
|
||||||
def lines = []
|
|
||||||
f.eachLine { line ->
|
|
||||||
if (line[0] == '\t') return //Skip any tabbed lines, those are ones we add
|
|
||||||
def idx = line.indexOf('#')
|
|
||||||
if (idx == 0 || line.isEmpty()) {
|
|
||||||
lines.add(line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
def comment = idx == -1 ? null : line.substring(idx)
|
|
||||||
if (idx != -1) line = line.substring(0, idx - 1)
|
|
||||||
def (cls, desc) = (line.trim() + ' ').split(' ', -1)
|
|
||||||
cls = cls.replaceAll('\\.', '/')
|
|
||||||
desc = desc.replace('(', ' (')
|
|
||||||
|
|
||||||
if (json[cls] == null || (!desc.isEmpty() && (json[cls]['methods'] == null || json[cls]['methods'][desc] == null))) {
|
|
||||||
println('Invalid: ' + line)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//Class SAS
|
|
||||||
if (desc.isEmpty()) {
|
|
||||||
lines.add(cls + (comment == null ? '' : ' ' + comment))
|
|
||||||
if (json[cls]['methods'] != null)
|
|
||||||
(json[cls]['methods'] as TreeMap).each {
|
|
||||||
findChildMethods(json, cls, it.key).each { lines.add('\t' + it) }
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//Method SAS
|
|
||||||
lines.add(cls + ' ' + desc.replace(' ', '') + (comment == null ? '' : ' ' + comment))
|
|
||||||
findChildMethods(json, cls, desc).each { lines.add('\t' + it) }
|
|
||||||
}
|
|
||||||
f.text = lines.join('\n')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static findChildMethods(json, cls, desc)
|
|
||||||
{
|
|
||||||
return json.values().findAll{ it.methods != null && it.methods[desc] != null && it.methods[desc].override == cls}
|
|
||||||
.collect { it.name + ' ' + desc.replace(' ', '') } as TreeSet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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()
|
||||||
|
}
|
||||||
@@ -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()
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
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 fmlLibs = project.configurations.detachedConfiguration(project.PACKED_DEPS.collect {
|
||||||
|
def artifactId = it.split(':')[1]
|
||||||
|
return project.dependencies.create("net.minecraftforge:${artifactId}:${inputVersion}")
|
||||||
|
}.toArray(Dependency[]::new))
|
||||||
|
|
||||||
|
project.tasks.named('checkJarCompatibility') {
|
||||||
|
baseLibraries.from(project.provider {
|
||||||
|
fmlLibs.resolvedConfiguration.lenientConfiguration.files
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
@@ -18,17 +18,17 @@ public class Util {
|
|||||||
return md.digest().collect {String.format "%02x", it}.join()
|
return md.digest().collect {String.format "%02x", it}.join()
|
||||||
}
|
}
|
||||||
File.metaClass.getSha1 = { !delegate.exists() ? null : delegate.sha1() }
|
File.metaClass.getSha1 = { !delegate.exists() ? null : delegate.sha1() }
|
||||||
|
|
||||||
File.metaClass.json = { -> new JsonSlurper().parseText(delegate.text) }
|
File.metaClass.json = { -> new JsonSlurper().parseText(delegate.text) }
|
||||||
File.metaClass.getJson = { return delegate.exists() ? new JsonSlurper().parse(delegate) : [:] }
|
File.metaClass.getJson = { return delegate.exists() ? new JsonSlurper().parse(delegate) : [:] }
|
||||||
File.metaClass.setJson = { json -> delegate.text = new JsonBuilder(json).toPrettyString() }
|
File.metaClass.setJson = { json -> delegate.text = new JsonBuilder(json).toPrettyString() }
|
||||||
|
|
||||||
Date.metaClass.iso8601 = { ->
|
Date.metaClass.iso8601 = { ->
|
||||||
def format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
|
def format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
def result = format.format(delegate)
|
def result = format.format(delegate)
|
||||||
return result[0..21] + ':' + result[22..-1]
|
return result[0..21] + ':' + result[22..-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
String.metaClass.rsplit = { String del, int limit = -1 ->
|
String.metaClass.rsplit = { String del, int limit = -1 ->
|
||||||
def lst = new ArrayList()
|
def lst = new ArrayList()
|
||||||
def x = 0, idx
|
def x = 0, idx
|
||||||
@@ -41,7 +41,7 @@ public class Util {
|
|||||||
return lst
|
return lst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getClasspath(project, libs, artifact) {
|
public static String[] getClasspath(project, libs, artifact) {
|
||||||
def ret = []
|
def ret = []
|
||||||
artifactTree(project, artifact).each { key, lib ->
|
artifactTree(project, artifact).each { key, lib ->
|
||||||
@@ -51,7 +51,7 @@ public class Util {
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
public static def getArtifacts(project, config, classifiers) {
|
public static def getArtifacts(project, config, classifiers) {
|
||||||
def ret = [:]
|
def ret = [:]
|
||||||
config.resolvedConfiguration.resolvedArtifacts.each {
|
config.resolvedConfiguration.resolvedArtifacts.each {
|
||||||
@@ -75,7 +75,7 @@ public class Util {
|
|||||||
url = "https://maven.minecraftforge.net/${path}"
|
url = "https://maven.minecraftforge.net/${path}"
|
||||||
}
|
}
|
||||||
//TODO remove when Mojang launcher is updated
|
//TODO remove when Mojang launcher is updated
|
||||||
if (!classifiers && art.classifier != null) {
|
if (!classifiers && art.classifier != null) {
|
||||||
//Mojang launcher doesn't currently support classifiers, so... move it to part of the version, and force the extension to 'jar'
|
//Mojang launcher doesn't currently support classifiers, so... move it to part of the version, and force the extension to 'jar'
|
||||||
// However, keep the path normal so that our mirror system works.
|
// However, keep the path normal so that our mirror system works.
|
||||||
art.version = "${art.version}-${art.classifier}"
|
art.version = "${art.version}-${art.classifier}"
|
||||||
@@ -96,14 +96,14 @@ public class Util {
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
public static def getMavenPath(task) {
|
public static def getMavenPath(task) {
|
||||||
def classifier = task.archiveClassifier.get()
|
def classifier = task.archiveClassifier.get()
|
||||||
def dep = "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
def dep = "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
||||||
return "${task.project.group.replace('.', '/')}/${task.project.name}/${task.project.version}/${task.project.name}-${task.project.version}".toString() + (classifier == '' ? '' : '-' + classifier) + '.jar'
|
return "${task.project.group.replace('.', '/')}/${task.project.name}/${task.project.version}/${task.project.name}-${task.project.version}".toString() + (classifier == '' ? '' : '-' + classifier) + '.jar'
|
||||||
}
|
}
|
||||||
|
|
||||||
public static def getMavenDep(task) {
|
public static def getMavenDep(task) {
|
||||||
def classifier = task.archiveClassifier.get()
|
def classifier = task.archiveClassifier.get()
|
||||||
return "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
return "${task.project.group}:${task.project.name}:${task.project.version}" + (classifier == '' ? '' : ':' + classifier)
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ public class Util {
|
|||||||
def files = cfg.resolve()
|
def files = cfg.resolve()
|
||||||
return getArtifacts(project, cfg, true)
|
return getArtifacts(project, cfg, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkExists(url) {
|
private static boolean checkExists(url) {
|
||||||
try {
|
try {
|
||||||
def code = new URL(url).openConnection().with {
|
def code = new URL(url).openConnection().with {
|
||||||
@@ -142,4 +142,9 @@ public class Util {
|
|||||||
throw e
|
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") }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ public interface IExtensionPoint<T extends Record>
|
|||||||
* The predicate tests the version from a remote instance or save for acceptability (Boolean is true for impl, false for local save)
|
* The predicate tests the version from a remote instance or save for acceptability (Boolean is true for impl, false for local save)
|
||||||
* and returns true if the version is compatible.
|
* and returns true if the version is compatible.
|
||||||
*
|
*
|
||||||
* <p>Return {@code net.minecraftforge.impl.impl.FMLNetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored
|
* <p>Return {@code net.minecraftforge.network.NetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored
|
||||||
* as a server side only mod.</p>
|
* as a server side only mod.</p>
|
||||||
* <p>Return true in the predicate for all values of the input string (when impl boolean is true) if you are client side,
|
* <p>Return true in the predicate for all values of the input string (when impl boolean is true) if you are client side,
|
||||||
* and don't care about matching any potential server version.</p>
|
* and don't care about matching any potential server version.</p>
|
||||||
@@ -27,8 +27,8 @@ public interface IExtensionPoint<T extends Record>
|
|||||||
* Examples: A server only mod
|
* Examples: A server only mod
|
||||||
* </p>
|
* </p>
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* registerExtensionPoint(DISPLAYTEST, ()->Pair.of(
|
* registerExtensionPoint(DisplayTest.class, ()->new DisplayTest(
|
||||||
* ()->FMLNetworkConstants.IGNORESERVERONLY, // ignore me, I'm a server only mod
|
* ()->NetworkConstants.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
|
* (s,b)->true // i accept anything from the server or the save, if I'm asked
|
||||||
* )
|
* )
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -37,7 +37,7 @@ public interface IExtensionPoint<T extends Record>
|
|||||||
* Examples: A client only mod
|
* Examples: A client only mod
|
||||||
* </p>
|
* </p>
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* registerExtensionPoint(DISPLAYTEST, ()->Pair.of(
|
* registerExtensionPoint(DisplayTest.class, ()->new DisplayTest(
|
||||||
* ()->"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
|
* ()->"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
|
* (remoteversionstring,networkbool)->networkbool // i accept anything from the server, by returning true if it's asking about the server
|
||||||
* )
|
* )
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import net.minecraftforge.fml.event.IModBusEvent;
|
|||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.LoadingModList;
|
import net.minecraftforge.fml.loading.LoadingModList;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier;
|
import net.minecraftforge.fml.loading.moddiscovery.InvalidModIdentifier;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -222,7 +223,7 @@ public class ModLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ModContainer> buildMods(final ModFile modFile)
|
private List<ModContainer> buildMods(final IModFile modFile)
|
||||||
{
|
{
|
||||||
final Map<String, IModInfo> modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity()));
|
final Map<String, IModInfo> modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity()));
|
||||||
|
|
||||||
@@ -244,7 +245,7 @@ public class ModLoader
|
|||||||
return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).collect(Collectors.toList());
|
return containers.stream().filter(mc -> mc.modLoadingStage != ModLoadingStage.ERROR).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModContainer buildModContainerFromTOML(final ModFile modFile, final Map<String, IModInfo> modInfoMap, final Map.Entry<String, ? extends IModLanguageProvider.IModLanguageLoader> idToProviderEntry) {
|
private ModContainer buildModContainerFromTOML(final IModFile modFile, final Map<String, IModInfo> modInfoMap, final Map.Entry<String, ? extends IModLanguageProvider.IModLanguageLoader> idToProviderEntry) {
|
||||||
try {
|
try {
|
||||||
final String modId = idToProviderEntry.getKey();
|
final String modId = idToProviderEntry.getKey();
|
||||||
final IModLanguageProvider.IModLanguageLoader languageLoader = idToProviderEntry.getValue();
|
final IModLanguageProvider.IModLanguageLoader languageLoader = idToProviderEntry.getValue();
|
||||||
|
|||||||
@@ -117,14 +117,22 @@ public class VersionChecker
|
|||||||
/**
|
/**
|
||||||
* Returns the response body as a String for the given URL while following redirects
|
* Returns the response body as a String for the given URL while following redirects
|
||||||
*/
|
*/
|
||||||
private String openUrlString(URL url) throws IOException, URISyntaxException, InterruptedException {
|
private String openUrlString(URL url, IModInfo mod) throws IOException, URISyntaxException, InterruptedException {
|
||||||
URL currentUrl = url;
|
URL currentUrl = url;
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Java-http-client/").append(System.getProperty("java.version")).append(' ');
|
||||||
|
sb.append("MinecraftForge/").append(FMLLoader.versionInfo().mcAndForgeVersion()).append(' ');
|
||||||
|
sb.append(mod.getModId()).append('/').append(mod.getVersion());
|
||||||
|
final String userAgent = sb.toString();
|
||||||
|
|
||||||
for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++)
|
for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++)
|
||||||
{
|
{
|
||||||
var request = HttpRequest.newBuilder()
|
var request = HttpRequest.newBuilder()
|
||||||
.uri(currentUrl.toURI())
|
.uri(currentUrl.toURI())
|
||||||
.timeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS))
|
.timeout(Duration.ofSeconds(HTTP_TIMEOUT_SECS))
|
||||||
.setHeader("Accept-Encoding", "gzip")
|
.setHeader("Accept-Encoding", "gzip")
|
||||||
|
.setHeader("User-Agent", userAgent)
|
||||||
.GET()
|
.GET()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -166,7 +174,7 @@ public class VersionChecker
|
|||||||
URL url = mod.getUpdateURL().get();
|
URL url = mod.getUpdateURL().get();
|
||||||
LOGGER.info("[{}] Starting version check at {}", mod.getModId(), url.toString());
|
LOGGER.info("[{}] Starting version check at {}", mod.getModId(), url.toString());
|
||||||
|
|
||||||
String data = openUrlString(url);
|
String data = openUrlString(url, mod);
|
||||||
|
|
||||||
LOGGER.debug("[{}] Received version check data:\n{}", mod.getModId(), data);
|
LOGGER.debug("[{}] Received version check data:\n{}", mod.getModId(), data);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ dependencies {
|
|||||||
api("org.ow2.asm:asm:${ASM_VERSION}")
|
api("org.ow2.asm:asm:${ASM_VERSION}")
|
||||||
api("org.ow2.asm:asm-tree:${ASM_VERSION}")
|
api("org.ow2.asm:asm-tree:${ASM_VERSION}")
|
||||||
api("org.ow2.asm:asm-commons:${ASM_VERSION}")
|
api("org.ow2.asm:asm-commons:${ASM_VERSION}")
|
||||||
api('net.minecraftforge:forgespi:4.0.+')
|
api("net.minecraftforge:forgespi:${SPI_VERSION}")
|
||||||
api('org.apache.logging.log4j:log4j-api:2.17.0')
|
api('org.apache.logging.log4j:log4j-api:2.17.0')
|
||||||
api('org.slf4j:slf4j-api:1.8.0-beta4')
|
api('org.slf4j:slf4j-api:1.8.0-beta4')
|
||||||
api('com.google.guava:guava:21.0')
|
api('com.google.guava:guava:21.0')
|
||||||
@@ -27,6 +27,7 @@ dependencies {
|
|||||||
api('com.electronwill.night-config:toml:3.6.4')
|
api('com.electronwill.night-config:toml:3.6.4')
|
||||||
api('cpw.mods:modlauncher:9.0.+')
|
api('cpw.mods:modlauncher:9.0.+')
|
||||||
api('net.minecraftforge:coremods:5.0.+')
|
api('net.minecraftforge:coremods:5.0.+')
|
||||||
|
api "net.minecraftforge:JarJar:${JARJAR_VERSION}"
|
||||||
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
|
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
|
||||||
implementation('org.apache.logging.log4j:log4j-core:2.17.0')
|
implementation('org.apache.logging.log4j:log4j-core:2.17.0')
|
||||||
annotationProcessor('org.apache.logging.log4j:log4j-core:2.17.0')
|
annotationProcessor('org.apache.logging.log4j:log4j-core:2.17.0')
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
public class ClasspathLocatorUtils {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
public static Path findJarPathFor(final String resourceName, final String jarName, final URL resource) {
|
||||||
|
try {
|
||||||
|
Path path;
|
||||||
|
final URI uri = resource.toURI();
|
||||||
|
if (uri.getScheme().equals("jar") && uri.getRawSchemeSpecificPart().contains("!/")) {
|
||||||
|
int lastExcl = uri.getRawSchemeSpecificPart().lastIndexOf("!/");
|
||||||
|
path = Paths.get(new URI(uri.getRawSchemeSpecificPart().substring(0, lastExcl)));
|
||||||
|
} else {
|
||||||
|
path = Paths.get(new URI("file://"+uri.getRawSchemeSpecificPart().substring(0, uri.getRawSchemeSpecificPart().length()-resourceName.length())));
|
||||||
|
}
|
||||||
|
//LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
|
||||||
|
return path;
|
||||||
|
} catch (NullPointerException | URISyntaxException e) {
|
||||||
|
LOGGER.fatal(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName);
|
||||||
|
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.NamedPath;
|
||||||
|
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ClasspathTransformerDiscoverer implements ITransformerDiscoveryService {
|
||||||
|
|
||||||
|
private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NamedPath> candidates(Path gameDirectory) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NamedPath> candidates(final Path gameDirectory, final String launchTarget) {
|
||||||
|
if (launchTarget != null && launchTarget.contains("dev")) {
|
||||||
|
this.scan(gameDirectory);
|
||||||
|
}
|
||||||
|
return List.copyOf(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static List<NamedPath> found = new ArrayList<>();
|
||||||
|
|
||||||
|
public static List<Path> allExcluded() {
|
||||||
|
return found.stream().map(np->np.paths()[0]).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scan(final Path gameDirectory) {
|
||||||
|
try {
|
||||||
|
locateTransformers("META-INF/services/cpw.mods.modlauncher.api.ITransformationService");
|
||||||
|
locateTransformers("META-INF/services/net.minecraftforge.forgespi.locating.IModLocator");
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogManager.getLogger().error("Error during discovery of transform services from the classpath", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void locateTransformers(String resource) throws IOException {
|
||||||
|
final Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(resource);
|
||||||
|
while (resources.hasMoreElements()) {
|
||||||
|
URL url = resources.nextElement();
|
||||||
|
Path path = ClasspathLocatorUtils.findJarPathFor(resource, url.toString(), url);
|
||||||
|
if (legacyClasspath.stream().anyMatch(path::equals) || !Files.exists(path) || Files.isDirectory(path))
|
||||||
|
continue;
|
||||||
|
found.add(new NamedPath(path.toUri().toString(), path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ public class EarlyLoadingException extends RuntimeException {
|
|||||||
return errorMessages;
|
return errorMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
EarlyLoadingException(final String message, final Throwable originalException, List<ExceptionData> errorMessages) {
|
public EarlyLoadingException(final String message, final Throwable originalException, List<ExceptionData> errorMessages) {
|
||||||
super(message, originalException);
|
super(message, originalException);
|
||||||
this.errorMessages = errorMessages;
|
this.errorMessages = errorMessages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.google.common.graph.GraphBuilder;
|
|||||||
import com.google.common.graph.MutableGraph;
|
import com.google.common.graph.MutableGraph;
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator;
|
import net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator;
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import net.minecraftforge.fml.loading.EarlyLoadingException.ExceptionData;
|
import net.minecraftforge.fml.loading.EarlyLoadingException.ExceptionData;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
@@ -17,7 +16,6 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
|||||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||||
import net.minecraftforge.fml.loading.toposort.CyclePresentException;
|
import net.minecraftforge.fml.loading.toposort.CyclePresentException;
|
||||||
import net.minecraftforge.fml.loading.toposort.TopologicalSort;
|
import net.minecraftforge.fml.loading.toposort.TopologicalSort;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
@@ -36,14 +34,15 @@ import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
|||||||
public class ModSorter
|
public class ModSorter
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private final UniqueModListBuilder uniqueModListBuilder;
|
||||||
private List<ModFile> modFiles;
|
private List<ModFile> modFiles;
|
||||||
private List<ModInfo> sortedList;
|
private List<ModInfo> sortedList;
|
||||||
private Map<String, ModInfo> modIdNameLookup;
|
private Map<String, IModInfo> modIdNameLookup;
|
||||||
private List<ModFile> systemMods;
|
private List<ModFile> systemMods;
|
||||||
|
|
||||||
private ModSorter(final List<ModFile> modFiles)
|
private ModSorter(final List<ModFile> modFiles)
|
||||||
{
|
{
|
||||||
this.modFiles = modFiles;
|
this.uniqueModListBuilder = new UniqueModListBuilder(modFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LoadingModList sort(List<ModFile> mods, final List<ExceptionData> errors)
|
public static LoadingModList sort(List<ModFile> mods, final List<ExceptionData> errors)
|
||||||
@@ -78,11 +77,12 @@ public class ModSorter
|
|||||||
// lambdas are identity based, so sorting them is impossible unless you hold reference to them
|
// lambdas are identity based, so sorting them is impossible unless you hold reference to them
|
||||||
final MutableGraph<ModFileInfo> graph = GraphBuilder.directed().build();
|
final MutableGraph<ModFileInfo> graph = GraphBuilder.directed().build();
|
||||||
AtomicInteger counter = new AtomicInteger();
|
AtomicInteger counter = new AtomicInteger();
|
||||||
Map<IModFileInfo, Integer> infos = modFiles.stream()
|
Map<ModFileInfo, Integer> infos = modFiles.stream()
|
||||||
.map(ModFile::getModFileInfo)
|
.map(ModFile::getModFileInfo)
|
||||||
.filter(ModFileInfo.class::isInstance)
|
.filter(ModFileInfo.class::isInstance)
|
||||||
|
.map(ModFileInfo.class::cast)
|
||||||
.collect(toMap(Function.identity(), e -> counter.incrementAndGet()));
|
.collect(toMap(Function.identity(), e -> counter.incrementAndGet()));
|
||||||
infos.keySet().forEach(i -> graph.addNode((ModFileInfo) i));
|
infos.keySet().forEach(graph::addNode);
|
||||||
modFiles.stream()
|
modFiles.stream()
|
||||||
.map(ModFile::getModInfos)
|
.map(ModFile::getModInfos)
|
||||||
.<IModInfo>mapMulti(Iterable::forEach)
|
.<IModInfo>mapMulti(Iterable::forEach)
|
||||||
@@ -125,10 +125,9 @@ public class ModSorter
|
|||||||
private void addDependency(MutableGraph<ModFileInfo> topoGraph, IModInfo.ModVersion dep)
|
private void addDependency(MutableGraph<ModFileInfo> topoGraph, IModInfo.ModVersion dep)
|
||||||
{
|
{
|
||||||
final ModFileInfo self = (ModFileInfo)dep.getOwner().getOwningFile();
|
final ModFileInfo self = (ModFileInfo)dep.getOwner().getOwningFile();
|
||||||
final ModInfo targetModInfo = modIdNameLookup.get(dep.getModId());
|
final IModInfo targetModInfo = modIdNameLookup.get(dep.getModId());
|
||||||
// soft dep that doesn't exist. Just return. No edge required.
|
// soft dep that doesn't exist. Just return. No edge required.
|
||||||
if (targetModInfo == null) return;
|
if (targetModInfo == null || !(targetModInfo.getOwningFile() instanceof final ModFileInfo target)) return;
|
||||||
final ModFileInfo target = targetModInfo.getOwningFile();
|
|
||||||
if (self == target)
|
if (self == target)
|
||||||
return; // in case a jar has two mods that have dependencies between
|
return; // in case a jar has two mods that have dependencies between
|
||||||
switch (dep.getOrdering()) {
|
switch (dep.getOrdering()) {
|
||||||
@@ -139,10 +138,22 @@ public class ModSorter
|
|||||||
|
|
||||||
private void buildUniqueList()
|
private void buildUniqueList()
|
||||||
{
|
{
|
||||||
// Collect mod files by module name. This will be used for deduping purposes
|
final UniqueModListBuilder.UniqueModListData uniqueModListData = uniqueModListBuilder.buildUniqueList();
|
||||||
final Map<String, List<IModFile>> modFilesByFirstId = modFiles.stream()
|
|
||||||
.collect(groupingBy(mf -> mf.getModFileInfo().moduleName()));
|
|
||||||
|
|
||||||
|
this.modFiles = uniqueModListData.modFiles();
|
||||||
|
|
||||||
|
detectSystemMods(uniqueModListData.modFilesByFirstId());
|
||||||
|
|
||||||
|
modIdNameLookup = uniqueModListData.modFilesByFirstId().entrySet().stream()
|
||||||
|
.filter(e -> !e.getValue().get(0).getModInfos().isEmpty())
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
Map.Entry::getKey,
|
||||||
|
e -> e.getValue().get(0).getModInfos().get(0)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void detectSystemMods(final Map<String, List<ModFile>> modFilesByFirstId)
|
||||||
|
{
|
||||||
// Capture system mods (ex. MC, Forge) here, so we can keep them for later
|
// Capture system mods (ex. MC, Forge) here, so we can keep them for later
|
||||||
final Set<String> systemMods = new HashSet<>();
|
final Set<String> systemMods = new HashSet<>();
|
||||||
// The minecraft mod is always a system mod
|
// The minecraft mod is always a system mod
|
||||||
@@ -169,47 +180,6 @@ public class ModSorter
|
|||||||
throw new IllegalStateException("Failed to find system mod: " + systemMod);
|
throw new IllegalStateException("Failed to find system mod: " + systemMod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the newest by artifact version sorting of non-unique files thus identified
|
|
||||||
this.modFiles = modFilesByFirstId.entrySet().stream()
|
|
||||||
.map(this::selectNewestModInfo)
|
|
||||||
.map(Map.Entry::getValue)
|
|
||||||
.map(ModFile.class::cast)
|
|
||||||
.collect(toList());
|
|
||||||
|
|
||||||
// Transform to the full mod id list
|
|
||||||
final Map<String, List<ModInfo>> modIds = modFiles.stream()
|
|
||||||
.map(ModFile::getModInfos)
|
|
||||||
.flatMap(Collection::stream)
|
|
||||||
.map(ModInfo.class::cast)
|
|
||||||
.collect(groupingBy(IModInfo::getModId));
|
|
||||||
|
|
||||||
// Its theoretically possible that some mod has somehow moved an id to a secondary place, thus causing a dupe.
|
|
||||||
// We can't handle this
|
|
||||||
final List<ModInfo> dupedMods = modIds.values().stream()
|
|
||||||
.filter(modInfos -> modInfos.size() > 1)
|
|
||||||
.map(modInfos -> modInfos.get(0))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (!dupedMods.isEmpty()) {
|
|
||||||
final List<EarlyLoadingException.ExceptionData> duplicateModErrors = dupedMods.stream()
|
|
||||||
.map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedmod",
|
|
||||||
dm, Objects.toString(dm))).toList();
|
|
||||||
throw new EarlyLoadingException("Duplicate mods found", null, duplicateModErrors);
|
|
||||||
}
|
|
||||||
|
|
||||||
modIdNameLookup = modIds.entrySet().stream()
|
|
||||||
.collect(toMap(Map.Entry::getKey, e -> e.getValue().get(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map.Entry<String, IModFile> selectNewestModInfo(Map.Entry<String, List<IModFile>> fullList) {
|
|
||||||
List<IModFile> modInfoList = fullList.getValue();
|
|
||||||
if (modInfoList.size() > 1) {
|
|
||||||
LOGGER.debug("Found {} mods for first modid {}, selecting most recent based on version data", modInfoList.size(), fullList.getKey());
|
|
||||||
modInfoList.sort(Comparator.<IModFile, ArtifactVersion>comparing(mf -> mf.getModInfos().get(0).getVersion()).reversed());
|
|
||||||
LOGGER.debug("Selected file {} for modid {} with version {}", modInfoList.get(0).getFileName(), fullList.getKey(), modInfoList.get(0).getModInfos().get(0).getVersion());
|
|
||||||
}
|
|
||||||
return Map.entry(fullList.getKey(), modInfoList.get(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EarlyLoadingException.ExceptionData> verifyDependencyVersions()
|
private List<EarlyLoadingException.ExceptionData> verifyDependencyVersions()
|
||||||
@@ -239,10 +209,24 @@ public class ModSorter
|
|||||||
|
|
||||||
if (!missingVersions.isEmpty()) {
|
if (!missingVersions.isEmpty()) {
|
||||||
if (mandatoryMissing > 0) {
|
if (mandatoryMissing > 0) {
|
||||||
LOGGER.error(LOADING, "Missing mandatory dependencies: {}", missingVersions.stream().filter(IModInfo.ModVersion::isMandatory).map(IModInfo.ModVersion::getModId).collect(Collectors.joining(", ")));
|
LOGGER.error(
|
||||||
|
LOADING,
|
||||||
|
"Missing or unsupported mandatory dependencies:\n{}",
|
||||||
|
missingVersions.stream()
|
||||||
|
.filter(IModInfo.ModVersion::isMandatory)
|
||||||
|
.map(ver -> formatDependencyError(ver, modVersions))
|
||||||
|
.collect(Collectors.joining("\n"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (missingVersions.size() - mandatoryMissing > 0) {
|
if (missingVersions.size() - mandatoryMissing > 0) {
|
||||||
LOGGER.error(LOADING, "Unsupported installed optional dependencies: {}", missingVersions.stream().filter(ver -> !ver.isMandatory()).map(IModInfo.ModVersion::getModId).collect(Collectors.joining(", ")));
|
LOGGER.error(
|
||||||
|
LOADING,
|
||||||
|
"Unsupported installed optional dependencies:\n{}",
|
||||||
|
missingVersions.stream()
|
||||||
|
.filter(ver -> !ver.isMandatory())
|
||||||
|
.map(ver -> formatDependencyError(ver, modVersions))
|
||||||
|
.collect(Collectors.joining("\n"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return missingVersions.stream()
|
return missingVersions.stream()
|
||||||
@@ -254,6 +238,18 @@ public class ModSorter
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String formatDependencyError(IModInfo.ModVersion dependency, Map<String, ArtifactVersion> modVersions)
|
||||||
|
{
|
||||||
|
ArtifactVersion installed = modVersions.get(dependency.getModId());
|
||||||
|
return String.format(
|
||||||
|
"\tMod ID: '%s', Requested by: '%s', Expected range: '%s', Actual version: '%s'",
|
||||||
|
dependency.getModId(),
|
||||||
|
dependency.getOwner().getModId(),
|
||||||
|
dependency.getVersionRange(),
|
||||||
|
installed != null ? installed.toString() : "[MISSING]"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean modVersionNotContained(final IModInfo.ModVersion mv, final Map<String, ArtifactVersion> modVersions)
|
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) &&
|
return !(VersionSupportMatrix.testVersionSupportMatrix(mv.getVersionRange(), mv.getModId(), "mod", (modId, range) -> modVersions.containsKey(modId) &&
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.*;
|
||||||
|
|
||||||
|
public class UniqueModListBuilder
|
||||||
|
{
|
||||||
|
private final static Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
private final List<ModFile> modFiles;
|
||||||
|
|
||||||
|
public UniqueModListBuilder(final List<ModFile> modFiles) {this.modFiles = modFiles;}
|
||||||
|
|
||||||
|
public UniqueModListData buildUniqueList()
|
||||||
|
{
|
||||||
|
List<ModFile> uniqueModList;
|
||||||
|
List<ModFile> uniqueLibListWithVersion;
|
||||||
|
|
||||||
|
// Collect mod files by module name. This will be used for deduping purposes
|
||||||
|
final Map<String, List<ModFile>> modFilesByFirstId = modFiles.stream()
|
||||||
|
.filter(mf -> mf.getModFileInfo() != null)
|
||||||
|
.collect(groupingBy(UniqueModListBuilder::getModId));
|
||||||
|
|
||||||
|
final Map<String, List<ModFile>> libFilesWithVersionByModuleName = modFiles.stream()
|
||||||
|
.filter(mf -> mf.getModFileInfo() == null)
|
||||||
|
.collect(groupingBy(UniqueModListBuilder::getModId));
|
||||||
|
|
||||||
|
// Select the newest by artifact version sorting of non-unique files thus identified
|
||||||
|
uniqueModList = modFilesByFirstId.entrySet().stream()
|
||||||
|
.map(this::selectNewestModInfo)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Select the newest by artifact version sorting of non-unique files thus identified
|
||||||
|
uniqueLibListWithVersion = libFilesWithVersionByModuleName.entrySet().stream()
|
||||||
|
.map(this::selectNewestModInfo)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Transform to the full mod id list
|
||||||
|
final Map<String, List<IModInfo>> modIds = uniqueModList.stream()
|
||||||
|
.filter(mf -> mf.getModFileInfo() != null) //Filter out non-mod files, we don't care about those for now.....
|
||||||
|
.map(ModFile::getModInfos)
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(groupingBy(IModInfo::getModId));
|
||||||
|
|
||||||
|
// Transform to the full lib id list
|
||||||
|
final Map<String, List<ModFile>> versionedLibIds = uniqueLibListWithVersion.stream()
|
||||||
|
.map(UniqueModListBuilder::getModId)
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
Function.identity(),
|
||||||
|
libFilesWithVersionByModuleName::get
|
||||||
|
));
|
||||||
|
|
||||||
|
// Its theoretically possible that some mod has somehow moved an id to a secondary place, thus causing a dupe.
|
||||||
|
// We can't handle this
|
||||||
|
final List<IModInfo> dupedMods = modIds.values().stream()
|
||||||
|
.filter(modInfos -> modInfos.size() > 1)
|
||||||
|
.map(modInfos -> modInfos.get(0))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!dupedMods.isEmpty()) {
|
||||||
|
final List<EarlyLoadingException.ExceptionData> duplicateModErrors = dupedMods.stream()
|
||||||
|
.map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedmod", dm, Objects.toString(dm)))
|
||||||
|
.toList();
|
||||||
|
throw new EarlyLoadingException("Duplicate mods found", null, duplicateModErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<ModFile> dupedLibs = versionedLibIds.values().stream()
|
||||||
|
.filter(modFiles -> modFiles.size() > 1)
|
||||||
|
.map(modFiles -> modFiles.get(0))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!dupedLibs.isEmpty()) {
|
||||||
|
final List<EarlyLoadingException.ExceptionData> duplicateLibErrors = dupedLibs.stream()
|
||||||
|
.map(dm -> new EarlyLoadingException.ExceptionData("fml.modloading.dupedlib.versioned", dm, Objects.toString(dm)))
|
||||||
|
.toList();
|
||||||
|
throw new EarlyLoadingException("Duplicate plugins or libraries found", null, duplicateLibErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect unique mod files by module name. This will be used for deduping purposes
|
||||||
|
final Map<String, List<ModFile>> uniqueModFilesByFirstId = uniqueModList.stream()
|
||||||
|
.collect(groupingBy(UniqueModListBuilder::getModId));
|
||||||
|
|
||||||
|
final List<ModFile> loadedList = new ArrayList<>();
|
||||||
|
loadedList.addAll(uniqueModList);
|
||||||
|
loadedList.addAll(uniqueLibListWithVersion);
|
||||||
|
|
||||||
|
return new UniqueModListData(loadedList, uniqueModFilesByFirstId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ModFile selectNewestModInfo(Map.Entry<String, List<ModFile>> fullList) {
|
||||||
|
List<ModFile> modInfoList = fullList.getValue();
|
||||||
|
if (modInfoList.size() > 1) {
|
||||||
|
LOGGER.debug("Found {} mods for first modid {}, selecting most recent based on version data", modInfoList.size(), fullList.getKey());
|
||||||
|
modInfoList.sort(Comparator.comparing(this::getVersion).reversed());
|
||||||
|
LOGGER.debug("Selected file {} for modid {} with version {}", modInfoList.get(0).getFileName(), fullList.getKey(), modInfoList.get(0).getModInfos().get(0).getVersion());
|
||||||
|
}
|
||||||
|
return modInfoList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArtifactVersion getVersion(final ModFile mf)
|
||||||
|
{
|
||||||
|
if (mf.getModFileInfo() == null) {
|
||||||
|
return mf.getJarVersion();
|
||||||
|
}
|
||||||
|
return mf.getModInfos().get(0).getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getModId(ModFile modFile) {
|
||||||
|
if (modFile.getModFileInfo() == null || modFile.getModFileInfo().getMods().isEmpty()) {
|
||||||
|
return modFile.getSecureJar().name();
|
||||||
|
}
|
||||||
|
|
||||||
|
return modFile.getModFileInfo().moduleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public record UniqueModListData(List<ModFile> modFiles, Map<String, List<ModFile>> modFilesByFirstId) {}
|
||||||
|
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public abstract class AbstractJarFileDependencyLocator extends AbstractJarFileLocator
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
protected Optional<InputStream> loadResourceFromModFile(final IModFile modFile, final Path path) {
|
||||||
|
try {
|
||||||
|
return Optional.of(Files.newInputStream(modFile.findResource(path.toString())));
|
||||||
|
}
|
||||||
|
catch (final FileNotFoundException e) {
|
||||||
|
LOGGER.debug("Failed to load resource {} from {}, it does not contain dependency information.", path, modFile.getFileName());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
catch (final Exception e) {
|
||||||
|
LOGGER.error("Failed to load resource {} from mod {}, cause {}", path, modFile.getFileName(), e);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Optional<IModFile> loadModFileFrom(final IModFile file, final Path path) {
|
||||||
|
try {
|
||||||
|
final Path pathInModFile = file.findResource(path.toString());
|
||||||
|
return createMod(pathInModFile);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
LOGGER.error("Failed to load mod file {} from {}", path, file.getFileName());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String identifyMod(final IModFile modFile) {
|
||||||
|
return modFile.getFileName();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-23
@@ -6,30 +6,20 @@
|
|||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import cpw.mods.jarhandling.JarMetadata;
|
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.jar.Manifest;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public abstract class AbstractJarFileLocator extends AbstractModLocator {
|
public abstract class AbstractJarFileLocator extends AbstractModLocator
|
||||||
|
{
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,15 +33,4 @@ public abstract class AbstractJarFileLocator extends AbstractModLocator {
|
|||||||
}
|
}
|
||||||
LOGGER.debug(LogMarkers.SCAN,"Scan finished: {}", file);
|
LOGGER.debug(LogMarkers.SCAN,"Scan finished: {}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IModFile> scanMods() {
|
|
||||||
return scanCandidates()
|
|
||||||
.map(this::createMod)
|
|
||||||
.filter(Optional::isPresent)
|
|
||||||
.map(Optional::get)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Stream<Path> scanCandidates();
|
|
||||||
}
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public abstract class AbstractJarFileModLocator extends AbstractJarFileLocator implements IModLocator
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public List<IModFile> scanMods()
|
||||||
|
{
|
||||||
|
return scanCandidates()
|
||||||
|
.map(this::createMod)
|
||||||
|
.filter(Optional::isPresent)
|
||||||
|
.map(Optional::get)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Stream<Path> scanCandidates();
|
||||||
|
}
|
||||||
+46
-22
@@ -24,8 +24,9 @@ import java.util.Optional;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
public abstract class AbstractModLocator implements IModLocator {
|
public abstract class AbstractModLocator implements IModLocator
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
protected static final String MODS_TOML = "META-INF/mods.toml";
|
protected static final String MODS_TOML = "META-INF/mods.toml";
|
||||||
protected static final String MANIFEST = "META-INF/MANIFEST.MF";
|
protected static final String MANIFEST = "META-INF/MANIFEST.MF";
|
||||||
|
|
||||||
@@ -40,12 +41,15 @@ public abstract class AbstractModLocator implements IModLocator {
|
|||||||
|
|
||||||
IModFile mod;
|
IModFile mod;
|
||||||
var type = sj.getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
var type = sj.getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
||||||
|
if (type == null) {
|
||||||
|
type = getDefaultJarModType();
|
||||||
|
}
|
||||||
if (sj.findFile(MODS_TOML).isPresent()) {
|
if (sj.findFile(MODS_TOML).isPresent()) {
|
||||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
||||||
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
||||||
} else if (type != null) {
|
} else if (type != null) {
|
||||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path);
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path);
|
||||||
mod = new ModFile(sj, this, this::manifestParser);
|
mod = new ModFile(sj, this, this::manifestParser, type);
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@@ -68,29 +72,49 @@ public abstract class AbstractModLocator implements IModLocator {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return new IModFileInfo() {
|
return new DefaultModFileInfo(mod, license, dummy);
|
||||||
@Override public List<IModInfo> getMods() { return Collections.emptyList(); }
|
|
||||||
@Override public List<LanguageSpec> requiredLanguageLoaders() { return Collections.emptyList(); }
|
|
||||||
@Override public boolean showAsResourcePack() { return false; }
|
|
||||||
@Override public Map<String, Object> getFileProperties() { return Collections.emptyMap(); }
|
|
||||||
@Override public String getLicense() { return license; }
|
|
||||||
@Override public IModFile getFile() { return mod; }
|
|
||||||
@Override public IConfigurable getConfig() { return dummy; }
|
|
||||||
|
|
||||||
// These Should never be called as it's only called from ModJarMetadata.version and we bypass that
|
|
||||||
@Override public String moduleName() { return mod.getSecureJar().name(); }
|
|
||||||
@Override public String versionString() { return null; }
|
|
||||||
@Override public List<String> usesServices() { return null; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "IModFileInfo(" + mod.getFilePath() + ")";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(final IModFile modFile) {
|
public boolean isValid(final IModFile modFile) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getDefaultJarModType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private record DefaultModFileInfo(IModFile mod, String license, IConfigurable configurable) implements IModFileInfo, IConfigurable {
|
||||||
|
@Override
|
||||||
|
public <T> Optional<T> getConfigElement(final String... strings)
|
||||||
|
{
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends IConfigurable> getConfigList(final String... strings)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public List<IModInfo> getMods() { return Collections.emptyList(); }
|
||||||
|
@Override public List<LanguageSpec> requiredLanguageLoaders() { return Collections.emptyList(); }
|
||||||
|
@Override public boolean showAsResourcePack() { return false; }
|
||||||
|
@Override public Map<String, Object> getFileProperties() { return Collections.emptyMap(); }
|
||||||
|
@Override
|
||||||
|
public String getLicense() { return license; }
|
||||||
|
|
||||||
|
@Override public IModFile getFile() { return mod; }
|
||||||
|
@Override public IConfigurable getConfig() { return configurable; }
|
||||||
|
|
||||||
|
// These Should never be called as it's only called from ModJarMetadata.version and we bypass that
|
||||||
|
@Override public String moduleName() { return mod.getSecureJar().name(); }
|
||||||
|
@Override public String versionString() { return null; }
|
||||||
|
@Override public List<String> usesServices() { return null; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "IModFileInfo(" + mod.getFilePath() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-23
@@ -5,18 +5,16 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.loading.ClasspathLocatorUtils;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -24,7 +22,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ClasspathLocator extends AbstractJarFileLocator {
|
public class ClasspathLocator extends AbstractJarFileModLocator {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
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 final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
@@ -58,7 +56,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
|
|||||||
final Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(resource);
|
final Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(resource);
|
||||||
while (resources.hasMoreElements()) {
|
while (resources.hasMoreElements()) {
|
||||||
URL url = resources.nextElement();
|
URL url = resources.nextElement();
|
||||||
Path path = findJarPathFor(resource, resource, url);
|
Path path = ClasspathLocatorUtils.findJarPathFor(resource, resource, url);
|
||||||
if (claimed.stream().anyMatch(path::equals) || !Files.exists(path) || Files.isDirectory(path))
|
if (claimed.stream().anyMatch(path::equals) || !Files.exists(path) || Files.isDirectory(path))
|
||||||
continue;
|
continue;
|
||||||
ret.add(path);
|
ret.add(path);
|
||||||
@@ -71,22 +69,4 @@ public class ClasspathLocator extends AbstractJarFileLocator {
|
|||||||
var launchTarget = (String) arguments.get("launchTarget");
|
var launchTarget = (String) arguments.get("launchTarget");
|
||||||
enabled = launchTarget != null && launchTarget.contains("dev");
|
enabled = launchTarget != null && launchTarget.contains("dev");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path findJarPathFor(final String resourceName, final String jarName, final URL resource) {
|
|
||||||
try {
|
|
||||||
Path path;
|
|
||||||
final URI uri = resource.toURI();
|
|
||||||
if (uri.getScheme().equals("jar") && uri.getRawSchemeSpecificPart().contains("!/")) {
|
|
||||||
int lastExcl = uri.getRawSchemeSpecificPart().lastIndexOf("!/");
|
|
||||||
path = Paths.get(new URI(uri.getRawSchemeSpecificPart().substring(0, lastExcl)));
|
|
||||||
} else {
|
|
||||||
path = Paths.get(new URI("file://"+uri.getRawSchemeSpecificPart().substring(0, uri.getRawSchemeSpecificPart().length()-resourceName.length())));
|
|
||||||
}
|
|
||||||
//LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
|
|
||||||
return path;
|
|
||||||
} catch (NullPointerException | URISyntaxException e) {
|
|
||||||
LOGGER.fatal(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName);
|
|
||||||
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+113
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
|
import net.minecraftforge.jarjar.selection.JarSelector;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class JarInJarDependencyLocator extends AbstractJarFileDependencyLocator
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "JarInJar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IModFile> scanMods(final Iterable<IModFile> loadedMods) {
|
||||||
|
final List<IModFile> sources = Lists.newArrayList();
|
||||||
|
loadedMods.forEach(sources::add);
|
||||||
|
|
||||||
|
|
||||||
|
final List<IModFile> dependenciesToLoad = JarSelector.detectAndSelect(
|
||||||
|
sources,
|
||||||
|
this::loadResourceFromModFile,
|
||||||
|
this::loadModFileFrom,
|
||||||
|
this::identifyMod,
|
||||||
|
this::exception
|
||||||
|
);
|
||||||
|
|
||||||
|
if (dependenciesToLoad.isEmpty()) {
|
||||||
|
LOGGER.info("No dependencies to load found. Skipping!");
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("Found {} dependencies adding them to mods collection", dependenciesToLoad.size());
|
||||||
|
return dependenciesToLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initArguments(final Map<String, ?> arguments)
|
||||||
|
{
|
||||||
|
// NO-OP, for now
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDefaultJarModType()
|
||||||
|
{
|
||||||
|
return IModFile.Type.GAMELIBRARY.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected EarlyLoadingException exception(Collection<JarSelector.ResolutionFailureInformation<IModFile>> failedDependencies)
|
||||||
|
{
|
||||||
|
|
||||||
|
final List<EarlyLoadingException.ExceptionData> errors = failedDependencies.stream()
|
||||||
|
.filter(entry -> !entry.sources().isEmpty()) //Should never be the case, but just to be sure
|
||||||
|
.map(entry -> new EarlyLoadingException.ExceptionData(
|
||||||
|
getErrorTranslationKey(entry),
|
||||||
|
entry.identifier().group() + ":" + entry.identifier().artifact(),
|
||||||
|
entry.sources()
|
||||||
|
.stream()
|
||||||
|
.flatMap(this::getModWithVersionRangeStream)
|
||||||
|
.map(this::formatError)
|
||||||
|
.collect(Collectors.joining(", ")))).toList();
|
||||||
|
|
||||||
|
return new EarlyLoadingException(failedDependencies.size() + " Dependency restrictions were not met.", null, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String getErrorTranslationKey(final JarSelector.ResolutionFailureInformation<IModFile> entry)
|
||||||
|
{
|
||||||
|
return entry.failureReason() == JarSelector.FailureReason.VERSION_RESOLUTION_FAILED
|
||||||
|
? "fml.dependencyloading.conflictingdependencies"
|
||||||
|
: "fml.dependencyloading.mismatchedcontaineddependencies";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Stream<ModWithVersionRange> getModWithVersionRangeStream(final JarSelector.SourceWithRequestedVersionRange<IModFile> file)
|
||||||
|
{
|
||||||
|
return file.sources().stream().map(IModFile::getModFileInfo)
|
||||||
|
.flatMap(modFileInfo -> modFileInfo.getMods().stream())
|
||||||
|
.map(modInfo -> new ModWithVersionRange(modInfo, file.requestedVersionRange(), file.includedVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String formatError(final ModWithVersionRange modWithVersionRange)
|
||||||
|
{
|
||||||
|
return "\u00a7e" + modWithVersionRange.modInfo().getModId() + "\u00a7r - \u00a74"
|
||||||
|
+ modWithVersionRange.versionRange().toString() + "\u00a74 - \u00a72"
|
||||||
|
+ modWithVersionRange.artifactVersion().toString() + "\u00a72";
|
||||||
|
}
|
||||||
|
|
||||||
|
private record ModWithVersionRange(IModInfo modInfo, VersionRange versionRange, ArtifactVersion artifactVersion) {}
|
||||||
|
}
|
||||||
+1
-1
@@ -15,7 +15,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class MavenDirectoryLocator extends AbstractJarFileLocator {
|
public class MavenDirectoryLocator extends AbstractJarFileModLocator {
|
||||||
private List<Path> modCoords;
|
private List<Path> modCoords;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class MinecraftLocator extends AbstractModLocator {
|
public class MinecraftLocator extends AbstractModLocator implements IModLocator {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+106
-26
@@ -5,10 +5,14 @@
|
|||||||
|
|
||||||
package net.minecraftforge.fml.loading.moddiscovery;
|
package net.minecraftforge.fml.loading.moddiscovery;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import cpw.mods.modlauncher.Launcher;
|
import cpw.mods.modlauncher.Launcher;
|
||||||
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
import cpw.mods.modlauncher.api.IModuleLayerManager;
|
||||||
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
import cpw.mods.modlauncher.util.ServiceLoaderUtils;
|
||||||
|
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
|
import net.minecraftforge.fml.loading.UniqueModListBuilder;
|
||||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||||
import net.minecraftforge.forgespi.Environment;
|
import net.minecraftforge.forgespi.Environment;
|
||||||
import net.minecraftforge.forgespi.locating.IModFile;
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
@@ -24,43 +28,119 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ModDiscoverer {
|
public class ModDiscoverer {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private final ServiceLoader<IModLocator> locators;
|
private final ServiceLoader<IModLocator> modLocators;
|
||||||
private final List<IModLocator> locatorList;
|
private final List<IModLocator> modLocatorList;
|
||||||
|
|
||||||
public ModDiscoverer(Map<String, ?> arguments) {
|
public ModDiscoverer(Map<String, ?> arguments) {
|
||||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new);
|
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new);
|
||||||
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v-> StartupMessageManager.locatorConsumer().orElseGet(()-> s->{}));
|
Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v-> StartupMessageManager.locatorConsumer().orElseGet(()-> s->{}));
|
||||||
final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow();
|
final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow();
|
||||||
locators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class);
|
modLocators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class);
|
||||||
locatorList = ServiceLoaderUtils.streamServiceLoader(()->locators, sce->LOGGER.error("Failed to load locator list", sce)).collect(Collectors.toList());
|
modLocatorList = ServiceLoaderUtils.streamServiceLoader(()-> modLocators, sce->LOGGER.error("Failed to load mod locator list", sce)).collect(Collectors.toList());
|
||||||
locatorList.forEach(l->l.initArguments(arguments));
|
modLocatorList.forEach(l->l.initArguments(arguments));
|
||||||
LOGGER.debug(LogMarkers.CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(",")));
|
if (LOGGER.isDebugEnabled(LogMarkers.CORE))
|
||||||
}
|
{
|
||||||
|
LOGGER.debug(LogMarkers.CORE, "Found Mod Locators : {}", modLocatorList.stream()
|
||||||
ModDiscoverer(List<IModLocator> locatorList) {
|
.map(modLocator -> "(%s:%s)".formatted(modLocator.name(),
|
||||||
this.locatorList = locatorList;
|
modLocator.getClass().getPackage().getImplementationVersion())).collect(Collectors.joining(",")));
|
||||||
this.locators = null;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModValidator discoverMods() {
|
public ModValidator discoverMods() {
|
||||||
LOGGER.debug(LogMarkers.SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", locatorList.size());
|
LOGGER.debug(LogMarkers.SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", modLocatorList.size());
|
||||||
var loadedFiles = new ArrayList<>();
|
List<ModFile> loadedFiles = new ArrayList<>();
|
||||||
for (IModLocator locator : locatorList) {
|
List<EarlyLoadingException.ExceptionData> discoveryErrorData = new ArrayList<>();
|
||||||
LOGGER.debug(LogMarkers.SCAN,"Trying locator {}", locator);
|
boolean successfullyLoadedMods = true;
|
||||||
var modFiles = locator.scanMods();
|
|
||||||
for (IModFile mf : modFiles) {
|
|
||||||
LOGGER.info(LogMarkers.SCAN, "Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator());
|
|
||||||
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType()));
|
|
||||||
}
|
|
||||||
loadedFiles.addAll(modFiles);
|
|
||||||
}
|
|
||||||
final var modFilesMap = loadedFiles.stream()
|
|
||||||
.map(ModFile.class::cast)
|
|
||||||
.collect(Collectors.groupingBy(IModFile::getType));
|
|
||||||
|
|
||||||
var validator = new ModValidator(modFilesMap);
|
//Loop all mod locators to get the prime mods to load from.
|
||||||
|
for (IModLocator locator : modLocatorList) {
|
||||||
|
try {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN,"Trying locator {}", locator);
|
||||||
|
var locatedFiles = locator.scanMods();
|
||||||
|
|
||||||
|
if (locatedFiles.stream().anyMatch(file -> !(file instanceof ModFile))) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "A mod locator returned a file which is not a ModFile instance!. They will be skipped!");
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLocatedFiles(loadedFiles, locatedFiles);
|
||||||
|
} catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to load mods with locator {}", locator, exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//First processing run of the mod list. Any duplicates will cause resolution failure and dependency loading will be skipped.
|
||||||
|
Map<IModFile.Type, List<ModFile>> modFilesMap = Maps.newHashMap();
|
||||||
|
try {
|
||||||
|
final UniqueModListBuilder modsUniqueListBuilder = new UniqueModListBuilder(loadedFiles);
|
||||||
|
final UniqueModListBuilder.UniqueModListData uniqueModsData = modsUniqueListBuilder.buildUniqueList();
|
||||||
|
|
||||||
|
//Grab the temporary results.
|
||||||
|
//This allows loading to continue to a base state, in case dependency loading fails.
|
||||||
|
modFilesMap = uniqueModsData.modFiles().stream()
|
||||||
|
.collect(Collectors.groupingBy(IModFile::getType));
|
||||||
|
loadedFiles = uniqueModsData.modFiles();
|
||||||
|
}
|
||||||
|
catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to build unique mod list after mod discovery.", exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
successfullyLoadedMods = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//We can continue loading if prime mods loaded successfully.
|
||||||
|
if (successfullyLoadedMods) {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN, "Successfully Loaded {} mods. Attempting to load dependencies...", loadedFiles.size());
|
||||||
|
for (IModLocator locator : modLocatorList) {
|
||||||
|
try {
|
||||||
|
LOGGER.debug(LogMarkers.SCAN,"Trying locator {}", locator);
|
||||||
|
final List<IModFile> locatedMods = ImmutableList.copyOf(loadedFiles);
|
||||||
|
|
||||||
|
var locatedFiles = locator.scanMods(locatedMods);
|
||||||
|
if (locatedFiles.stream().anyMatch(file -> !(file instanceof ModFile))) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "A dependency locator returned a file which is not a ModFile instance!. They will be skipped!");
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLocatedFiles(loadedFiles, locatedFiles);
|
||||||
|
}
|
||||||
|
catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to load dependencies with locator {}", locator, exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Second processing run of the mod list. Any duplicates will cause resolution failure and only the mods list will be loaded.
|
||||||
|
try {
|
||||||
|
final UniqueModListBuilder modsAndDependenciesUniqueListBuilder = new UniqueModListBuilder(loadedFiles);
|
||||||
|
final UniqueModListBuilder.UniqueModListData uniqueModsAndDependenciesData = modsAndDependenciesUniqueListBuilder.buildUniqueList();
|
||||||
|
|
||||||
|
//We now only need the mod files map, not the list.
|
||||||
|
modFilesMap = uniqueModsAndDependenciesData.modFiles().stream()
|
||||||
|
.collect(Collectors.groupingBy(IModFile::getType));
|
||||||
|
} catch (EarlyLoadingException exception) {
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Failed to build unique mod list after dependency discovery.", exception);
|
||||||
|
discoveryErrorData.addAll(exception.getAllData());
|
||||||
|
modFilesMap = loadedFiles.stream().collect(Collectors.groupingBy(IModFile::getType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//Failure notify the listeners.
|
||||||
|
LOGGER.error(LogMarkers.SCAN, "Mod Discovery failed. Skipping dependency discovery.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Validate the loading. With a deduplicated list, we can now successfully process the artifacts and load
|
||||||
|
//transformer plugins.
|
||||||
|
var validator = new ModValidator(modFilesMap, discoveryErrorData);
|
||||||
validator.stage1Validation();
|
validator.stage1Validation();
|
||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleLocatedFiles(final List<ModFile> loadedFiles, final List<IModFile> locatedFiles)
|
||||||
|
{
|
||||||
|
var locatedModFiles = locatedFiles.stream().filter(ModFile.class::isInstance).map(ModFile.class::cast).toList();
|
||||||
|
for (IModFile mf : locatedModFiles) {
|
||||||
|
LOGGER.info(LogMarkers.SCAN, "Found mod file {} of type {} with provider {}", mf.getFileName(), mf.getType(), mf.getLocator());
|
||||||
|
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType()));
|
||||||
|
}
|
||||||
|
loadedFiles.addAll(locatedModFiles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,8 @@ import net.minecraftforge.forgespi.locating.IModLocator;
|
|||||||
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -51,9 +53,9 @@ public class ModFile implements IModFile {
|
|||||||
private Throwable scanError;
|
private Throwable scanError;
|
||||||
private final SecureJar jar;
|
private final SecureJar jar;
|
||||||
private final Type modFileType;
|
private final Type modFileType;
|
||||||
private final Manifest manifest;
|
private final Manifest manifest;
|
||||||
private final IModLocator locator;
|
private final IModLocator locator;
|
||||||
private IModFileInfo modFileInfo;
|
private IModFileInfo modFileInfo;
|
||||||
private ModFileScanData fileModFileScanData;
|
private ModFileScanData fileModFileScanData;
|
||||||
private CompletableFuture<ModFileScanData> futureScanResult;
|
private CompletableFuture<ModFileScanData> futureScanResult;
|
||||||
private List<CoreModFile> coreMods;
|
private List<CoreModFile> coreMods;
|
||||||
@@ -63,14 +65,18 @@ public class ModFile implements IModFile {
|
|||||||
private SecureJar.Status securityStatus;
|
private SecureJar.Status securityStatus;
|
||||||
|
|
||||||
public ModFile(final SecureJar jar, final IModLocator locator, final ModFileFactory.ModFileInfoParser parser) {
|
public ModFile(final SecureJar jar, final IModLocator locator, final ModFileFactory.ModFileInfoParser parser) {
|
||||||
|
this(jar, locator, parser, parseType(jar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModFile(final SecureJar jar, final IModLocator locator, final ModFileFactory.ModFileInfoParser parser, String type) {
|
||||||
this.locator = locator;
|
this.locator = locator;
|
||||||
this.jar = jar;
|
this.jar = jar;
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
|
|
||||||
manifest = this.jar.getManifest();
|
manifest = this.jar.getManifest();
|
||||||
final Optional<String> value = Optional.ofNullable(manifest.getMainAttributes().getValue(TYPE));
|
modFileType = Type.valueOf(type);
|
||||||
modFileType = Type.valueOf(value.orElse("MOD"));
|
|
||||||
jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("0.0NONE");
|
jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("0.0NONE");
|
||||||
|
this.modFileInfo = ModFileParser.readModList(this, this.parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,4 +207,15 @@ public class ModFile implements IModFile {
|
|||||||
public void setSecurityStatus(final SecureJar.Status status) {
|
public void setSecurityStatus(final SecureJar.Status status) {
|
||||||
this.securityStatus = status;
|
this.securityStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArtifactVersion getJarVersion()
|
||||||
|
{
|
||||||
|
return new DefaultArtifactVersion(this.jarVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String parseType(final SecureJar jar) {
|
||||||
|
final Manifest m = jar.getManifest();
|
||||||
|
final Optional<String> value = Optional.ofNullable(m.getMainAttributes().getValue(TYPE));
|
||||||
|
return value.orElse("MOD");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+14
-8
@@ -26,13 +26,15 @@ public class ModValidator {
|
|||||||
private final List<ModFile> candidateMods;
|
private final List<ModFile> candidateMods;
|
||||||
private LoadingModList loadingModList;
|
private LoadingModList loadingModList;
|
||||||
private List<ModFile> brokenFiles;
|
private List<ModFile> brokenFiles;
|
||||||
|
private final List<EarlyLoadingException.ExceptionData> discoveryErrorData;
|
||||||
|
|
||||||
public ModValidator(final Map<IModFile.Type, List<ModFile>> modFiles) {
|
public ModValidator(final Map<IModFile.Type, List<ModFile>> modFiles, final List<EarlyLoadingException.ExceptionData> discoveryErrorData) {
|
||||||
this.modFiles = modFiles;
|
this.modFiles = modFiles;
|
||||||
this.candidateMods = lst(modFiles.get(IModFile.Type.MOD));
|
this.candidateMods = lst(modFiles.get(IModFile.Type.MOD));
|
||||||
this.candidateMods.addAll(lst(modFiles.get(IModFile.Type.GAMELIBRARY)));
|
this.candidateMods.addAll(lst(modFiles.get(IModFile.Type.GAMELIBRARY)));
|
||||||
this.candidatePlugins = lst(modFiles.get(IModFile.Type.LANGPROVIDER));
|
this.candidatePlugins = lst(modFiles.get(IModFile.Type.LANGPROVIDER));
|
||||||
this.candidatePlugins.addAll(lst(modFiles.get(IModFile.Type.LIBRARY)));
|
this.candidatePlugins.addAll(lst(modFiles.get(IModFile.Type.LIBRARY)));
|
||||||
|
this.discoveryErrorData = discoveryErrorData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ModFile> lst(List<ModFile> files) {
|
private static List<ModFile> lst(List<ModFile> files) {
|
||||||
@@ -50,22 +52,22 @@ public class ModValidator {
|
|||||||
final List<ModFile> brokenFiles = new ArrayList<>();
|
final List<ModFile> brokenFiles = new ArrayList<>();
|
||||||
for (Iterator<ModFile> iterator = mods.iterator(); iterator.hasNext(); )
|
for (Iterator<ModFile> iterator = mods.iterator(); iterator.hasNext(); )
|
||||||
{
|
{
|
||||||
ModFile mod = iterator.next();
|
ModFile modFile = iterator.next();
|
||||||
if (!mod.getLocator().isValid(mod) || !mod.identifyMods()) {
|
if (!modFile.getLocator().isValid(modFile) || !modFile.identifyMods()) {
|
||||||
LOGGER.warn(LogMarkers.SCAN, "File {} has been ignored - it is invalid", mod.getFilePath());
|
LOGGER.warn(LogMarkers.SCAN, "File {} has been ignored - it is invalid", modFile.getFilePath());
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
brokenFiles.add(mod);
|
brokenFiles.add(modFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return brokenFiles;
|
return brokenFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITransformationService.Resource getPluginResources() {
|
public ITransformationService.Resource getPluginResources() {
|
||||||
return new ITransformationService.Resource(IModuleLayerManager.Layer.PLUGIN, this.candidatePlugins.stream().map(ModFile::getSecureJar).toList());
|
return new ITransformationService.Resource(IModuleLayerManager.Layer.PLUGIN, this.candidatePlugins.stream().map(IModFile::getSecureJar).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITransformationService.Resource getModResources() {
|
public ITransformationService.Resource getModResources() {
|
||||||
return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().map(ModFile::getSecureJar).toList());
|
return new ITransformationService.Resource(IModuleLayerManager.Layer.GAME, this.candidateMods.stream().map(IModFile::getSecureJar).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EarlyLoadingException.ExceptionData> validateLanguages() {
|
private List<EarlyLoadingException.ExceptionData> validateLanguages() {
|
||||||
@@ -84,7 +86,11 @@ public class ModValidator {
|
|||||||
|
|
||||||
public BackgroundScanHandler stage2Validation() {
|
public BackgroundScanHandler stage2Validation() {
|
||||||
var errors = validateLanguages();
|
var errors = validateLanguages();
|
||||||
loadingModList = ModSorter.sort(candidateMods, errors);
|
|
||||||
|
var allErrors = new ArrayList<>(errors);
|
||||||
|
allErrors.addAll(this.discoveryErrorData);
|
||||||
|
|
||||||
|
loadingModList = ModSorter.sort(candidateMods, allErrors);
|
||||||
loadingModList.addCoreMods();
|
loadingModList.addCoreMods();
|
||||||
loadingModList.addAccessTransformers();
|
loadingModList.addAccessTransformers();
|
||||||
loadingModList.setBrokenFiles(brokenFiles);
|
loadingModList.setBrokenFiles(brokenFiles);
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck;
|
|||||||
/**
|
/**
|
||||||
* Support loading mods located in JAR files in the mods folder
|
* Support loading mods located in JAR files in the mods folder
|
||||||
*/
|
*/
|
||||||
public class ModsFolderLocator extends AbstractJarFileLocator {
|
public class ModsFolderLocator extends AbstractJarFileModLocator {
|
||||||
private static final String SUFFIX = ".jar";
|
private static final String SUFFIX = ".jar";
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private final Path modFolder;
|
private final Path modFolder;
|
||||||
|
|||||||
+2
-1
@@ -45,9 +45,10 @@ public abstract class CommonClientLaunchHandler extends CommonLaunchHandler {
|
|||||||
|
|
||||||
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
||||||
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
||||||
|
var lowcodelang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "lowcodelanguage", "", "", vers.mcAndForgeVersion());
|
||||||
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
||||||
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), (a,b) -> true, modstream.build().toList(), List.of(fmlcore, javafmllang, mclang));
|
return new LocatedPaths(mcstream.build().toList(), (a,b) -> true, modstream.build().toList(), List.of(fmlcore, javafmllang, lowcodelang, mclang));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods);
|
protected abstract void processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, Stream.Builder<List<Path>> mods);
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ public abstract class CommonDevLaunchHandler extends CommonLaunchHandler {
|
|||||||
protected List<Path> getFmlStuff(String[] classpath) {
|
protected List<Path> getFmlStuff(String[] classpath) {
|
||||||
// We also want the FML things, fmlcore, javafmllanguage, mclanguage, I don't like hard coding these, but hey whatever works for now.
|
// We also want the FML things, fmlcore, javafmllanguage, mclanguage, I don't like hard coding these, but hey whatever works for now.
|
||||||
return Arrays.stream(classpath)
|
return Arrays.stream(classpath)
|
||||||
.filter(e -> e.contains("fmlcore") || e.contains("javafmllanguage") || e.contains("mclanguage"))
|
.filter(e -> e.contains("fmlcore") || e.contains("javafmllanguage") || e.contains("lowcodelanguage") || e.contains("mclanguage"))
|
||||||
.map(Paths::get)
|
.map(Paths::get)
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -55,9 +55,10 @@ public abstract class CommonServerLaunchHandler extends CommonLaunchHandler {
|
|||||||
|
|
||||||
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
var fmlcore = LibraryFinder.findPathForMaven(vers.forgeGroup(), "fmlcore", "", "", vers.mcAndForgeVersion());
|
||||||
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
var javafmllang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "javafmllanguage", "", "", vers.mcAndForgeVersion());
|
||||||
|
var lowcodelang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "lowcodelanguage", "", "", vers.mcAndForgeVersion());
|
||||||
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
var mclang = LibraryFinder.findPathForMaven(vers.forgeGroup(), "mclanguage", "", "", vers.mcAndForgeVersion());
|
||||||
|
|
||||||
return new LocatedPaths(mcstream.build().toList(), filter, modstream.build().toList(), List.of(fmlcore, javafmllang, mclang));
|
return new LocatedPaths(mcstream.build().toList(), filter, modstream.build().toList(), List.of(fmlcore, javafmllang, lowcodelang, mclang));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract BiPredicate<String, String> processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, BiPredicate<String, String> filter, Stream.Builder<List<Path>> mods);
|
protected abstract BiPredicate<String, String> processMCStream(VersionInfo versionInfo, Stream.Builder<Path> mc, BiPredicate<String, String> filter, Stream.Builder<List<Path>> mods);
|
||||||
|
|||||||
+2
-1
@@ -1 +1,2 @@
|
|||||||
net.minecraftforge.fml.loading.ModDirTransformerDiscoverer
|
net.minecraftforge.fml.loading.ModDirTransformerDiscoverer
|
||||||
|
net.minecraftforge.fml.loading.ClasspathTransformerDiscoverer
|
||||||
+1
@@ -3,3 +3,4 @@ net.minecraftforge.fml.loading.moddiscovery.MavenDirectoryLocator
|
|||||||
net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator
|
net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator
|
||||||
net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator
|
net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator
|
||||||
net.minecraftforge.fml.loading.moddiscovery.ClasspathLocator
|
net.minecraftforge.fml.loading.moddiscovery.ClasspathLocator
|
||||||
|
net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.github.ben-manes.versions'
|
||||||
|
id 'org.javamodularity.moduleplugin' version '1.8.3' apply false
|
||||||
|
id 'org.cadixdev.licenser'
|
||||||
|
}
|
||||||
|
apply plugin: 'java-library'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
apply plugin: 'org.javamodularity.moduleplugin'
|
||||||
|
|
||||||
|
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
|
||||||
|
|
||||||
|
java.withSourcesJar()
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly('org.jetbrains:annotations:21.0.1')
|
||||||
|
implementation(project(':fmlloader'))
|
||||||
|
implementation(project(':fmlcore'))
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
MANIFESTS = [
|
||||||
|
'': [
|
||||||
|
'FMLModType': 'LANGPROVIDER',
|
||||||
|
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
|
'Git-Commit': GIT_INFO.abbreviatedId,
|
||||||
|
'Git-Branch': GIT_INFO.branch,
|
||||||
|
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}",
|
||||||
|
] as LinkedHashMap,
|
||||||
|
'net/minecraftforge/fml/loading/': [
|
||||||
|
'Specification-Title': 'FMLLoader',
|
||||||
|
'Specification-Vendor': 'Forge Development LLC',
|
||||||
|
'Specification-Version': '1',
|
||||||
|
'Implementation-Title': 'FML Loader',
|
||||||
|
'Implementation-Version': '1.0',
|
||||||
|
'Implementation-Vendor': 'Forge'
|
||||||
|
] as LinkedHashMap
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
jar.doFirst {
|
||||||
|
MANIFESTS.each { pkg, values ->
|
||||||
|
if (pkg == '')
|
||||||
|
manifest.attributes(values)
|
||||||
|
else
|
||||||
|
manifest.attributes(values, pkg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs << '-Xlint:unchecked'
|
||||||
|
}
|
||||||
|
|
||||||
|
license {
|
||||||
|
header = rootProject.file('LICENSE-header.txt')
|
||||||
|
include 'net/minecraftforge/'
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing.publications.mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.lowcodemod;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.IExtensionPoint;
|
||||||
|
import net.minecraftforge.fml.ModContainer;
|
||||||
|
import net.minecraftforge.fml.event.IModBusEvent;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
||||||
|
|
||||||
|
public class LowCodeModContainer extends ModContainer
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private final ModFileScanData scanResults;
|
||||||
|
private Object modInstance;
|
||||||
|
|
||||||
|
public LowCodeModContainer(IModInfo info, ModFileScanData modFileScanResults, ModuleLayer gameLayer)
|
||||||
|
{
|
||||||
|
super(info);
|
||||||
|
LOGGER.debug(LOADING, "Creating LowCodeModContainer for {}", info.getModId());
|
||||||
|
this.scanResults = modFileScanResults;
|
||||||
|
this.modInstance = new Object();
|
||||||
|
this.contextExtension = () -> null;
|
||||||
|
this.extensionPoints.remove(IExtensionPoint.DisplayTest.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(Object mod)
|
||||||
|
{
|
||||||
|
return mod == modInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getMod()
|
||||||
|
{
|
||||||
|
return modInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <T extends Event & IModBusEvent> void acceptEvent(final T e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Forge Development LLC and contributors
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.minecraftforge.fml.lowcodemod;
|
||||||
|
|
||||||
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
|
import net.minecraftforge.fml.ModLoadingException;
|
||||||
|
import net.minecraftforge.fml.ModLoadingStage;
|
||||||
|
import net.minecraftforge.forgespi.language.ILifecycleEvent;
|
||||||
|
import net.minecraftforge.forgespi.language.IModLanguageProvider;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.Logging.LOADING;
|
||||||
|
|
||||||
|
public class LowCodeModLanguageProvider implements IModLanguageProvider
|
||||||
|
{
|
||||||
|
private record LowCodeModTarget(String modId) implements IModLanguageProvider.IModLanguageLoader
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> T loadMod(final IModInfo info, final ModFileScanData modFileScanResults, ModuleLayer gameLayer)
|
||||||
|
{
|
||||||
|
// This language class is loaded in the system level classloader - before the game even starts
|
||||||
|
// So we must treat container construction as an arms length operation, and load the container
|
||||||
|
// in the classloader of the game - the context classloader is appropriate here.
|
||||||
|
try {
|
||||||
|
final Class<?> fmlContainer = Class.forName("net.minecraftforge.fml.lowcodemod.LowCodeModContainer", true, Thread.currentThread().getContextClassLoader());
|
||||||
|
LOGGER.debug(LOADING, "Loading LowCodeModContainer from classloader {} - got {}", Thread.currentThread().getContextClassLoader(), fmlContainer.getClassLoader());
|
||||||
|
final Constructor<?> constructor = fmlContainer.getConstructor(IModInfo.class, ModFileScanData.class, ModuleLayer.class);
|
||||||
|
return (T) constructor.newInstance(info, modFileScanResults, gameLayer);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
LOGGER.fatal(LOADING, "Failed to build mod", e);
|
||||||
|
if (e.getTargetException() instanceof ModLoadingException mle) {
|
||||||
|
throw mle;
|
||||||
|
} else {
|
||||||
|
throw new ModLoadingException(info, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmodclass", e);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
|
LOGGER.fatal(LOADING, "Unable to load FMLModContainer, wut?", e);
|
||||||
|
final Class<RuntimeException> mle = (Class<RuntimeException>) LamdbaExceptionUtils.uncheck(() -> Class.forName("net.minecraftforge.fml.ModLoadingException", true, Thread.currentThread().getContextClassLoader()));
|
||||||
|
final Class<ModLoadingStage> mls = (Class<ModLoadingStage>) LamdbaExceptionUtils.uncheck(() -> Class.forName("net.minecraftforge.fml.ModLoadingStage", true, Thread.currentThread().getContextClassLoader()));
|
||||||
|
throw LamdbaExceptionUtils.uncheck(() -> LamdbaExceptionUtils.uncheck(() -> mle.getConstructor(IModInfo.class, mls, String.class, Throwable.class)).newInstance(info, Enum.valueOf(mls, "CONSTRUCT"), "fml.modloading.failedtoloadmodclass", e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "lowcodefml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Consumer<ModFileScanData> getFileVisitor()
|
||||||
|
{
|
||||||
|
return scanResult ->
|
||||||
|
{
|
||||||
|
final Map<String, LowCodeModTarget> modTargetMap = scanResult.getIModInfoData().stream()
|
||||||
|
.flatMap(fi->fi.getMods().stream())
|
||||||
|
.map(IModInfo::getModId)
|
||||||
|
.map(LowCodeModTarget::new)
|
||||||
|
.collect(Collectors.toMap(LowCodeModTarget::modId, Function.identity(), (a, b)->a));
|
||||||
|
scanResult.addLanguageLoader(modTargetMap);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R extends ILifecycleEvent<R>> void consumeLifecycleEvent(final Supplier<R> consumeEvent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
net.minecraftforge.fml.lowcodemod.LowCodeModLanguageProvider
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"pack": {
|
"pack": {
|
||||||
"description": "examplemod resources",
|
"description": "examplemod resources",
|
||||||
"pack_format": 9
|
"pack_format": 9,
|
||||||
|
"forge:resource_pack_format": 8,
|
||||||
|
"forge:data_pack_format": 9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
this.f_85648_.clear();
|
this.f_85648_.clear();
|
||||||
return Pair.of(bufferbuilder$drawstate, bytebuffer);
|
return Pair.of(bufferbuilder$drawstate, bytebuffer);
|
||||||
}
|
}
|
||||||
@@ -444,4 +_,15 @@
|
@@ -444,4 +_,16 @@
|
||||||
this.f_166822_ = p_166829_;
|
this.f_166822_ = p_166829_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,5 +22,6 @@
|
|||||||
+ this.f_85652_ += buffer.limit();
|
+ this.f_85652_ += buffer.limit();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ @Override
|
||||||
+ public VertexFormat getVertexFormat() { return this.f_85658_; }
|
+ public VertexFormat getVertexFormat() { return this.f_85658_; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
--- a/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java
|
||||||
|
+++ b/com/mojang/blaze3d/vertex/SheetedDecalTextureGenerator.java
|
||||||
|
@@ -91,4 +_,6 @@
|
||||||
|
this.f_85878_ = p_85902_;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ public VertexFormat getVertexFormat() { return f_85867_.getVertexFormat(); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
--- a/com/mojang/blaze3d/vertex/VertexMultiConsumer.java
|
||||||
|
+++ b/com/mojang/blaze3d/vertex/VertexMultiConsumer.java
|
||||||
|
@@ -91,6 +_,8 @@
|
||||||
|
this.f_86171_.m_141991_();
|
||||||
|
this.f_86172_.m_141991_();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ public VertexFormat getVertexFormat() { return f_86171_.getVertexFormat(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@@ -176,6 +_,13 @@
|
||||||
|
|
||||||
|
public void m_141991_() {
|
||||||
|
this.m_167144_(VertexConsumer::m_141991_);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public VertexFormat getVertexFormat()
|
||||||
|
+ {
|
||||||
|
+ if (f_167071_.length > 0)
|
||||||
|
+ return f_167071_[0].getVertexFormat();
|
||||||
|
+ return DefaultVertexFormat.f_85811_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,3 +19,13 @@
|
|||||||
if (SharedConstants.f_136183_) {
|
if (SharedConstants.f_136183_) {
|
||||||
throw illegalargumentexception;
|
throw illegalargumentexception;
|
||||||
}
|
}
|
||||||
|
@@ -649,7 +_,8 @@
|
||||||
|
|
||||||
|
public static <T, R> Function<T, R> m_143827_(final Function<T, R> p_143828_) {
|
||||||
|
return new Function<T, R>() {
|
||||||
|
- private final Map<T, R> f_143852_ = Maps.newHashMap();
|
||||||
|
+ // FORGE: Allow using memoized functions from multiple threads.
|
||||||
|
+ private final Map<T, R> f_143852_ = Maps.newConcurrentMap();
|
||||||
|
|
||||||
|
public R apply(T p_211578_) {
|
||||||
|
return this.f_143852_.computeIfAbsent(p_211578_, p_143828_);
|
||||||
@@ -1,5 +1,14 @@
|
|||||||
--- a/net/minecraft/client/ClientRecipeBook.java
|
--- a/net/minecraft/client/ClientRecipeBook.java
|
||||||
+++ b/net/minecraft/client/ClientRecipeBook.java
|
+++ b/net/minecraft/client/ClientRecipeBook.java
|
||||||
|
@@ -52,7 +_,7 @@
|
||||||
|
for(Recipe<?> recipe : p_90643_) {
|
||||||
|
if (!recipe.m_5598_() && !recipe.m_142505_()) {
|
||||||
|
RecipeBookCategories recipebookcategories = m_90646_(recipe);
|
||||||
|
- String s = recipe.m_6076_();
|
||||||
|
+ String s = recipe.m_6076_().isEmpty() ? recipe.m_6423_().toString() : recipe.m_6076_(); // FORGE: Group value defaults to the recipe's ID if the recipe's explicit group is empty.
|
||||||
|
if (s.isEmpty()) {
|
||||||
|
map.computeIfAbsent(recipebookcategories, (p_90645_) -> {
|
||||||
|
return Lists.newArrayList();
|
||||||
@@ -104,6 +_,8 @@
|
@@ -104,6 +_,8 @@
|
||||||
} else if (recipetype == RecipeType.f_44113_) {
|
} else if (recipetype == RecipeType.f_44113_) {
|
||||||
return RecipeBookCategories.SMITHING;
|
return RecipeBookCategories.SMITHING;
|
||||||
|
|||||||
@@ -41,15 +41,21 @@
|
|||||||
this.f_91068_ = new KeyboardHandler(this);
|
this.f_91068_ = new KeyboardHandler(this);
|
||||||
this.f_91068_.m_90887_(this.f_90990_.m_85439_());
|
this.f_91068_.m_90887_(this.f_90990_.m_85439_());
|
||||||
RenderSystem.m_69580_(this.f_91066_.f_92035_, false);
|
RenderSystem.m_69580_(this.f_91066_.f_92035_, false);
|
||||||
@@ -456,6 +_,7 @@
|
@@ -456,6 +_,8 @@
|
||||||
this.f_91042_.m_83931_(0.0F, 0.0F, 0.0F, 0.0F);
|
this.f_91042_.m_83931_(0.0F, 0.0F, 0.0F, 0.0F);
|
||||||
this.f_91042_.m_83954_(f_91002_);
|
this.f_91042_.m_83954_(f_91002_);
|
||||||
this.f_91036_ = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
|
this.f_91036_ = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
|
||||||
|
+ net.minecraftforge.client.RecipeBookRegistry.initDefaultValues();
|
||||||
+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_);
|
+ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_);
|
||||||
this.f_91038_.m_10506_();
|
this.f_91038_.m_10506_();
|
||||||
this.f_91066_.m_92145_(this.f_91038_);
|
this.f_91066_.m_92145_(this.f_91038_);
|
||||||
this.f_91039_ = new LanguageManager(this.f_91066_.f_92075_);
|
this.f_91039_ = new LanguageManager(this.f_91066_.f_92075_);
|
||||||
@@ -504,6 +_,7 @@
|
@@ -500,10 +_,12 @@
|
||||||
|
this.f_91052_ = new BlockRenderDispatcher(this.f_91051_.m_119430_(), blockentitywithoutlevelrenderer, this.f_91040_);
|
||||||
|
this.f_91036_.m_7217_(this.f_91052_);
|
||||||
|
this.f_91060_ = new LevelRenderer(this, this.f_90993_);
|
||||||
|
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.RenderLevelStageEvent.RegisterStageEvent());
|
||||||
|
this.f_91036_.m_7217_(this.f_91060_);
|
||||||
this.m_91271_();
|
this.m_91271_();
|
||||||
this.f_91036_.m_7217_(this.f_90997_);
|
this.f_91036_.m_7217_(this.f_90997_);
|
||||||
this.f_91061_ = new ParticleEngine(this.f_91073_, this.f_90987_);
|
this.f_91061_ = new ParticleEngine(this.f_91073_, this.f_90987_);
|
||||||
@@ -214,16 +220,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1460,6 +_,8 @@
|
@@ -1460,14 +_,20 @@
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
- switch(this.f_91077_.m_6662_()) {
|
||||||
+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND);
|
+ net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.f_91066_.f_92096_, InteractionHand.MAIN_HAND);
|
||||||
|
+ HitResult.Type hitType = this.f_91077_.m_6662_();
|
||||||
|
+ if(this.f_91077_ instanceof EntityHitResult entityHit) { // Forge: Perform attack range checks here, instead of in GameRenderer#pick, so extended-reach interactions work.
|
||||||
|
+ if(!f_91074_.canHit(entityHit.m_82443_(), 0)) hitType = HitResult.Type.MISS; // No padding in client code.
|
||||||
|
+ }
|
||||||
+ if (!inputEvent.isCanceled())
|
+ if (!inputEvent.isCanceled())
|
||||||
switch(this.f_91077_.m_6662_()) {
|
+ switch(hitType) {
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_());
|
this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_());
|
||||||
@@ -1467,7 +_,7 @@
|
break;
|
||||||
case BLOCK:
|
case BLOCK:
|
||||||
BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_;
|
BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_;
|
||||||
BlockPos blockpos = blockhitresult.m_82425_();
|
BlockPos blockpos = blockhitresult.m_82425_();
|
||||||
@@ -255,6 +266,14 @@
|
|||||||
ItemStack itemstack = this.f_91074_.m_21120_(interactionhand);
|
ItemStack itemstack = this.f_91074_.m_21120_(interactionhand);
|
||||||
if (this.f_91077_ != null) {
|
if (this.f_91077_ != null) {
|
||||||
switch(this.f_91077_.m_6662_()) {
|
switch(this.f_91077_.m_6662_()) {
|
||||||
|
@@ -1506,6 +_,7 @@
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if(!this.f_91074_.canInteractWith(entityhitresult.m_82443_(), 0)) break; //Forge: Entity may be traced via attack range, but the player may not have sufficient reach. No padding in client code.
|
||||||
|
InteractionResult interactionresult = this.f_91072_.m_105230_(this.f_91074_, entity, entityhitresult, interactionhand);
|
||||||
|
if (!interactionresult.m_19077_()) {
|
||||||
|
interactionresult = this.f_91072_.m_105226_(this.f_91074_, entity, interactionhand);
|
||||||
@@ -1513,6 +_,7 @@
|
@@ -1513,6 +_,7 @@
|
||||||
|
|
||||||
if (interactionresult.m_19077_()) {
|
if (interactionresult.m_19077_()) {
|
||||||
@@ -488,15 +507,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2713,7 +_,7 @@
|
@@ -2713,8 +_,8 @@
|
||||||
return this.f_90993_;
|
return this.f_90993_;
|
||||||
}
|
}
|
||||||
|
|
||||||
- private static Pack m_167933_(String p_167934_, Component p_167935_, boolean p_167936_, Supplier<PackResources> p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_) {
|
- private static Pack m_167933_(String p_167934_, Component p_167935_, boolean p_167936_, Supplier<PackResources> p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_) {
|
||||||
|
- int i = p_167938_.m_10374_();
|
||||||
+ private static Pack createClientPackAdapter(String p_167934_, Component p_167935_, boolean p_167936_, Supplier<PackResources> p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_, boolean hidden) {
|
+ private static Pack createClientPackAdapter(String p_167934_, Component p_167935_, boolean p_167936_, Supplier<PackResources> p_167937_, PackMetadataSection p_167938_, Pack.Position p_167939_, PackSource p_167940_, boolean hidden) {
|
||||||
int i = p_167938_.m_10374_();
|
+ int i = p_167938_.getPackFormat(PackType.CLIENT_RESOURCES);
|
||||||
Supplier<PackResources> supplier = p_167937_;
|
Supplier<PackResources> supplier = p_167937_;
|
||||||
if (i <= 3) {
|
if (i <= 3) {
|
||||||
|
supplier = m_91330_(p_167937_);
|
||||||
@@ -2724,7 +_,7 @@
|
@@ -2724,7 +_,7 @@
|
||||||
supplier = m_91352_(supplier);
|
supplier = m_91352_(supplier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
--- a/net/minecraft/client/gui/Gui.java
|
--- a/net/minecraft/client/gui/Gui.java
|
||||||
+++ b/net/minecraft/client/gui/Gui.java
|
+++ b/net/minecraft/client/gui/Gui.java
|
||||||
|
@@ -411,6 +_,7 @@
|
||||||
|
if (this.f_92986_.f_91076_ != null && this.f_92986_.f_91076_ instanceof LivingEntity && f >= 1.0F) {
|
||||||
|
flag = this.f_92986_.f_91074_.m_36333_() > 5.0F;
|
||||||
|
flag &= this.f_92986_.f_91076_.m_6084_();
|
||||||
|
+ flag &= this.f_92986_.f_91074_.canHit(this.f_92986_.f_91076_, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int j = this.f_92978_ / 2 - 7 + 16;
|
||||||
@@ -463,6 +_,10 @@
|
@@ -463,6 +_,10 @@
|
||||||
|
|
||||||
for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
|
for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
|
||||||
@@ -19,7 +27,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,7 +_,8 @@
|
@@ -620,12 +_,13 @@
|
||||||
|
public void m_93069_(PoseStack p_93070_) {
|
||||||
|
this.f_92986_.m_91307_().m_6180_("selectedItemName");
|
||||||
|
if (this.f_92993_ > 0 && !this.f_92994_.m_41619_()) {
|
||||||
|
- MutableComponent mutablecomponent = (new TextComponent("")).m_7220_(this.f_92994_.m_41786_()).m_130940_(this.f_92994_.m_41791_().f_43022_);
|
||||||
|
+ MutableComponent mutablecomponent = (new TextComponent("")).m_7220_(this.f_92994_.m_41786_()).m_130938_(this.f_92994_.m_41791_().getStyleModifier());
|
||||||
|
if (this.f_92994_.m_41788_()) {
|
||||||
mutablecomponent.m_130940_(ChatFormatting.ITALIC);
|
mutablecomponent.m_130940_(ChatFormatting.ITALIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
--- a/net/minecraft/client/gui/screens/inventory/LoomScreen.java
|
||||||
|
+++ b/net/minecraft/client/gui/screens/inventory/LoomScreen.java
|
||||||
|
@@ -125,20 +_,20 @@
|
||||||
|
int l2 = j + 13;
|
||||||
|
int l = this.f_99072_ + 16;
|
||||||
|
|
||||||
|
- for(int i1 = this.f_99072_; i1 < l && i1 < BannerPattern.f_58526_ - BannerPattern.f_58527_; ++i1) {
|
||||||
|
+ for(int i1 = this.f_99072_; i1 < l && i1 < net.minecraftforge.common.ForgeHooks.getNonPatternItemCount(); ++i1) {
|
||||||
|
int j1 = i1 - this.f_99072_;
|
||||||
|
int k1 = j2 + j1 % 4 * 14;
|
||||||
|
int l1 = l2 + j1 / 4 * 14;
|
||||||
|
RenderSystem.m_157456_(0, f_99060_);
|
||||||
|
int i2 = this.f_97727_;
|
||||||
|
- if (i1 == this.f_97732_.m_39891_()) {
|
||||||
|
+ if (net.minecraftforge.common.ForgeHooks.getActualPatternIndex(i1) == this.f_97732_.m_39891_()) {
|
||||||
|
i2 += 14;
|
||||||
|
} else if (p_99101_ >= k1 && p_99102_ >= l1 && p_99101_ < k1 + 14 && p_99102_ < l1 + 14) {
|
||||||
|
i2 += 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.m_93228_(p_99099_, k1, l1, 0, i2, 14, 14);
|
||||||
|
- this.m_99108_(i1, k1, l1);
|
||||||
|
+ this.m_99108_(net.minecraftforge.common.ForgeHooks.getActualPatternIndex(i1), k1, l1);
|
||||||
|
}
|
||||||
|
} else if (this.f_99068_) {
|
||||||
|
int k2 = i + 60;
|
||||||
|
@@ -209,7 +_,7 @@
|
||||||
|
int j = i + 56;
|
||||||
|
this.f_99070_ = ((float)p_99088_ - (float)i - 7.5F) / ((float)(j - i) - 15.0F);
|
||||||
|
this.f_99070_ = Mth.m_14036_(this.f_99070_, 0.0F, 1.0F);
|
||||||
|
- int k = f_99061_ - 4;
|
||||||
|
+ int k = net.minecraftforge.common.ForgeHooks.getTotalPatternRows() - 4;
|
||||||
|
int l = (int)((double)(this.f_99070_ * (float)k) + 0.5D);
|
||||||
|
if (l < 0) {
|
||||||
|
l = 0;
|
||||||
|
@@ -224,7 +_,7 @@
|
||||||
|
|
||||||
|
public boolean m_6050_(double p_99079_, double p_99080_, double p_99081_) {
|
||||||
|
if (this.f_99067_) {
|
||||||
|
- int i = f_99061_ - 4;
|
||||||
|
+ int i = net.minecraftforge.common.ForgeHooks.getTotalPatternRows() - 4;
|
||||||
|
float f = (float)p_99081_ / (float)i;
|
||||||
|
this.f_99070_ = Mth.m_14036_(this.f_99070_ - f, 0.0F, 1.0F);
|
||||||
|
this.f_99072_ = 1 + (int)(this.f_99070_ * (float)i + 0.5F) * 4;
|
||||||
+9
@@ -8,6 +8,15 @@
|
|||||||
this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_104523_, this.f_104519_.m_193590_()));
|
this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_104523_, this.f_104519_.m_193590_()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -122,7 +_,7 @@
|
||||||
|
if (this.f_104520_ != null && this.f_104520_ instanceof RealmsScreen) {
|
||||||
|
this.f_104519_.m_91152_(new DisconnectedRealmsScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_));
|
||||||
|
} else {
|
||||||
|
- this.f_104519_.m_91152_(new DisconnectedScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_));
|
||||||
|
+ this.f_104519_.m_91152_(net.minecraftforge.network.NetworkHooks.getModMismatchData(f_104522_) != null ? new net.minecraftforge.client.gui.ModMismatchDisconnectedScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_, net.minecraftforge.network.NetworkHooks.getModMismatchData(f_104522_)) : new DisconnectedScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -143,6 +_,7 @@
|
@@ -143,6 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
--- a/net/minecraft/client/multiplayer/ClientLevel.java
|
--- a/net/minecraft/client/multiplayer/ClientLevel.java
|
||||||
+++ b/net/minecraft/client/multiplayer/ClientLevel.java
|
+++ b/net/minecraft/client/multiplayer/ClientLevel.java
|
||||||
|
@@ -117,6 +_,7 @@
|
||||||
|
private final Deque<Runnable> f_194122_ = Queues.newArrayDeque();
|
||||||
|
private int f_194123_;
|
||||||
|
private static final Set<Item> f_194124_ = Set.of(Items.f_42127_, Items.f_151033_);
|
||||||
|
+ private final it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraftforge.entity.PartEntity<?>> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
public ClientLevel(ClientPacketListener p_205505_, ClientLevel.ClientLevelData p_205506_, ResourceKey<Level> p_205507_, Holder<DimensionType> p_205508_, int p_205509_, int p_205510_, Supplier<ProfilerFiller> p_205511_, LevelRenderer p_205512_, boolean p_205513_, long p_205514_) {
|
||||||
|
super(p_205506_, p_205507_, p_205508_, p_205511_, true, p_205513_, p_205514_);
|
||||||
@@ -129,6 +_,8 @@
|
@@ -129,6 +_,8 @@
|
||||||
this.f_194123_ = p_205510_;
|
this.f_194123_ = p_205510_;
|
||||||
this.m_46465_();
|
this.m_46465_();
|
||||||
@@ -60,13 +68,34 @@
|
|||||||
this.f_104840_ = p_104852_;
|
this.f_104840_ = p_104852_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,6 +_,9 @@
|
@@ -907,11 +_,30 @@
|
||||||
|
ClientLevel.this.f_104566_.add((AbstractClientPlayer)p_171712_);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (p_171712_.isMultipartEntity()) {
|
||||||
|
+ for (net.minecraftforge.entity.PartEntity<?> part : p_171712_.getParts()) {
|
||||||
|
+ ClientLevel.this.partEntities.put(part.m_142049_(), part);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
public void m_141981_(Entity p_171716_) {
|
public void m_141981_(Entity p_171716_) {
|
||||||
p_171716_.m_19877_();
|
p_171716_.m_19877_();
|
||||||
ClientLevel.this.f_104566_.remove(p_171716_);
|
ClientLevel.this.f_104566_.remove(p_171716_);
|
||||||
+
|
+
|
||||||
+ p_171716_.onRemovedFromWorld();
|
+ p_171716_.onRemovedFromWorld();
|
||||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_171716_, ClientLevel.this));
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_171716_, ClientLevel.this));
|
||||||
|
+
|
||||||
|
+ if (p_171716_.isMultipartEntity()) {
|
||||||
|
+ for (net.minecraftforge.entity.PartEntity<?> part : p_171716_.getParts()) {
|
||||||
|
+ ClientLevel.this.partEntities.remove(part.m_142049_());
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
}
|
}
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public java.util.Collection<net.minecraftforge.entity.PartEntity<?>> getPartEntities() {
|
||||||
|
+ return this.partEntities.values();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.f_104888_.m_91171_(SearchRegistry.f_119942_).m_7729_();
|
this.f_104888_.m_91171_(SearchRegistry.f_119942_).m_7729_();
|
||||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.f_104903_));
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.f_104903_, true, f_104885_.m_129531_()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void m_205560_(ResourceKey<? extends Registry<? extends T>> p_205561_, TagNetworkSerialization.NetworkPayload p_205562_) {
|
private <T> void m_205560_(ResourceKey<? extends Registry<? extends T>> p_205561_, TagNetworkSerialization.NetworkPayload p_205562_) {
|
||||||
|
|||||||
@@ -68,13 +68,12 @@
|
|||||||
if (this.f_105193_ >= 1.0F) {
|
if (this.f_105193_ >= 1.0F) {
|
||||||
this.f_105196_ = false;
|
this.f_105196_ = false;
|
||||||
this.m_105272_(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, p_105284_, p_105285_);
|
this.m_105272_(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, p_105284_, p_105285_);
|
||||||
@@ -227,7 +_,8 @@
|
@@ -227,7 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public float m_105286_() {
|
public float m_105286_() {
|
||||||
- return this.f_105197_.m_46408_() ? 5.0F : 4.5F;
|
- return this.f_105197_.m_46408_() ? 5.0F : 4.5F;
|
||||||
+ float attrib = (float)f_105189_.f_91074_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_();
|
+ return (float) this.f_105189_.f_91074_.getReachDistance();
|
||||||
+ return this.f_105197_.m_46408_() ? attrib : attrib - 0.5F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void m_105287_() {
|
public void m_105287_() {
|
||||||
@@ -142,16 +141,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return interactionresultholder.m_19089_();
|
return interactionresultholder.m_19089_();
|
||||||
@@ -343,6 +_,9 @@
|
|
||||||
public InteractionResult m_105226_(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) {
|
|
||||||
this.m_105297_();
|
|
||||||
this.f_105190_.m_104955_(ServerboundInteractPacket.m_179608_(p_105228_, p_105227_.m_6144_(), p_105229_));
|
|
||||||
+ if (this.f_105197_ == GameType.SPECTATOR) return InteractionResult.PASS; // don't fire for spectators to match non-specific EntityInteract
|
|
||||||
+ InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(p_105227_, p_105228_, p_105229_);
|
|
||||||
+ if(cancelResult != null) return cancelResult;
|
|
||||||
return this.f_105197_ == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.m_36157_(p_105228_, p_105229_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -350,6 +_,9 @@
|
@@ -350,6 +_,9 @@
|
||||||
this.m_105297_();
|
this.m_105297_();
|
||||||
Vec3 vec3 = p_105233_.m_82450_().m_82492_(p_105232_.m_20185_(), p_105232_.m_20186_(), p_105232_.m_20189_());
|
Vec3 vec3 = p_105233_.m_82450_().m_82492_(p_105232_.m_20185_(), p_105232_.m_20186_(), p_105232_.m_20189_());
|
||||||
|
|||||||
@@ -17,6 +17,40 @@
|
|||||||
} catch (IOException ioexception) {
|
} catch (IOException ioexception) {
|
||||||
list1.forEach((p_172772_) -> {
|
list1.forEach((p_172772_) -> {
|
||||||
p_172772_.getFirst().close();
|
p_172772_.getFirst().close();
|
||||||
|
@@ -625,19 +_,21 @@
|
||||||
|
boolean flag = false;
|
||||||
|
int i = 3;
|
||||||
|
double d1 = d0;
|
||||||
|
+ double atkRange = this.f_109059_.f_91074_.getAttackRange();
|
||||||
|
if (this.f_109059_.f_91072_.m_105291_()) {
|
||||||
|
- d1 = 6.0D;
|
||||||
|
+ d1 = Math.max(d0, atkRange);
|
||||||
|
d0 = d1;
|
||||||
|
} else {
|
||||||
|
- if (d0 > 3.0D) {
|
||||||
|
+ if (d0 > atkRange) {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
d0 = d0;
|
||||||
|
+ d0 = d1 = Math.max(d0, atkRange); // Pick entities with the max of the reach distance and attack range.
|
||||||
|
}
|
||||||
|
|
||||||
|
d1 *= d1;
|
||||||
|
- if (this.f_109059_.f_91077_ != null) {
|
||||||
|
+ if (this.f_109059_.f_91077_ != null && this.f_109059_.f_91077_.m_6662_() != HitResult.Type.MISS) { // Add != MISS to ensure Attack Range is not clamped at the value of Reach Distance.
|
||||||
|
d1 = this.f_109059_.f_91077_.m_82450_().m_82557_(vec3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -652,7 +_,7 @@
|
||||||
|
Entity entity1 = entityhitresult.m_82443_();
|
||||||
|
Vec3 vec33 = entityhitresult.m_82450_();
|
||||||
|
double d2 = vec3.m_82557_(vec33);
|
||||||
|
- if (flag && d2 > 9.0D) {
|
||||||
|
+ if (false && flag && d2 > 9.0D) { //Forge: Always keep the entity result to allow for extended reach interactions.
|
||||||
|
this.f_109059_.f_91077_ = BlockHitResult.m_82426_(vec33, Direction.m_122366_(vec31.f_82479_, vec31.f_82480_, vec31.f_82481_), new BlockPos(vec33));
|
||||||
|
} else if (d2 < d1 || this.f_109059_.f_91077_ == null) {
|
||||||
|
this.f_109059_.f_91077_ = entityhitresult;
|
||||||
@@ -706,7 +_,7 @@
|
@@ -706,7 +_,7 @@
|
||||||
d0 *= (double)Mth.m_14179_(this.f_109059_.f_91066_.f_92070_, 1.0F, 0.85714287F);
|
d0 *= (double)Mth.m_14179_(this.f_109059_.f_91066_.f_92070_, 1.0F, 0.85714287F);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
if (!Minecraft.m_91085_()) {
|
if (!Minecraft.m_91085_()) {
|
||||||
return Sheets.m_110792_();
|
return Sheets.m_110792_();
|
||||||
} else {
|
} else {
|
||||||
@@ -340,9 +_,58 @@
|
@@ -340,9 +_,111 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,11 +54,22 @@
|
|||||||
+
|
+
|
||||||
+ // FORGE START
|
+ // FORGE START
|
||||||
+
|
+
|
||||||
+ private static final Map<net.minecraftforge.registries.IRegistryDelegate<Block>, java.util.function.Predicate<RenderType>> blockRenderChecks = Maps.newHashMap();
|
+ private static final java.util.function.Predicate<RenderType> SOLID_PREDICATE = type -> type == RenderType.m_110451_();
|
||||||
+ private static final Map<net.minecraftforge.registries.IRegistryDelegate<Fluid>, java.util.function.Predicate<RenderType>> fluidRenderChecks = Maps.newHashMap();
|
+ // Access to the two following editable maps is guarded by synchronization and they are lazily copied to the "readonly" maps on first read after modification
|
||||||
+ static {
|
+ private static final Map<net.minecraftforge.registries.IRegistryDelegate<Block>, java.util.function.Predicate<RenderType>> blockRenderChecks = createRenderCheckMap(f_109275_);
|
||||||
+ f_109275_.forEach(ItemBlockRenderTypes::setRenderLayer);
|
+ private static final Map<net.minecraftforge.registries.IRegistryDelegate<Fluid>, java.util.function.Predicate<RenderType>> fluidRenderChecks = createRenderCheckMap(f_109276_);
|
||||||
+ f_109276_.forEach(ItemBlockRenderTypes::setRenderLayer);
|
+ @org.jetbrains.annotations.Nullable private static volatile Map<net.minecraftforge.registries.IRegistryDelegate<Block>, java.util.function.Predicate<RenderType>> blockRenderChecksReadOnly = null;
|
||||||
|
+ @org.jetbrains.annotations.Nullable private static volatile Map<net.minecraftforge.registries.IRegistryDelegate<Fluid>, java.util.function.Predicate<RenderType>> fluidRenderChecksReadOnly = null;
|
||||||
|
+
|
||||||
|
+ private static <T extends net.minecraftforge.registries.ForgeRegistryEntry<T>> Map<net.minecraftforge.registries.IRegistryDelegate<T>, java.util.function.Predicate<RenderType>> createRenderCheckMap(
|
||||||
|
+ Map<T, RenderType> vanillaMap
|
||||||
|
+ ) {
|
||||||
|
+ return Util.m_137469_(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(vanillaMap.size(), 0.5F), map -> {
|
||||||
|
+ map.defaultReturnValue(SOLID_PREDICATE);
|
||||||
|
+ for (Map.Entry<T, RenderType> entry : vanillaMap.entrySet()) {
|
||||||
|
+ map.put(entry.getKey().delegate, createMatchingLayerPredicate(entry.getValue()));
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static boolean canRenderInLayer(BlockState state, RenderType type) {
|
+ public static boolean canRenderInLayer(BlockState state, RenderType type) {
|
||||||
@@ -66,38 +77,80 @@
|
|||||||
+ if (block instanceof LeavesBlock) {
|
+ if (block instanceof LeavesBlock) {
|
||||||
+ return f_109277_ ? type == RenderType.m_110457_() : type == RenderType.m_110451_();
|
+ return f_109277_ ? type == RenderType.m_110457_() : type == RenderType.m_110451_();
|
||||||
+ } else {
|
+ } else {
|
||||||
+ java.util.function.Predicate<RenderType> rendertype;
|
+ return getBlockLayerPredicates().get(block.delegate).test(type);
|
||||||
+ synchronized (ItemBlockRenderTypes.class) {
|
|
||||||
+ rendertype = blockRenderChecks.get(block.delegate);
|
|
||||||
+ }
|
|
||||||
+ return rendertype != null ? rendertype.test(type) : type == RenderType.m_110451_();
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static boolean canRenderInLayer(FluidState fluid, RenderType type) {
|
+ public static boolean canRenderInLayer(FluidState fluid, RenderType type) {
|
||||||
+ java.util.function.Predicate<RenderType> rendertype;
|
+ return getFluidLayerPredicates().get(fluid.m_76152_().delegate).test(type);
|
||||||
+ synchronized (ItemBlockRenderTypes.class) {
|
|
||||||
+ rendertype = fluidRenderChecks.get(fluid.m_76152_().delegate);
|
|
||||||
+ }
|
|
||||||
+ return rendertype != null ? rendertype.test(type) : type == RenderType.m_110451_();
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static void setRenderLayer(Block block, RenderType type) {
|
+ public static void setRenderLayer(Block block, RenderType type) {
|
||||||
+ java.util.Objects.requireNonNull(type);
|
+ setRenderLayer(block, createMatchingLayerPredicate(type));
|
||||||
+ setRenderLayer(block, type::equals);
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static synchronized void setRenderLayer(Block block, java.util.function.Predicate<RenderType> predicate) {
|
+ public static void setRenderLayer(Block block, java.util.function.Predicate<RenderType> predicate) {
|
||||||
+ blockRenderChecks.put(block.delegate, predicate);
|
+ synchronized (blockRenderChecks) {
|
||||||
|
+ blockRenderChecks.put(block.delegate, predicate);
|
||||||
|
+ blockRenderChecksReadOnly = null;
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static void setRenderLayer(Fluid fluid, RenderType type) {
|
+ public static void setRenderLayer(Fluid fluid, RenderType type) {
|
||||||
+ java.util.Objects.requireNonNull(type);
|
+ setRenderLayer(fluid, createMatchingLayerPredicate(type));
|
||||||
+ setRenderLayer(fluid, type::equals);
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static synchronized void setRenderLayer(Fluid fluid, java.util.function.Predicate<RenderType> predicate) {
|
+ public static void setRenderLayer(Fluid fluid, java.util.function.Predicate<RenderType> predicate) {
|
||||||
+ fluidRenderChecks.put(fluid.delegate, predicate);
|
+ synchronized (fluidRenderChecks) {
|
||||||
|
+ fluidRenderChecks.put(fluid.delegate, predicate);
|
||||||
|
+ fluidRenderChecksReadOnly = null;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static Map<net.minecraftforge.registries.IRegistryDelegate<Block>, java.util.function.Predicate<RenderType>> getBlockLayerPredicatesView() {
|
||||||
|
+ return java.util.Collections.unmodifiableMap(getBlockLayerPredicates());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static Map<net.minecraftforge.registries.IRegistryDelegate<Block>, java.util.function.Predicate<RenderType>> getBlockLayerPredicates() {
|
||||||
|
+ Map<net.minecraftforge.registries.IRegistryDelegate<Block>, java.util.function.Predicate<RenderType>> map = blockRenderChecksReadOnly;
|
||||||
|
+ if (map == null) {
|
||||||
|
+ synchronized (blockRenderChecks) {
|
||||||
|
+ map = blockRenderChecksReadOnly;
|
||||||
|
+ if (map == null) {
|
||||||
|
+ blockRenderChecksReadOnly = map = copy(blockRenderChecks);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return map;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ public static Map<net.minecraftforge.registries.IRegistryDelegate<Fluid>, java.util.function.Predicate<RenderType>> getFluidLayerPredicatesView() {
|
||||||
|
+ return java.util.Collections.unmodifiableMap(getFluidLayerPredicates());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static Map<net.minecraftforge.registries.IRegistryDelegate<Fluid>, java.util.function.Predicate<RenderType>> getFluidLayerPredicates() {
|
||||||
|
+ Map<net.minecraftforge.registries.IRegistryDelegate<Fluid>, java.util.function.Predicate<RenderType>> map = fluidRenderChecksReadOnly;
|
||||||
|
+ if (map == null) {
|
||||||
|
+ synchronized (fluidRenderChecks) {
|
||||||
|
+ map = fluidRenderChecksReadOnly;
|
||||||
|
+ if (map == null) {
|
||||||
|
+ fluidRenderChecksReadOnly = map = copy(fluidRenderChecks);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return map;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static <T> Map<net.minecraftforge.registries.IRegistryDelegate<T>, java.util.function.Predicate<RenderType>> copy(Map<net.minecraftforge.registries.IRegistryDelegate<T>, java.util.function.Predicate<RenderType>> map) {
|
||||||
|
+ var newMap = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(map);
|
||||||
|
+ newMap.defaultReturnValue(SOLID_PREDICATE);
|
||||||
|
+ return newMap;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static java.util.function.Predicate<RenderType> createMatchingLayerPredicate(RenderType type) {
|
||||||
|
+ java.util.Objects.requireNonNull(type);
|
||||||
|
+ return type::equals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void m_109291_(boolean p_109292_) {
|
public static void m_109291_(boolean p_109292_) {
|
||||||
@@ -15,6 +15,15 @@
|
|||||||
this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.f_109301_, f7, p_109316_, p_109317_, p_109319_);
|
this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.f_109301_, f7, p_109316_, p_109317_, p_109319_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -342,7 +_,7 @@
|
||||||
|
} else {
|
||||||
|
this.m_109353_(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_);
|
||||||
|
}
|
||||||
|
- } else if (p_109377_.m_150930_(Items.f_42717_)) {
|
||||||
|
+ } else if (p_109377_.m_41720_() instanceof CrossbowItem) {
|
||||||
|
boolean flag1 = CrossbowItem.m_40932_(p_109377_);
|
||||||
|
boolean flag2 = humanoidarm == HumanoidArm.RIGHT;
|
||||||
|
int i = flag2 ? 1 : -1;
|
||||||
@@ -487,8 +_,16 @@
|
@@ -487,8 +_,16 @@
|
||||||
this.f_109304_ = Mth.m_14036_(this.f_109304_ - 0.4F, 0.0F, 1.0F);
|
this.f_109304_ = Mth.m_14036_(this.f_109304_ - 0.4F, 0.0F, 1.0F);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
float f = this.f_109461_.f_91073_.m_46722_(1.0F) / (Minecraft.m_91405_() ? 1.0F : 2.0F);
|
float f = this.f_109461_.f_91073_.m_46722_(1.0F) / (Minecraft.m_91405_() ? 1.0F : 2.0F);
|
||||||
if (!(f <= 0.0F)) {
|
if (!(f <= 0.0F)) {
|
||||||
Random random = new Random((long)this.f_109477_ * 312987231L);
|
Random random = new Random((long)this.f_109477_ * 312987231L);
|
||||||
@@ -1134,20 +_,23 @@
|
@@ -1134,20 +_,24 @@
|
||||||
RenderSystem.m_69421_(16640, Minecraft.f_91002_);
|
RenderSystem.m_69421_(16640, Minecraft.f_91002_);
|
||||||
float f = p_109605_.m_109152_();
|
float f = p_109605_.m_109152_();
|
||||||
boolean flag2 = this.f_109461_.f_91073_.m_104583_().m_5781_(Mth.m_14107_(d0), Mth.m_14107_(d1)) || this.f_109461_.f_91065_.m_93090_().m_93715_();
|
boolean flag2 = this.f_109461_.f_91073_.m_104583_().m_5781_(Mth.m_14107_(d0), Mth.m_14107_(d1)) || this.f_109461_.f_91065_.m_93090_().m_93715_();
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2);
|
- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2);
|
||||||
+ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2, p_109601_);
|
+ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2, p_109601_);
|
||||||
});
|
});
|
||||||
|
+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum);
|
||||||
profilerfiller.m_6182_("fog");
|
profilerfiller.m_6182_("fog");
|
||||||
- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2);
|
- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2);
|
||||||
+ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2, p_109601_);
|
+ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag2, p_109601_);
|
||||||
@@ -89,24 +90,50 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
PoseStack posestack = RenderSystem.m_157191_();
|
PoseStack posestack = RenderSystem.m_157191_();
|
||||||
@@ -1333,7 +_,7 @@
|
@@ -1333,7 +_,8 @@
|
||||||
this.f_109415_.m_83945_(this.f_109461_.m_91385_());
|
this.f_109415_.m_83945_(this.f_109461_.m_91385_());
|
||||||
RenderStateShard.f_110126_.m_110185_();
|
RenderStateShard.f_110126_.m_110185_();
|
||||||
profilerfiller.m_6182_("particles");
|
profilerfiller.m_6182_("particles");
|
||||||
- this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_);
|
- this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_);
|
||||||
+ this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum);
|
+ this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum);
|
||||||
|
+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum);
|
||||||
RenderStateShard.f_110126_.m_110188_();
|
RenderStateShard.f_110126_.m_110188_();
|
||||||
} else {
|
} else {
|
||||||
profilerfiller.m_6182_("translucent");
|
profilerfiller.m_6182_("translucent");
|
||||||
@@ -1347,7 +_,7 @@
|
@@ -1347,7 +_,8 @@
|
||||||
profilerfiller.m_6182_("string");
|
profilerfiller.m_6182_("string");
|
||||||
this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_109607_);
|
this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_109607_);
|
||||||
profilerfiller.m_6182_("particles");
|
profilerfiller.m_6182_("particles");
|
||||||
- this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_);
|
- this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_);
|
||||||
+ this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum);
|
+ this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum);
|
||||||
|
+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum);
|
||||||
}
|
}
|
||||||
|
|
||||||
posestack.m_85836_();
|
posestack.m_85836_();
|
||||||
|
@@ -1371,6 +_,7 @@
|
||||||
|
RenderStateShard.f_110127_.m_110185_();
|
||||||
|
profilerfiller.m_6182_("weather");
|
||||||
|
this.m_109703_(p_109606_, p_109601_, d0, d1, d2);
|
||||||
|
+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum);
|
||||||
|
this.m_173012_(p_109604_);
|
||||||
|
RenderStateShard.f_110127_.m_110188_();
|
||||||
|
this.f_109418_.m_110023_(p_109601_);
|
||||||
|
@@ -1379,6 +_,7 @@
|
||||||
|
RenderSystem.m_69458_(false);
|
||||||
|
profilerfiller.m_6182_("weather");
|
||||||
|
this.m_109703_(p_109606_, p_109601_, d0, d1, d2);
|
||||||
|
+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_109607_, this.f_109477_, p_109604_, frustum);
|
||||||
|
this.m_173012_(p_109604_);
|
||||||
|
RenderSystem.m_69458_(true);
|
||||||
|
}
|
||||||
|
@@ -1521,6 +_,7 @@
|
||||||
|
VertexBuffer.m_85931_();
|
||||||
|
VertexBuffer.m_166875_();
|
||||||
|
this.f_109461_.m_91307_().m_7238_();
|
||||||
|
+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_172994_, this, p_172995_, p_172999_, this.f_109477_, this.f_109461_.f_91063_.m_109153_(), this.f_109442_ != null ? this.f_109442_ : this.f_172938_);
|
||||||
|
p_172994_.m_110188_();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1783,6 +_,11 @@
|
@@ -1783,6 +_,11 @@
|
||||||
|
|
||||||
public void m_202423_(PoseStack p_202424_, Matrix4f p_202425_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) {
|
public void m_202423_(PoseStack p_202424_, Matrix4f p_202425_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
--- a/net/minecraft/client/renderer/OutlineBufferSource.java
|
||||||
|
+++ b/net/minecraft/client/renderer/OutlineBufferSource.java
|
||||||
|
@@ -105,5 +_,7 @@
|
||||||
|
public void m_5752_() {
|
||||||
|
this.f_109936_.m_5483_(this.f_109937_, this.f_109938_, this.f_109939_).m_6122_(this.f_85825_, this.f_85826_, this.f_85827_, this.f_85828_).m_7421_(this.f_109940_, this.f_109941_).m_5752_();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ public com.mojang.blaze3d.vertex.VertexFormat getVertexFormat() { return f_109936_.getVertexFormat(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
--- a/net/minecraft/client/renderer/SpriteCoordinateExpander.java
|
||||||
|
+++ b/net/minecraft/client/renderer/SpriteCoordinateExpander.java
|
||||||
|
@@ -54,4 +_,6 @@
|
||||||
|
public void m_5954_(float p_110808_, float p_110809_, float p_110810_, float p_110811_, float p_110812_, float p_110813_, float p_110814_, float p_110815_, float p_110816_, int p_110817_, int p_110818_, float p_110819_, float p_110820_, float p_110821_) {
|
||||||
|
this.f_110795_.m_5954_(p_110808_, p_110809_, p_110810_, p_110811_, p_110812_, p_110813_, p_110814_, this.f_110796_.m_118367_((double)(p_110815_ * 16.0F)), this.f_110796_.m_118393_((double)(p_110816_ * 16.0F)), p_110817_, p_110818_, p_110819_, p_110820_, p_110821_);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ public com.mojang.blaze3d.vertex.VertexFormat getVertexFormat() { return f_110795_.getVertexFormat(); }
|
||||||
|
}
|
||||||
@@ -78,6 +78,26 @@
|
|||||||
public boolean m_111477_(String p_111478_) {
|
public boolean m_111477_(String p_111478_) {
|
||||||
return !MissingTextureAtlasSprite.m_118071_().equals(this.m_111480_(p_111478_).m_119203_());
|
return !MissingTextureAtlasSprite.m_118071_().equals(this.m_111480_(p_111478_).m_119203_());
|
||||||
}
|
}
|
||||||
|
@@ -269,7 +_,18 @@
|
||||||
|
ItemTransform itemtransform5 = this.m_111444_(ItemTransforms.TransformType.GUI);
|
||||||
|
ItemTransform itemtransform6 = this.m_111444_(ItemTransforms.TransformType.GROUND);
|
||||||
|
ItemTransform itemtransform7 = this.m_111444_(ItemTransforms.TransformType.FIXED);
|
||||||
|
- return new ItemTransforms(itemtransform, itemtransform1, itemtransform2, itemtransform3, itemtransform4, itemtransform5, itemtransform6, itemtransform7);
|
||||||
|
+
|
||||||
|
+ var builder = com.google.common.collect.ImmutableMap.<ItemTransforms.TransformType, ItemTransform>builder();
|
||||||
|
+ for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values()) {
|
||||||
|
+ if (type.isModded()) {
|
||||||
|
+ var transform = this.m_111444_(type);
|
||||||
|
+ if (transform != ItemTransform.f_111754_) {
|
||||||
|
+ builder.put(type, transform);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return new ItemTransforms(itemtransform, itemtransform1, itemtransform2, itemtransform3, itemtransform4, itemtransform5, itemtransform6, itemtransform7, builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemTransform m_111444_(ItemTransforms.TransformType p_111445_) {
|
||||||
@@ -388,6 +_,8 @@
|
@@ -388,6 +_,8 @@
|
||||||
public boolean m_111526_() {
|
public boolean m_111526_() {
|
||||||
return this == SIDE;
|
return this == SIDE;
|
||||||
|
|||||||
+129
-12
@@ -1,26 +1,143 @@
|
|||||||
--- a/net/minecraft/client/renderer/block/model/ItemTransforms.java
|
--- a/net/minecraft/client/renderer/block/model/ItemTransforms.java
|
||||||
+++ b/net/minecraft/client/renderer/block/model/ItemTransforms.java
|
+++ b/net/minecraft/client/renderer/block/model/ItemTransforms.java
|
||||||
@@ -25,6 +_,7 @@
|
@@ -20,6 +_,7 @@
|
||||||
this(ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_);
|
public final ItemTransform f_111792_;
|
||||||
}
|
public final ItemTransform f_111793_;
|
||||||
|
public final ItemTransform f_111794_;
|
||||||
|
+ public final com.google.common.collect.ImmutableMap<TransformType, ItemTransform> moddedTransforms;
|
||||||
|
|
||||||
+ @Deprecated
|
private ItemTransforms() {
|
||||||
public ItemTransforms(ItemTransforms p_111807_) {
|
this(ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_, ItemTransform.f_111754_);
|
||||||
this.f_111787_ = p_111807_.f_111787_;
|
@@ -34,9 +_,16 @@
|
||||||
this.f_111788_ = p_111807_.f_111788_;
|
this.f_111792_ = p_111807_.f_111792_;
|
||||||
@@ -36,6 +_,7 @@
|
this.f_111793_ = p_111807_.f_111793_;
|
||||||
this.f_111794_ = p_111807_.f_111794_;
|
this.f_111794_ = p_111807_.f_111794_;
|
||||||
|
+ this.moddedTransforms = p_111807_.moddedTransforms;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
public ItemTransforms(ItemTransform p_111798_, ItemTransform p_111799_, ItemTransform p_111800_, ItemTransform p_111801_, ItemTransform p_111802_, ItemTransform p_111803_, ItemTransform p_111804_, ItemTransform p_111805_) {
|
public ItemTransforms(ItemTransform p_111798_, ItemTransform p_111799_, ItemTransform p_111800_, ItemTransform p_111801_, ItemTransform p_111802_, ItemTransform p_111803_, ItemTransform p_111804_, ItemTransform p_111805_) {
|
||||||
|
+ this(p_111798_, p_111799_, p_111800_, p_111801_, p_111802_, p_111803_, p_111804_, p_111805_, com.google.common.collect.ImmutableMap.of());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ItemTransforms(ItemTransform p_111798_, ItemTransform p_111799_, ItemTransform p_111800_, ItemTransform p_111801_, ItemTransform p_111802_, ItemTransform p_111803_, ItemTransform p_111804_, ItemTransform p_111805_,
|
||||||
|
+ com.google.common.collect.ImmutableMap<TransformType, ItemTransform> moddedTransforms) {
|
||||||
this.f_111787_ = p_111798_;
|
this.f_111787_ = p_111798_;
|
||||||
this.f_111788_ = p_111799_;
|
this.f_111788_ = p_111799_;
|
||||||
@@ -47,6 +_,7 @@
|
this.f_111789_ = p_111800_;
|
||||||
|
@@ -45,6 +_,7 @@
|
||||||
|
this.f_111792_ = p_111803_;
|
||||||
|
this.f_111793_ = p_111804_;
|
||||||
this.f_111794_ = p_111805_;
|
this.f_111794_ = p_111805_;
|
||||||
|
+ this.moddedTransforms = moddedTransforms;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ @Deprecated
|
|
||||||
public ItemTransform m_111808_(ItemTransforms.TransformType p_111809_) {
|
public ItemTransform m_111808_(ItemTransforms.TransformType p_111809_) {
|
||||||
switch(p_111809_) {
|
@@ -66,7 +_,7 @@
|
||||||
case THIRD_PERSON_LEFT_HAND:
|
case FIXED:
|
||||||
|
return this.f_111794_;
|
||||||
|
default:
|
||||||
|
- return ItemTransform.f_111754_;
|
||||||
|
+ return moddedTransforms.getOrDefault(p_111809_, ItemTransform.f_111754_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -94,7 +_,23 @@
|
||||||
|
ItemTransform itemtransform5 = this.m_111815_(p_111822_, jsonobject, "gui");
|
||||||
|
ItemTransform itemtransform6 = this.m_111815_(p_111822_, jsonobject, "ground");
|
||||||
|
ItemTransform itemtransform7 = this.m_111815_(p_111822_, jsonobject, "fixed");
|
||||||
|
- return new ItemTransforms(itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7);
|
||||||
|
+
|
||||||
|
+ var builder = com.google.common.collect.ImmutableMap.<TransformType, ItemTransform>builder();
|
||||||
|
+ for (TransformType type : TransformType.values()) {
|
||||||
|
+ if (type.isModded()) {
|
||||||
|
+ var transform = this.m_111815_(p_111822_, jsonobject, type.getSerializeName());
|
||||||
|
+ var fallbackType = type;
|
||||||
|
+ while (transform == ItemTransform.f_111754_ && fallbackType.fallback != null) {
|
||||||
|
+ fallbackType = fallbackType.fallback;
|
||||||
|
+ transform = this.m_111815_(p_111822_, jsonobject, fallbackType.getSerializeName());
|
||||||
|
+ }
|
||||||
|
+ if (transform != ItemTransform.f_111754_){
|
||||||
|
+ builder.put(type, transform);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return new ItemTransforms(itemtransform1, itemtransform, itemtransform3, itemtransform2, itemtransform4, itemtransform5, itemtransform6, itemtransform7, builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemTransform m_111815_(JsonDeserializationContext p_111816_, JsonObject p_111817_, String p_111818_) {
|
||||||
|
@@ -103,19 +_,63 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
- public static enum TransformType {
|
||||||
|
- NONE,
|
||||||
|
- THIRD_PERSON_LEFT_HAND,
|
||||||
|
- THIRD_PERSON_RIGHT_HAND,
|
||||||
|
- FIRST_PERSON_LEFT_HAND,
|
||||||
|
- FIRST_PERSON_RIGHT_HAND,
|
||||||
|
- HEAD,
|
||||||
|
- GUI,
|
||||||
|
- GROUND,
|
||||||
|
- FIXED;
|
||||||
|
+ public static enum TransformType implements net.minecraftforge.common.IExtensibleEnum {
|
||||||
|
+ NONE("none"),
|
||||||
|
+ THIRD_PERSON_LEFT_HAND("thirdperson_lefthand"),
|
||||||
|
+ THIRD_PERSON_RIGHT_HAND("thirdperson_righthand"),
|
||||||
|
+ FIRST_PERSON_LEFT_HAND("firstperson_lefthand"),
|
||||||
|
+ FIRST_PERSON_RIGHT_HAND("firstperson_righthand"),
|
||||||
|
+ HEAD("head"),
|
||||||
|
+ GUI("gui"),
|
||||||
|
+ GROUND("ground"),
|
||||||
|
+ FIXED("fixed");
|
||||||
|
|
||||||
|
public boolean m_111841_() {
|
||||||
|
return this == FIRST_PERSON_LEFT_HAND || this == FIRST_PERSON_RIGHT_HAND;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Forge start
|
||||||
|
+ private final String serializeName;
|
||||||
|
+ private final boolean isModded;
|
||||||
|
+ @javax.annotation.Nullable
|
||||||
|
+ private final TransformType fallback;
|
||||||
|
+
|
||||||
|
+ private TransformType(String name) {
|
||||||
|
+ serializeName = name;
|
||||||
|
+ isModded = false;
|
||||||
|
+ fallback = null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private TransformType(net.minecraft.resources.ResourceLocation serializeName) {
|
||||||
|
+ this.serializeName = java.util.Objects.requireNonNull(serializeName, "Modded TransformTypes must have a non-null serializeName").toString();
|
||||||
|
+ isModded = true;
|
||||||
|
+ fallback = null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private TransformType(net.minecraft.resources.ResourceLocation serializeName, TransformType fallback) {
|
||||||
|
+ this.serializeName = java.util.Objects.requireNonNull(serializeName, "Modded TransformTypes must have a non-null serializeName").toString();
|
||||||
|
+ isModded = true;
|
||||||
|
+ this.fallback = fallback;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean isModded() {
|
||||||
|
+ return isModded;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @javax.annotation.Nullable
|
||||||
|
+ public TransformType fallback() {
|
||||||
|
+ return fallback;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public String getSerializeName() {
|
||||||
|
+ return serializeName;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static TransformType create(String keyName, net.minecraft.resources.ResourceLocation serializeName) {
|
||||||
|
+ throw new IllegalStateException("Enum not extended!");
|
||||||
|
+ }
|
||||||
|
+ public static TransformType create(String keyName, net.minecraft.resources.ResourceLocation serializeName, TransformType fallback) {
|
||||||
|
+ throw new IllegalStateException("Enum not extended!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -10,6 +10,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 m_7860_(AbstractClientPlayer p_117785_, float p_117786_) {
|
public Vec3 m_7860_(AbstractClientPlayer p_117785_, float p_117786_) {
|
||||||
|
@@ -123,7 +_,7 @@
|
||||||
|
if (useanim == UseAnim.SPYGLASS) {
|
||||||
|
return HumanoidModel.ArmPose.SPYGLASS;
|
||||||
|
}
|
||||||
|
- } else if (!p_117795_.f_20911_ && itemstack.m_150930_(Items.f_42717_) && CrossbowItem.m_40932_(itemstack)) {
|
||||||
|
+ } else if (!p_117795_.f_20911_ && itemstack.m_41720_() instanceof CrossbowItem && CrossbowItem.m_40932_(itemstack)) {
|
||||||
|
return HumanoidModel.ArmPose.CROSSBOW_HOLD;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -158,10 +_,12 @@
|
@@ -158,10 +_,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
--- a/net/minecraft/client/renderer/texture/MipmapGenerator.java
|
||||||
|
+++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java
|
||||||
|
@@ -34,9 +_,12 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(p_118055_.m_84982_(), p_118055_.m_85084_());
|
||||||
|
for(int k1 = 1; k1 <= p_118056_; ++k1) {
|
||||||
|
NativeImage nativeimage1 = anativeimage[k1 - 1];
|
||||||
|
- NativeImage nativeimage = new NativeImage(nativeimage1.m_84982_() >> 1, nativeimage1.m_85084_() >> 1, false);
|
||||||
|
+ // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes
|
||||||
|
+ NativeImage nativeimage = new NativeImage(Math.max(1, nativeimage1.m_84982_() >> 1), Math.max(1, nativeimage1.m_85084_() >> 1), false);
|
||||||
|
+ if (k1 <= maxMipmapLevel) {
|
||||||
|
int k = nativeimage.m_84982_();
|
||||||
|
int l = nativeimage.m_85084_();
|
||||||
|
|
||||||
|
@@ -44,6 +_,7 @@
|
||||||
|
for(int j1 = 0; j1 < l; ++j1) {
|
||||||
|
nativeimage.m_84988_(i1, j1, m_118048_(nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 0), nativeimage1.m_84985_(i1 * 2 + 0, j1 * 2 + 1), nativeimage1.m_84985_(i1 * 2 + 1, j1 * 2 + 1), flag));
|
||||||
|
}
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
anativeimage[k1] = nativeimage;
|
||||||
@@ -8,6 +8,25 @@
|
|||||||
p_118378_[i].m_85003_(i, this.f_118349_ >> i, this.f_118350_ >> i, p_118376_ >> i, p_118377_ >> i, this.f_174723_ >> i, this.f_174724_ >> i, this.f_118342_.length > 1, false);
|
p_118378_[i].m_85003_(i, this.f_118349_ >> i, this.f_118350_ >> i, p_118376_ >> i, p_118377_ >> i, this.f_174723_ >> i, this.f_174724_ >> i, this.f_118342_.length > 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -389,7 +_,8 @@
|
||||||
|
int j = p_118446_.f_118423_ >> i;
|
||||||
|
int k = p_118446_.f_118424_ >> i;
|
||||||
|
if (this.f_118443_[i] == null) {
|
||||||
|
- this.f_118443_[i] = new NativeImage(j, k, false);
|
||||||
|
+ // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes
|
||||||
|
+ this.f_118443_[i] = new NativeImage(Math.max(1, j), Math.max(1, k), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -404,6 +_,8 @@
|
||||||
|
for(int k = 0; k < this.f_118443_.length; ++k) {
|
||||||
|
int l = TextureAtlasSprite.this.f_174723_ >> k;
|
||||||
|
int i1 = TextureAtlasSprite.this.f_174724_ >> k;
|
||||||
|
+ // Forge: guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes
|
||||||
|
+ if (l == 0 || i1 == 0) continue;
|
||||||
|
|
||||||
|
for(int j1 = 0; j1 < i1; ++j1) {
|
||||||
|
for(int k1 = 0; k1 < l; ++k1) {
|
||||||
@@ -438,5 +_,15 @@
|
@@ -438,5 +_,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
--- a/net/minecraft/client/server/LanServerDetection.java
|
||||||
|
+++ b/net/minecraft/client/server/LanServerDetection.java
|
||||||
|
@@ -33,7 +_,7 @@
|
||||||
|
this.setDaemon(true);
|
||||||
|
this.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LanServerDetection.f_120082_));
|
||||||
|
this.f_120088_ = new MulticastSocket(4445);
|
||||||
|
- this.f_120087_ = InetAddress.getByName("224.0.2.60");
|
||||||
|
+ this.f_120087_ = InetAddress.getByName(LanServerPinger.f_174974_);
|
||||||
|
this.f_120088_.setSoTimeout(5000);
|
||||||
|
this.f_120088_.joinGroup(this.f_120087_);
|
||||||
|
}
|
||||||
|
@@ -88,7 +_,19 @@
|
||||||
|
String s = LanServerPinger.m_120111_(p_120097_);
|
||||||
|
String s1 = LanServerPinger.m_120116_(p_120097_);
|
||||||
|
if (s1 != null) {
|
||||||
|
+ if (net.minecraftforge.network.DualStackUtils.checkIPv6(p_120098_)) {
|
||||||
|
+ final String ip;
|
||||||
|
+
|
||||||
|
+ // compress to short form if enabled in config
|
||||||
|
+ if (net.minecraftforge.common.ForgeConfig.CLIENT.compressLanIPv6Addresses.get())
|
||||||
|
+ ip = com.google.common.net.InetAddresses.toAddrString(p_120098_);
|
||||||
|
+ else
|
||||||
|
+ ip = p_120098_.getHostAddress();
|
||||||
|
+
|
||||||
|
+ s1 = "[" + ip + "]:" + s1;
|
||||||
|
+ } else {
|
||||||
|
s1 = p_120098_.getHostAddress() + ":" + s1;
|
||||||
|
+ }
|
||||||
|
boolean flag = false;
|
||||||
|
|
||||||
|
for(LanServer lanserver : this.f_120092_) {
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
--- a/net/minecraft/client/server/LanServerPinger.java
|
||||||
|
+++ b/net/minecraft/client/server/LanServerPinger.java
|
||||||
|
@@ -16,7 +_,7 @@
|
||||||
|
public class LanServerPinger extends Thread {
|
||||||
|
private static final AtomicInteger f_120101_ = new AtomicInteger(0);
|
||||||
|
private static final Logger f_120102_ = LogUtils.getLogger();
|
||||||
|
- public static final String f_174974_ = "224.0.2.60";
|
||||||
|
+ public static final String f_174974_ = net.minecraftforge.network.DualStackUtils.getMulticastGroup();
|
||||||
|
public static final int f_174975_ = 4445;
|
||||||
|
private static final long f_174976_ = 1500L;
|
||||||
|
private final String f_120103_;
|
||||||
|
@@ -39,7 +_,7 @@
|
||||||
|
|
||||||
|
while(!this.isInterrupted() && this.f_120105_) {
|
||||||
|
try {
|
||||||
|
- InetAddress inetaddress = InetAddress.getByName("224.0.2.60");
|
||||||
|
+ InetAddress inetaddress = InetAddress.getByName(f_174974_);
|
||||||
|
DatagramPacket datagrampacket = new DatagramPacket(abyte, abyte.length, inetaddress, 4445);
|
||||||
|
this.f_120104_.send(datagrampacket);
|
||||||
|
} catch (IOException ioexception) {
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
this.f_82090_.findAmbiguities((p_82108_, p_82109_, p_82110_, p_82111_) -> {
|
this.f_82090_.findAmbiguities((p_82108_, p_82109_, p_82110_, p_82111_) -> {
|
||||||
f_82089_.warn("Ambiguity between arguments {} and {} with inputs: {}", this.f_82090_.getPath(p_82109_), this.f_82090_.getPath(p_82110_), p_82111_);
|
f_82089_.warn("Ambiguity between arguments {} and {} with inputs: {}", this.f_82090_.getPath(p_82109_), this.f_82090_.getPath(p_82110_), p_82111_);
|
||||||
@@ -220,7 +_,15 @@
|
@@ -220,7 +_,17 @@
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
@@ -25,7 +25,9 @@
|
|||||||
+ ParseResults<CommandSourceStack> parse = this.f_82090_.parse(stringreader, p_82118_);
|
+ ParseResults<CommandSourceStack> parse = this.f_82090_.parse(stringreader, p_82118_);
|
||||||
+ net.minecraftforge.event.CommandEvent event = new net.minecraftforge.event.CommandEvent(parse);
|
+ net.minecraftforge.event.CommandEvent event = new net.minecraftforge.event.CommandEvent(parse);
|
||||||
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) {
|
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) {
|
||||||
+ if (event.getException() != null) {
|
+ if (event.getException() instanceof Exception exception) {
|
||||||
|
+ throw exception;
|
||||||
|
+ } else if (event.getException() != null) {
|
||||||
+ com.google.common.base.Throwables.throwIfUnchecked(event.getException());
|
+ com.google.common.base.Throwables.throwIfUnchecked(event.getException());
|
||||||
+ }
|
+ }
|
||||||
+ return 1;
|
+ return 1;
|
||||||
@@ -34,3 +36,13 @@
|
|||||||
} catch (CommandRuntimeException commandruntimeexception) {
|
} catch (CommandRuntimeException commandruntimeexception) {
|
||||||
p_82118_.m_81352_(commandruntimeexception.m_79226_());
|
p_82118_.m_81352_(commandruntimeexception.m_79226_());
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -276,7 +_,8 @@
|
||||||
|
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newHashMap();
|
||||||
|
RootCommandNode<SharedSuggestionProvider> rootcommandnode = new RootCommandNode<>();
|
||||||
|
map.put(this.f_82090_.getRoot(), rootcommandnode);
|
||||||
|
- this.m_82112_(this.f_82090_.getRoot(), rootcommandnode, p_82096_.m_20203_(), map);
|
||||||
|
+ // FORGE: Use our own command node merging method to handle redirect nodes properly, see issue #7551
|
||||||
|
+ net.minecraftforge.server.command.CommandHelper.mergeCommandNode(this.f_82090_.getRoot(), rootcommandnode, map, p_82096_.m_20203_(), ctx -> 0, suggest -> SuggestionProviders.m_121664_((com.mojang.brigadier.suggestion.SuggestionProvider<SharedSuggestionProvider>) (com.mojang.brigadier.suggestion.SuggestionProvider<?>) suggest));
|
||||||
|
p_82096_.f_8906_.m_141995_(new ClientboundCommandsPacket(rootcommandnode));
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/core/RegistryAccess.java
|
||||||
|
+++ b/net/minecraft/core/RegistryAccess.java
|
||||||
|
@@ -58,7 +_,7 @@
|
||||||
|
m_123053_(builder, Registry.f_122878_, NoiseGeneratorSettings.f_64430_);
|
||||||
|
m_123053_(builder, Registry.f_194568_, NormalNoise.NoiseParameters.f_192851_);
|
||||||
|
m_123053_(builder, Registry.f_211074_, DensityFunction.f_208216_);
|
||||||
|
- return builder.build();
|
||||||
|
+ return net.minecraftforge.registries.DataPackRegistriesHooks.grabBuiltinRegistries(builder); // FORGE: Keep the map so custom registries can be added later
|
||||||
|
});
|
||||||
|
Codec<RegistryAccess> f_206151_ = m_206205_();
|
||||||
|
Supplier<RegistryAccess.Frozen> f_123049_ = Suppliers.memoize(() -> {
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Connection m_178300_(InetSocketAddress p_178301_, boolean p_178302_) {
|
public static Connection m_178300_(InetSocketAddress p_178301_, boolean p_178302_) {
|
||||||
+ if (p_178301_.getAddress() instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false");
|
+ net.minecraftforge.network.DualStackUtils.checkIPv6(p_178301_.getAddress());
|
||||||
final Connection connection = new Connection(PacketFlow.CLIENTBOUND);
|
final Connection connection = new Connection(PacketFlow.CLIENTBOUND);
|
||||||
+ connection.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel;
|
+ connection.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel;
|
||||||
Class<? extends SocketChannel> oclass;
|
Class<? extends SocketChannel> oclass;
|
||||||
|
|||||||
@@ -1,17 +1,29 @@
|
|||||||
--- a/net/minecraft/network/chat/Style.java
|
--- a/net/minecraft/network/chat/Style.java
|
||||||
+++ b/net/minecraft/network/chat/Style.java
|
+++ b/net/minecraft/network/chat/Style.java
|
||||||
@@ -133,6 +_,18 @@
|
@@ -133,6 +_,30 @@
|
||||||
return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, p_178525_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, p_178525_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * @deprecated Use {@link #withUnderlined(Boolean)} instead.
|
||||||
|
+ */
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.18.2")
|
||||||
+ public Style setUnderlined(@Nullable Boolean underlined) {
|
+ public Style setUnderlined(@Nullable Boolean underlined) {
|
||||||
+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, underlined, this.f_131105_, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, underlined, this.f_131105_, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ /**
|
||||||
|
+ * @deprecated Use {@link #withStrikethrough(Boolean)} instead.
|
||||||
|
+ */
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.18.2")
|
||||||
+ public Style setStrikethrough(@Nullable Boolean strikethrough) {
|
+ public Style setStrikethrough(@Nullable Boolean strikethrough) {
|
||||||
+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, strikethrough, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, strikethrough, this.f_131106_, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ /**
|
||||||
|
+ * @deprecated Use {@link #withObfuscated(Boolean)} instead.
|
||||||
|
+ */
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.18.2")
|
||||||
+ public Style setObfuscated(@Nullable Boolean obfuscated) {
|
+ public Style setObfuscated(@Nullable Boolean obfuscated) {
|
||||||
+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, obfuscated, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
+ return new Style(this.f_131101_, this.f_131102_, this.f_131103_, this.f_131104_, this.f_131105_, obfuscated, this.f_131107_, this.f_131108_, this.f_131109_, this.f_131110_);
|
||||||
+ }
|
+ }
|
||||||
|
|||||||
@@ -8,6 +8,15 @@
|
|||||||
optional = Optional.of(p_195896_.parse(p_195893_, jsonelement).map(RegistryResourceAccess.ParsedEntry::m_195956_));
|
optional = Optional.of(p_195896_.parse(p_195893_, jsonelement).map(RegistryResourceAccess.ParsedEntry::m_195956_));
|
||||||
} catch (Throwable throwable2) {
|
} catch (Throwable throwable2) {
|
||||||
try {
|
try {
|
||||||
|
@@ -102,6 +_,8 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String m_195909_(ResourceKey<? extends Registry<?>> p_195910_) {
|
||||||
|
+ if (net.minecraftforge.registries.RegistryManager.FROZEN.getRegistry(p_195910_.m_135782_()) != null && !(p_195910_.m_135782_().m_135827_().equals("minecraft")))
|
||||||
|
+ return p_195910_.m_135782_().m_135827_() + "/" + p_195910_.m_135782_().m_135815_(); // FORGE: add non-vanilla registry namespace to loader directory, same format as tag directory (see net.minecraft.tags.TagManager#getTagDir(ResourceKey))
|
||||||
|
return p_195910_.m_135782_().m_135815_();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -138,6 +_,8 @@
|
@@ -138,6 +_,8 @@
|
||||||
|
|
||||||
public <E> Optional<DataResult<RegistryResourceAccess.ParsedEntry<E>>> m_183313_(DynamicOps<JsonElement> p_195917_, ResourceKey<? extends Registry<E>> p_195918_, ResourceKey<E> p_195919_, Decoder<E> p_195920_) {
|
public <E> Optional<DataResult<RegistryResourceAccess.ParsedEntry<E>>> m_183313_(DynamicOps<JsonElement> p_195917_, ResourceKey<? extends Registry<E>> p_195918_, ResourceKey<E> p_195919_, Decoder<E> p_195920_) {
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
this.f_206849_ = new TagManager(p_206857_);
|
this.f_206849_ = new TagManager(p_206857_);
|
||||||
this.f_206847_ = new Commands(p_206858_);
|
this.f_206847_ = new Commands(p_206858_);
|
||||||
this.f_206854_ = new ServerFunctionLibrary(p_206859_, this.f_206847_.m_82094_());
|
this.f_206854_ = new ServerFunctionLibrary(p_206859_, this.f_206847_.m_82094_());
|
||||||
+ // Forge: pass condition context too
|
+ // Forge: Create context object and pass it to the recipe manager.
|
||||||
+ var context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.f_206849_);
|
+ this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.f_206849_);
|
||||||
+ this.f_206848_ = new RecipeManager(context);
|
+ this.f_206848_ = new RecipeManager(context);
|
||||||
+ this.f_206853_ = new ServerAdvancementManager(this.f_206850_, context);
|
+ this.f_206853_ = new ServerAdvancementManager(this.f_206850_, context);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,24 @@
|
|||||||
m_206870_(p_206869_, p_206884_);
|
m_206870_(p_206869_, p_206884_);
|
||||||
});
|
});
|
||||||
Blocks.m_50758_();
|
Blocks.m_50758_();
|
||||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(p_206869_));
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(p_206869_, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void m_206870_(RegistryAccess p_206871_, TagManager.LoadResult<T> p_206872_) {
|
private static <T> void m_206870_(RegistryAccess p_206871_, TagManager.LoadResult<T> p_206872_) {
|
||||||
|
@@ -96,5 +_,16 @@
|
||||||
|
return p_206874_.getValue().m_6497_();
|
||||||
|
}));
|
||||||
|
p_206871_.m_175515_(resourcekey).m_203652_(map);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context;
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Exposes the current condition context for usage in other reload listeners.<br>
|
||||||
|
+ * This is not useful outside the reloading stage.
|
||||||
|
+ * @return The condition context for the currently active reload.
|
||||||
|
+ */
|
||||||
|
+ public net.minecraftforge.common.crafting.conditions.ICondition.IContext getConditionContext() {
|
||||||
|
+ return this.context;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,16 +34,41 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void m_140792_(TicketType<T> p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) {
|
public <T> void m_140792_(TicketType<T> p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) {
|
||||||
@@ -201,6 +_,14 @@
|
@@ -188,19 +_,37 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void m_140840_(TicketType<T> p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_) {
|
||||||
|
- Ticket<T> ticket = new Ticket<>(p_140841_, 33 - p_140843_, p_140844_);
|
||||||
|
+ addRegionTicket(p_140841_, p_140842_, p_140843_, p_140844_, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public <T> void addRegionTicket(TicketType<T> p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_, boolean forceTicks) {
|
||||||
|
+ Ticket<T> ticket = new Ticket<>(p_140841_, 33 - p_140843_, p_140844_, forceTicks);
|
||||||
|
long i = p_140842_.m_45588_();
|
||||||
|
this.m_140784_(i, ticket);
|
||||||
|
this.f_183901_.m_184151_(i, ticket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void m_140849_(TicketType<T> p_140850_, ChunkPos p_140851_, int p_140852_, T p_140853_) {
|
||||||
|
- Ticket<T> ticket = new Ticket<>(p_140850_, 33 - p_140852_, p_140853_);
|
||||||
|
+ removeRegionTicket(p_140850_, p_140851_, p_140852_, p_140853_, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public <T> void removeRegionTicket(TicketType<T> p_140850_, ChunkPos p_140851_, int p_140852_, T p_140853_, boolean forceTicks) {
|
||||||
|
+ Ticket<T> ticket = new Ticket<>(p_140850_, 33 - p_140852_, p_140853_, forceTicks);
|
||||||
|
long i = p_140851_.m_45588_();
|
||||||
|
this.m_140818_(i, ticket);
|
||||||
this.f_183901_.m_184165_(i, ticket);
|
this.f_183901_.m_184165_(i, ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.18.2") // Use addRegionTicket overload
|
||||||
+ public <T> void registerTicking(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
+ public <T> void registerTicking(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
||||||
+ this.m_140784_(pos.m_45588_(), new Ticket<>(type, 33 - distance, value, true));
|
+ addRegionTicket(type, pos, distance, value, true);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.18.2") // Use removeRegionTicket overload
|
||||||
+ public <T> void releaseTicking(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
+ public <T> void releaseTicking(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
||||||
+ this.m_140818_(pos.m_45588_(), new Ticket<>(type, 33 - distance, value, true));
|
+ removeRegionTicket(type, pos, distance, value, true);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
private SortedArraySet<Ticket<?>> m_140857_(long p_140858_) {
|
private SortedArraySet<Ticket<?>> m_140857_(long p_140858_) {
|
||||||
|
|||||||
@@ -17,18 +17,35 @@
|
|||||||
levelchunk1.m_187632_(j);
|
levelchunk1.m_187632_(j);
|
||||||
if (flag2 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos)) {
|
if (flag2 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos)) {
|
||||||
NaturalSpawner.m_47029_(this.f_8329_, levelchunk1, naturalspawner$spawnstate, this.f_8336_, this.f_8335_, flag1);
|
NaturalSpawner.m_47029_(this.f_8329_, levelchunk1, naturalspawner$spawnstate, this.f_8336_, this.f_8335_, flag1);
|
||||||
@@ -426,6 +_,14 @@
|
@@ -421,11 +_,29 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void m_8387_(TicketType<T> p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_) {
|
||||||
|
- this.f_8327_.m_140840_(p_8388_, p_8389_, p_8390_, p_8391_);
|
||||||
|
+ addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public <T> void addRegionTicket(TicketType<T> p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_, boolean forceTicks) {
|
||||||
|
+ this.f_8327_.addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_, forceTicks);
|
||||||
|
}
|
||||||
|
|
||||||
public <T> void m_8438_(TicketType<T> p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_) {
|
public <T> void m_8438_(TicketType<T> p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_) {
|
||||||
this.f_8327_.m_140849_(p_8439_, p_8440_, p_8441_, p_8442_);
|
- this.f_8327_.m_140849_(p_8439_, p_8440_, p_8441_, p_8442_);
|
||||||
|
+ removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_, false);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ public <T> void removeRegionTicket(TicketType<T> p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_, boolean forceTicks) {
|
||||||
|
+ this.f_8327_.removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_, forceTicks);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.18.2") // Use addRegionTicket overload
|
||||||
+ public <T> void registerTickingTicket(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
+ public <T> void registerTickingTicket(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
||||||
+ this.f_8327_.registerTicking(type, pos, distance, value);
|
+ addRegionTicket(type, pos, distance, value, true);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.18.2") // Use removeRegionTicket overload
|
||||||
+ public <T> void releaseTickingTicket(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
+ public <T> void releaseTickingTicket(TicketType<T> type, ChunkPos pos, int distance, T value) {
|
||||||
+ this.f_8327_.releaseTicking(type, pos, distance, value);
|
+ removeRegionTicket(type, pos, distance, value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void m_6692_(ChunkPos p_8400_, boolean p_8401_) {
|
public void m_6692_(ChunkPos p_8400_, boolean p_8401_) {
|
||||||
@@ -260,12 +260,17 @@
|
|||||||
ServerLevel.this.f_143247_.remove(enderdragonpart.m_142049_());
|
ServerLevel.this.f_143247_.remove(enderdragonpart.m_142049_());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1538,6 +_,8 @@
|
@@ -1538,6 +_,13 @@
|
||||||
gameeventlistenerregistrar.m_157854_(p_143375_.f_19853_);
|
gameeventlistenerregistrar.m_157854_(p_143375_.f_19853_);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ p_143375_.onRemovedFromWorld();
|
+ p_143375_.onRemovedFromWorld();
|
||||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_143375_, ServerLevel.this));
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_143375_, ServerLevel.this));
|
||||||
}
|
}
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public java.util.Collection<net.minecraftforge.entity.PartEntity<?>> getPartEntities() {
|
||||||
|
+ return this.f_143247_.values();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,17 @@
|
|||||||
--- a/net/minecraft/server/level/ServerPlayerGameMode.java
|
--- a/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java
|
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||||
@@ -125,7 +_,15 @@
|
@@ -125,7 +_,13 @@
|
||||||
double d1 = this.f_9245_.m_20186_() - ((double)p_9282_.m_123342_() + 0.5D) + 1.5D;
|
double d1 = this.f_9245_.m_20186_() - ((double)p_9282_.m_123342_() + 0.5D) + 1.5D;
|
||||||
double d2 = this.f_9245_.m_20189_() - ((double)p_9282_.m_123343_() + 0.5D);
|
double d2 = this.f_9245_.m_20189_() - ((double)p_9282_.m_123343_() + 0.5D);
|
||||||
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
- if (d3 > 36.0D) {
|
- if (d3 > 36.0D) {
|
||||||
+ double dist = f_9245_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_() + 1;
|
|
||||||
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(f_9245_, p_9282_, p_9284_);
|
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(f_9245_, p_9282_, p_9284_);
|
||||||
+ if (event.isCanceled() || (!this.m_9295_() && event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data
|
+ if (event.isCanceled() || (!this.m_9295_() && event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY)) { // Restore block and te data
|
||||||
+ f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, f_9244_.m_8055_(p_9282_), p_9283_, false, "mod canceled"));
|
+ f_9245_.f_8906_.m_141995_(new ClientboundBlockBreakAckPacket(p_9282_, f_9244_.m_8055_(p_9282_), p_9283_, false, "mod canceled"));
|
||||||
+ f_9244_.m_7260_(p_9282_, f_9244_.m_8055_(p_9282_), f_9244_.m_8055_(p_9282_), 3);
|
+ f_9244_.m_7260_(p_9282_, f_9244_.m_8055_(p_9282_), f_9244_.m_8055_(p_9282_), 3);
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ dist *= dist;
|
+ if (!this.f_9245_.canInteractWith(p_9282_, 1)) {
|
||||||
+ if (d3 > dist) {
|
|
||||||
BlockState blockstate1;
|
BlockState blockstate1;
|
||||||
if (this.f_9245_.f_19853_.m_142572_() != null && this.f_9245_.m_146902_().m_45594_(new ChunkPos(p_9282_)) < this.f_9245_.f_19853_.m_142572_().m_6846_().m_11312_()) {
|
if (this.f_9245_.f_19853_.m_142572_() != null && this.f_9245_.m_146902_().m_45594_(new ChunkPos(p_9282_)) < this.f_9245_.f_19853_.m_142572_().m_6846_().m_11312_()) {
|
||||||
blockstate1 = this.f_9244_.m_8055_(p_9282_);
|
blockstate1 = this.f_9244_.m_8055_(p_9282_);
|
||||||
|
|||||||
@@ -15,11 +15,12 @@
|
|||||||
});
|
});
|
||||||
final MinecraftServer f_9702_;
|
final MinecraftServer f_9702_;
|
||||||
public volatile boolean f_9700_;
|
public volatile boolean f_9700_;
|
||||||
@@ -67,6 +_,7 @@
|
@@ -67,6 +_,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void m_9711_(@Nullable InetAddress p_9712_, int p_9713_) throws IOException {
|
public void m_9711_(@Nullable InetAddress p_9712_, int p_9713_) throws IOException {
|
||||||
+ if (p_9712_ instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false");
|
+ if (p_9712_ == null) p_9712_ = new java.net.InetSocketAddress(p_9713_).getAddress();
|
||||||
|
+ net.minecraftforge.network.DualStackUtils.checkIPv6(p_9712_);
|
||||||
synchronized(this.f_9703_) {
|
synchronized(this.f_9703_) {
|
||||||
Class<? extends ServerSocketChannel> oclass;
|
Class<? extends ServerSocketChannel> oclass;
|
||||||
LazyLoadedValue<? extends EventLoopGroup> lazyloadedvalue;
|
LazyLoadedValue<? extends EventLoopGroup> lazyloadedvalue;
|
||||||
|
|||||||
+26
-11
@@ -21,14 +21,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void m_7376_(ServerboundAcceptTeleportationPacket p_9835_) {
|
public void m_7376_(ServerboundAcceptTeleportationPacket p_9835_) {
|
||||||
@@ -979,7 +_,9 @@
|
@@ -979,7 +_,7 @@
|
||||||
this.f_9743_.m_9243_();
|
this.f_9743_.m_9243_();
|
||||||
int i = this.f_9743_.f_19853_.m_151558_();
|
int i = this.f_9743_.f_19853_.m_151558_();
|
||||||
if (blockpos.m_123342_() < i) {
|
if (blockpos.m_123342_() < i) {
|
||||||
- if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < 64.0D && serverlevel.m_7966_(this.f_9743_, blockpos)) {
|
- if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < 64.0D && serverlevel.m_7966_(this.f_9743_, blockpos)) {
|
||||||
+ double dist = f_9743_.m_21051_(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).m_22135_() + 3;
|
+ if (this.f_9766_ == null && this.f_9743_.canInteractWith(blockpos, 3) && serverlevel.m_7966_(this.f_9743_, blockpos)) {
|
||||||
+ dist *= dist;
|
|
||||||
+ if (this.f_9766_ == null && this.f_9743_.m_20275_((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.5D, (double)blockpos.m_123343_() + 0.5D) < dist && serverlevel.m_7966_(this.f_9743_, blockpos)) {
|
|
||||||
InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult);
|
InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult);
|
||||||
if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) {
|
if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) {
|
||||||
Component component = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED);
|
Component component = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED);
|
||||||
@@ -41,27 +39,44 @@
|
|||||||
|
|
||||||
for(int i = 0; i < s.length(); ++i) {
|
for(int i = 0; i < s.length(); ++i) {
|
||||||
if (!SharedConstants.m_136188_(s.charAt(i))) {
|
if (!SharedConstants.m_136188_(s.charAt(i))) {
|
||||||
@@ -1129,8 +_,11 @@
|
@@ -1129,8 +_,10 @@
|
||||||
String s1 = p_143629_.m_143722_();
|
String s1 = p_143629_.m_143722_();
|
||||||
Component component = s1.isEmpty() ? null : new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s1);
|
Component component = s1.isEmpty() ? null : new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s1);
|
||||||
Component component1 = new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s);
|
Component component1 = new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s);
|
||||||
+ component1 = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, component1);
|
- this.f_9745_.m_6846_().m_143991_(component1, (p_184197_) -> {
|
||||||
+ Component finalComponent = component1;
|
|
||||||
+ if (finalComponent != null)
|
|
||||||
this.f_9745_.m_6846_().m_143991_(component1, (p_184197_) -> {
|
|
||||||
- return this.f_9743_.m_143421_(p_184197_) ? component : component1;
|
- return this.f_9743_.m_143421_(p_184197_) ? component : component1;
|
||||||
+ return this.f_9743_.m_143421_(p_184197_) ? component : finalComponent;
|
+ var event = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, component1, s1, component);
|
||||||
|
+ if (event != null && event.getComponent() != null)
|
||||||
|
+ this.f_9745_.m_6846_().m_143991_(event.getComponent(), (p_184197_) -> {
|
||||||
|
+ return this.f_9743_.m_143421_(p_184197_) ? event.getFilteredComponent() : event.getComponent();
|
||||||
}, ChatType.CHAT, this.f_9743_.m_142081_());
|
}, ChatType.CHAT, this.f_9743_.m_142081_());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1222,6 +_,7 @@
|
@@ -1216,12 +_,13 @@
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
- double d0 = 36.0D;
|
||||||
|
- if (this.f_9743_.m_20280_(entity) < 36.0D) {
|
||||||
|
+ if (true) { //Forge: Perform distance checks below since interactions and attacks differ.
|
||||||
|
p_9866_.m_179617_(new ServerboundInteractPacket.Handler() {
|
||||||
private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) {
|
private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) {
|
||||||
|
+ if(!ServerGamePacketListenerImpl.this.f_9743_.canInteractWith(entity, 1.5D)) return; //Forge: If the entity cannot be reached, do nothing. Original check was dist < 6, range is 4.5, so vanilla used padding=1.5
|
||||||
ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_).m_41777_();
|
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_);
|
InteractionResult interactionresult = p_143680_.m_143694_(ServerGamePacketListenerImpl.this.f_9743_, entity, p_143679_);
|
||||||
+ if (net.minecraftforge.common.ForgeHooks.onInteractEntityAt(f_9743_, entity, entity.m_20182_(), p_143679_) != null) return;
|
+ if (net.minecraftforge.common.ForgeHooks.onInteractEntityAt(f_9743_, entity, entity.m_20182_(), p_143679_) != null) return;
|
||||||
if (interactionresult.m_19077_()) {
|
if (interactionresult.m_19077_()) {
|
||||||
CriteriaTriggers.f_10565_.m_61494_(ServerGamePacketListenerImpl.this.f_9743_, itemstack, entity);
|
CriteriaTriggers.f_10565_.m_61494_(ServerGamePacketListenerImpl.this.f_9743_, itemstack, entity);
|
||||||
if (interactionresult.m_19080_()) {
|
if (interactionresult.m_19080_()) {
|
||||||
|
@@ -1243,7 +_,7 @@
|
||||||
|
|
||||||
|
public void m_141994_() {
|
||||||
|
if (!(entity instanceof ItemEntity) && !(entity instanceof ExperienceOrb) && !(entity instanceof AbstractArrow) && entity != ServerGamePacketListenerImpl.this.f_9743_) {
|
||||||
|
- ServerGamePacketListenerImpl.this.f_9743_.m_5706_(entity);
|
||||||
|
+ if(ServerGamePacketListenerImpl.this.f_9743_.canHit(entity, 3)) ServerGamePacketListenerImpl.this.f_9743_.m_5706_(entity); //Forge: Perform attack range check. Original check was dist < 6, range is 3, so vanilla used padding=3
|
||||||
|
} else {
|
||||||
|
ServerGamePacketListenerImpl.this.m_9942_(new TranslatableComponent("multiplayer.disconnect.invalid_entity_attacked"));
|
||||||
|
ServerGamePacketListenerImpl.f_9744_.warn("Player {} tried to attack an invalid entity", (Object)ServerGamePacketListenerImpl.this.f_9743_.m_7755_().getString());
|
||||||
@@ -1430,6 +_,8 @@
|
@@ -1430,6 +_,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
--- a/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java
|
||||||
|
+++ b/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java
|
||||||
|
@@ -6,17 +_,29 @@
|
||||||
|
public static final PackMetadataSectionSerializer f_10366_ = new PackMetadataSectionSerializer();
|
||||||
|
private final Component f_10367_;
|
||||||
|
private final int f_10368_;
|
||||||
|
+ private final java.util.Map<net.minecraft.server.packs.PackType, Integer> packTypeVersions;
|
||||||
|
|
||||||
|
public PackMetadataSection(Component p_10371_, int p_10372_) {
|
||||||
|
this.f_10367_ = p_10371_;
|
||||||
|
this.f_10368_ = p_10372_;
|
||||||
|
+ this.packTypeVersions = java.util.Map.of();
|
||||||
|
+ }
|
||||||
|
+ public PackMetadataSection(Component p_10371_, int p_10372_, java.util.Map<net.minecraft.server.packs.PackType, Integer> packTypeVersions) {
|
||||||
|
+ this.f_10367_ = p_10371_;
|
||||||
|
+ this.f_10368_ = p_10372_;
|
||||||
|
+ this.packTypeVersions = packTypeVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component m_10373_() {
|
||||||
|
return this.f_10367_;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /** @deprecated Forge: Use {@link #getPackFormat(net.minecraft.server.packs.PackType)} instead.*/
|
||||||
|
+ @Deprecated
|
||||||
|
public int m_10374_() {
|
||||||
|
return this.f_10368_;
|
||||||
|
+ }
|
||||||
|
+ public int getPackFormat(net.minecraft.server.packs.PackType packType) {
|
||||||
|
+ return packTypeVersions.getOrDefault(packType, this.f_10368_);
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java
|
||||||
|
+++ b/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java
|
||||||
|
@@ -13,7 +_,7 @@
|
||||||
|
throw new JsonParseException("Invalid/missing description!");
|
||||||
|
} else {
|
||||||
|
int i = GsonHelper.m_13927_(p_10380_, "pack_format");
|
||||||
|
- return new PackMetadataSection(component, i);
|
||||||
|
+ return new PackMetadataSection(component, i, net.minecraftforge.common.ForgeHooks.readTypedPackFormats(p_10380_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/server/packs/repository/PackCompatibility.java
|
||||||
|
+++ b/net/minecraft/server/packs/repository/PackCompatibility.java
|
||||||
|
@@ -34,7 +_,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PackCompatibility m_143885_(PackMetadataSection p_143886_, PackType p_143887_) {
|
||||||
|
- return m_143882_(p_143886_.m_10374_(), p_143887_);
|
||||||
|
+ return m_143882_(p_143886_.getPackFormat(p_143887_), p_143887_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component m_10492_() {
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
--- a/net/minecraft/server/packs/resources/ReloadableResourceManager.java
|
||||||
|
+++ b/net/minecraft/server/packs/resources/ReloadableResourceManager.java
|
||||||
|
@@ -68,4 +_,10 @@
|
||||||
|
public Stream<PackResources> m_7536_() {
|
||||||
|
return this.f_203815_.m_7536_();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ public void registerReloadListenerIfNotPresent(PreparableReloadListener listener) {
|
||||||
|
+ if (!this.f_203816_.contains(listener)) {
|
||||||
|
+ this.m_7217_(listener);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
@@ -17,6 +17,14 @@
|
|||||||
private final EntityType<?> f_19847_;
|
private final EntityType<?> f_19847_;
|
||||||
private int f_19848_ = f_19843_.incrementAndGet();
|
private int f_19848_ = f_19843_.incrementAndGet();
|
||||||
public boolean f_19850_;
|
public boolean f_19850_;
|
||||||
|
@@ -175,6 +_,7 @@
|
||||||
|
public double f_19790_;
|
||||||
|
public double f_19791_;
|
||||||
|
public double f_19792_;
|
||||||
|
+ @Deprecated // Forge - see IForgeEntity#getStepHeight
|
||||||
|
public float f_19793_;
|
||||||
|
public boolean f_19794_;
|
||||||
|
protected final Random f_19796_ = new Random();
|
||||||
@@ -229,6 +_,7 @@
|
@@ -229,6 +_,7 @@
|
||||||
private BlockState f_185934_ = null;
|
private BlockState f_185934_ = null;
|
||||||
|
|
||||||
@@ -108,6 +116,22 @@
|
|||||||
return blockpos1;
|
return blockpos1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -791,10 +_,11 @@
|
||||||
|
boolean flag1 = p_20273_.f_82480_ != vec3.f_82480_;
|
||||||
|
boolean flag2 = p_20273_.f_82481_ != vec3.f_82481_;
|
||||||
|
boolean flag3 = this.f_19861_ || flag1 && p_20273_.f_82480_ < 0.0D;
|
||||||
|
- if (this.f_19793_ > 0.0F && flag3 && (flag || flag2)) {
|
||||||
|
- Vec3 vec31 = m_198894_(this, new Vec3(p_20273_.f_82479_, (double)this.f_19793_, p_20273_.f_82481_), aabb, this.f_19853_, list);
|
||||||
|
- Vec3 vec32 = m_198894_(this, new Vec3(0.0D, (double)this.f_19793_, 0.0D), aabb.m_82363_(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), this.f_19853_, list);
|
||||||
|
- if (vec32.f_82480_ < (double)this.f_19793_) {
|
||||||
|
+ float stepHeight = getStepHeight();
|
||||||
|
+ if (stepHeight > 0.0F && flag3 && (flag || flag2)) {
|
||||||
|
+ Vec3 vec31 = m_198894_(this, new Vec3(p_20273_.f_82479_, (double)stepHeight, p_20273_.f_82481_), aabb, this.f_19853_, list);
|
||||||
|
+ Vec3 vec32 = m_198894_(this, new Vec3(0.0D, (double)stepHeight, 0.0D), aabb.m_82363_(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), this.f_19853_, list);
|
||||||
|
+ if (vec32.f_82480_ < (double)stepHeight) {
|
||||||
|
Vec3 vec33 = m_198894_(this, new Vec3(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), aabb.m_82383_(vec32), this.f_19853_, list).m_82549_(vec32);
|
||||||
|
if (vec33.m_165925_() > vec31.m_165925_()) {
|
||||||
|
vec31 = vec33;
|
||||||
@@ -929,7 +_,7 @@
|
@@ -929,7 +_,7 @@
|
||||||
protected void m_7355_(BlockPos p_20135_, BlockState p_20136_) {
|
protected void m_7355_(BlockPos p_20135_, BlockState p_20136_) {
|
||||||
if (!p_20136_.m_60767_().m_76332_()) {
|
if (!p_20136_.m_60767_().m_76332_()) {
|
||||||
@@ -217,7 +241,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean m_7306_(Entity p_20356_) {
|
public boolean m_7306_(Entity p_20356_) {
|
||||||
@@ -2237,14 +_,19 @@
|
@@ -2237,14 +_,20 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity m_5489_(ServerLevel p_20118_) {
|
public Entity m_5489_(ServerLevel p_20118_) {
|
||||||
@@ -225,6 +249,7 @@
|
|||||||
+ }
|
+ }
|
||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ public Entity changeDimension(ServerLevel p_20118_, net.minecraftforge.common.util.ITeleporter teleporter) {
|
+ public Entity changeDimension(ServerLevel p_20118_, net.minecraftforge.common.util.ITeleporter teleporter) {
|
||||||
|
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_20118_.m_46472_())) return null;
|
||||||
if (this.f_19853_ instanceof ServerLevel && !this.m_146910_()) {
|
if (this.f_19853_ instanceof ServerLevel && !this.m_146910_()) {
|
||||||
this.f_19853_.m_46473_().m_6180_("changeDimension");
|
this.f_19853_.m_46473_().m_6180_("changeDimension");
|
||||||
this.m_19877_();
|
this.m_19877_();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
public static AttributeSupplier.Builder m_21183_() {
|
public static AttributeSupplier.Builder m_21183_() {
|
||||||
- return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_);
|
- return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_);
|
||||||
+ return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_).m_22266_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22266_(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.get()).m_22266_(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get());
|
+ return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_).m_22266_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22266_(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.get()).m_22266_(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()).m_22266_(net.minecraftforge.common.ForgeMod.STEP_HEIGHT_ADDITION.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void m_7840_(double p_20990_, boolean p_20991_, BlockState p_20992_, BlockPos p_20993_) {
|
protected void m_7840_(double p_20990_, boolean p_20991_, BlockState p_20992_, BlockPos p_20993_) {
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
--- a/net/minecraft/world/entity/Mob.java
|
--- a/net/minecraft/world/entity/Mob.java
|
||||||
+++ b/net/minecraft/world/entity/Mob.java
|
+++ b/net/minecraft/world/entity/Mob.java
|
||||||
@@ -206,6 +_,7 @@
|
@@ -205,7 +_,11 @@
|
||||||
|
}
|
||||||
|
|
||||||
public void m_6710_(@Nullable LivingEntity p_21544_) {
|
public void m_6710_(@Nullable LivingEntity p_21544_) {
|
||||||
this.f_21362_ = p_21544_;
|
- this.f_21362_ = p_21544_;
|
||||||
+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(this, p_21544_);
|
+ net.minecraftforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.minecraftforge.common.ForgeHooks.onLivingChangeTarget(this, p_21544_, net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.MOB_TARGET);
|
||||||
|
+ if(!changeTargetEvent.isCanceled()) {
|
||||||
|
+ this.f_21362_ = changeTargetEvent.getNewTarget();
|
||||||
|
+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(this, this.f_21362_); // TODO: Remove in 1.20
|
||||||
|
+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean m_6549_(EntityType<?> p_21399_) {
|
public boolean m_6549_(EntityType<?> p_21399_) {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
--- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java
|
||||||
|
+++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java
|
||||||
|
@@ -42,7 +_,11 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private void m_24213_(E p_24214_, LivingEntity p_24215_) {
|
||||||
|
- p_24214_.m_6274_().m_21879_(MemoryModuleType.f_26372_, p_24215_);
|
||||||
|
- p_24214_.m_6274_().m_21936_(MemoryModuleType.f_26326_);
|
||||||
|
- }
|
||||||
|
+ net.minecraftforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.minecraftforge.common.ForgeHooks.onLivingChangeTarget(p_24214_, p_24215_, net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET);
|
||||||
|
+ if(!changeTargetEvent.isCanceled()) {
|
||||||
|
+ p_24214_.m_6274_().m_21879_(MemoryModuleType.f_26372_, changeTargetEvent.getNewTarget());
|
||||||
|
+ p_24214_.m_6274_().m_21936_(MemoryModuleType.f_26326_);
|
||||||
|
+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(p_24214_, changeTargetEvent.getNewTarget(), net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); // TODO: Remove in 1.20
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/world/entity/ai/control/MoveControl.java
|
||||||
|
+++ b/net/minecraft/world/entity/ai/control/MoveControl.java
|
||||||
|
@@ -99,7 +_,7 @@
|
||||||
|
BlockPos blockpos = this.f_24974_.m_142538_();
|
||||||
|
BlockState blockstate = this.f_24974_.f_19853_.m_8055_(blockpos);
|
||||||
|
VoxelShape voxelshape = blockstate.m_60812_(this.f_24974_.f_19853_, blockpos);
|
||||||
|
- if (d2 > (double)this.f_24974_.f_19793_ && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.f_24974_.m_20205_()) || !voxelshape.m_83281_() && this.f_24974_.m_20186_() < voxelshape.m_83297_(Direction.Axis.Y) + (double)blockpos.m_123342_() && !blockstate.m_204336_(BlockTags.f_13103_) && !blockstate.m_204336_(BlockTags.f_13039_)) {
|
||||||
|
+ if (d2 > (double)this.f_24974_.getStepHeight() && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.f_24974_.m_20205_()) || !voxelshape.m_83281_() && this.f_24974_.m_20186_() < voxelshape.m_83297_(Direction.Axis.Y) + (double)blockpos.m_123342_() && !blockstate.m_204336_(BlockTags.f_13103_) && !blockstate.m_204336_(BlockTags.f_13039_)) {
|
||||||
|
this.f_24974_.m_21569_().m_24901_();
|
||||||
|
this.f_24981_ = MoveControl.Operation.JUMPING;
|
||||||
|
}
|
||||||
@@ -5,7 +5,18 @@
|
|||||||
|
|
||||||
public boolean m_8036_() {
|
public boolean m_8036_() {
|
||||||
- if (!this.f_25837_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) {
|
- if (!this.f_25837_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_)) {
|
||||||
+ if (!net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.f_25837_.f_19853_, this.f_25602_, this.f_25837_)) {
|
+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25837_.f_19853_, this.f_25837_)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (this.f_25600_ > 0) {
|
} else if (this.f_25600_ > 0) {
|
||||||
--this.f_25600_;
|
--this.f_25600_;
|
||||||
|
@@ -133,7 +_,9 @@
|
||||||
|
if (chunkaccess == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
- return chunkaccess.m_8055_(p_25851_).m_60713_(this.f_25836_) && chunkaccess.m_8055_(p_25851_.m_7494_()).m_60795_() && chunkaccess.m_8055_(p_25851_.m_6630_(2)).m_60795_();
|
||||||
|
+ net.minecraft.world.level.block.state.BlockState state = chunkaccess.m_8055_(p_25851_);
|
||||||
|
+ if (!(state.canEntityDestroy(p_25850_, p_25851_, this.f_25837_) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this.f_25837_, p_25851_, state))) return false;
|
||||||
|
+ return state.m_60713_(this.f_25836_) && chunkaccess.m_8055_(p_25851_.m_7494_()).m_60795_() && chunkaccess.m_8055_(p_25851_.m_6630_(2)).m_60795_();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
--- a/net/minecraft/world/entity/animal/Cat.java
|
--- a/net/minecraft/world/entity/animal/Cat.java
|
||||||
+++ b/net/minecraft/world/entity/animal/Cat.java
|
+++ b/net/minecraft/world/entity/animal/Cat.java
|
||||||
@@ -400,7 +_,7 @@
|
@@ -399,8 +_,8 @@
|
||||||
|
if (this.m_21830_(p_28153_)) {
|
||||||
if (!(item instanceof DyeItem)) {
|
if (!(item instanceof DyeItem)) {
|
||||||
if (item.m_41472_() && this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) {
|
if (item.m_41472_() && this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) {
|
||||||
|
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
|
||||||
this.m_142075_(p_28153_, p_28154_, itemstack);
|
this.m_142075_(p_28153_, p_28154_, itemstack);
|
||||||
- this.m_5634_((float)item.m_41473_().m_38744_());
|
- this.m_5634_((float)item.m_41473_().m_38744_());
|
||||||
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
|
|
||||||
return InteractionResult.CONSUME;
|
return InteractionResult.CONSUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
k = Mth.m_14107_(this.m_20189_() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F));
|
k = Mth.m_14107_(this.m_20189_() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F));
|
||||||
BlockPos blockpos1 = new BlockPos(i, j, k);
|
BlockPos blockpos1 = new BlockPos(i, j, k);
|
||||||
- if (this.f_19853_.m_8055_(blockpos1).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos1)) {
|
- if (this.f_19853_.m_8055_(blockpos1).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos1)) {
|
||||||
+ if (this.f_19853_.m_46859_(blockpos) && blockstate.m_60710_(this.f_19853_, blockpos)) {
|
+ if (this.f_19853_.m_46859_(blockpos1) && blockstate.m_60710_(this.f_19853_, blockpos1)) {
|
||||||
this.f_19853_.m_46597_(blockpos1, blockstate);
|
this.f_19853_.m_46597_(blockpos1, blockstate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
--- a/net/minecraft/world/entity/animal/Wolf.java
|
--- a/net/minecraft/world/entity/animal/Wolf.java
|
||||||
+++ b/net/minecraft/world/entity/animal/Wolf.java
|
+++ b/net/minecraft/world/entity/animal/Wolf.java
|
||||||
@@ -329,7 +_,7 @@
|
@@ -325,11 +_,11 @@
|
||||||
|
} else {
|
||||||
|
if (this.m_21824_()) {
|
||||||
|
if (this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) {
|
||||||
|
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
|
||||||
|
if (!p_30412_.m_150110_().f_35937_) {
|
||||||
itemstack.m_41774_(1);
|
itemstack.m_41774_(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
- this.m_5634_((float)item.m_41473_().m_38744_());
|
- this.m_5634_((float)item.m_41473_().m_38744_());
|
||||||
+ this.m_5634_((float)itemstack.getFoodProperties(this).m_38744_());
|
|
||||||
this.m_146859_(GameEvent.f_157771_, this.m_146901_());
|
this.m_146859_(GameEvent.f_157771_, this.m_146901_());
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-7
@@ -1,5 +1,20 @@
|
|||||||
--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||||
+++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
+++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||||
|
@@ -107,6 +_,14 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
this.f_31074_ = new EnderDragonPhaseManager(this);
|
||||||
|
+ this.m_20234_(f_19843_.getAndAdd(this.f_31089_.length + 1) + 1); // Forge: Fix MC-158205: Make sure part ids are successors of parent mob id
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void m_20234_(int p_20235_) {
|
||||||
|
+ super.m_20234_(p_20235_);
|
||||||
|
+ for (int i = 0; i < this.f_31089_.length; i++) // Forge: Fix MC-158205: Set part ids to successors of parent mob id
|
||||||
|
+ this.f_31089_[i].m_20234_(p_20235_ + i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AttributeSupplier.Builder m_31167_() {
|
||||||
@@ -150,7 +_,11 @@
|
@@ -150,7 +_,11 @@
|
||||||
return adouble;
|
return adouble;
|
||||||
}
|
}
|
||||||
@@ -41,12 +56,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.f_31073_ != null) {
|
if (this.f_31073_ != null) {
|
||||||
@@ -847,6 +_,16 @@
|
@@ -849,8 +_,19 @@
|
||||||
|
|
||||||
public boolean m_6072_() {
|
|
||||||
return false;
|
return false;
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public boolean isMultipartEntity() {
|
+ public boolean isMultipartEntity() {
|
||||||
+ return true;
|
+ return true;
|
||||||
@@ -55,6 +68,11 @@
|
|||||||
+ @Override
|
+ @Override
|
||||||
+ public net.minecraftforge.entity.PartEntity<?>[] getParts() {
|
+ public net.minecraftforge.entity.PartEntity<?>[] getParts() {
|
||||||
+ return this.f_31089_;
|
+ return this.f_31089_;
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
public void m_142223_(ClientboundAddMobPacket p_149572_) {
|
public void m_142223_(ClientboundAddMobPacket p_149572_) {
|
||||||
|
super.m_142223_(p_149572_);
|
||||||
|
+ if (true) return; // Forge: Fix MC-158205: Moved into setId()
|
||||||
|
EnderDragonPart[] aenderdragonpart = this.m_31156_();
|
||||||
|
|
||||||
|
for(int i = 0; i < aenderdragonpart.length; ++i) {
|
||||||
Loaded 100 of 291 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user