Compare commits

...
1 Commits
Author SHA1 Message Date
4ed9117799 Forge 1.19
* Bump pack.mcmeta formats
* 1.19 biome modifiers
* Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable
* Add docs and package-info to client extension interfaces package
* Move RenderBlockOverlayEvent hooks to ForgeHooksClient
* Add package-infos to client events package
* Rename SoundLoadEvent to SoundEngineLoadEvent

This reduces confusion from consumers which may think the
name SoundLoadEvent refers to an individual sound being loaded rather
than the sound engine.
* Document and change SoundLoadEvent to fire on mod bus

Previously, it fired on both the mod bus and the Forge bus, which is
confusing for consumers.
* Delete SoundSetupEvent

Looking at its original implementation shows that there isn't an
appropriate place in the new sound code to reinsert the event, and the
place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent.
* Perform some cleanup on client events

 - Removed nullable annotations from ClientPlayerNetworkEvent
 - Renamed #getPartialTicks methods to #getPartialTick, to be consistent
  with vanilla's naming of the partial tick
 - Cleanup documentation to remove line breaks, use the
  spelling 'cancelled' over
  'canceled', and improve docs on existing and
   new methods.
* Remove EntityEvent.CanUpdate

Closes MinecraftForge/MinecraftForge#6394
* Switch to Jetbrains nullability annotations
* New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent
* Remove ForgeWorldPresetScreens
* Remove IForgeRegistryEntry
* Remove use of List<Throwable> in FML's CompletableFutures
* Add docs to mod loading stages, stages, and phases
* Gradle 7.4.2
* Use SLF4J in FMLLoader and other subprojects
* Switch dynamic versions in subprojects to pinned ones
* Switch ForgeRoot and MDK to FG plugin markers
* Configure Forge javadoc task

The task now uses a custom stylesheet with MCForge elements, and
configured to combine the generation from the four FML subprojects
(fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project
into the javadoc output.
* Update docs/md files, for 1.19 update and the move away from IRC to Discord.
* Make "Potentially dangerous alternative prefix" a debug warning, not info.

Co-authored-by: Curle <[email protected]>
Co-authored-by: sciwhiz12 <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
2022-06-07 15:31:26 -05:00
1485 changed files with 14960 additions and 15446 deletions

No files matched your search

+1
View File
@@ -33,6 +33,7 @@
/projects/**/*.launch /projects/**/*.launch
/repo/ /repo/
src/generated/resources/.cache/ src/generated/resources/.cache/
src/generated_test/resources/.cache/
#Patch rejects #Patch rejects
/patches-/ /patches-/
+130 -40
View File
@@ -1,14 +1,3 @@
buildscript {
repositories {
mavenLocal()
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:[5.1.39,)'
}
}
import groovy.json.JsonBuilder import groovy.json.JsonBuilder
import java.nio.file.Files import java.nio.file.Files
@@ -31,6 +20,8 @@ plugins {
id 'net.minecraftforge.gradleutils' version '2.+' id 'net.minecraftforge.gradleutils' version '2.+'
id 'eclipse' id 'eclipse'
id 'de.undercouch.download' version '4.1.2' id 'de.undercouch.download' version '4.1.2'
id 'net.minecraftforge.gradle.patcher' version '[5.1.39,)' apply false
id 'net.minecraftforge.gradle.mcp' version '[5.1.39,)' apply false
} }
Util.init() //Init all our extension methods! Util.init() //Init all our extension methods!
@@ -45,9 +36,9 @@ ext {
] ]
} }
MAPPING_CHANNEL = 'official' MAPPING_CHANNEL = 'official'
MAPPING_VERSION = '1.18.2' MAPPING_VERSION = '1.19'
MC_VERSION = '1.18.2' MC_VERSION = '1.19'
MCP_VERSION = '20220404.173914' MCP_VERSION = '20220607.102129'
SPI_VERSION = '4.0.10' SPI_VERSION = '4.0.10'
ACCESSTRANSFORMERS_VERSION = '8.0.4' ACCESSTRANSFORMERS_VERSION = '8.0.4'
COREMODS_VERSION = '5.0.1' COREMODS_VERSION = '5.0.1'
@@ -55,22 +46,36 @@ ext {
MODLAUNCHER_VERSION = '9.1.3' MODLAUNCHER_VERSION = '9.1.3'
SECUREJARHANDLER_VERSION = '1.0.3' SECUREJARHANDLER_VERSION = '1.0.3'
BOOTSTRAPLAUNCHER_VERSION = '1.0.0' BOOTSTRAPLAUNCHER_VERSION = '1.0.0'
ASM_VERSION = '9.2' ASM_VERSION = '9.3'
INSTALLER_VERSION = '2.1.+' INSTALLER_VERSION = '2.1.+'
MIXIN_VERSION = '0.8.5' MIXIN_VERSION = '0.8.5'
TERMINALCONSOLEAPPENDER_VERSION = '1.2.0'
JLINE_VERSION = '3.12.+'
NIGHTCONFIG_VERSION = '3.6.4'
JETBRAINS_ANNOTATIONS_VERSION = '23.0.0'
SLF4J_API_VERSION = '1.8.0-beta4'
APACHE_MAVEN_ARTIFACT_VERSION = '3.8.5'
// These versions should be kept in sync with the version manifest JSON
// To use a version newer than the version manifest JSON, the dependency must be added to the installer configuration
MOJANG_LOGGING_VERSION = '1.0.0'
LOG4J_VERSION = '2.17.0'
GUAVA_VERSION = '31.0.1-jre'
GSON_VERSION = '2.8.9'
APACHE_COMMONS_LANG3_VERSION = '3.12.0'
JOPT_SIMPLE_VERSION = '5.0.4'
COMMONS_IO_VERSION = '2.11.0'
GIT_INFO = gradleutils.gitInfo GIT_INFO = gradleutils.gitInfo
VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION) VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION)
// FML_VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, 'FML', MC_VERSION) // FML_VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, 'FML', MC_VERSION)
FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1) FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1)
SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0' BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.1.1:fatjar'
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar'
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.3.0' INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.3.0'
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4' JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all' FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all'
MIN_TAG_FOR_CHANGELOG = "39.0" MIN_TAG_FOR_CHANGELOG = "39.0"
LAST_RB = GIT_INFO.tag.rsplit('.', 1)[1] as int >= 1 ? GIT_INFO.tag + '.0' : null
} }
println('Version: ' + VERSION + println('Version: ' + VERSION +
@@ -138,6 +143,10 @@ subprojects {
name = 'forge' name = 'forge'
url = 'https://maven.minecraftforge.net/' url = 'https://maven.minecraftforge.net/'
} }
maven {
name = 'minecraft'
url = 'https://libraries.minecraft.net/'
}
} }
java.toolchain.languageVersion = JavaLanguageVersion.of(17) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
@@ -259,19 +268,19 @@ def sharedDeps = {
installer "org.ow2.asm:asm-util:${ASM_VERSION}" installer "org.ow2.asm:asm-util:${ASM_VERSION}"
installer "org.ow2.asm:asm-analysis:${ASM_VERSION}" installer "org.ow2.asm:asm-analysis:${ASM_VERSION}"
installer "net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}" installer "net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}"
installer 'org.antlr:antlr4-runtime:4.9.1' //Dep of AccessTransformer installer 'org.antlr:antlr4-runtime:4.9.1' // Dep of AccessTransformer
installer "net.minecraftforge:eventbus:${EVENTBUS_VERSION}" installer "net.minecraftforge:eventbus:${EVENTBUS_VERSION}"
installer "net.minecraftforge:forgespi:${SPI_VERSION}" installer "net.minecraftforge:forgespi:${SPI_VERSION}"
installer "net.minecraftforge:coremods:${COREMODS_VERSION}" installer "net.minecraftforge:coremods:${COREMODS_VERSION}"
installer "cpw.mods:modlauncher:${MODLAUNCHER_VERSION}" installer "cpw.mods:modlauncher:${MODLAUNCHER_VERSION}"
installer 'net.minecraftforge:unsafe:0.2.+' installer 'net.minecraftforge:unsafe:0.2.+'
installer 'com.electronwill.night-config:core:3.6.4' installer "com.electronwill.night-config:core:${NIGHTCONFIG_VERSION}"
installer 'com.electronwill.night-config:toml:3.6.4' installer "com.electronwill.night-config:toml:${NIGHTCONFIG_VERSION}"
installer 'org.apache.maven:maven-artifact:3.6.3' installer "org.apache.maven:maven-artifact:${APACHE_MAVEN_ARTIFACT_VERSION}"
installer 'net.jodah:typetools:0.8.3' installer 'net.jodah:typetools:0.8.3'
installer 'net.minecrell:terminalconsoleappender:1.2.0' installer "net.minecrell:terminalconsoleappender:${TERMINALCONSOLEAPPENDER_VERSION}"
installer 'org.jline:jline-reader:3.12.+' //Dep of TerminaalConsoleeAppender installer "org.jline:jline-reader:${JLINE_VERSION}" // Dep of TerminalConsoleAppender
installer 'org.jline:jline-terminal:3.12.+' //Dep of TerminaalConsoleeAppender installer "org.jline:jline-terminal:${JLINE_VERSION}" // Dep of TerminalConsoleAppender
installer "org.spongepowered:mixin:${MIXIN_VERSION}" installer "org.spongepowered:mixin:${MIXIN_VERSION}"
installer 'org.openjdk.nashorn:nashorn-core:15.3' installer 'org.openjdk.nashorn:nashorn-core:15.3'
@@ -1049,6 +1058,7 @@ project(':forge') {
'--mod', 'tag_based_tool_types', '--mod', 'tag_based_tool_types',
'--mod', 'custom_transformtype_test', '--mod', 'custom_transformtype_test',
'--mod', 'data_pack_registries_test', '--mod', 'data_pack_registries_test',
'--mod', 'biome_modifiers_test',
'--output', rootProject.file('src/generated_test/resources/'), '--output', rootProject.file('src/generated_test/resources/'),
'--existing', sourceSets.main.resources.srcDirs[0], '--existing', sourceSets.main.resources.srcDirs[0],
'--existing', sourceSets.test.resources.srcDirs[0] '--existing', sourceSets.test.resources.srcDirs[0]
@@ -1180,18 +1190,28 @@ project(':forge') {
lineEnding = '\n' lineEnding = '\n'
} }
def baseForgeVersion = LAST_RB == null ? null : "${MC_VERSION}-${LAST_RB}" def baseForgeVersion = System.getProperty("forge.compatibility_check_version")
if (baseForgeVersion == null)
baseForgeVersion = "${MC_VERSION}-${GIT_INFO.tag}.0"
if (baseForgeVersion == "null")
baseForgeVersion = null // Allow disabling from system property if not wanted
def baseForgeUniversal = null
if (baseForgeVersion != null)
baseForgeUniversal = project.dependencies.create("net.minecraftforge:forge:${baseForgeVersion}:universal")
def jarCompatibilityTaskSetup = { task ->
task.group = 'jar compatibility'
task.onlyIf {
baseForgeVersion != null
}
task.inputs.property 'baseForgeVersion', baseForgeVersion
}
task downloadBaseCompatibilityBinPatches(type: DownloadBaseCompatibilityBinPatches) { task downloadBaseCompatibilityBinPatches(type: DownloadBaseCompatibilityBinPatches) {
inputVersion = baseForgeVersion inputVersion = baseForgeVersion
} }
task applyBaseCompatibilityJarBinPatches(type: ApplyBinPatches) { task applyBaseCompatibilityJarBinPatches(type: ApplyBinPatches) {
group = 'jar compatibility' jarCompatibilityTaskSetup(it)
onlyIf {
baseForgeVersion != null
}
inputs.property 'baseForgeVersion', baseForgeVersion
clean = createJoinedSRG.output clean = createJoinedSRG.output
patch = downloadBaseCompatibilityBinPatches.output patch = downloadBaseCompatibilityBinPatches.output
@@ -1199,23 +1219,16 @@ project(':forge') {
} }
task checkJarCompatibility(type: CheckJarCompatibility) { task checkJarCompatibility(type: CheckJarCompatibility) {
group = 'jar compatibility' jarCompatibilityTaskSetup(it)
onlyIf {
baseForgeVersion != null
}
inputs.property 'baseForgeVersion', baseForgeVersion
if (baseForgeVersion != null) { if (baseForgeVersion != null) {
def baseForgeUniversal = project.configurations.detachedConfiguration(project.dependencies.create("net.minecraftforge:forge:${baseForgeVersion}:universal"))
def fmlLibs = project.configurations.detachedConfiguration(PACKED_DEPS.collect { def fmlLibs = project.configurations.detachedConfiguration(PACKED_DEPS.collect {
def artifactId = it.split(':')[1] def artifactId = it.split(':')[1]
return project.dependencies.create("net.minecraftforge:${artifactId}:${baseForgeVersion}") return project.dependencies.create("net.minecraftforge:${artifactId}:${baseForgeVersion}")
}.toArray(Dependency[]::new)) }.toArray(Dependency[]::new))
baseJar = project.tasks.applyBaseCompatibilityJarBinPatches.output baseJar = project.tasks.applyBaseCompatibilityJarBinPatches.output
baseLibraries.from(project.file(project.provider { baseLibraries.from(baseForgeUniversal)
baseForgeUniversal.resolve().iterator().next()
}))
baseLibraries.from(project.tasks.createJoinedSRG.output) baseLibraries.from(project.tasks.createJoinedSRG.output)
baseLibraries.from(fmlLibs) baseLibraries.from(fmlLibs)
@@ -1578,6 +1591,83 @@ project(':forge') {
sourceSets.test.java.srcDirs.each { extractMappedNew.addTarget it } sourceSets.test.java.srcDirs.each { extractMappedNew.addTarget it }
} }
tasks.named('javadoc', Javadoc).configure {
description 'Generates the combined javadocs for the FML projects and the main Forge project'
var includedProjects = [ ':fmlcore', ':fmlloader', ':javafmllanguage', ':mclanguage' ]
source includedProjects.collect { project(it).sourceSets.main.allJava }
classpath = classpath + files(includedProjects.collect { project(it).sourceSets.main.compileClasspath })
var docsDir = rootProject.file('src/docs/')
inputs.dir(docsDir)
.withPropertyName('docs resources directory')
.withPathSensitivity(PathSensitivity.RELATIVE)
.optional()
failOnError = false
// Exclude the Minecraft classes if not enabled
if (!project.hasProperty('generateAllDocumentation')) {
exclude 'net/minecraft/**'
exclude 'com/mojang/**'
}
exclude 'mcp/**'
options.addStringOption('Xdoclint:all,-missing', '-public')
options {
stylesheetFile = new File(docsDir, 'stylesheet.css')
tags = [
'apiNote:a:<em>API Note:</em>',
'implSpec:a:<em>Implementation Requirements:</em>',
'implNote:a:<em>Implementation Note:</em>'
]
groups = [
'Forge Mod Loader': [
'net.minecraftforge.fml.common.asm*',
'net.minecraftforge.fml.loading*',
'net.minecraftforge.fml.server*'
],
'FML Core': [
'net.minecraftforge.fml',
'net.minecraftforge.fml.config*',
'net.minecraftforge.fml.event*',
'net.minecraftforge.fml.util*'
],
'FML Common': [
'net.minecraftforge.fml.core',
'net.minecraftforge.fml.event.config',
'net.minecraftforge.fml.event.lifecycle'
],
'FML Java/MC Language Providers': [
'net.minecraftforge.fml.common',
'net.minecraftforge.fml.javafmlmod',
'net.minecraftforge.fml.mclanguageprovider'
],
'Minecraft Forge API': [
'net.minecraftforge*'
]
]
author = false
noSince = true
noHelp = true
bottom = "Minecraft Forge is an open source modding API for Minecraft: Java Edition, licensed under the Lesser GNU General Public License, version 2.1."
windowTitle = "Minecraft Forge API ${VERSION}"
docTitle = "Minecraft Forge API - ${FORGE_VERSION} for Minecraft ${MC_VERSION}"
header = "<div style=\"margin-top: 9px;padding: 5px 6px;\"><strong>${FORGE_VERSION} for Minecraft ${MC_VERSION}</strong></div>"
}
doLast {
project.copy {
from docsDir
exclude '/stylesheet.css'
into destinationDir
}
}
}
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
+3 -2
View File
@@ -2,8 +2,9 @@ repositories {
maven { url = 'https://maven.minecraftforge.net/' } maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
implementation 'org.ow2.asm:asm:9.1' implementation 'org.ow2.asm:asm:9.3'
implementation 'org.ow2.asm:asm-tree:9.1' implementation 'org.ow2.asm:asm-tree:9.3'
implementation 'net.minecraftforge:srgutils:0.4.+' implementation 'net.minecraftforge:srgutils:0.4.+'
} }
+3 -3
View File
@@ -1,11 +1,11 @@
Contributing to Forge Contributing to Forge
===================== =====================
1) Keep patches to Minecraft classes minimal. If you need a lot of things done, you may either add to relevant forge classes or make a new class. 1) Keep patches to Minecraft classes together. If you need a lot of things done, you may either add to relevant forge classes or make a new class. Try not to spread out your patches across multiple disjoint lines, as this makes maintenance of your patches difficult.
2) An example mod must be provided for all PRs adding events/hooks to Forge. Whether it's a full mod using your proposed hooks, or just a pastebin containing a simple example, an example mod is required. Please also explain in detail what your new hook does. 2) TODO: Test Mods
3) Follow Forge coding guidelines (braces on newlines, spaces instead of tabs, etc) 3) Follow the code style of the class you're working in (braces on newlines & spaces instead of tabs in Forge classes, inline brackets in patches, etc).
For more information, refer to [the wiki](https://github.com/MinecraftForge/MinecraftForge/wiki/If-you-want-to-contribute-to-Forge) For more information, refer to [the wiki](https://github.com/MinecraftForge/MinecraftForge/wiki/If-you-want-to-contribute-to-Forge)
+11 -10
View File
@@ -8,10 +8,10 @@ MinecraftForge
Forge is a free, open-source modding API all of your favourite mods use! Forge is a free, open-source modding API all of your favourite mods use!
| Version | Support | | Version | Support |
| ------------- | ------------- | |---------| ------------- |
| 1.18.x | Active | | 1.19.x | Active |
| 1.16.x | LTS | | 1.18.x | LTS |
* [Download] * [Download]
* [Forum] * [Forum]
@@ -29,7 +29,7 @@ You can download the installer for the *Recommended Build* or the
into your vanilla launcher environment, where you can then create a new into your vanilla launcher environment, where you can then create a new
profile using that version and play the game! profile using that version and play the game!
For support and questions, visit [the Support Forum](https://www.minecraftforge.net/forum/forum/18-support-bug-reports/). For support and questions, visit [the Support Forum](https://www.minecraftforge.net/forum/forum/18-support-bug-reports/) or [the Forge Discord server](https://discord.gg/forge).
[Here is a short video from Rorax showing how to install and setup Forge.](https://www.youtube.com/watch?v=lB3ArN_-3Oc) [Here is a short video from Rorax showing how to install and setup Forge.](https://www.youtube.com/watch?v=lB3ArN_-3Oc)
@@ -41,7 +41,7 @@ For support and questions, visit [the Support Forum](https://www.minecraftforge.
If you wish to actually inspect Forge, submit PRs or otherwise work If you wish to actually inspect Forge, submit PRs or otherwise work
with Forge itself, you're in the right place! with Forge itself, you're in the right place!
[See the guide to setting up a Forge workspace](http://mcforge.readthedocs.io/en/latest/forgedev/). [See the guide to setting up a Forge workspace](http://mcforge.readthedocs.io/en/latest/forgedev/).
### Pull requests ### Pull requests
@@ -51,13 +51,14 @@ If you wish to actually inspect Forge, submit PRs or otherwise work
Please read the contributing guidelines found [here](CONTRIBUTING.md) before making a pull request. Please read the contributing guidelines found [here](CONTRIBUTING.md) before making a pull request.
### Contributor License Agreement ### Contributor License Agreement
We require all contributors to acknowledge the [Forge Contributor We require all contributors to acknowledge the [Forge Contributor License Agreement](https://cla-assistant.io/MinecraftForge/MinecraftForge).
License Agreement](https://cla-assistant.io/MinecraftForge/MinecraftForge). Please ensure you have a valid email address Please ensure you have a valid email address associated with your GitHub account to do this. If you have previously
associated with your GitHub account to do this. If you have previously
signed it, you should be OK. signed it, you should be OK.
#### Donate #### Donate
*Forge is a large project with many collaborators working on it around the clock. Forge is and will always remain free to use and modify. However, it costs money to run such a large project as this, so please consider [becoming a patron](https://www.patreon.com/LexManos).* *Forge is a large project with many collaborators working on it around the clock. Forge is and will always remain free
to use and modify. However, it costs money to run such a large project as this, so please consider
[becoming a patron](https://www.patreon.com/LexManos).*
[Download]: https://files.minecraftforge.net/ [Download]: https://files.minecraftforge.net/
[Forum]: https://www.minecraftforge.net/forum/ [Forum]: https://www.minecraftforge.net/forum/
+3 -2
View File
@@ -76,7 +76,7 @@ If you're certain you've found an issue that is directly caused by Forge, you ha
1. **Forge Forums:** There's a dedicated [Support & Bug Report](http://www.minecraftforge.net/forum/forum/18-support-bug-reports/) section on the Forge forums, which is led by team of moderators and volunteers who will try to deal with your reports as quickly as possible. *As a player you should probably report here first.* 1. **Forge Forums:** There's a dedicated [Support & Bug Report](http://www.minecraftforge.net/forum/forum/18-support-bug-reports/) section on the Forge forums, which is led by team of moderators and volunteers who will try to deal with your reports as quickly as possible. *As a player you should probably report here first.*
- For modders, there also is a separate [Modder Support](http://www.minecraftforge.net/forum/forum/70-modder-support/) section where you can ask all your development-related questions. *You should prefer this section for coding help.* - For modders, there also is a separate [Modder Support](http://www.minecraftforge.net/forum/forum/70-modder-support/) section where you can ask all your development-related questions. *You should prefer this section for coding help.*
2. **Forge IRC Channel:** You can find a lot of help on the official [`#minecraftforge`](irc://irc.esper.net:6667/minecraftforge) channel on EsperNet. Especially smaller issues that you quickly need help with could be reported there. *Be aware that the channel is more suited towards development questions, so while you may get support there as a player, you should almost always prefer the forums.* 2. **Forge Discord Server:** You can find a lot of help on the official [Discord Server](https://discord.gg/forge), especially smaller issues that you quickly need help with. *Be aware that the channel is more suited towards development questions, so while you may get support there as a player, you should almost always prefer the forums.*
3. **Forge Issue Tracker:** If you're absolutely certain that you've found an issue in the Forge codebase (e.g. you're a modder yourself and have analyzed the stacktrace and relevant code), don't refrain from reporting it on this repository's [issue tracker](https://github.com/MinecraftForge/MinecraftForge/issues). *Please do not use the issues as a means of getting coding help. For developers, the IRC and the [official documentation](https://mcforge.readthedocs.io) are the best sources of information.* 3. **Forge Issue Tracker:** If you're absolutely certain that you've found an issue in the Forge codebase (e.g. you're a modder yourself and have analyzed the stacktrace and relevant code), don't refrain from reporting it on this repository's [issue tracker](https://github.com/MinecraftForge/MinecraftForge/issues). *Please do not use the issues as a means of getting coding help. For developers, the IRC and the [official documentation](https://mcforge.readthedocs.io) are the best sources of information.*
### Mod Support ### Mod Support
@@ -84,7 +84,8 @@ If you're certain you've found an issue that is directly caused by Forge, you ha
A lot of mods also use GitHub or other source management systems and their integrated issue trackers. The following options will give you the best chances of reporting your issue in the right place: A lot of mods also use GitHub or other source management systems and their integrated issue trackers. The following options will give you the best chances of reporting your issue in the right place:
- **CurseForge:** Many mods are hosted on the [CurseForge platform](https://minecraft.curseforge.com) nowadays. Chances are you already downloaded them from there or as a part of a modpack hosted there. Projects may specify an issue reporting link on their own page, so simply look for it on the mod's project page and you should be directed to the preferred means of error reporting. - **CurseForge:** Many mods are hosted on the [CurseForge platform](https://minecraft.curseforge.com) nowadays. Chances are you already downloaded them from there or as a part of a modpack hosted there. Projects may specify an issue reporting link on their own page, so simply look for it on the mod's project page and you should be directed to the preferred means of error reporting.
- **Searching for a repository directly:** You may need to try and find a repository directly on source control sites. The most common ones are [GitHub](https://github.com) and [BitBucket](https://bitbucket.org). Both come with search capabilities, so simply try to search for the mod's name. - **Modrinth:** Some modders use [Modrinth](https://modrinth.com/mods) to host their mods, but be mindful that not all mods on this platform are for the Forge modloader.
- **Searching for a repository directly:** You may need to try and find a repository directly on source control sites. The most common ones are [GitHub](https://github.com), [GitLab](https://gitlab.com), and [BitBucket](https://bitbucket.org). Both come with search capabilities, so simply try to search for the mod's name.
### Vanilla Support ### Vanilla Support
+5 -3
View File
@@ -10,10 +10,12 @@ apply plugin: 'org.javamodularity.moduleplugin'
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) } dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
dependencies { dependencies {
compileOnly('org.jetbrains:annotations:21.0.1') compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
api("net.minecraftforge:eventbus:${EVENTBUS_VERSION}")
implementation(project(':fmlloader')) implementation(project(':fmlloader'))
api('net.minecraftforge:eventbus:5.0.+') implementation("commons-io:commons-io:${COMMONS_IO_VERSION}")
implementation('commons-io:commons-io:2.5')
} }
task sourcesJar(type: Jar) { task sourcesJar(type: Jar) {
@@ -8,41 +8,90 @@ package net.minecraftforge.fml;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import java.util.function.Supplier; import java.util.function.Supplier;
/**
* An extension point for a mod container.
*
* <p>An extension point can be registered for a mod container using {@link ModContainer#registerExtensionPoint(Class, Supplier)}
* and retrieved (if present) using {@link ModContainer#getCustomExtension(Class)}. An extension point allows a mod to
* supply an arbitrary value as a record class to another mod or framework through their mod container class, avoiding
* the use of {@link InterModComms} or other external frameworks to pass around these values.</p>
*
* <p>The usual way to declare an extension point is to implement this interface on a record class, with the type
* parameter being a reference to the class itself. For example, {@code record MyExtension(...) extends
* IExtensionPoint<MyExtension>} would declare an extension point which supplies a {@code MyExtension} object. However,
* there is no hard requirement that an extension point's type parameter must be in reference to itself; the type
* parameter may reference another record class instead.</p>
*
* @param <T> the type of the record which is held by the extension point
*/
@SuppressWarnings("unused") // Type parameter T
public interface IExtensionPoint<T extends Record> public interface IExtensionPoint<T extends Record>
{ {
/** /**
* Compatibility display test for the mod. * Extension point for the compatibility display test used on the server selection screen.
* Used for displaying compatibility with remote servers with the same mod, and on disk saves.
* *
* The supplier provides my "local" version for sending across the impl or writing to disk * <em>Note: "server" and "client" refers to the {@linkplain net.minecraftforge.api.distmarker.Dist#DEDICATED_SERVER dedicated server}
* The predicate tests the version from a remote instance or save for acceptability (Boolean is true for impl, false for local save) * and {@linkplain net.minecraftforge.api.distmarker.Dist#CLIENT game client} physical distributions, rather than the
* and returns true if the version is compatible. * {@linkplain LogicalSide logical server and client}.</em>
* *
* <p>Return {@code net.minecraftforge.network.NetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored * <p>The {@link Supplier} provides the local compatibility version, which is sent from the server to the client
* as a server side only mod.</p> * for multiplayer connections or stored to disk for the world save. The {@link BiPredicate} accepts the remote
* <p>Return true in the predicate for all values of the input string (when impl boolean is true) if you are client side, * compatibility version and a boolean indicating whether the remote version is from the server or a world save,
* and don't care about matching any potential server version.</p> * where {@code true} means it is from the server and {@code false} means it is from the world save. The return
* value of the predicate determines whether the remote version is "compatible" for the purposes of the display test.</p>
* *
* <p> * <p>The local compatibility version may be of the value {@link net.minecraftforge.network.NetworkConstants#IGNORESERVERONLY},
* Examples: A server only mod * in which case clients will ignore the mod's presence if it is present on the server but not on the client.
* </p> * However, the remote version test predicate must still accept this value as a remote version in order to display
* as compatible if the mod is present on the client.</p>
*
* <p><strong>The compatibility display test does not necessarily indicate the success or failure of an actual
* connection attempt.</strong> Factors such as display test extension misconfiguration, truncation of ping data,
* difference of registry data or network channels between server and client, and others may cause the result of the
* compatibility test to not reflect the actual likelihood of a connection successfully being established between
* the server and the client.</p>
*
* <p>An example declaration of a display test extension registration for a regular mod (requires to be present on
* server and client) is as follows:</p>
* <pre>{@code * <pre>{@code
* registerExtensionPoint(DisplayTest.class, ()->new DisplayTest( * String compatibilityVersion = "1"; // Could be linked with a network channel version or mod version
* ()->NetworkConstants.IGNORESERVERONLY, // ignore me, I'm a server only mod * ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
* (s,b)->true // i accept anything from the server or the save, if I'm asked * () -> new IExtensionPoint.DisplayTest(
* ) * () -> compatibilityVersion,
* (remoteVersion, isFromServer) -> remoteVersion.equals(compatibilityVersion)
* )
* );
* }</pre> * }</pre>
* *
* <p> * <p>An example declaration of a display test extension registration for a <em>server-side-only</em> mod (does not
* Examples: A client only mod * require to be present on the client) is as follows:</p>
* </p>
* <pre>{@code * <pre>{@code
* registerExtensionPoint(DisplayTest.class, ()->new DisplayTest( * ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
* ()->"anything. i don't care", // if i'm actually on the server, this string is sent but i'm a client only mod, so it won't be * () -> new IExtensionPoint.DisplayTest(
* (remoteversionstring,networkbool)->networkbool // i accept anything from the server, by returning true if it's asking about the server * // Ignore this mod if not present on the client
* ) * () -> NetworkConstants.IGNORESERVERONLY,
* // If present on the client, accept any version if from a server
* (remoteVersion, isFromServer) -> isFromServer
* )
* );
* }</pre> * }</pre>
* *
* <p>An example declaration of a display test extension registration for a <em>client-side-only</em> mod (does not
* require to be present on the server) is as follows:</p>
* <pre>{@code
* ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
* () -> new IExtensionPoint.DisplayTest(
* // Send any version from server to client, since we will be accepting any version as well
* () -> "dQw4w9WgXcQ",
* // Accept any version on the client, from server or from save
* (remoteVersion, isFromServer) -> true
* )
* );
* }</pre>
*
* @see net.minecraftforge.network.ServerStatusPing
* @see net.minecraftforge.client.ForgeHooksClient#processForgeListPingData(net.minecraft.network.protocol.status.ServerStatus, net.minecraft.client.multiplayer.ServerData)
*/ */
@SuppressWarnings("JavadocReference") // reference to NetworkConstants, ForgeHooksClient
record DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) implements IExtensionPoint<DisplayTest> {} record DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) implements IExtensionPoint<DisplayTest> {}
} }
@@ -8,23 +8,79 @@ package net.minecraftforge.fml;
import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.fml.event.IModBusEvent;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
/**
* A mod loading state. During mod loading, the mod loader transitions between states in a defined sorted list of states,
* grouped into various {@link ModLoadingPhase phases}.
*
* @see IModStateProvider
*/
public interface IModLoadingState { public interface IModLoadingState {
/**
* {@return the name of this state}
*/
String name(); String name();
/**
* {@return the name of the state immediately previous to this state} This may be a blank name, which indicates this
* is either the first mod loading state or an exceptional mod loading state (such as a situation where errors
* prevent the loading process from continuing normally).
*/
String previous(); String previous();
/**
* {@return the mod loading phase this state belongs to} For exceptional mod loading states, this should be
* {@link ModLoadingPhase#ERROR}.
*/
ModLoadingPhase phase(); ModLoadingPhase phase();
/**
* {@return a function returning a human-friendly message for this state}
*/
Function<ModList, String> message(); Function<ModList, String> message();
/**
* {@return an optional runnable, which runs before starting the transition from this state to the next}
* @see #buildTransition(Executor, Executor, Function, Function)
*/
Optional<Consumer<ModList>> inlineRunnable(); Optional<Consumer<ModList>> inlineRunnable();
default <T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor) { /**
return buildTransition(syncExecutor, parallelExecutor, e->CompletableFuture.runAsync(()->{}, e), e->CompletableFuture.runAsync(()->{}, e)); * Builds the transition task for this state with a blank pre-sync and post-sync task.
*
* @param syncExecutor a synchronous executor
* @param parallelExecutor a parallel executor
* @param <T> a type of event fired on the mod-specific event bus
* @return a transition task for this state
* @see #buildTransition(Executor, Executor, Function, Function)
*/
default <T extends Event & IModBusEvent>
Optional<CompletableFuture<Void>> buildTransition(final Executor syncExecutor,
final Executor parallelExecutor) {
return buildTransition(syncExecutor, parallelExecutor,
e -> CompletableFuture.runAsync(() -> {}, e),
e -> CompletableFuture.runAsync(() -> {}, e));
} }
<T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(Executor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask); /**
* Builds the transition task for this state. The pre-sync and post-sync task functions allow the transition builder
* to run these tasks on the same executor as the actual event dispatch and pre/post hooks.
*
* @param syncExecutor a synchronous executor
* @param parallelExecutor a parallel executor
* @param preSyncTask a function which returns a task to run before event pre-dispatch hook
* @param postSyncTask a function which returns a task to run after event post-dispatch hook
* @param <T> a type of event fired on the mod-specific event bus
* @return a transition task for this state
*/
<T extends Event & IModBusEvent>
Optional<CompletableFuture<Void>> buildTransition(final Executor syncExecutor,
final Executor parallelExecutor,
final Function<Executor, CompletableFuture<Void>> preSyncTask,
final Function<Executor, CompletableFuture<Void>> postSyncTask);
} }
@@ -7,6 +7,15 @@ package net.minecraftforge.fml;
import java.util.List; import java.util.List;
/**
* Provides a list of mod loading states which the mod loader may transition between.
*
* <p>There may be multiple mod state providers in a single application, where all states from each provider is
* combined into a single list and ordered.</p>
*/
public interface IModStateProvider { public interface IModStateProvider {
/**
* {@return the list of mod loading states known to this provider}
*/
List<IModLoadingState> getAllStates(); List<IModLoadingState> getAllStates();
} }
@@ -9,7 +9,6 @@ import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.fml.event.IModBusEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@@ -24,18 +23,26 @@ public interface IModStateTransition {
return new NoopTransition(); return new NoopTransition();
} }
default <T extends Event & IModBusEvent> CompletableFuture<List<Throwable>> build(Executor syncExecutor, Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) { default <T extends Event & IModBusEvent>
List<CompletableFuture<List<Throwable>>> cfs = new ArrayList<>(); CompletableFuture<Void> build(final Executor syncExecutor,
final Executor parallelExecutor,
final Function<Executor, CompletableFuture<Void>> preSyncTask,
final Function<Executor, CompletableFuture<Void>> postSyncTask) {
List<CompletableFuture<Void>> futures = new ArrayList<>();
this.eventFunctionStream().get() this.eventFunctionStream().get()
.map(f->(EventGenerator<T>)f) .map(f -> (EventGenerator<T>) f)
.reduce((head, tail)-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, head, ModLoadingStage::currentState, tail)) .reduce((head, tail) -> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, futures, head, ModLoadingStage::currentState, tail))
.ifPresent(last-> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, cfs, last, nextModLoadingStage(), null)); .ifPresent(last -> addCompletableFutureTaskForModDispatch(syncExecutor, parallelExecutor, futures, last, nextModLoadingStage(), null));
final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor); final CompletableFuture<Void> preSyncTaskCF = preSyncTask.apply(syncExecutor);
final CompletableFuture<List<Throwable>> eventDispatchCF = ModList.gather(cfs).thenCompose(ModList::completableFutureFromExceptionList); final CompletableFuture<Void> eventDispatchCF = ModList.gather(futures).thenCompose(ModList::completableFutureFromExceptionList);
final CompletableFuture<List<Throwable>> postEventDispatchCF = preSyncTaskCF.thenComposeAsync(n -> eventDispatchCF, parallelExecutor).thenApply(r -> { final CompletableFuture<Void> postEventDispatchCF = preSyncTaskCF
postSyncTask.apply(syncExecutor); .thenComposeAsync(n -> eventDispatchCF, parallelExecutor)
return r; .thenApply(r -> {
}); postSyncTask.apply(syncExecutor);
return null;
});
return this.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF); return this.finalActivityGenerator().apply(syncExecutor, postEventDispatchCF);
} }
@@ -43,18 +50,31 @@ public interface IModStateTransition {
return ModLoadingStage::nextState; return ModLoadingStage::nextState;
} }
private <T extends Event & IModBusEvent> EventGenerator<T> addCompletableFutureTaskForModDispatch(final Executor syncExecutor, final Executor parallelExecutor, final List<CompletableFuture<List<Throwable>>> completeableFutures, final EventGenerator<T> eventGenerator, BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextState, final EventGenerator<T> nextGenerator) { private <T extends Event & IModBusEvent>
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)preDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator)); EventGenerator<T> addCompletableFutureTaskForModDispatch(final Executor syncExecutor,
completeableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector().apply(syncExecutor, parallelExecutor))); final Executor parallelExecutor,
completeableFutures.add(((BiFunction<Executor, EventGenerator<T>, CompletableFuture<List<Throwable>>>)postDispatchHook()).apply(threadSelector().apply(syncExecutor, parallelExecutor), eventGenerator)); final List<CompletableFuture<Void>> completableFutures,
final EventGenerator<T> eventGenerator,
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> nextState,
final EventGenerator<T> nextGenerator) {
final Executor selectedExecutor = threadSelector().apply(syncExecutor, parallelExecutor);
var preDispatchHook = (BiFunction<Executor, EventGenerator<T>, CompletableFuture<Void>>) preDispatchHook();
completableFutures.add(preDispatchHook.apply(selectedExecutor, eventGenerator));
completableFutures.add(ModList.get().futureVisitor(eventGenerator, nextState).apply(threadSelector().apply(syncExecutor, parallelExecutor)));
var postDispatchHook = (BiFunction<Executor, EventGenerator<T>, CompletableFuture<Void>>) postDispatchHook();
completableFutures.add(postDispatchHook.apply(selectedExecutor, eventGenerator));
return nextGenerator; return nextGenerator;
} }
Supplier<Stream<EventGenerator<?>>> eventFunctionStream(); Supplier<Stream<EventGenerator<?>>> eventFunctionStream();
ThreadSelector threadSelector(); ThreadSelector threadSelector();
BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator(); BiFunction<Executor, CompletableFuture<Void>, CompletableFuture<Void>> finalActivityGenerator();
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook(); BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> preDispatchHook();
BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook(); BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> postDispatchHook();
interface EventGenerator<T extends Event & IModBusEvent> extends Function<ModContainer, T> { interface EventGenerator<T extends Event & IModBusEvent> extends Function<ModContainer, T> {
static <FN extends Event & IModBusEvent> EventGenerator<FN> fromFunction(Function<ModContainer, FN> fn) { static <FN extends Event & IModBusEvent> EventGenerator<FN> fromFunction(Function<ModContainer, FN> fn) {
@@ -76,17 +96,17 @@ record NoopTransition() implements IModStateTransition {
} }
@Override @Override
public BiFunction<Executor, CompletableFuture<List<Throwable>>, CompletableFuture<List<Throwable>>> finalActivityGenerator() { public BiFunction<Executor, CompletableFuture<Void>, CompletableFuture<Void>> finalActivityGenerator() {
return (e, t) -> t.thenApplyAsync(Function.identity(), e); return (e, t) -> t.thenApplyAsync(Function.identity(), e);
} }
@Override @Override
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> preDispatchHook() { public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> preDispatchHook() {
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList()); return (t, f)-> CompletableFuture.completedFuture(null);
} }
@Override @Override
public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<List<Throwable>>> postDispatchHook() { public BiFunction<Executor, ? extends EventGenerator<?>, CompletableFuture<Void>> postDispatchHook() {
return (t, f)-> CompletableFuture.completedFuture(Collections.emptyList()); return (t, f)-> CompletableFuture.completedFuture(null);
} }
} }
@@ -5,12 +5,41 @@
package net.minecraftforge.fml; package net.minecraftforge.fml;
import net.minecraftforge.api.distmarker.Dist;
/**
* A logical side of the Minecraft game.
* <p>
* The {@linkplain Dist#CLIENT client distribution} has a copy of the logical client and the logical server, while the
* {@linkplain Dist#DEDICATED_SERVER dedicated server distribution} only holds
* the logical server.
*
* @see Dist
*/
public enum LogicalSide public enum LogicalSide
{ {
CLIENT, SERVER; /**
* The logical client of the Minecraft game, which interfaces with the player's inputs and renders the player's
* viewpoint.
* <p>
* The logical client is only shipped with the client distribution of the game.
*
* @see Dist#CLIENT
*/
CLIENT,
/**
* The logical server of the Minecraft game, responsible for connecting to clients and running the simulation logic
* on the level.
* <p>
* The logical server is shipped with both client and dedicated server distributions. The client distribution runs
* the logical server for singleplayer mode and LAN play.
*
* @see Dist#DEDICATED_SERVER
*/
SERVER;
/** /**
* @return if the logical side is a server. * {@return if this logical side is the server}
*/ */
public boolean isServer() public boolean isServer()
{ {
@@ -18,7 +47,7 @@ public enum LogicalSide
} }
/** /**
* @return if the logical side is a client. * {@return if the logical side is the client}
*/ */
public boolean isClient() public boolean isClient()
{ {
@@ -21,7 +21,6 @@ import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@@ -111,7 +110,7 @@ public class ModList
return this.fileById.get(modid); return this.fileById.get(modid);
} }
<T extends Event & IModBusEvent> Function<Executor, CompletableFuture<List<Throwable>>> futureVisitor( <T extends Event & IModBusEvent> Function<Executor, CompletableFuture<Void>> futureVisitor(
final IModStateTransition.EventGenerator<T> eventGenerator, final IModStateTransition.EventGenerator<T> eventGenerator,
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> stateChange) { final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> stateChange) {
return executor -> gather( return executor -> gather(
@@ -120,12 +119,12 @@ public class ModList
.collect(Collectors.toList())) .collect(Collectors.toList()))
.thenComposeAsync(ModList::completableFutureFromExceptionList, executor); .thenComposeAsync(ModList::completableFutureFromExceptionList, executor);
} }
static CompletionStage<List<Throwable>> completableFutureFromExceptionList(List<? extends Map.Entry<?, Throwable>> t) { static CompletionStage<Void> completableFutureFromExceptionList(List<? extends Map.Entry<?, Throwable>> t) {
if (t.stream().noneMatch(e->e.getValue()!=null)) { if (t.stream().noneMatch(e->e.getValue()!=null)) {
return CompletableFuture.completedFuture(Collections.emptyList()); return CompletableFuture.completedFuture(null);
} else { } else {
final List<Throwable> throwables = t.stream().filter(e -> e.getValue() != null).map(Map.Entry::getValue).collect(Collectors.toList()); final List<Throwable> throwables = t.stream().filter(e -> e.getValue() != null).map(Map.Entry::getValue).collect(Collectors.toList());
CompletableFuture<List<Throwable>> cf = new CompletableFuture<>(); CompletableFuture<Void> cf = new CompletableFuture<>();
final RuntimeException accumulator = new RuntimeException(); final RuntimeException accumulator = new RuntimeException();
cf.completeExceptionally(accumulator); cf.completeExceptionally(accumulator);
throwables.forEach(exception -> { throwables.forEach(exception -> {
@@ -196,7 +196,7 @@ public class ModLoader
state.buildTransition(syncExecutor, parallelExecutor, preSyncTask, postSyncTask).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t)); state.buildTransition(syncExecutor, parallelExecutor, preSyncTask, postSyncTask).ifPresent(t->waitForTransition(state, syncExecutor, ticker, t));
} }
private void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture<List<Throwable>> transition) { private void waitForTransition(final IModLoadingState state, final ModWorkManager.DrivenExecutor syncExecutor, final Runnable ticker, final CompletableFuture<Void> transition) {
while (!transition.isDone()) { while (!transition.isDone()) {
syncExecutor.drive(ticker); syncExecutor.drive(ticker);
} }
@@ -5,10 +5,34 @@
package net.minecraftforge.fml; package net.minecraftforge.fml;
/**
* Phases of mod loading, for grouping mod loading states.
*/
public enum ModLoadingPhase { public enum ModLoadingPhase {
/**
* Special phase for exceptional situations and error handling, where mod loading cannot continue normally.
*
* <p>There is conventionally only one state with this phase.</p>
*/
ERROR, // Special state for error handling ERROR, // Special state for error handling
/**
* Phase for discovering and gathering mods for loading.
*/
GATHER, GATHER,
/**
* Phase for the loading of mods found from mod discovery.
*
* @see #GATHER
*/
LOAD, LOAD,
/**
* Phase after mod loading has completed, for post-loading tasks.
*
* @see #LOAD
*/
COMPLETE, COMPLETE,
DONE; /**
* Marker phase for the last state in the full mod loading process.
*/
DONE
} }
@@ -5,16 +5,53 @@
package net.minecraftforge.fml; package net.minecraftforge.fml;
/**
* Mod loading stage of mod containers during the mod loading process. These will have a corresponding {@link ModLoadingState}
* in the basic mod loading process provided by FML.
*
* <p>Each mod loading stage has a global {@link DeferredWorkQueue}, which is populated during the execution of the state
* associated with this stage and emptied at the end of the state's execution.</p>
*/
public enum ModLoadingStage public enum ModLoadingStage
{ {
/**
* Special stage for exceptional situations and error handling.
*/
ERROR, ERROR,
/**
* Validation of the mod list.
* TODO: figure out where this is used and why this exists instead of CONSTRUCT being the first normal stage
*/
VALIDATE, VALIDATE,
/**
* Default stage of mod containers after construction.
*/
CONSTRUCT, CONSTRUCT,
/**
* Common (non-side-specific) setup and initialization.
*/
COMMON_SETUP, COMMON_SETUP,
/**
* Side-specific setup and initialization.
*
* @see net.minecraftforge.api.distmarker.Dist
*/
SIDED_SETUP, SIDED_SETUP,
/**
* Stage for enqueuing {@link net.minecraftforge.fml.InterModComms} messages for later processing.
*/
ENQUEUE_IMC, ENQUEUE_IMC,
/**
* Stage for processing received messages though {@link net.minecraftforge.fml.InterModComms}.
*/
PROCESS_IMC, PROCESS_IMC,
/**
* Marks the completion of mod loading for this container.
*/
COMPLETE, COMPLETE,
/**
* Marks the completion of the full mod loading process.
*/
DONE; DONE;
private final DeferredWorkQueue deferredWorkQueue; private final DeferredWorkQueue deferredWorkQueue;
@@ -23,14 +60,27 @@ public enum ModLoadingStage
deferredWorkQueue = new DeferredWorkQueue(this); deferredWorkQueue = new DeferredWorkQueue(this);
} }
/**
* {@return the next stage after this stage, or {@link #ERROR} if the exception is not {@code null}}
*
* @param exception the exception that occurred during this stage, may be {@code null}
*/
ModLoadingStage nextState(Throwable exception) { ModLoadingStage nextState(Throwable exception) {
return exception != null ? ERROR : values()[this.ordinal()+1]; return exception != null ? ERROR : values()[this.ordinal()+1];
} }
/**
* {@return this stage, or {@link #ERROR} if the exception is not {@code null}}
*
* @param exception the exception that occurred during this stage, may be {@code null}
*/
public ModLoadingStage currentState(Throwable exception) { public ModLoadingStage currentState(Throwable exception) {
return exception != null ? ERROR : this; return exception != null ? ERROR : this;
} }
/**
* {@return the deferred work queue for this stage}
*/
public DeferredWorkQueue getDeferredWorkQueue() { public DeferredWorkQueue getDeferredWorkQueue() {
return deferredWorkQueue; return deferredWorkQueue;
} }
@@ -8,31 +8,91 @@ package net.minecraftforge.fml;
import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.fml.event.IModBusEvent;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
public record ModLoadingState(String name, String previous, Function<ModList, String> message, ModLoadingPhase phase, Optional<Consumer<ModList>> inlineRunnable, Optional<IModStateTransition> transition) implements IModLoadingState { /**
* Implementation of the {@link IModLoadingState} interface.
*
* @param name the name of this state
* @param previous the name of the state immediately previous to this state
* @param message a function returning a human-friendly message for this state
* @param phase the mod loading phase this state belongs to
* @param inlineRunnable an optional runnable, which runs before starting the transition from this state to the next
* @param transition optional state transition information
*/
public record ModLoadingState(String name, String previous,
Function<ModList, String> message,
ModLoadingPhase phase,
Optional<Consumer<ModList>> inlineRunnable,
Optional<IModStateTransition> transition) implements IModLoadingState {
@Override @Override
public <T extends Event & IModBusEvent> Optional<CompletableFuture<List<Throwable>>> buildTransition(final Executor syncExecutor, final Executor parallelExecutor, Function<Executor, CompletableFuture<Void>> preSyncTask, Function<Executor, CompletableFuture<Void>> postSyncTask) { public <T extends Event & IModBusEvent>
return transition.map(t->t.build(syncExecutor, parallelExecutor, preSyncTask, postSyncTask)); Optional<CompletableFuture<Void>> buildTransition(final Executor syncExecutor,
final Executor parallelExecutor,
final Function<Executor, CompletableFuture<Void>> preSyncTask,
final Function<Executor, CompletableFuture<Void>> postSyncTask) {
return transition.map(t -> t.build(syncExecutor, parallelExecutor, preSyncTask, postSyncTask));
} }
/**
* {@return an empty mod loading state} The mod loading state has a blank human-readable message, no inline runnable,
* and no state transition information.
*
* @param name the name of the state
* @param previous the name of the immediately previous state to this state
* @param phase the mod loading phase the state belongs to
*/
public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) { public static ModLoadingState empty(final String name, final String previous, final ModLoadingPhase phase) {
return new ModLoadingState(name, previous, ml->"", phase, Optional.empty(), Optional.empty()); return new ModLoadingState(name, previous, ml -> "", phase, Optional.empty(), Optional.empty());
} }
public static ModLoadingState withTransition(final String name, final String previous, final ModLoadingPhase phase, IModStateTransition transition) { /**
return new ModLoadingState(name, previous, ml->"Processing transition "+name, phase, Optional.empty(), Optional.of(transition)); * Returns a mod loading state with state transition information and a default human-friendly message of
* {@code Processing transition [name]}.
*
* @param name the name of the state
* @param previous the name of the immediately previous state to this state
* @param phase the mod loading phase the state belongs to
* @param transition the state transition information
* @return a mod loading state with state transition information and a default message
*/
public static ModLoadingState withTransition(final String name, final String previous, final ModLoadingPhase phase,
final IModStateTransition transition) {
return new ModLoadingState(name, previous, ml -> "Processing transition " + name, phase, Optional.empty(), Optional.of(transition));
} }
public static ModLoadingState withTransition(final String name, final String previous, final Function<ModList, String> message, final ModLoadingPhase phase, IModStateTransition transition) { /**
* Returns a mod loading state with state transition information and a custom human-friendly message function.
*
* @param name the name of the state
* @param previous the name of the immediately previous state to this state
* @param message a function returning a human-friendly message for this state
* @param phase the mod loading phase the state belongs to
* @param transition the state transition information
* @return a mod loading state with state transition information and a custom message
*/
public static ModLoadingState withTransition(final String name, final String previous,
final Function<ModList, String> message, final ModLoadingPhase phase,
final IModStateTransition transition) {
return new ModLoadingState(name, previous, message, phase, Optional.empty(), Optional.of(transition)); return new ModLoadingState(name, previous, message, phase, Optional.empty(), Optional.of(transition));
} }
public static ModLoadingState withInline(final String name, final String previous, final ModLoadingPhase phase, Consumer<ModList> inline) {
return new ModLoadingState(name, previous, ml->"Processing work "+name, phase, Optional.of(inline), Optional.empty()); /**
* Returns a mod loading state with an inline runnable and a default human-friendly message of {@code Processing
* work [name]}.
*
* @param name the name of the state
* @param previous the name of the immediately previous state to this state
* @param phase the mod loading phase the state belongs to
* @param inline an optional runnable, which runs before starting the transition from this state to the next
* @return a mod loading state with an inline runnable and default message
*/
public static ModLoadingState withInline(final String name, final String previous, final ModLoadingPhase phase,
final Consumer<ModList> inline) {
return new ModLoadingState(name, previous, ml -> "Processing work " + name, phase, Optional.of(inline), Optional.empty());
} }
} }
@@ -10,11 +10,11 @@ import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.file.FileWatcher; import com.electronwill.nightconfig.core.file.FileWatcher;
import com.electronwill.nightconfig.core.io.ParsingException; import com.electronwill.nightconfig.core.io.ParsingException;
import com.electronwill.nightconfig.core.io.WritingMode; import com.electronwill.nightconfig.core.io.WritingMode;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.FMLConfig; import net.minecraftforge.fml.loading.FMLConfig;
import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.FMLPaths;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -24,7 +24,7 @@ import java.util.function.Function;
import static net.minecraftforge.fml.config.ConfigTracker.CONFIG; import static net.minecraftforge.fml.config.ConfigTracker.CONFIG;
public class ConfigFileTypeHandler { public class ConfigFileTypeHandler {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
static ConfigFileTypeHandler TOML = new ConfigFileTypeHandler(); static ConfigFileTypeHandler TOML = new ConfigFileTypeHandler();
private static final Path defaultConfigPath = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath()); private static final Path defaultConfigPath = FMLPaths.GAMEDIR.get().resolve(FMLConfig.defaultConfigPath());
@@ -7,18 +7,18 @@ package net.minecraftforge.fml.config;
import com.electronwill.nightconfig.core.CommentedConfig; import com.electronwill.nightconfig.core.CommentedConfig;
import com.electronwill.nightconfig.core.file.CommentedFileConfig; import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import org.apache.logging.log4j.LogManager; import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import org.apache.logging.log4j.Marker; import org.slf4j.Marker;
import org.apache.logging.log4j.MarkerManager; import org.slf4j.MarkerFactory;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class ConfigTracker { public class ConfigTracker {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
static final Marker CONFIG = MarkerManager.getMarker("CONFIG"); static final Marker CONFIG = MarkerFactory.getMarker("CONFIG");
public static final ConfigTracker INSTANCE = new ConfigTracker(); public static final ConfigTracker INSTANCE = new ConfigTracker();
private final ConcurrentHashMap<String, ModConfig> fileMap; private final ConcurrentHashMap<String, ModConfig> fileMap;
private final EnumMap<ModConfig.Type, Set<ModConfig>> configSets; private final EnumMap<ModConfig.Type, Set<ModConfig>> configSets;
+24 -19
View File
@@ -11,29 +11,34 @@ dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
configurations.forEach{ it.transitive = false } configurations.forEach{ it.transitive = false }
dependencies { dependencies {
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
compileOnly('org.jetbrains:annotations:23.0.0')
api("org.ow2.asm:asm:${ASM_VERSION}") api("org.ow2.asm:asm:${ASM_VERSION}")
api("org.ow2.asm:asm-tree:${ASM_VERSION}") api("org.ow2.asm:asm-tree:${ASM_VERSION}")
api("org.ow2.asm:asm-commons:${ASM_VERSION}") api("org.ow2.asm:asm-commons:${ASM_VERSION}")
api('net.minecraftforge:forgespi:4.0.+') api("net.minecraftforge:forgespi:${SPI_VERSION}")
api('org.apache.logging.log4j:log4j-api:2.17.0') api("org.apache.logging.log4j:log4j-api:${LOG4J_VERSION}")
api('org.slf4j:slf4j-api:1.8.0-beta4') api("org.slf4j:slf4j-api:${SLF4J_API_VERSION}")
api('com.google.guava:guava:21.0') api("com.google.guava:guava:${GUAVA_VERSION}")
api('com.google.code.gson:gson:2.8.9') api("com.google.code.gson:gson:${GSON_VERSION}")
api('org.apache.maven:maven-artifact:3.8.1') api("org.apache.maven:maven-artifact:${APACHE_MAVEN_ARTIFACT_VERSION}")
api('org.apache.commons:commons-lang3:3.12.0') api("org.apache.commons:commons-lang3:${APACHE_COMMONS_LANG3_VERSION}")
api('com.electronwill.night-config:core:3.6.4') api("com.electronwill.night-config:core:${NIGHTCONFIG_VERSION}")
api('com.electronwill.night-config:toml:3.6.4') api("com.electronwill.night-config:toml:${NIGHTCONFIG_VERSION}")
api('cpw.mods:modlauncher:9.0.+') api("cpw.mods:modlauncher:${MODLAUNCHER_VERSION}")
api('net.minecraftforge:coremods:5.0.+') api("net.minecraftforge:coremods:${COREMODS_VERSION}")
api("com.mojang:logging:${MOJANG_LOGGING_VERSION}")
implementation("net.sf.jopt-simple:jopt-simple:${JOPT_SIMPLE_VERSION}")
implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}") implementation("cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}")
implementation('org.apache.logging.log4j:log4j-core:2.17.0') implementation("net.minecraftforge:accesstransformers:${ACCESSTRANSFORMERS_VERSION}")
annotationProcessor('org.apache.logging.log4j:log4j-core:2.17.0') implementation("net.minecrell:terminalconsoleappender:${TERMINALCONSOLEAPPENDER_VERSION}")
implementation('net.minecraftforge:accesstransformers:8.0.4') // implementation("org.jline:jline:${JLINE_VERSION}")
implementation('net.minecrell:terminalconsoleappender:1.2.0')
// implementation('org.jline:jline:3.12.+') implementation("org.apache.logging.log4j:log4j-core:${LOG4J_VERSION}")
testCompileOnly('org.jetbrains:annotations:21.0.0') annotationProcessor("org.apache.logging.log4j:log4j-core:${LOG4J_VERSION}")
testCompileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}") testRuntimeOnly("cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}")
} }
@@ -7,7 +7,11 @@ package net.minecraftforge.fml.common.asm;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
@@ -20,7 +24,17 @@ import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
* Will also de-finalize all fields in on class level annotations. * Will also de-finalize all fields in on class level annotations.
*/ */
public class ObjectHolderDefinalize implements ILaunchPluginService { public class ObjectHolderDefinalize implements ILaunchPluginService {
// Hardcoded map of vanilla classes that should have object holders for each field of the given registry type.
// IMPORTANT: Updates to this collection must be reflected in ObjectHolderRegistry. Duplicated cuz classloaders, yay!
// Classnames are validated in ObjectHolderRegistry.
private static final Map<String, VanillaObjectHolderData> VANILLA_OBJECT_HOLDERS = Stream.of(
new VanillaObjectHolderData("net.minecraft.world.level.block.Blocks", "block", "net.minecraft.world.level.block.Block"),
new VanillaObjectHolderData("net.minecraft.world.item.Items", "item", "net.minecraft.world.item.Item"),
new VanillaObjectHolderData("net.minecraft.world.item.enchantment.Enchantments", "enchantment", "net.minecraft.world.item.enchantment.Enchantment"),
new VanillaObjectHolderData("net.minecraft.world.effect.MobEffects", "mob_effect", "net.minecraft.world.effect.MobEffect"),
new VanillaObjectHolderData("net.minecraft.core.particles.ParticleTypes", "particle_type", "net.minecraft.core.particles.ParticleType"),
new VanillaObjectHolderData("net.minecraft.sounds.SoundEvents", "sound_event", "net.minecraft.sounds.SoundEvent")
).collect(Collectors.toMap(VanillaObjectHolderData::holderClass, Function.identity()));
private final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading. private final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
@Override @Override
@@ -28,7 +42,6 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
return "object_holder_definalize"; return "object_holder_definalize";
} }
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER); private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class); private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
@@ -73,10 +86,8 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
changes.compareAndSet(false, prev != f.access); changes.compareAndSet(false, prev != f.access);
}); });
if (hasHolder(classNode.visibleAnnotations)) //Class level, de-finalize all fields and add @ObjectHolder to them! if (VANILLA_OBJECT_HOLDERS.containsKey(classType.getClassName())) //Class level, de-finalize all fields and add @ObjectHolder to them!
{ {
@SuppressWarnings("unused")
String value = getValue(classNode.visibleAnnotations);
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L")).forEach(f -> classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L")).forEach(f ->
{ {
int prev = f.access; int prev = f.access;
@@ -95,4 +106,5 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE; return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE;
} }
private record VanillaObjectHolderData(String holderClass, String registryName, String registryType) {}
} }
@@ -9,9 +9,7 @@ import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter; import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.Label; import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
@@ -21,6 +19,9 @@ import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
/** /**
* Modifies specified enums to allow runtime extension by making the $VALUES field non-final and * Modifies specified enums to allow runtime extension by making the $VALUES field non-final and
@@ -28,7 +29,7 @@ import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
*/ */
public class RuntimeEnumExtender implements ILaunchPluginService { public class RuntimeEnumExtender implements ILaunchPluginService {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final Type STRING = Type.getType(String.class); private final Type STRING = Type.getType(String.class);
private final Type ENUM = Type.getType(Enum.class); private final Type ENUM = Type.getType(Enum.class);
private final Type MARKER_IFACE = Type.getType("Lnet/minecraftforge/common/IExtensibleEnum;"); private final Type MARKER_IFACE = Type.getType("Lnet/minecraftforge/common/IExtensibleEnum;");
@@ -63,43 +64,49 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
final int flags = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC; final int flags = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC;
FieldNode values = classNode.fields.stream().filter(f -> f.desc.contentEquals(array.getDescriptor()) && ((f.access & flags) == flags)).findFirst().orElse(null); FieldNode values = classNode.fields.stream().filter(f -> f.desc.contentEquals(array.getDescriptor()) && ((f.access & flags) == flags)).findFirst().orElse(null);
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) { if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) {
return ComputeFlags.NO_REWRITE; return ComputeFlags.NO_REWRITE;
} }
//Static methods named "create" with first argument as a string //Static methods named "create" with first argument as a string
List<MethodNode> candidates = classNode.methods.stream() List<MethodNode> candidates = classNode.methods.stream()
.filter(m -> ((m.access & Opcodes.ACC_STATIC) != 0) && m.name.equals("create")) .filter(m -> ((m.access & Opcodes.ACC_STATIC) != 0) && m.name.equals("create"))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (candidates.isEmpty()) { if (candidates.isEmpty()) {
throw new IllegalStateException("IExtensibleEnum has no candidate factory methods: " + classType.getClassName()); throw new IllegalStateException("IExtensibleEnum has no candidate factory methods: " + classType.getClassName());
} }
candidates.forEach(mtd -> candidates.forEach(mtd ->
{ {
Type[] args = Type.getArgumentTypes(mtd.desc); Type[] args = Type.getArgumentTypes(mtd.desc);
if (args.length == 0 || !args[0].equals(STRING)) { if (args.length == 0 || !args[0].equals(STRING)) {
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> { if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
{
StringBuilder sb = new StringBuilder();
sb.append("Enum has create method without String as first parameter:\n"); sb.append("Enum has create method without String as first parameter:\n");
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n"); sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n"); sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
})); LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
}
throw new IllegalStateException("Enum has create method without String as first parameter: " + mtd.name + mtd.desc); throw new IllegalStateException("Enum has create method without String as first parameter: " + mtd.name + mtd.desc);
} }
Type ret = Type.getReturnType(mtd.desc); Type ret = Type.getReturnType(mtd.desc);
if (!ret.equals(classType)) { if (!ret.equals(classType)) {
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> { if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
{
StringBuilder sb = new StringBuilder();
sb.append("Enum has create method with incorrect return type:\n"); sb.append("Enum has create method with incorrect return type:\n");
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n"); sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n"); sb.append(" Target: ").append(mtd.name).append(mtd.desc).append("\n");
sb.append(" Found: ").append(ret.getClassName()).append(", Expected: ").append(classType.getClassName()); sb.append(" Found: ").append(ret.getClassName()).append(", Expected: ").append(classType.getClassName());
})); LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
}
throw new IllegalStateException("Enum has create method with incorrect return type: " + mtd.name + mtd.desc); throw new IllegalStateException("Enum has create method with incorrect return type: " + mtd.name + mtd.desc);
} }
Type[] ctrArgs = new Type[args.length + 1]; Type[] ctrArgs = new Type[args.length + 1];
ctrArgs[0] = STRING; ctrArgs[0] = STRING;
ctrArgs[1] = Type.INT_TYPE; ctrArgs[1] = Type.INT_TYPE;
@@ -111,23 +118,29 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
MethodNode ctr = classNode.methods.stream().filter(m -> m.name.equals("<init>") && m.desc.equals(desc)).findFirst().orElse(null); MethodNode ctr = classNode.methods.stream().filter(m -> m.name.equals("<init>") && m.desc.equals(desc)).findFirst().orElse(null);
if (ctr == null) if (ctr == null)
{ {
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> { if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
{
StringBuilder sb = new StringBuilder();
sb.append("Enum has create method with no matching constructor:\n"); sb.append("Enum has create method with no matching constructor:\n");
sb.append(" Enum: ").append(classType.getDescriptor()).append("\n"); sb.append(" Enum: ").append(classType.getDescriptor()).append("\n");
sb.append(" Candidate: ").append(mtd.desc).append("\n"); sb.append(" Candidate: ").append(mtd.desc).append("\n");
sb.append(" Target: ").append(desc).append("\n"); sb.append(" Target: ").append(desc).append("\n");
classNode.methods.stream().filter(m -> m.name.equals("<init>")).forEach(m -> sb.append(" : ").append(m.desc).append("\n")); classNode.methods.stream().filter(m -> m.name.equals("<init>")).forEach(m -> sb.append(" : ").append(m.desc).append("\n"));
})); LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
}
throw new IllegalStateException("Enum has create method with no matching constructor: " + desc); throw new IllegalStateException("Enum has create method with no matching constructor: " + desc);
} }
if (values == null) if (values == null)
{ {
LOGGER.fatal(()->new AdvancedLogMessageAdapter(sb-> { if (LOGGER.isErrorEnabled(LogUtils.FATAL_MARKER))
{
StringBuilder sb = new StringBuilder();
sb.append("Enum has create method but we could not find $VALUES. Found:\n"); sb.append("Enum has create method but we could not find $VALUES. Found:\n");
classNode.fields.stream().filter(f -> (f.access & Opcodes.ACC_STATIC) != 0). classNode.fields.stream().filter(f -> (f.access & Opcodes.ACC_STATIC) != 0).
forEach(m -> sb.append(" ").append(m.name).append(" ").append(m.desc).append("\n")); forEach(m -> sb.append(" ").append(m.name).append(" ").append(m.desc).append("\n"));
})); LOGGER.error(LogUtils.FATAL_MARKER, sb.toString());
}
throw new IllegalStateException("Enum has create method but we could not find $VALUES"); throw new IllegalStateException("Enum has create method but we could not find $VALUES");
} }
@@ -1,48 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.loading;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.util.StringBuilderFormattable;
import java.util.function.Consumer;
public class AdvancedLogMessageAdapter implements Message, StringBuilderFormattable {
private static final long serialVersionUID = -8291754833965087436L;
private static final Object[] EMPTY = new Object[0];
private final Consumer<StringBuilder> logMessageBuilder;
public AdvancedLogMessageAdapter(final Consumer<StringBuilder> logMessageBuilder) {
this.logMessageBuilder = logMessageBuilder;
}
@Override
public String getFormattedMessage() {
return "";
}
@Override
public String getFormat() {
return "";
}
@Override
public Object[] getParameters() {
return EMPTY;
}
@Override
public Throwable getThrowable() {
return null;
}
@Override
public void formatTo(final StringBuilder buffer) {
logMessageBuilder.accept(buffer);
}
}
@@ -10,8 +10,8 @@ import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.file.FileNotFoundAction; import com.electronwill.nightconfig.core.file.FileNotFoundAction;
import com.electronwill.nightconfig.core.io.ParsingException; import com.electronwill.nightconfig.core.io.ParsingException;
import com.electronwill.nightconfig.core.io.WritingMode; import com.electronwill.nightconfig.core.io.WritingMode;
import org.apache.logging.log4j.LogManager; import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@@ -21,7 +21,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
public class FMLConfig public class FMLConfig
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static FMLConfig INSTANCE = new FMLConfig(); private static FMLConfig INSTANCE = new FMLConfig();
private static ConfigSpec configSpec = new ConfigSpec(); private static ConfigSpec configSpec = new ConfigSpec();
static { static {
@@ -60,11 +60,14 @@ public class FMLConfig
{ {
final Path configFile = FMLPaths.FMLCONFIG.get(); final Path configFile = FMLPaths.FMLCONFIG.get();
INSTANCE.loadFrom(configFile); INSTANCE.loadFrom(configFile);
LOGGER.trace(CORE, "Loaded FML config from {}", FMLPaths.FMLCONFIG.get()); if (LOGGER.isTraceEnabled(CORE))
LOGGER.trace(CORE, "Splash screen is {}", FMLConfig::splashScreenEnabled); {
LOGGER.trace(CORE, "Max threads for mod loading computed at {}", FMLConfig::loadingThreadCount); LOGGER.trace(CORE, "Loaded FML config from {}", FMLPaths.FMLCONFIG.get());
LOGGER.trace(CORE, "Version check is {}", FMLConfig::runVersionCheck); LOGGER.trace(CORE, "Splash screen is {}", FMLConfig.splashScreenEnabled());
LOGGER.trace(CORE, "Default config paths at {}", FMLConfig::defaultConfigPath); LOGGER.trace(CORE, "Max threads for mod loading computed at {}", FMLConfig.loadingThreadCount());
LOGGER.trace(CORE, "Version check is {}", FMLConfig.runVersionCheck());
LOGGER.trace(CORE, "Default config paths at {}", FMLConfig.defaultConfigPath());
}
FMLPaths.getOrCreateGameRelativePath(Paths.get(FMLConfig.defaultConfigPath()), "default config directory"); FMLPaths.getOrCreateGameRelativePath(Paths.get(FMLConfig.defaultConfigPath()), "default config directory");
} }
@@ -5,6 +5,7 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.Launcher; import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.api.*; import cpw.mods.modlauncher.api.*;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
@@ -21,8 +22,7 @@ import net.minecraftforge.fml.loading.targets.CommonLaunchHandler;
import net.minecraftforge.forgespi.Environment; import net.minecraftforge.forgespi.Environment;
import net.minecraftforge.forgespi.coremod.ICoreModProvider; import net.minecraftforge.forgespi.coremod.ICoreModProvider;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@@ -35,7 +35,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
public class FMLLoader public class FMLLoader
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static AccessTransformerService accessTransformer; private static AccessTransformerService accessTransformer;
private static ModDiscoverer modDiscoverer; private static ModDiscoverer modDiscoverer;
private static ICoreModProvider coreModProvider; private static ICoreModProvider coreModProvider;
@@ -62,47 +62,47 @@ public class FMLLoader
final Package modLauncherPackage = ITransformationService.class.getPackage(); final Package modLauncherPackage = ITransformationService.class.getPackage();
LOGGER.debug(CORE,"FML found ModLauncher version : {}", modLauncherPackage.getImplementationVersion()); LOGGER.debug(CORE,"FML found ModLauncher version : {}", modLauncherPackage.getImplementationVersion());
if (!modLauncherPackage.isCompatibleWith("4.0")) { if (!modLauncherPackage.isCompatibleWith("4.0")) {
LOGGER.fatal(CORE,"Found incompatible ModLauncher specification : {}, version {} from {}", modLauncherPackage.getSpecificationVersion(), modLauncherPackage.getImplementationVersion(), modLauncherPackage.getImplementationVendor()); LOGGER.error(CORE, "Found incompatible ModLauncher specification : {}, version {} from {}", modLauncherPackage.getSpecificationVersion(), modLauncherPackage.getImplementationVersion(), modLauncherPackage.getImplementationVendor());
throw new IncompatibleEnvironmentException("Incompatible modlauncher found "+modLauncherPackage.getSpecificationVersion()); throw new IncompatibleEnvironmentException("Incompatible modlauncher found "+modLauncherPackage.getSpecificationVersion());
} }
accessTransformer = (AccessTransformerService) environment.findLaunchPlugin("accesstransformer").orElseThrow(()-> { accessTransformer = (AccessTransformerService) environment.findLaunchPlugin("accesstransformer").orElseThrow(()-> {
LOGGER.fatal(CORE,"Access Transformer library is missing, we need this to run"); LOGGER.error(CORE, "Access Transformer library is missing, we need this to run");
return new IncompatibleEnvironmentException("Missing AccessTransformer, cannot run"); return new IncompatibleEnvironmentException("Missing AccessTransformer, cannot run");
}); });
final Package atPackage = accessTransformer.getClass().getPackage(); final Package atPackage = accessTransformer.getClass().getPackage();
LOGGER.debug(CORE,"FML found AccessTransformer version : {}", atPackage.getImplementationVersion()); LOGGER.debug(CORE,"FML found AccessTransformer version : {}", atPackage.getImplementationVersion());
if (!atPackage.isCompatibleWith("1.0")) { if (!atPackage.isCompatibleWith("1.0")) {
LOGGER.fatal(CORE,"Found incompatible AccessTransformer specification : {}, version {} from {}", atPackage.getSpecificationVersion(), atPackage.getImplementationVersion(), atPackage.getImplementationVendor()); LOGGER.error(CORE, "Found incompatible AccessTransformer specification : {}, version {} from {}", atPackage.getSpecificationVersion(), atPackage.getImplementationVersion(), atPackage.getImplementationVendor());
throw new IncompatibleEnvironmentException("Incompatible accesstransformer found "+atPackage.getSpecificationVersion()); throw new IncompatibleEnvironmentException("Incompatible accesstransformer found "+atPackage.getSpecificationVersion());
} }
eventBus = environment.findLaunchPlugin("eventbus").orElseThrow(()-> { eventBus = environment.findLaunchPlugin("eventbus").orElseThrow(()-> {
LOGGER.fatal(CORE,"Event Bus library is missing, we need this to run"); LOGGER.error(CORE, "Event Bus library is missing, we need this to run");
return new IncompatibleEnvironmentException("Missing EventBus, cannot run"); return new IncompatibleEnvironmentException("Missing EventBus, cannot run");
}); });
final Package eventBusPackage = eventBus.getClass().getPackage(); final Package eventBusPackage = eventBus.getClass().getPackage();
LOGGER.debug(CORE,"FML found EventBus version : {}", eventBusPackage.getImplementationVersion()); LOGGER.debug(CORE,"FML found EventBus version : {}", eventBusPackage.getImplementationVersion());
if (!eventBusPackage.isCompatibleWith("1.0")) { if (!eventBusPackage.isCompatibleWith("1.0")) {
LOGGER.fatal(CORE,"Found incompatible EventBus specification : {}, version {} from {}", eventBusPackage.getSpecificationVersion(), eventBusPackage.getImplementationVersion(), eventBusPackage.getImplementationVendor()); LOGGER.error(CORE, "Found incompatible EventBus specification : {}, version {} from {}", eventBusPackage.getSpecificationVersion(), eventBusPackage.getImplementationVersion(), eventBusPackage.getImplementationVendor());
throw new IncompatibleEnvironmentException("Incompatible eventbus found "+eventBusPackage.getSpecificationVersion()); throw new IncompatibleEnvironmentException("Incompatible eventbus found "+eventBusPackage.getSpecificationVersion());
} }
runtimeDistCleaner = (RuntimeDistCleaner)environment.findLaunchPlugin("runtimedistcleaner").orElseThrow(()-> { runtimeDistCleaner = (RuntimeDistCleaner)environment.findLaunchPlugin("runtimedistcleaner").orElseThrow(()-> {
LOGGER.fatal(CORE,"Dist Cleaner is missing, we need this to run"); LOGGER.error(CORE, "Dist Cleaner is missing, we need this to run");
return new IncompatibleEnvironmentException("Missing DistCleaner, cannot run!"); return new IncompatibleEnvironmentException("Missing DistCleaner, cannot run!");
}); });
LOGGER.debug(CORE, "Found Runtime Dist Cleaner"); LOGGER.debug(CORE, "Found Runtime Dist Cleaner");
var coreModProviders = ServiceLoaderUtils.streamWithErrorHandling(ServiceLoader.load(FMLLoader.class.getModule().getLayer(), ICoreModProvider.class), sce -> LOGGER.fatal(CORE, "Failed to load a coremod library, expect problems", sce)).toList(); var coreModProviders = ServiceLoaderUtils.streamWithErrorHandling(ServiceLoader.load(FMLLoader.class.getModule().getLayer(), ICoreModProvider.class), sce -> LOGGER.error(CORE, "Failed to load a coremod library, expect problems", sce)).toList();
if (coreModProviders.isEmpty()) { if (coreModProviders.isEmpty()) {
LOGGER.fatal(CORE, "Found no coremod provider. Cannot run"); LOGGER.error(CORE, "Found no coremod provider. Cannot run");
throw new IncompatibleEnvironmentException("No coremod library found"); throw new IncompatibleEnvironmentException("No coremod library found");
} else if (coreModProviders.size() > 1) { } else if (coreModProviders.size() > 1) {
LOGGER.fatal(CORE, "Found multiple coremod providers : {}. Cannot run", coreModProviders.stream().map(p -> p.getClass().getName()).collect(Collectors.toList())); LOGGER.error(CORE, "Found multiple coremod providers : {}. Cannot run", coreModProviders.stream().map(p -> p.getClass().getName()).collect(Collectors.toList()));
throw new IncompatibleEnvironmentException("Multiple coremod libraries found"); throw new IncompatibleEnvironmentException("Multiple coremod libraries found");
} }
@@ -114,7 +114,7 @@ public class FMLLoader
LOGGER.debug(CORE, "Found ForgeSPI package implementation version {}", Environment.class.getPackage().getImplementationVersion()); LOGGER.debug(CORE, "Found ForgeSPI package implementation version {}", Environment.class.getPackage().getImplementationVersion());
LOGGER.debug(CORE, "Found ForgeSPI package specification {}", Environment.class.getPackage().getSpecificationVersion()); LOGGER.debug(CORE, "Found ForgeSPI package specification {}", Environment.class.getPackage().getSpecificationVersion());
if (Integer.parseInt(Environment.class.getPackage().getSpecificationVersion()) < 2) { if (Integer.parseInt(Environment.class.getPackage().getSpecificationVersion()) < 2) {
LOGGER.fatal(CORE, "Found an out of date ForgeSPI implementation: {}, loading cannot continue", Environment.class.getPackage().getSpecificationVersion()); LOGGER.error(CORE, "Found an out of date ForgeSPI implementation: {}, loading cannot continue", Environment.class.getPackage().getSpecificationVersion());
throw new IncompatibleEnvironmentException("ForgeSPI is out of date, we cannot continue"); throw new IncompatibleEnvironmentException("ForgeSPI is out of date, we cannot continue");
} }
@@ -122,7 +122,7 @@ public class FMLLoader
Class.forName("com.electronwill.nightconfig.core.Config", false, environment.getClass().getClassLoader()); Class.forName("com.electronwill.nightconfig.core.Config", false, environment.getClass().getClassLoader());
Class.forName("com.electronwill.nightconfig.toml.TomlFormat", false, environment.getClass().getClassLoader()); Class.forName("com.electronwill.nightconfig.toml.TomlFormat", false, environment.getClass().getClassLoader());
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
LOGGER.fatal(CORE, "Failed to load NightConfig"); LOGGER.error(CORE, "Failed to load NightConfig");
throw new IncompatibleEnvironmentException("Missing NightConfig"); throw new IncompatibleEnvironmentException("Missing NightConfig");
} }
} }
@@ -134,12 +134,12 @@ public class FMLLoader
final Optional<ILaunchHandlerService> launchHandler = environment.findLaunchHandler(launchTarget); final Optional<ILaunchHandlerService> launchHandler = environment.findLaunchHandler(launchTarget);
LOGGER.debug(CORE, "Using {} as launch service", launchTarget); LOGGER.debug(CORE, "Using {} as launch service", launchTarget);
if (launchHandler.isEmpty()) { if (launchHandler.isEmpty()) {
LOGGER.fatal(CORE,"Missing LaunchHandler {}, cannot continue", launchTarget); LOGGER.error(CORE, "Missing LaunchHandler {}, cannot continue", launchTarget);
throw new RuntimeException("Missing launch handler: " + launchTarget); throw new RuntimeException("Missing launch handler: " + launchTarget);
} }
if (!(launchHandler.get() instanceof CommonLaunchHandler)) { if (!(launchHandler.get() instanceof CommonLaunchHandler)) {
LOGGER.fatal(CORE, "Incompatible Launch handler found - type {}, cannot continue", launchHandler.get().getClass().getName()); LOGGER.error(CORE, "Incompatible Launch handler found - type {}, cannot continue", launchHandler.get().getClass().getName());
throw new RuntimeException("Incompatible launch handler found"); throw new RuntimeException("Incompatible launch handler found");
} }
commonLaunchHandler = (CommonLaunchHandler)launchHandler.get(); commonLaunchHandler = (CommonLaunchHandler)launchHandler.get();
@@ -5,9 +5,9 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.IEnvironment; import cpw.mods.modlauncher.api.IEnvironment;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@@ -22,7 +22,7 @@ public enum FMLPaths
CONFIGDIR("config"), CONFIGDIR("config"),
FMLCONFIG(false, CONFIGDIR, "fml.toml"); FMLCONFIG(false, CONFIGDIR, "fml.toml");
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final Path relativePath; private final Path relativePath;
private final boolean isDirectory; private final boolean isDirectory;
private Path absolutePath; private Path absolutePath;
@@ -61,7 +61,10 @@ public enum FMLPaths
{ {
FileUtils.getOrCreateDirectory(path.absolutePath, path.name()); FileUtils.getOrCreateDirectory(path.absolutePath, path.name());
} }
LOGGER.debug(CORE,"Path {} is {}", ()-> path, ()-> path.absolutePath); if (LOGGER.isDebugEnabled(CORE))
{
LOGGER.debug(CORE, "Path {} is {}", path, path.absolutePath);
}
} }
} }
@@ -5,14 +5,14 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.*; import cpw.mods.modlauncher.api.*;
import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.ArgumentAcceptingOptionSpec;
import joptsimple.OptionSpecBuilder; import joptsimple.OptionSpecBuilder;
import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFile;
import net.minecraftforge.forgespi.Environment; import net.minecraftforge.forgespi.Environment;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -26,7 +26,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
public class FMLServiceProvider implements ITransformationService public class FMLServiceProvider implements ITransformationService
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private ArgumentAcceptingOptionSpec<String> modsOption; private ArgumentAcceptingOptionSpec<String> modsOption;
private ArgumentAcceptingOptionSpec<String> modListsOption; private ArgumentAcceptingOptionSpec<String> modListsOption;
private ArgumentAcceptingOptionSpec<String> mavenRootsOption; private ArgumentAcceptingOptionSpec<String> mavenRootsOption;
@@ -5,8 +5,8 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import org.apache.logging.log4j.LogManager; import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.file.FileAlreadyExistsException; import java.nio.file.FileAlreadyExistsException;
@@ -17,7 +17,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
public class FileUtils public class FileUtils
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
public static Path getOrCreateDirectory(Path dirPath, String dirLabel) { public static Path getOrCreateDirectory(Path dirPath, String dirLabel) {
if (!Files.isDirectory(dirPath.getParent())) { if (!Files.isDirectory(dirPath.getParent())) {
@@ -25,20 +25,20 @@ public class FileUtils
} }
if (!Files.isDirectory(dirPath)) if (!Files.isDirectory(dirPath))
{ {
LOGGER.debug(CORE,"Making {} directory : {}", dirLabel, dirPath); LOGGER.debug(CORE, "Making {} directory : {}", dirLabel, dirPath);
try { try {
Files.createDirectory(dirPath); Files.createDirectory(dirPath);
} catch (IOException e) { } catch (IOException e) {
if (e instanceof FileAlreadyExistsException) { if (e instanceof FileAlreadyExistsException) {
LOGGER.fatal(CORE,"Failed to create {} directory - there is a file in the way", dirLabel); LOGGER.error(CORE, "Failed to create {} directory - there is a file in the way", dirLabel);
} else { } else {
LOGGER.fatal(CORE,"Problem with creating {} directory (Permissions?)", dirLabel, e); LOGGER.error(CORE, "Problem with creating {} directory (Permissions?)", dirLabel, e);
} }
throw new RuntimeException("Problem creating directory", e); throw new RuntimeException("Problem creating directory", e);
} }
LOGGER.debug(CORE,"Created {} directory : {}", dirLabel, dirPath); LOGGER.debug(CORE, "Created {} directory : {}", dirLabel, dirPath);
} else { } else {
LOGGER.debug(CORE,"Found existing {} directory : {}", dirLabel, dirPath); LOGGER.debug(CORE, "Found existing {} directory : {}", dirLabel, dirPath);
} }
return dirPath; return dirPath;
} }
@@ -5,6 +5,7 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.Launcher; import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.api.IModuleLayerManager; import cpw.mods.modlauncher.api.IModuleLayerManager;
import cpw.mods.modlauncher.util.ServiceLoaderUtils; import cpw.mods.modlauncher.util.ServiceLoaderUtils;
@@ -12,11 +13,10 @@ import net.minecraftforge.fml.loading.progress.StartupMessageManager;
import net.minecraftforge.forgespi.language.IModLanguageProvider; import net.minecraftforge.forgespi.language.IModLanguageProvider;
import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator; import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator;
import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.slf4j.Logger;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -38,7 +38,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
public class LanguageLoadingProvider public class LanguageLoadingProvider
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final List<IModLanguageProvider> languageProviders = new ArrayList<>(); private final List<IModLanguageProvider> languageProviders = new ArrayList<>();
private final ServiceLoader<IModLanguageProvider> serviceLoader; private final ServiceLoader<IModLanguageProvider> serviceLoader;
private final Map<String, ModLanguageWrapper> languageProviderMap = new HashMap<>(); private final Map<String, ModLanguageWrapper> languageProviderMap = new HashMap<>();
@@ -81,7 +81,7 @@ public class LanguageLoadingProvider
loadLanguageProviders(); loadLanguageProviders();
} }
private void loadLanguageProviders() { private void loadLanguageProviders() {
LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderUtils.streamServiceLoader(()->serviceLoader, sce->LOGGER.fatal("Problem with language loaders")).count()); LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderUtils.streamServiceLoader(()->serviceLoader, sce->LOGGER.error("Problem with language loaders")).count());
serviceLoader.forEach(languageProviders::add); serviceLoader.forEach(languageProviders::add);
languageProviders.forEach(lp -> { languageProviders.forEach(lp -> {
@@ -94,7 +94,7 @@ public class LanguageLoadingProvider
Optional<String> implementationVersion = JarVersionLookupHandler.getImplementationVersion(lp.getClass()); Optional<String> implementationVersion = JarVersionLookupHandler.getImplementationVersion(lp.getClass());
String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.versionInfo().forgeVersion().split("\\.")[0] : null); String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.versionInfo().forgeVersion().split("\\.")[0] : null);
if (impl == null) { if (impl == null) {
LOGGER.fatal(CORE, "Found unversioned language provider {}", lp.name()); LOGGER.error(CORE, "Found unversioned language provider {}", lp.name());
throw new RuntimeException("Failed to find implementation version for language provider "+ lp.name()); throw new RuntimeException("Failed to find implementation version for language provider "+ lp.name());
} }
LOGGER.debug(CORE, "Found language provider {}, version {}", lp.name(), impl); LOGGER.debug(CORE, "Found language provider {}, version {}", lp.name(), impl);
@@ -5,13 +5,13 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import org.apache.logging.log4j.LogManager; import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import static net.minecraftforge.fml.loading.LogMarkers.CORE; import static net.minecraftforge.fml.loading.LogMarkers.CORE;
public class LauncherVersion { public class LauncherVersion {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final String launcherVersion; private static final String launcherVersion;
static { static {
@@ -5,14 +5,14 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import org.apache.logging.log4j.LogManager; import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
public class LibraryFinder { public class LibraryFinder {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static Path libsPath; private static Path libsPath;
static Path findLibsPath() { static Path findLibsPath() {
if (libsPath == null) { if (libsPath == null) {
@@ -5,12 +5,12 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import org.apache.logging.log4j.Marker; import org.slf4j.Marker;
import org.apache.logging.log4j.MarkerManager; import org.slf4j.MarkerFactory;
public class LogMarkers { public class LogMarkers {
public static final Marker CORE = MarkerManager.getMarker("CORE"); public static final Marker CORE = MarkerFactory.getMarker("CORE");
public static final Marker LOADING = MarkerManager.getMarker("LOADING"); public static final Marker LOADING = MarkerFactory.getMarker("LOADING");
public static final Marker SCAN = MarkerManager.getMarker("SCAN"); public static final Marker SCAN = MarkerFactory.getMarker("SCAN");
public static final Marker SPLASH = MarkerManager.getMarker("SPLASH"); public static final Marker SPLASH = MarkerFactory.getMarker("SPLASH");
} }
@@ -5,10 +5,10 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.INameMappingService; import cpw.mods.modlauncher.api.INameMappingService;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@@ -20,7 +20,7 @@ import java.util.function.BiConsumer;
import java.util.function.BiFunction; import java.util.function.BiFunction;
public class MCPNamingService implements INameMappingService { public class MCPNamingService implements INameMappingService {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private HashMap<String, String> methods; private HashMap<String, String> methods;
private HashMap<String, String> fields; private HashMap<String, String> fields;
@@ -5,10 +5,11 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import cpw.mods.modlauncher.api.NamedPath; import cpw.mods.modlauncher.api.NamedPath;
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService; import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -19,6 +20,8 @@ import java.util.List;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService { public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
private static final Logger LOGGER = LogUtils.getLogger();
@Override @Override
public List<NamedPath> candidates(final Path gameDirectory) { public List<NamedPath> candidates(final Path gameDirectory) {
ModDirTransformerDiscoverer.scan(gameDirectory); ModDirTransformerDiscoverer.scan(gameDirectory);
@@ -40,7 +43,7 @@ public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService
try (var walk = Files.walk(modsDir, 1)){ try (var walk = Files.walk(modsDir, 1)){
walk.forEach(ModDirTransformerDiscoverer::visitFile); walk.forEach(ModDirTransformerDiscoverer::visitFile);
} catch (IOException | IllegalStateException ioe) { } catch (IOException | IllegalStateException ioe) {
LogManager.getLogger().error("Error during early discovery", ioe); LOGGER.error("Error during early discovery", ioe);
} }
} }
@@ -55,7 +58,7 @@ public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService
found.add(new NamedPath(zf.getName(), path)); found.add(new NamedPath(zf.getName(), path));
} }
} catch (IOException ioe) { } catch (IOException ioe) {
LogManager.getLogger().error("Zip Error when loading jar file {}", path, ioe); LOGGER.error("Zip Error when loading jar file {}", path, ioe);
} }
} }
} }
@@ -5,9 +5,9 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -24,7 +24,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
public class ModJarURLHandler extends URLStreamHandler public class ModJarURLHandler extends URLStreamHandler
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
// modjar://modid/path/to/file // modjar://modid/path/to/file
@Override @Override
protected URLConnection openConnection(URL url) { protected URLConnection openConnection(URL url) {
@@ -7,6 +7,7 @@ package net.minecraftforge.fml.loading;
import com.google.common.graph.GraphBuilder; import com.google.common.graph.GraphBuilder;
import com.google.common.graph.MutableGraph; import com.google.common.graph.MutableGraph;
import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.SecureJar;
import net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator; import net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator;
import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModFileInfo;
@@ -18,10 +19,9 @@ 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 net.minecraftforge.forgespi.locating.IModFile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.slf4j.Logger;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@@ -35,7 +35,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
public class ModSorter public class ModSorter
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private List<ModFile> modFiles; private List<ModFile> modFiles;
private List<ModInfo> sortedList; private List<ModInfo> sortedList;
private Map<String, ModInfo> modIdNameLookup; private Map<String, ModInfo> modIdNameLookup;
@@ -98,11 +98,10 @@ public class ModSorter
catch (CyclePresentException e) catch (CyclePresentException e)
{ {
Set<Set<ModFileInfo>> cycles = e.getCycles(); Set<Set<ModFileInfo>> cycles = e.getCycles();
LOGGER.error(LOADING, () -> new AdvancedLogMessageAdapter(buffer -> if (LOGGER.isErrorEnabled(LOADING))
buffer.append("Mod Sorting failed.\n") {
.append("Detected Cycles: ") LOGGER.error(LOADING, "Mod Sorting failed.\nDetected Cycles: {}\n", cycles);
.append(cycles) }
.append('\n')));
var dataList = cycles.stream() var dataList = cycles.stream()
.<ModFileInfo>mapMulti(Iterable::forEach) .<ModFileInfo>mapMulti(Iterable::forEach)
.<IModInfo>mapMulti((mf,c)->mf.getMods().forEach(c)) .<IModInfo>mapMulti((mf,c)->mf.getMods().forEach(c))
@@ -16,14 +16,11 @@ import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.OnlyIns; import net.minecraftforge.api.distmarker.OnlyIns;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import org.objectweb.asm.Handle; import org.objectweb.asm.Handle;
import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
@@ -33,11 +30,14 @@ import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
public class RuntimeDistCleaner implements ILaunchPluginService public class RuntimeDistCleaner implements ILaunchPluginService
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final Marker DISTXFORM = MarkerManager.getMarker("DISTXFORM"); private static final Marker DISTXFORM = MarkerFactory.getMarker("DISTXFORM");
private static String DIST; private static String DIST;
private static final String ONLYIN = Type.getDescriptor(OnlyIn.class); private static final String ONLYIN = Type.getDescriptor(OnlyIn.class);
private static final String ONLYINS = Type.getDescriptor(OnlyIns.class); private static final String ONLYINS = Type.getDescriptor(OnlyIns.class);
@@ -53,7 +53,7 @@ public class RuntimeDistCleaner implements ILaunchPluginService
AtomicBoolean changes = new AtomicBoolean(); AtomicBoolean changes = new AtomicBoolean();
if (remove(classNode.visibleAnnotations, DIST)) if (remove(classNode.visibleAnnotations, DIST))
{ {
LOGGER.fatal(DISTXFORM, "Attempted to load class {} for invalid dist {}", classNode.name, DIST); LOGGER.error(DISTXFORM, "Attempted to load class {} for invalid dist {}", classNode.name, DIST);
throw new RuntimeException("Attempted to load class "+ classNode.name + " for invalid dist "+ DIST); throw new RuntimeException("Attempted to load class "+ classNode.name + " for invalid dist "+ DIST);
} }
@@ -5,8 +5,7 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import java.io.PrintStream; import java.io.PrintStream;
/** /**
@@ -5,32 +5,23 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.SecureJar;
import cpw.mods.jarhandling.JarMetadata;
import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.language.IConfigurable;
import net.minecraftforge.forgespi.language.IModFileInfo;
import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.forgespi.locating.IModLocator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.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.List;
import java.util.Map;
import java.util.Optional; 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.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.locating.IModFile;
import org.slf4j.Logger;
public abstract class AbstractJarFileLocator extends AbstractModLocator { public abstract class AbstractJarFileLocator extends AbstractModLocator {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@Override @Override
public void scanFile(final IModFile file, final Consumer<Path> pathConsumer) { public void scanFile(final IModFile file, final Consumer<Path> pathConsumer) {
@@ -5,6 +5,7 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.JarMetadata; import cpw.mods.jarhandling.JarMetadata;
import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.SecureJar;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
@@ -13,8 +14,7 @@ import net.minecraftforge.forgespi.language.IModFileInfo;
import net.minecraftforge.forgespi.language.IModInfo; 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 net.minecraftforge.forgespi.locating.IModLocator;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collections; import java.util.Collections;
@@ -25,7 +25,7 @@ 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 = LogUtils.getLogger();
protected static final String MODS_TOML = "META-INF/mods.toml"; protected static final String MODS_TOML = "META-INF/mods.toml";
protected static final String MANIFEST = "META-INF/MANIFEST.MF"; protected static final String MANIFEST = "META-INF/MANIFEST.MF";
@@ -5,11 +5,11 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.LoadingModList; import net.minecraftforge.fml.loading.LoadingModList;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
@@ -28,7 +28,7 @@ public class BackgroundScanHandler
ERRORED ERRORED
} }
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final ExecutorService modContentScanner; private final ExecutorService modContentScanner;
private final List<ModFile> pendingFiles; private final List<ModFile> pendingFiles;
private final List<ModFile> scannedFiles; private final List<ModFile> scannedFiles;
@@ -5,9 +5,9 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -25,7 +25,7 @@ import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
public class ClasspathLocator extends AbstractJarFileLocator { public class ClasspathLocator extends AbstractJarFileLocator {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList(); private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
private boolean enabled = false; private boolean enabled = false;
@@ -48,7 +48,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
return paths.build(); return paths.build();
} catch (IOException e) { } catch (IOException e) {
LOGGER.fatal(LogMarkers.SCAN, "Error trying to find resources", e); LOGGER.error(LogMarkers.SCAN, "Error trying to find resources", e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@@ -85,7 +85,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
//LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString()); //LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString());
return path; return path;
} catch (NullPointerException | URISyntaxException e) { } catch (NullPointerException | URISyntaxException e) {
LOGGER.fatal(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName); LOGGER.error(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName);
throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e); throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e);
} }
} }
@@ -5,11 +5,11 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.forgespi.locating.IModLocator; import net.minecraftforge.forgespi.locating.IModLocator;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -22,7 +22,7 @@ import java.util.function.Consumer;
import java.util.stream.Stream; import java.util.stream.Stream;
public class ExplodedDirectoryLocator implements IModLocator { public class ExplodedDirectoryLocator implements IModLocator {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
public record ExplodedMod(String modid, List<Path> paths) {} public record ExplodedMod(String modid, List<Path> paths) {}
@@ -6,15 +6,14 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.electronwill.nightconfig.core.Config; import com.electronwill.nightconfig.core.Config;
import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.SecureJar;
import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModFileInfo;
import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.forgespi.locating.IModLocator;
import net.minecraftforge.forgespi.locating.ModFileFactory; import net.minecraftforge.forgespi.locating.ModFileFactory;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.file.*; import java.nio.file.*;
@@ -24,7 +23,7 @@ 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 {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@Override @Override
public List<IModFile> scanMods() { public List<IModFile> scanMods() {
@@ -5,6 +5,7 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.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;
@@ -13,8 +14,7 @@ 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;
import net.minecraftforge.forgespi.locating.IModLocator; import net.minecraftforge.forgespi.locating.IModLocator;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -23,7 +23,7 @@ import java.util.ServiceLoader;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ModDiscoverer { public class ModDiscoverer {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final ServiceLoader<IModLocator> locators; private final ServiceLoader<IModLocator> locators;
private final List<IModLocator> locatorList; private final List<IModLocator> locatorList;
@@ -34,7 +34,11 @@ public class ModDiscoverer {
locators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class); locators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class);
locatorList = ServiceLoaderUtils.streamServiceLoader(()->locators, sce->LOGGER.error("Failed to load locator list", sce)).collect(Collectors.toList()); locatorList = ServiceLoaderUtils.streamServiceLoader(()->locators, sce->LOGGER.error("Failed to load locator list", sce)).collect(Collectors.toList());
locatorList.forEach(l->l.initArguments(arguments)); locatorList.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 : {}", locatorList.stream()
.map(iModLocator -> "(" + iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion() + ")").collect(Collectors.joining(",")));
}
} }
ModDiscoverer(List<IModLocator> locatorList) { ModDiscoverer(List<IModLocator> locatorList) {
@@ -6,6 +6,7 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.SecureJar;
import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
@@ -17,8 +18,7 @@ import net.minecraftforge.forgespi.language.ModFileScanData;
import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.forgespi.locating.IModLocator; import net.minecraftforge.forgespi.locating.IModLocator;
import net.minecraftforge.forgespi.locating.ModFileFactory; import net.minecraftforge.forgespi.locating.ModFileFactory;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -37,7 +37,7 @@ public class ModFile implements IModFile {
// Mods either must have a mods.toml or a manifest. We can no longer just put any jar on the classpath. // Mods either must have a mods.toml or a manifest. We can no longer just put any jar on the classpath.
@Deprecated(forRemoval = true, since = "1.18") @Deprecated(forRemoval = true, since = "1.18")
public static final Manifest DEFAULTMANIFEST; public static final Manifest DEFAULTMANIFEST;
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
static { static {
DEFAULTMANIFEST = new Manifest(); DEFAULTMANIFEST = new Manifest();
@@ -6,6 +6,7 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils; import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.fml.loading.StringUtils;
@@ -13,8 +14,7 @@ import net.minecraftforge.forgespi.language.IConfigurable;
import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModFileInfo;
import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.MavenVersionAdapter; import net.minecraftforge.forgespi.language.MavenVersionAdapter;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import javax.security.auth.x500.X500Principal; import javax.security.auth.x500.X500Principal;
import java.net.URL; import java.net.URL;
import java.security.CodeSigner; import java.security.CodeSigner;
@@ -32,7 +32,7 @@ import java.util.stream.Stream;
public class ModFileInfo implements IModFileInfo, IConfigurable public class ModFileInfo implements IModFileInfo, IConfigurable
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final IConfigurable config; private final IConfigurable config;
private final ModFile modFile; private final ModFile modFile;
private final URL issueURL; private final URL issueURL;
@@ -68,10 +68,13 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
this.mods = modConfigs.stream() this.mods = modConfigs.stream()
.map(mi-> new ModInfo(this, mi)) .map(mi-> new ModInfo(this, mi))
.collect(Collectors.toList()); .collect(Collectors.toList());
LOGGER.debug(LogMarkers.LOADING, "Found valid mod file {} with {} mods - versions {}", if (LOGGER.isDebugEnabled(LogMarkers.LOADING))
this.modFile::getFileName, {
() -> this.mods.stream().map(IModInfo::getModId).collect(Collectors.joining(",", "{", "}")), LOGGER.debug(LogMarkers.LOADING, "Found valid mod file {} with {} mods - versions {}",
() -> this.mods.stream().map(IModInfo::getVersion).map(Objects::toString).collect(Collectors.joining(",", "{", "}"))); this.modFile.getFileName(),
this.mods.stream().map(IModInfo::getModId).collect(Collectors.joining(",", "{", "}")),
this.mods.stream().map(IModInfo::getVersion).map(Objects::toString).collect(Collectors.joining(",", "{", "}")));
}
} }
public ModFileInfo(final ModFile file, final IConfigurable config, final List<LanguageSpec> languageSpecs) { public ModFileInfo(final ModFile file, final IConfigurable config, final List<LanguageSpec> languageSpecs) {
@@ -8,12 +8,12 @@ package net.minecraftforge.fml.loading.moddiscovery;
import com.electronwill.nightconfig.core.file.FileConfig; import com.electronwill.nightconfig.core.file.FileConfig;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModFileInfo;
import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.forgespi.locating.ModFileFactory; import net.minecraftforge.forgespi.locating.ModFileFactory;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@@ -25,7 +25,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ModFileParser { public class ModFileParser {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
public static IModFileInfo readModList(final ModFile modFile, final ModFileFactory.ModFileInfoParser parser) { public static IModFileInfo readModList(final ModFile modFile, final ModFileFactory.ModFileInfoParser parser) {
return parser.build(modFile); return parser.build(modFile);
@@ -5,16 +5,18 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.StringSubstitutor; import net.minecraftforge.fml.loading.StringSubstitutor;
import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.fml.loading.StringUtils;
import net.minecraftforge.forgespi.language.IConfigurable; import net.minecraftforge.forgespi.language.IConfigurable;
import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.MavenVersionAdapter; import net.minecraftforge.forgespi.language.MavenVersionAdapter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
import java.net.URL; import java.net.URL;
import java.util.Collections; import java.util.Collections;
@@ -26,7 +28,7 @@ import java.util.stream.Collectors;
public class ModInfo implements IModInfo, IConfigurable public class ModInfo implements IModInfo, IConfigurable
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1"); private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1");
private static final Pattern VALID_MODID = Pattern.compile("^[a-z][a-z0-9_]{1,63}$"); private static final Pattern VALID_MODID = Pattern.compile("^[a-z][a-z0-9_]{1,63}$");
private static final Pattern VALID_NAMESPACE = Pattern.compile("^[a-z][a-z0-9_.-]{1,63}$"); private static final Pattern VALID_NAMESPACE = Pattern.compile("^[a-z][a-z0-9_.-]{1,63}$");
@@ -52,12 +54,12 @@ public class ModInfo implements IModInfo, IConfigurable
this.modId = config.<String>getConfigElement("modId") this.modId = config.<String>getConfigElement("modId")
.orElseThrow(() -> new InvalidModFileException("Missing modId", owningFile)); .orElseThrow(() -> new InvalidModFileException("Missing modId", owningFile));
if (!VALID_MODID.matcher(this.modId).matches()) { if (!VALID_MODID.matcher(this.modId).matches()) {
LOGGER.fatal("Invalid modId found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.modId, VALID_MODID.pattern()); LOGGER.error(LogUtils.FATAL_MARKER, "Invalid modId found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.modId, VALID_MODID.pattern());
throw new InvalidModFileException("Invalid modId found : " + this.modId, owningFile); throw new InvalidModFileException("Invalid modId found : " + this.modId, owningFile);
} }
this.namespace = config.<String>getConfigElement("namespace").orElse(this.modId); this.namespace = config.<String>getConfigElement("namespace").orElse(this.modId);
if (!VALID_NAMESPACE.matcher(this.namespace).matches()) { if (!VALID_NAMESPACE.matcher(this.namespace).matches()) {
LOGGER.fatal("Invalid override namespace found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.namespace, VALID_NAMESPACE.pattern()); LOGGER.error(LogUtils.FATAL_MARKER, "Invalid override namespace found in file {} - {} does not match the standard: {}", this.owningFile.getFile().getFilePath(), this.namespace, VALID_NAMESPACE.pattern());
throw new InvalidModFileException("Invalid override namespace found : " + this.namespace, owningFile); throw new InvalidModFileException("Invalid override namespace found : " + this.namespace, owningFile);
} }
this.version = config.<String>getConfigElement("version") this.version = config.<String>getConfigElement("version")
@@ -5,13 +5,13 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.fml.loading.FileUtils; import net.minecraftforge.fml.loading.FileUtils;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.fml.loading.MavenCoordinateResolver; import net.minecraftforge.fml.loading.MavenCoordinateResolver;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -23,7 +23,7 @@ import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ModListHandler { public class ModListHandler {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
/** /**
* Reads the modList paths specified, and searches each maven root for mods matching. Returns a list of mods * Reads the modList paths specified, and searches each maven root for mods matching. Returns a list of mods
* found. * found.
@@ -5,6 +5,7 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.IModuleLayerManager; import cpw.mods.modlauncher.api.IModuleLayerManager;
import cpw.mods.modlauncher.api.ITransformationService; import cpw.mods.modlauncher.api.ITransformationService;
import net.minecraftforge.fml.loading.EarlyLoadingException; import net.minecraftforge.fml.loading.EarlyLoadingException;
@@ -13,14 +14,13 @@ import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.fml.loading.ModSorter; import net.minecraftforge.fml.loading.ModSorter;
import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.fml.loading.progress.StartupMessageManager;
import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModFile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import java.util.*; import java.util.*;
public class ModValidator { public class ModValidator {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final Map<IModFile.Type, List<ModFile>> modFiles; private final Map<IModFile.Type, List<ModFile>> modFiles;
private final List<ModFile> candidatePlugins; private final List<ModFile> candidatePlugins;
private final List<ModFile> candidateMods; private final List<ModFile> candidateMods;
@@ -41,7 +41,9 @@ public class ModValidator {
public void stage1Validation() { public void stage1Validation() {
brokenFiles = validateFiles(candidateMods); brokenFiles = validateFiles(candidateMods);
LOGGER.debug(LogMarkers.SCAN,"Found {} mod files with {} mods", candidateMods::size, ()-> candidateMods.stream().mapToInt(mf -> mf.getModInfos().size()).sum()); if (LOGGER.isDebugEnabled(LogMarkers.SCAN)) {
LOGGER.debug(LogMarkers.SCAN, "Found {} mod files with {} mods", candidateMods.size(), candidateMods.stream().mapToInt(mf -> mf.getModInfos().size()).sum());
}
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found "+ candidateMods.size()+" modfiles to load")); StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found "+ candidateMods.size()+" modfiles to load"));
} }
@@ -5,12 +5,12 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer; import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.fml.loading.StringUtils;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -25,7 +25,7 @@ import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck;
*/ */
public class ModsFolderLocator extends AbstractJarFileLocator { public class ModsFolderLocator extends AbstractJarFileLocator {
private static final String SUFFIX = ".jar"; private static final String SUFFIX = ".jar";
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final Path modFolder; private final Path modFolder;
private final String customName; private final String customName;
@@ -5,12 +5,12 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.forgespi.language.IModLanguageProvider; import net.minecraftforge.forgespi.language.IModLanguageProvider;
import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.slf4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -19,7 +19,7 @@ import java.nio.file.Path;
import java.util.List; import java.util.List;
public class Scanner { public class Scanner {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final ModFile fileToScan; private final ModFile fileToScan;
public Scanner(final ModFile fileToScan) { public Scanner(final ModFile fileToScan) {
@@ -34,8 +34,6 @@ import java.util.function.IntSupplier;
import java.util.function.LongSupplier; import java.util.function.LongSupplier;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.annotation.Nullable;
import static org.lwjgl.glfw.GLFW.*; import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.glfw.GLFW.glfwCreateWindow; import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
@@ -5,8 +5,8 @@
package net.minecraftforge.fml.loading.targets; package net.minecraftforge.fml.loading.targets;
import org.apache.logging.log4j.LogManager; import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -20,7 +20,7 @@ import java.util.function.Supplier;
* Can not use JOptSimple as that doesn't parse out the values for keys unless the spec says it has a value. * Can not use JOptSimple as that doesn't parse out the values for keys unless the spec says it has a value.
*/ */
class ArgumentList { class ArgumentList {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private List<Supplier<String[]>> entries = new ArrayList<>(); private List<Supplier<String[]>> entries = new ArrayList<>();
private Map<String, EntryValue> values = new HashMap<>(); private Map<String, EntryValue> values = new HashMap<>();
@@ -10,17 +10,12 @@ import net.minecraftforge.fml.loading.LibraryFinder;
import net.minecraftforge.fml.loading.VersionInfo; import net.minecraftforge.fml.loading.VersionInfo;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.stream.Stream; import java.util.stream.Stream;
public abstract class CommonClientLaunchHandler extends CommonLaunchHandler { public abstract class CommonClientLaunchHandler extends CommonLaunchHandler {
private static final Logger LOGGER = LogManager.getLogger();
@Override public Dist getDist() { return Dist.CLIENT; } @Override public Dist getDist() { return Dist.CLIENT; }
@Override public String getNaming() { return "srg"; } @Override public String getNaming() { return "srg"; }
@Override public boolean isProduction() { return true; } @Override public boolean isProduction() { return true; }
@@ -5,12 +5,12 @@
package net.minecraftforge.fml.loading.targets; package net.minecraftforge.fml.loading.targets;
import com.mojang.logging.LogUtils;
import cpw.mods.modlauncher.api.ILaunchHandlerService; import cpw.mods.modlauncher.api.ILaunchHandlerService;
import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder; import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder;
import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.LogMarkers;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
public abstract class CommonLaunchHandler implements ILaunchHandlerService { public abstract class CommonLaunchHandler implements ILaunchHandlerService {
public record LocatedPaths(List<Path> minecraftPaths, BiPredicate<String, String> minecraftFilter, List<List<Path>> otherModPaths, List<Path> otherArtifacts) {} public record LocatedPaths(List<Path> minecraftPaths, BiPredicate<String, String> minecraftFilter, List<List<Path>> otherModPaths, List<Path> otherArtifacts) {}
protected static final Logger LOGGER = LogManager.getLogger(); protected static final Logger LOGGER = LogUtils.getLogger();
public abstract Dist getDist(); public abstract Dist getDist();
@@ -10,8 +10,6 @@ import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.LibraryFinder; import net.minecraftforge.fml.loading.LibraryFinder;
import net.minecraftforge.fml.loading.VersionInfo; import net.minecraftforge.fml.loading.VersionInfo;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
@@ -20,8 +18,6 @@ import java.util.function.BiPredicate;
import java.util.stream.Stream; import java.util.stream.Stream;
public abstract class CommonServerLaunchHandler extends CommonLaunchHandler { public abstract class CommonServerLaunchHandler extends CommonLaunchHandler {
protected static final Logger LOGGER = LogManager.getLogger();
@Override public Dist getDist() { return Dist.DEDICATED_SERVER; } @Override public Dist getDist() { return Dist.DEDICATED_SERVER; }
@Override public String getNaming() { return "srg"; } @Override public String getNaming() { return "srg"; }
@Override public boolean isProduction() { return true; } @Override public boolean isProduction() { return true; }
Binary file not shown.
+1 -1
View File
@@ -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.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
Vendored
+5 -5
View File
@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# Copyright © 2015-2021 the original authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script # Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features: # requires all of these POSIX shell features:
# * functions; # * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»; # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»; # * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit». # * various built-in commands including «command», «set», and «ulimit».
# #
# Important for patching: # Important for patching:
# #
+1 -1
View File
@@ -10,7 +10,7 @@ apply plugin: 'org.javamodularity.moduleplugin'
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) } dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
dependencies { dependencies {
compileOnly('org.jetbrains:annotations:21.0.1') compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
implementation(project(':fmlloader')) implementation(project(':fmlloader'))
implementation(project(':fmlcore')) implementation(project(':fmlcore'))
} }
@@ -18,14 +18,15 @@ import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import java.util.Optional; import java.util.Optional;
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
public class FMLModContainer extends ModContainer public class FMLModContainer extends ModContainer
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
private static final Marker LOADING = MarkerManager.getMarker("LOADING");
private final ModFileScanData scanResults; private final ModFileScanData scanResults;
private final IEventBus eventBus; private final IEventBus eventBus;
private Object modInstance; private Object modInstance;
-26
View File
@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!--The ID below indicates application support for Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--The ID below indicates application support for Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--The ID below indicates application supprort for Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<!-- following stuff is so the EXE doesnt ask for admin access -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
@@ -5,14 +5,14 @@
package net.minecraftforge.fml.lowcodemod; package net.minecraftforge.fml.lowcodemod;
import com.mojang.logging.LogUtils;
import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.IExtensionPoint; import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger;
import java.util.Objects; import java.util.Objects;
@@ -20,7 +20,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
public class LowCodeModContainer extends ModContainer public class LowCodeModContainer extends ModContainer
{ {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private final ModFileScanData scanResults; private final ModFileScanData scanResults;
private Object modInstance; private Object modInstance;
+1 -1
View File
@@ -10,7 +10,7 @@ apply plugin: 'org.javamodularity.moduleplugin'
dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) } dependencyUpdates.rejectVersionIf { isNonStable(it.candidate.version) }
dependencies { dependencies {
compileOnly('org.jetbrains:annotations:21.0.1') compileOnly("org.jetbrains:annotations:${JETBRAINS_ANNOTATIONS_VERSION}")
implementation(project(':fmlloader')) implementation(project(':fmlloader'))
implementation(project(':fmlcore')) implementation(project(':fmlcore'))
} }
+1 -13
View File
@@ -1,20 +1,8 @@
buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
plugins { plugins {
id 'eclipse' id 'eclipse'
id 'maven-publish' id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.+'
} }
apply plugin: 'net.minecraftforge.gradle'
version = '1.0' version = '1.0'
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
+6
View File
@@ -0,0 +1,6 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net/' }
}
}
+2 -2
View File
@@ -2,7 +2,7 @@
"pack": { "pack": {
"description": "examplemod resources", "description": "examplemod resources",
"pack_format": 9, "pack_format": 9,
"forge:resource_pack_format": 8, "forge:resource_pack_format": 9,
"forge:data_pack_format": 9 "forge:data_pack_format": 10
} }
} }
@@ -26,7 +26,7 @@
} }
this.m_83949_(); this.m_83949_();
@@ -292,4 +_,27 @@ @@ -291,4 +_,27 @@
public int m_83980_() { public int m_83980_() {
return this.f_83924_; return this.f_83924_;
} }
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/platform/Window.java --- a/com/mojang/blaze3d/platform/Window.java
+++ b/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java
@@ -81,7 +_,7 @@ @@ -80,7 +_,7 @@
GLFW.glfwWindowHint(139267, 2); GLFW.glfwWindowHint(139267, 2);
GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139272, 204801);
GLFW.glfwWindowHint(139270, 1); GLFW.glfwWindowHint(139270, 1);
@@ -9,7 +9,7 @@
if (monitor != null) { if (monitor != null) {
VideoMode videomode = monitor.m_84948_(this.f_85355_ ? this.f_85354_ : Optional.empty()); VideoMode videomode = monitor.m_84948_(this.f_85355_ ? this.f_85354_ : Optional.empty());
this.f_85350_ = this.f_85357_ = monitor.m_84951_() + videomode.m_85332_() / 2 - this.f_85359_ / 2; this.f_85350_ = this.f_85357_ = monitor.m_84951_() + videomode.m_85332_() / 2 - this.f_85359_ / 2;
@@ -299,6 +_,7 @@ @@ -298,6 +_,7 @@
GLFW.glfwGetFramebufferSize(this.f_85349_, aint, aint1); GLFW.glfwGetFramebufferSize(this.f_85349_, aint, aint1);
this.f_85361_ = aint[0] > 0 ? aint[0] : 1; this.f_85361_ = aint[0] > 0 ? aint[0] : 1;
this.f_85362_ = aint1[0] > 0 ? aint1[0] : 1; this.f_85362_ = aint1[0] > 0 ? aint1[0] : 1;
@@ -1,14 +1,6 @@
--- a/com/mojang/blaze3d/vertex/BufferBuilder.java --- a/com/mojang/blaze3d/vertex/BufferBuilder.java
+++ b/com/mojang/blaze3d/vertex/BufferBuilder.java +++ b/com/mojang/blaze3d/vertex/BufferBuilder.java
@@ -332,6 +_,7 @@ @@ -486,4 +_,15 @@
}
ByteBuffer bytebuffer = this.f_85648_.slice();
+ bytebuffer.order(this.f_85648_.order()); // FORGE: Fix incorrect byte order
this.f_85648_.clear();
return Pair.of(bufferbuilder$drawstate, bytebuffer);
}
@@ -444,4 +_,15 @@
this.f_166822_ = p_166829_; this.f_166822_ = p_166829_;
} }
} }
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/vertex/VertexFormat.java --- a/com/mojang/blaze3d/vertex/VertexFormat.java
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/blaze3d/vertex/VertexFormat.java
@@ -195,4 +_,11 @@ @@ -181,4 +_,11 @@
return i; return i;
} }
} }
@@ -1,7 +1,7 @@
--- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java --- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java
+++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java
@@ -67,6 +_,15 @@ @@ -65,6 +_,15 @@
return (new TextComponent("")).m_7220_(this.f_200947_.getFirst()).m_130946_(": ").m_7220_(this.f_200947_.getSecond()); return Component.m_237119_().m_7220_(this.f_200947_.getFirst()).m_130946_(": ").m_7220_(this.f_200947_.getSecond());
} }
+ @Override + @Override
@@ -1,6 +1,6 @@
--- a/net/minecraft/SharedConstants.java --- a/net/minecraft/SharedConstants.java
+++ b/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java
@@ -183,6 +_,7 @@ @@ -203,6 +_,7 @@
} }
static { static {
@@ -1,16 +1,18 @@
--- a/net/minecraft/Util.java --- a/net/minecraft/Util.java
+++ b/net/minecraft/Util.java +++ b/net/minecraft/Util.java
@@ -155,6 +_,9 @@ @@ -164,6 +_,11 @@
return 255; return 255;
} }
+ // We add this inner class to compensate for Mojang's missing inner class and allow us to obf subsequent anon inner classes correctly. + // We add these inner classes to compensate for Mojang's missing inner classes and shift the anonymous class index.
+ @SuppressWarnings("unused") private static LongSupplier INNER_CLASS_SHIFT = new LongSupplier() { public long getAsLong() { return 0; } }; + // This allows us to obfuscate subsequent anonymous inner classes correctly.
+ @SuppressWarnings("unused") private static LongSupplier INNER_CLASS_SHIFT1 = new LongSupplier() { public long getAsLong() { return 0; } };
+ @SuppressWarnings("unused") private static LongSupplier INNER_CLASS_SHIFT2 = new LongSupplier() { public long getAsLong() { return 0; } };
+ +
public static ExecutorService m_183988_() { public static ExecutorService m_183988_() {
return f_137443_; return f_137443_;
} }
@@ -233,7 +_,7 @@ @@ -242,7 +_,7 @@
try { try {
type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_183709_().getWorldVersion())).getChoiceType(p_137552_, p_137553_); type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_183709_().getWorldVersion())).getChoiceType(p_137552_, p_137553_);
} catch (IllegalArgumentException illegalargumentexception) { } catch (IllegalArgumentException illegalargumentexception) {
@@ -1,16 +1,15 @@
--- a/net/minecraft/advancements/Advancement.java --- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java
@@ -129,8 +_,8 @@ @@ -127,7 +_,7 @@
return this.f_138305_; return this.f_138305_;
} }
- public static class Builder { - public static class Builder {
@Nullable
+ public static class Builder implements net.minecraftforge.common.extensions.IForgeAdvancementBuilder { + public static class Builder implements net.minecraftforge.common.extensions.IForgeAdvancementBuilder {
@Nullable
private ResourceLocation f_138332_; private ResourceLocation f_138332_;
@Nullable @Nullable
private Advancement f_138333_; @@ -308,7 +_,14 @@
@@ -320,7 +_,14 @@
return "Task Advancement{parentId=" + this.f_138332_ + ", display=" + this.f_138334_ + ", rewards=" + this.f_138335_ + ", criteria=" + this.f_138336_ + ", requirements=" + Arrays.deepToString(this.f_138337_) + "}"; return "Task Advancement{parentId=" + this.f_138332_ + ", display=" + this.f_138334_ + ", rewards=" + this.f_138335_ + ", criteria=" + this.f_138336_ + ", requirements=" + Arrays.deepToString(this.f_138337_) + "}";
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/AdvancementList.java --- a/net/minecraft/advancements/AdvancementList.java
+++ b/net/minecraft/advancements/AdvancementList.java +++ b/net/minecraft/advancements/AdvancementList.java
@@ -91,6 +_,7 @@ @@ -90,6 +_,7 @@
} }
} }
@@ -4,8 +4,8 @@
public void m_9989_(ServerPlayer p_9990_) { public void m_9989_(ServerPlayer p_9990_) {
p_9990_.m_6756_(this.f_9979_); p_9990_.m_6756_(this.f_9979_);
- LootContext lootcontext = (new LootContext.Builder(p_9990_.m_183503_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78975_(LootContextParamSets.f_81418_); - LootContext lootcontext = (new LootContext.Builder(p_9990_.m_9236_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_230911_(p_9990_.m_217043_()).m_78975_(LootContextParamSets.f_81418_);
+ LootContext lootcontext = (new LootContext.Builder(p_9990_.m_183503_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78963_(p_9990_.m_36336_()).m_78975_(LootContextParamSets.f_81418_); // FORGE: luck to LootContext + LootContext lootcontext = (new LootContext.Builder(p_9990_.m_9236_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_230911_(p_9990_.m_217043_()).m_78963_(p_9990_.m_36336_()).m_78975_(LootContextParamSets.f_81418_); // FORGE: luck to LootContext
boolean flag = false; boolean flag = false;
for(ResourceLocation resourcelocation : this.f_9980_) { for(ResourceLocation resourcelocation : this.f_9980_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/ClientRecipeBook.java --- a/net/minecraft/client/ClientRecipeBook.java
+++ b/net/minecraft/client/ClientRecipeBook.java +++ b/net/minecraft/client/ClientRecipeBook.java
@@ -104,6 +_,8 @@ @@ -103,6 +_,8 @@
} else if (recipetype == RecipeType.f_44113_) { } else if (recipetype == RecipeType.f_44113_) {
return RecipeBookCategories.SMITHING; return RecipeBookCategories.SMITHING;
} else { } else {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/KeyMapping.java --- a/net/minecraft/client/KeyMapping.java
+++ b/net/minecraft/client/KeyMapping.java +++ b/net/minecraft/client/KeyMapping.java
@@ -14,9 +_,9 @@ @@ -13,9 +_,9 @@
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -12,7 +12,7 @@
private static final Set<String> f_90811_ = Sets.newHashSet(); private static final Set<String> f_90811_ = Sets.newHashSet();
public static final String f_167805_ = "key.categories.movement"; public static final String f_167805_ = "key.categories.movement";
public static final String f_167806_ = "key.categories.misc"; public static final String f_167806_ = "key.categories.misc";
@@ -42,7 +_,7 @@ @@ -41,7 +_,7 @@
private int f_90818_; private int f_90818_;
public static void m_90835_(InputConstants.Key p_90836_) { public static void m_90835_(InputConstants.Key p_90836_) {
@@ -21,7 +21,7 @@
if (keymapping != null) { if (keymapping != null) {
++keymapping.f_90818_; ++keymapping.f_90818_;
} }
@@ -50,7 +_,7 @@ @@ -49,7 +_,7 @@
} }
public static void m_90837_(InputConstants.Key p_90838_, boolean p_90839_) { public static void m_90837_(InputConstants.Key p_90838_, boolean p_90839_) {
@@ -30,7 +30,7 @@
if (keymapping != null) { if (keymapping != null) {
keymapping.m_7249_(p_90839_); keymapping.m_7249_(p_90839_);
} }
@@ -74,10 +_,10 @@ @@ -73,10 +_,10 @@
} }
public static void m_90854_() { public static void m_90854_() {
@@ -43,7 +43,7 @@
} }
} }
@@ -92,12 +_,12 @@ @@ -91,12 +_,12 @@
this.f_90814_ = this.f_90816_; this.f_90814_ = this.f_90816_;
this.f_90815_ = p_90828_; this.f_90815_ = p_90828_;
f_90809_.put(p_90825_, this); f_90809_.put(p_90825_, this);
@@ -58,7 +58,7 @@
} }
public String m_90858_() { public String m_90858_() {
@@ -131,7 +_,13 @@ @@ -130,7 +_,13 @@
} }
public int compareTo(KeyMapping p_90841_) { public int compareTo(KeyMapping p_90841_) {
@@ -73,7 +73,7 @@
} }
public static Supplier<Component> m_90842_(String p_90843_) { public static Supplier<Component> m_90842_(String p_90843_) {
@@ -142,6 +_,20 @@ @@ -141,6 +_,20 @@
} }
public boolean m_90850_(KeyMapping p_90851_) { public boolean m_90850_(KeyMapping p_90851_) {
@@ -94,7 +94,7 @@
return this.f_90816_.equals(p_90851_.f_90816_); return this.f_90816_.equals(p_90851_.f_90816_);
} }
@@ -162,11 +_,13 @@ @@ -161,11 +_,13 @@
} }
public Component m_90863_() { public Component m_90863_() {
@@ -109,7 +109,7 @@
} }
public String m_90865_() { public String m_90865_() {
@@ -176,4 +_,84 @@ @@ -175,4 +_,84 @@
public void m_7249_(boolean p_90846_) { public void m_7249_(boolean p_90846_) {
this.f_90817_ = p_90846_; this.f_90817_ = p_90846_;
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/KeyboardHandler.java --- a/net/minecraft/client/KeyboardHandler.java
+++ b/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java
@@ -307,7 +_,9 @@ @@ -300,7 +_,9 @@
} }
Screen screen = this.f_90867_.f_91080_; Screen screen = this.f_90867_.f_91080_;
@@ -10,8 +10,8 @@
+ if (p_90897_ == 1) { + if (p_90897_ == 1) {
if (this.f_90867_.f_91066_.f_92105_.m_90832_(p_90895_, p_90896_)) { if (this.f_90867_.f_91066_.f_92105_.m_90832_(p_90895_, p_90896_)) {
this.f_90867_.m_91268_().m_85438_(); this.f_90867_.m_91268_().m_85438_();
this.f_90867_.f_91066_.f_92052_ = this.f_90867_.m_91268_().m_85440_(); this.f_90867_.f_91066_.m_231829_().m_231514_(this.f_90867_.m_91268_().m_85440_());
@@ -326,6 +_,8 @@ @@ -318,6 +_,8 @@
}); });
return; return;
} }
@@ -20,7 +20,7 @@
} }
if (NarratorChatListener.f_93311_.m_93316_()) { if (NarratorChatListener.f_93311_.m_93316_()) {
@@ -349,11 +_,15 @@ @@ -340,11 +_,15 @@
Screen.m_96579_(() -> { Screen.m_96579_(() -> {
if (p_90897_ != 1 && (p_90897_ != 2 || !this.f_90868_)) { if (p_90897_ != 1 && (p_90897_ != 2 || !this.f_90868_)) {
if (p_90897_ == 0) { if (p_90897_ == 0) {
@@ -38,7 +38,7 @@
} }
}, "keyPressed event handler", screen.getClass().getCanonicalName()); }, "keyPressed event handler", screen.getClass().getCanonicalName());
@@ -406,22 +_,26 @@ @@ -397,22 +_,26 @@
} }
} }
} }
@@ -1,31 +1,32 @@
--- a/net/minecraft/client/Minecraft.java --- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java
@@ -252,7 +_,7 @@ @@ -236,7 +_,7 @@
import org.slf4j.Logger; import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
-public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler { -public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler {
+public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft { +public class Minecraft extends ReentrantBlockableEventLoop<Runnable> implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft {
private static Minecraft f_90981_; static Minecraft f_90981_;
private static final Logger f_90982_ = LogUtils.getLogger(); private static final Logger f_90982_ = LogUtils.getLogger();
public static final boolean f_91002_ = Util.m_137581_() == Util.OS.OSX; public static final boolean f_91002_ = Util.m_137581_() == Util.OS.OSX;
@@ -394,14 +_,13 @@ @@ -385,7 +_,7 @@
this.f_91029_ = p_91084_.f_101908_.f_101928_; this.f_91029_ = p_91084_.f_101908_.f_101928_;
this.f_90986_ = p_91084_.f_101905_.f_101944_; this.f_90986_ = p_91084_.f_101905_.f_101944_;
this.f_91037_ = new ClientPackSource(new File(this.f_91069_, "server-resource-packs"), p_91084_.f_101907_.m_101925_()); this.f_91037_ = new ClientPackSource(new File(this.f_91069_, "server-resource-packs"), p_91084_.f_101907_.m_101925_());
- this.f_91038_ = new PackRepository(Minecraft::m_167933_, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); - this.f_91038_ = new PackRepository(Minecraft::m_167933_, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_));
+ this.f_91038_ = new PackRepository(Minecraft::createClientPackAdapter, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_)); + this.f_91038_ = new PackRepository(Minecraft::createClientPackAdapter, this.f_91037_, new FolderRepositorySource(this.f_90985_, PackSource.f_10527_));
this.f_91030_ = p_91084_.f_101905_.f_101945_; this.f_91030_ = p_91084_.f_101905_.f_101945_;
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_); this.f_231338_ = new YggdrasilAuthenticationService(this.f_91030_);
this.f_91048_ = yggdrasilauthenticationservice.createMinecraftSessionService(); this.f_91048_ = this.f_231338_.createMinecraftSessionService();
this.f_193584_ = this.m_193585_(yggdrasilauthenticationservice, p_91084_); @@ -393,7 +_,6 @@
this.f_231339_ = SignatureValidator.m_216358_(this.f_231338_.getServicesKey());
this.f_90998_ = p_91084_.f_101905_.f_101942_; this.f_90998_ = p_91084_.f_101905_.f_101942_;
f_90982_.info("Setting user: {}", (Object)this.f_90998_.m_92546_()); f_90982_.info("Setting user: {}", (Object)this.f_90998_.m_92546_());
- f_90982_.debug("(Session ID is {})", (Object)this.f_90998_.m_92544_()); - f_90982_.debug("(Session ID is {})", (Object)this.f_90998_.m_92544_());
this.f_91033_ = p_91084_.f_101908_.f_101926_; this.f_91033_ = p_91084_.f_101908_.f_101926_;
this.f_91034_ = !p_91084_.f_101908_.f_101929_; this.f_91034_ = !p_91084_.f_101908_.f_101929_;
this.f_91035_ = !p_91084_.f_101908_.f_101930_; this.f_91035_ = !p_91084_.f_101908_.f_101930_;
@@ -433,6 +_,7 @@ @@ -426,6 +_,7 @@
} }
Util.f_137440_ = RenderSystem.m_69576_(); Util.f_137440_ = RenderSystem.m_69576_();
@@ -33,15 +34,15 @@
this.f_90989_ = new VirtualScreen(this); this.f_90989_ = new VirtualScreen(this);
this.f_90990_ = this.f_90989_.m_110872_(displaydata, this.f_91066_.f_92123_, this.m_91270_()); this.f_90990_ = this.f_90989_.m_110872_(displaydata, this.f_91066_.f_92123_, this.m_91270_());
this.m_7440_(true); this.m_7440_(true);
@@ -448,7 +_,6 @@ @@ -445,7 +_,6 @@
this.f_90990_.m_85380_(this.f_91066_.f_92113_); this.f_90990_.m_85380_(this.f_91066_.m_232035_().m_231551_());
this.f_91067_ = new MouseHandler(this); this.f_91067_ = new MouseHandler(this);
- this.f_91067_.m_91524_(this.f_90990_.m_85439_()); - this.f_91067_.m_91524_(this.f_90990_.m_85439_());
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 @@ @@ -453,6 +_,7 @@
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);
@@ -49,7 +50,7 @@
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,6 +_,7 @@
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_);
@@ -57,17 +58,17 @@
this.f_91036_.m_7217_(this.f_91061_); this.f_91036_.m_7217_(this.f_91061_);
this.f_91053_ = new PaintingTextureManager(this.f_90987_); this.f_91053_ = new PaintingTextureManager(this.f_90987_);
this.f_91036_.m_7217_(this.f_91053_); this.f_91036_.m_7217_(this.f_91053_);
@@ -512,7 +_,8 @@ @@ -508,7 +_,8 @@
this.f_91047_ = new GpuWarnlistManager(); this.f_91047_ = new GpuWarnlistManager();
this.f_91036_.m_7217_(this.f_91047_); this.f_91036_.m_7217_(this.f_91047_);
this.f_91036_.m_7217_(this.f_205120_); this.f_91036_.m_7217_(this.f_205120_);
- this.f_91065_ = new Gui(this); - this.f_91065_ = new Gui(this, this.f_90995_);
+ this.f_91065_ = new net.minecraftforge.client.gui.ForgeIngameGui(this); + this.f_91065_ = new net.minecraftforge.client.gui.ForgeIngameGui(this);
+ this.f_91067_.m_91524_(this.f_90990_.m_85439_()); //Forge: Moved below ingameGUI setting to prevent NPEs in handeler. + this.f_91067_.m_91524_(this.f_90990_.m_85439_()); //Forge: Moved below ingameGUI setting to prevent NPEs in handeler.
this.f_91064_ = new DebugRenderer(this); this.f_91064_ = new DebugRenderer(this);
RenderSystem.m_69900_(this::m_91113_); RenderSystem.m_69900_(this::m_91113_);
if (this.f_91042_.f_83915_ == this.f_90990_.m_85441_() && this.f_91042_.f_83916_ == this.f_90990_.m_85442_()) { if (this.f_91042_.f_83915_ == this.f_90990_.m_85441_() && this.f_91042_.f_83916_ == this.f_90990_.m_85442_()) {
@@ -530,6 +_,11 @@ @@ -526,6 +_,11 @@
TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false); TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false);
} }
@@ -76,10 +77,10 @@
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterLayerDefinitions()); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterLayerDefinitions());
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers()); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers());
+ +
this.f_90990_.m_85409_(this.f_91066_.f_92041_); this.f_90990_.m_85409_(this.f_91066_.m_231817_().m_231551_());
this.f_90990_.m_85424_(this.f_91066_.f_92034_); this.f_90990_.m_85424_(this.f_91066_.m_232123_().m_231551_());
this.f_90990_.m_85426_(); this.f_90990_.m_85426_();
@@ -545,13 +_,16 @@ @@ -543,13 +_,16 @@
} }
this.f_167847_.m_168556_(); this.f_167847_.m_168556_();
@@ -101,7 +102,7 @@
} }
@@ -594,6 +_,8 @@ @@ -592,6 +_,8 @@
private UserApiService m_193585_(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { private UserApiService m_193585_(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) {
try { try {
@@ -110,7 +111,7 @@
return p_193586_.createUserApiService(p_193587_.f_101905_.f_101942_.m_92547_()); return p_193586_.createUserApiService(p_193587_.f_101905_.f_101942_.m_92547_());
} catch (AuthenticationException authenticationexception) { } catch (AuthenticationException authenticationexception) {
f_90982_.error("Failed to verify authentication", (Throwable)authenticationexception); f_90982_.error("Failed to verify authentication", (Throwable)authenticationexception);
@@ -606,7 +_,7 @@ @@ -604,7 +_,7 @@
} }
private void m_91239_(Throwable p_91240_) { private void m_91239_(Throwable p_91240_) {
@@ -119,7 +120,7 @@
this.m_91241_(p_91240_, (Component)null); this.m_91241_(p_91240_, (Component)null);
} else { } else {
Util.m_137559_(p_91240_); Util.m_137559_(p_91240_);
@@ -763,13 +_,13 @@ @@ -762,13 +_,13 @@
Bootstrap.m_135875_(p_91333_.m_127526_()); Bootstrap.m_135875_(p_91333_.m_127526_());
if (p_91333_.m_127527_() != null) { if (p_91333_.m_127527_() != null) {
Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.m_127527_()); Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.m_127527_());
@@ -136,7 +137,7 @@
} }
} }
@@ -879,10 +_,6 @@ @@ -892,10 +_,6 @@
f_90982_.error("setScreen called from non-game thread"); f_90982_.error("setScreen called from non-game thread");
} }
@@ -147,7 +148,7 @@
if (p_91153_ == null && this.f_91073_ == null) { if (p_91153_ == null && this.f_91073_ == null) {
p_91153_ = new TitleScreen(); p_91153_ = new TitleScreen();
} else if (p_91153_ == null && this.f_91074_.m_21224_()) { } else if (p_91153_ == null && this.f_91074_.m_21224_()) {
@@ -893,6 +_,15 @@ @@ -906,6 +_,15 @@
} }
} }
@@ -163,7 +164,7 @@
this.f_91080_ = p_91153_; this.f_91080_ = p_91153_;
BufferUploader.m_166835_(); BufferUploader.m_166835_();
if (p_91153_ != null) { if (p_91153_ != null) {
@@ -1022,11 +_,13 @@ @@ -1049,11 +_,13 @@
RenderSystem.m_69481_(); RenderSystem.m_69481_();
this.f_91026_.m_7238_(); this.f_91026_.m_7238_();
if (!this.f_91079_) { if (!this.f_91079_) {
@@ -177,7 +178,7 @@
} }
if (this.f_91056_ != null) { if (this.f_91056_ != null) {
@@ -1132,10 +_,12 @@ @@ -1180,10 +_,12 @@
this.f_90990_.m_85378_((double)i); this.f_90990_.m_85378_((double)i);
if (this.f_91080_ != null) { if (this.f_91080_ != null) {
this.f_91080_.m_6574_(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_()); this.f_91080_.m_6574_(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_());
@@ -190,7 +191,15 @@
this.f_91063_.m_109097_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_()); this.f_91063_.m_109097_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_());
this.f_91067_.m_91599_(); this.f_91067_.m_91599_();
} }
@@ -1432,11 +_,21 @@ @@ -1461,6 +_,7 @@
}
public void m_91395_() {
+ if (this.m_91396_()) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.GameShuttingDownEvent());
this.f_91019_ = false;
}
@@ -1490,10 +_,18 @@
if (p_91387_ && this.f_91077_ != null && this.f_91077_.m_6662_() == HitResult.Type.BLOCK) { if (p_91387_ && this.f_91077_ != null && this.f_91077_.m_6662_() == HitResult.Type.BLOCK) {
BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_;
BlockPos blockpos = blockhitresult.m_82425_(); BlockPos blockpos = blockhitresult.m_82425_();
@@ -205,20 +214,18 @@
+ return; + return;
+ } + }
Direction direction = blockhitresult.m_82434_(); Direction direction = blockhitresult.m_82434_();
if (this.f_91072_.m_105283_(blockpos, direction)) { - if (this.f_91072_.m_105283_(blockpos, direction)) {
- this.f_91061_.m_107367_(blockpos, direction); - this.f_91061_.m_107367_(blockpos, direction);
+ if (inputEvent.shouldSwingHand()) { + if (this.f_91072_.m_105283_(blockpos, direction) && inputEvent.shouldSwingHand()) {
+ this.f_91061_.addBlockHitEffects(blockpos, blockhitresult); + this.f_91061_.addBlockHitEffects(blockpos, blockhitresult);
this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); this.f_91074_.m_6674_(InteractionHand.MAIN_HAND);
+ }
} }
} }
@@ -1518,14 +_,20 @@
@@ -1460,14 +_,20 @@
return false; return false;
} else { } else {
boolean flag = false; boolean flag = false;
- switch(this.f_91077_.m_6662_()) { - 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_(); + 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(this.f_91077_ instanceof EntityHitResult entityHit) { // Forge: Perform attack range checks here, instead of in GameRenderer#pick, so extended-reach interactions work.
@@ -226,21 +233,21 @@
+ } + }
+ if (!inputEvent.isCanceled()) + if (!inputEvent.isCanceled())
+ switch(hitType) { + 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_());
break; 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_();
- if (!this.f_91073_.m_8055_(blockpos).m_60795_()) { - if (!this.f_91073_.m_8055_(blockpos).m_60795_()) {
+ if (!this.f_91073_.m_46859_(blockpos)) { + if (!this.f_91073_.m_46859_(blockpos)) {
this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_()); this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_());
if (this.f_91073_.m_8055_(blockpos).m_60795_()) { if (this.f_91073_.m_8055_(blockpos).m_60795_()) {
flag = true; flag = true;
@@ -1480,8 +_,10 @@ @@ -1538,8 +_,10 @@
} }
this.f_91074_.m_36334_(); this.f_91074_.m_36334_();
+ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.f_91074_); + net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.f_91074_);
} }
@@ -248,7 +255,7 @@
this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); this.f_91074_.m_6674_(InteractionHand.MAIN_HAND);
return flag; return flag;
} }
@@ -1496,6 +_,11 @@ @@ -1554,6 +_,11 @@
} }
for(InteractionHand interactionhand : InteractionHand.values()) { for(InteractionHand interactionhand : InteractionHand.values()) {
@@ -259,32 +266,32 @@
+ } + }
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 @@ @@ -1564,6 +_,7 @@
return; return;
}
+ if(!this.f_91074_.canInteractWith(entityhitresult.m_82443_(), 0)) return; //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 @@
if (interactionresult.m_19077_()) {
if (interactionresult.m_19080_()) {
+ if (inputEvent.shouldSwingHand())
this.f_91074_.m_6674_(interactionhand);
} }
@@ -1525,6 +_,7 @@ + if(!this.f_91074_.canInteractWith(entityhitresult.m_82443_(), 0)) return; //Forge: Entity may be traced via attack range, but the player may not have sufficient reach. No padding in client code.
InteractionResult interactionresult1 = this.f_91072_.m_105262_(this.f_91074_, this.f_91073_, interactionhand, blockhitresult); InteractionResult interactionresult = this.f_91072_.m_105230_(this.f_91074_, entity, entityhitresult, interactionhand);
if (interactionresult1.m_19077_()) { if (!interactionresult.m_19077_()) {
if (interactionresult1.m_19080_()) { interactionresult = this.f_91072_.m_105226_(this.f_91074_, entity, interactionhand);
@@ -1571,6 +_,7 @@
if (interactionresult.m_19077_()) {
if (interactionresult.m_19080_()) {
+ if (inputEvent.shouldSwingHand()) + if (inputEvent.shouldSwingHand())
this.f_91074_.m_6674_(interactionhand); this.f_91074_.m_6674_(interactionhand);
if (!itemstack.m_41619_() && (itemstack.m_41613_() != i || this.f_91072_.m_105290_())) { }
this.f_91063_.f_109055_.m_109320_(interactionhand);
@@ -1540,6 +_,9 @@ @@ -1583,6 +_,7 @@
InteractionResult interactionresult1 = this.f_91072_.m_233732_(this.f_91074_, interactionhand, blockhitresult);
if (interactionresult1.m_19077_()) {
if (interactionresult1.m_19080_()) {
+ if (inputEvent.shouldSwingHand())
this.f_91074_.m_6674_(interactionhand);
if (!itemstack.m_41619_() && (itemstack.m_41613_() != i || this.f_91072_.m_105290_())) {
this.f_91063_.f_109055_.m_109320_(interactionhand);
@@ -1598,6 +_,9 @@
} }
} }
@@ -292,9 +299,9 @@
+ net.minecraftforge.common.ForgeHooks.onEmptyClick(this.f_91074_, interactionhand); + net.minecraftforge.common.ForgeHooks.onEmptyClick(this.f_91074_, interactionhand);
+ +
if (!itemstack.m_41619_()) { if (!itemstack.m_41619_()) {
InteractionResult interactionresult2 = this.f_91072_.m_105235_(this.f_91074_, this.f_91073_, interactionhand); InteractionResult interactionresult2 = this.f_91072_.m_233721_(this.f_91074_, interactionhand);
if (interactionresult2.m_19077_()) { if (interactionresult2.m_19077_()) {
@@ -1566,6 +_,8 @@ @@ -1624,6 +_,8 @@
--this.f_91011_; --this.f_91011_;
} }
@@ -303,7 +310,7 @@
this.f_91026_.m_6180_("gui"); this.f_91026_.m_6180_("gui");
this.f_91065_.m_193832_(this.f_91012_); this.f_91065_.m_193832_(this.f_91012_);
this.f_91026_.m_7238_(); this.f_91026_.m_7238_();
@@ -1694,6 +_,8 @@ @@ -1752,6 +_,8 @@
this.f_91026_.m_6182_("keyboard"); this.f_91026_.m_6182_("keyboard");
this.f_91068_.m_90931_(); this.f_91068_.m_90931_();
this.f_91026_.m_7238_(); this.f_91026_.m_7238_();
@@ -312,105 +319,26 @@
} }
private boolean m_91278_() { private boolean m_91278_() {
@@ -1814,11 +_,11 @@ @@ -1894,8 +_,8 @@
} SkullBlockEntity.m_222885_(services, this);
GameProfileCache.m_11004_(false);
public void m_91200_(String p_91201_) { this.f_91007_ = MinecraftServer.m_129872_((p_231361_) -> {
- this.m_205205_(p_91201_, WorldStem.DataPackConfigSupplier::m_206928_, WorldStem.WorldDataSupplier::m_206954_, false, Minecraft.ExperimentalDialogType.BACKUP); - return new IntegratedServer(p_231361_, this, p_231382_, p_231383_, p_231384_, services, (p_231447_) -> {
+ this.doLoadLevel(p_91201_, WorldStem.DataPackConfigSupplier::m_206928_, WorldStem.WorldDataSupplier::m_206954_, false, Minecraft.ExperimentalDialogType.BACKUP, false); - StoringChunkProgressListener storingchunkprogresslistener = new StoringChunkProgressListener(p_231447_ + 0);
} + return new IntegratedServer(p_231361_, this, p_231382_, p_231383_, p_231384_, services, (p_210795_) -> { //TODO-PATCHING: Handle the registry freeze delay again.
+ StoringChunkProgressListener storingchunkprogresslistener = new StoringChunkProgressListener(p_210795_ + 0);
public void m_205185_(String p_205186_, LevelSettings p_205187_, RegistryAccess p_205188_, WorldGenSettings p_205189_) { this.f_90999_.set(storingchunkprogresslistener);
- this.m_205205_(p_205186_, (p_210684_) -> { return ProcessorChunkProgressListener.m_143583_(storingchunkprogresslistener, this.f_91023_::add);
+ this.doLoadLevel(p_205186_, (p_210684_) -> { });
return p_205187_::m_46934_; @@ -1945,6 +_,7 @@
}, (p_210718_) -> {
return (p_210712_, p_210713_) -> {
@@ -1831,10 +_,10 @@
WorldGenSettings worldgensettings = dataresult.getOrThrow(false, Util.m_137489_("Error reading worldgen settings after loading data packs: ", f_90982_::error));
return Pair.of(new PrimaryLevelData(p_205187_, worldgensettings, dataresult.lifecycle()), registryaccess$writable.m_203557_());
};
- }, false, Minecraft.ExperimentalDialogType.CREATE);
+ }, false, Minecraft.ExperimentalDialogType.CREATE, true);
}
- private void m_205205_(String p_205206_, Function<LevelStorageSource.LevelStorageAccess, WorldStem.DataPackConfigSupplier> p_205207_, Function<LevelStorageSource.LevelStorageAccess, WorldStem.WorldDataSupplier> p_205208_, boolean p_205209_, Minecraft.ExperimentalDialogType p_205210_) {
+ private void doLoadLevel(String p_205206_, Function<LevelStorageSource.LevelStorageAccess, WorldStem.DataPackConfigSupplier> p_205207_, Function<LevelStorageSource.LevelStorageAccess, WorldStem.WorldDataSupplier> p_205208_, boolean p_205209_, Minecraft.ExperimentalDialogType p_205210_, boolean creating) {
LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess;
try {
levelstoragesource$levelstorageaccess = this.f_91031_.m_78260_(p_205206_);
@@ -1849,11 +_,12 @@
WorldStem worldstem;
try {
+ if (!creating) levelstoragesource$levelstorageaccess.readAdditionalLevelSaveData();
worldstem = this.m_205125_(packrepository, p_205209_, p_205207_.apply(levelstoragesource$levelstorageaccess), p_205208_.apply(levelstoragesource$levelstorageaccess));
} catch (Exception exception) {
f_90982_.warn("Failed to load datapacks, can't proceed with server load", (Throwable)exception);
this.m_91152_(new DatapackLoadFailureScreen(() -> {
- this.m_205205_(p_205206_, p_205207_, p_205208_, true, p_205210_);
+ this.doLoadLevel(p_205206_, p_205207_, p_205208_, true, p_205210_, creating);
}));
try {
@@ -1869,13 +_,15 @@
WorldData worlddata = worldstem.f_206895_();
boolean flag = worlddata.m_5961_().m_64670_();
boolean flag1 = worlddata.m_5754_() != Lifecycle.stable();
- if (p_205210_ == Minecraft.ExperimentalDialogType.NONE || !flag && !flag1) {
+ //Skip confirmation if it has been done already for this world
+ boolean skipConfirmation = worlddata instanceof PrimaryLevelData pld && pld.hasConfirmedExperimentalWarning();
+ if (skipConfirmation || p_205210_ == Minecraft.ExperimentalDialogType.NONE || !flag && !flag1) {
this.m_91399_();
this.f_90999_.set((StoringChunkProgressListener)null);
try {
RegistryAccess.Frozen registryaccess$frozen = worldstem.f_206894_();
- levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata);
+ levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata); //TODO-PATCHING: Figure out what registry access needs to be passed in here.
worldstem.m_206901_();
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_);
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
@@ -1885,7 +_,7 @@
SkullBlockEntity.m_196700_(gameprofilecache, minecraftsessionservice, this);
GameProfileCache.m_11004_(false);
this.f_91007_ = MinecraftServer.m_129872_((p_210695_) -> {
- return new IntegratedServer(p_210695_, this, levelstoragesource$levelstorageaccess, packrepository, worldstem, minecraftsessionservice, gameprofilerepository, gameprofilecache, (p_210795_) -> {
+ return new IntegratedServer(p_210695_, this, levelstoragesource$levelstorageaccess, packrepository, worldstem, minecraftsessionservice, gameprofilerepository, gameprofilecache, (p_210795_) -> { //TODO-PATCHING: Handle the registry freeze delay again.
StoringChunkProgressListener storingchunkprogresslistener = new StoringChunkProgressListener(p_210795_ + 0);
this.f_90999_.set(storingchunkprogresslistener);
return ProcessorChunkProgressListener.m_143583_(storingchunkprogresslistener, this.f_91023_::add);
@@ -1929,12 +_,19 @@
connection.m_129505_(new ClientHandshakePacketListenerImpl(connection, this, (Screen)null, (p_210793_) -> {
}));
connection.m_129512_(new ClientIntentionPacket(socketaddress.toString(), 0, ConnectionProtocol.LOGIN));
- connection.m_129512_(new ServerboundHelloPacket(this.m_91094_().m_92548_()));
+ com.mojang.authlib.GameProfile gameProfile = this.m_91094_().m_92548_();
+ if (!this.m_91094_().hasCachedProperties()) {
+ gameProfile = f_91048_.fillProfileProperties(gameProfile, true); //Forge: Fill profile properties upon game load. Fixes MC-52974.
+ this.m_91094_().setProperties(gameProfile.getProperties());
+ }
+ connection.m_129512_(new ServerboundHelloPacket(gameProfile));
this.f_91009_ = connection;
} else {
+ if (flag) //FORGE: For legacy world options, let vanilla handle it.
this.m_91143_(p_205210_, p_205206_, flag, () -> {
- this.m_205205_(p_205206_, p_205207_, p_205208_, p_205209_, Minecraft.ExperimentalDialogType.NONE);
+ this.doLoadLevel(p_205206_, p_205207_, p_205208_, p_205209_, Minecraft.ExperimentalDialogType.NONE, creating);
});
+ else net.minecraftforge.client.ForgeHooksClient.createWorldConfirmationScreen(f_91031_, p_205206_, creating, p_205208_, wds -> () -> this.doLoadLevel(p_205206_, p_205207_, wds, p_205209_, ExperimentalDialogType.NONE, creating));
worldstem.close();
try {
@@ -2026,6 +_,7 @@
} }
public void m_91156_(ClientLevel p_91157_) { public void m_91156_(ClientLevel p_91157_) {
+ if (f_91073_ != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(f_91073_)); + if (f_91073_ != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(f_91073_));
ProgressScreen progressscreen = new ProgressScreen(true); ProgressScreen progressscreen = new ProgressScreen(true);
progressscreen.m_6309_(new TranslatableComponent("connect.joining")); progressscreen.m_6309_(Component.m_237115_("connect.joining"));
this.m_91362_(progressscreen); this.m_91362_(progressscreen);
@@ -2058,10 +_,12 @@ @@ -1978,10 +_,12 @@
IntegratedServer integratedserver = this.f_91007_; IntegratedServer integratedserver = this.f_91007_;
this.f_91007_ = null; this.f_91007_ = null;
this.f_91063_.m_109150_(); this.f_91063_.m_109150_();
@@ -423,7 +351,7 @@
if (integratedserver != null) { if (integratedserver != null) {
this.f_91026_.m_6180_("waitForServer"); this.f_91026_.m_6180_("waitForServer");
@@ -2076,6 +_,7 @@ @@ -1996,6 +_,7 @@
this.f_91065_.m_93089_(); this.f_91065_.m_93089_();
this.f_91008_ = null; this.f_91008_ = null;
this.f_91010_ = false; this.f_91010_ = false;
@@ -431,7 +359,7 @@
this.f_91004_.m_90740_(); this.f_91004_.m_90740_();
} }
@@ -2162,66 +_,9 @@ @@ -2082,66 +_,9 @@
private void m_91280_() { private void m_91280_() {
if (this.f_91077_ != null && this.f_91077_.m_6662_() != HitResult.Type.MISS) { if (this.f_91077_ != null && this.f_91077_.m_6662_() != HitResult.Type.MISS) {
@@ -501,7 +429,7 @@
} }
} }
@@ -2713,8 +_,8 @@ @@ -2632,8 +_,8 @@
return this.f_90993_; return this.f_90993_;
} }
@@ -512,7 +440,7 @@
Supplier<PackResources> supplier = p_167937_; Supplier<PackResources> supplier = p_167937_;
if (i <= 3) { if (i <= 3) {
supplier = m_91330_(p_167937_); supplier = m_91330_(p_167937_);
@@ -2724,7 +_,7 @@ @@ -2643,7 +_,7 @@
supplier = m_91352_(supplier); supplier = m_91352_(supplier);
} }
@@ -521,7 +449,7 @@
} }
private static Supplier<PackResources> m_91330_(Supplier<PackResources> p_91331_) { private static Supplier<PackResources> m_91330_(Supplier<PackResources> p_91331_) {
@@ -2741,6 +_,14 @@ @@ -2660,6 +_,14 @@
public void m_91312_(int p_91313_) { public void m_91312_(int p_91313_) {
this.f_91051_.m_119410_(p_91313_); this.f_91051_.m_119410_(p_91313_);
@@ -41,13 +41,13 @@
private void m_91526_(long p_91527_, double p_91528_, double p_91529_) { private void m_91526_(long p_91527_, double p_91528_, double p_91529_) {
if (p_91527_ == Minecraft.m_91087_().m_91268_().m_85439_()) { if (p_91527_ == Minecraft.m_91087_().m_91268_().m_85439_()) {
- double d0 = (this.f_91503_.f_91066_.f_92045_ ? Math.signum(p_91529_) : p_91529_) * this.f_91503_.f_91066_.f_92033_; - double d0 = (this.f_91503_.f_91066_.m_231821_().m_231551_() ? Math.signum(p_91529_) : p_91529_) * this.f_91503_.f_91066_.m_232122_().m_231551_();
+ // FORGE: Allows for Horizontal Scroll to be recognized as Vertical Scroll - Fixes MC-121772 + // FORGE: Allows for Horizontal Scroll to be recognized as Vertical Scroll - Fixes MC-121772
+ double offset = p_91529_; + double offset = p_91529_;
+ if (Minecraft.f_91002_ && p_91529_ == 0) { + if (Minecraft.f_91002_ && p_91529_ == 0) {
+ offset = p_91528_; + offset = p_91528_;
+ } + }
+ double d0 = (this.f_91503_.f_91066_.f_92045_ ? Math.signum(offset) : offset) * this.f_91503_.f_91066_.f_92033_; + double d0 = (this.f_91503_.f_91066_.m_231821_().m_231551_() ? Math.signum(offset) : offset) * this.f_91503_.f_91066_.m_232122_().m_231551_();
if (this.f_91503_.m_91265_() == null) { if (this.f_91503_.m_91265_() == null) {
if (this.f_91503_.f_91080_ != null) { if (this.f_91503_.f_91080_ != null) {
double d1 = this.f_91507_ * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_(); double d1 = this.f_91507_ * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_();
@@ -1,15 +1,15 @@
--- a/net/minecraft/client/Options.java --- a/net/minecraft/client/Options.java
+++ b/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java
@@ -188,6 +_,7 @@ @@ -772,6 +_,7 @@
public boolean f_92076_; }
public Options(Minecraft p_92138_, File p_92139_) { public Options(Minecraft p_92138_, File p_92139_) {
+ setForgeKeybindProperties(); + setForgeKeybindProperties();
this.f_92060_ = p_92138_; this.f_92060_ = p_92138_;
this.f_92110_ = new File(p_92139_, "options.txt"); this.f_92110_ = new File(p_92139_, "options.txt");
if (p_92138_.m_91103_() && Runtime.getRuntime().maxMemory() >= 1000000000L) { boolean flag = p_92138_.m_91103_();
@@ -302,10 +_,14 @@ @@ -887,10 +_,14 @@
this.f_193762_ = p_168428_.m_142682_("allowServerListing", this.f_193762_); p_168428_.m_213982_("onlyShowSecureChat", this.f_231798_);
for(KeyMapping keymapping : this.f_92059_) { for(KeyMapping keymapping : this.f_92059_) {
- String s = keymapping.m_90865_(); - String s = keymapping.m_90865_();
@@ -25,7 +25,7 @@
} }
} }
@@ -493,6 +_,7 @@ @@ -1058,6 +_,7 @@
} }
public void m_92169_() { public void m_92169_() {
@@ -33,7 +33,7 @@
try { try {
final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.f_92110_), StandardCharsets.UTF_8)); final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.f_92110_), StandardCharsets.UTF_8));
@@ -641,6 +_,23 @@ @@ -1205,6 +_,23 @@
} }
p_92146_.m_10509_(set); p_92146_.m_10509_(set);
@@ -19,12 +19,12 @@
private RecipeBookCategories(ItemStack... p_92267_) { private RecipeBookCategories(ItemStack... p_92267_) {
@@ -54,11 +_,17 @@ @@ -54,11 +_,17 @@
case SMOKER: case SMOKER:
return f_92256_; return f_92256_;
default: default:
+ if (net.minecraftforge.client.RecipeBookRegistry.TYPE_TO_CATEGORIES_VIEW.containsKey(p_92270_)) + if (net.minecraftforge.client.RecipeBookRegistry.TYPE_TO_CATEGORIES_VIEW.containsKey(p_92270_))
+ return net.minecraftforge.client.RecipeBookRegistry.TYPE_TO_CATEGORIES_VIEW.get(p_92270_); + return net.minecraftforge.client.RecipeBookRegistry.TYPE_TO_CATEGORIES_VIEW.get(p_92270_);
return ImmutableList.of(); return ImmutableList.of();
} }
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Screenshot.java --- a/net/minecraft/client/Screenshot.java
+++ b/net/minecraft/client/Screenshot.java +++ b/net/minecraft/client/Screenshot.java
@@ -61,13 +_,23 @@ @@ -59,13 +_,23 @@
file2 = new File(file1, p_92307_); file2 = new File(file1, p_92307_);
} }
@@ -15,15 +15,15 @@
try { try {
- nativeimage.m_85056_(file2); - nativeimage.m_85056_(file2);
+ nativeimage.m_85056_(target); + nativeimage.m_85056_(target);
Component component = (new TextComponent(file2.getName())).m_130940_(ChatFormatting.UNDERLINE).m_130938_((p_168608_) -> { Component component = Component.m_237113_(file2.getName()).m_130940_(ChatFormatting.UNDERLINE).m_130938_((p_168608_) -> {
- return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath())); - return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath()));
+ return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath())); + return p_168608_.m_131142_(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath()));
}); });
- p_92311_.accept(new TranslatableComponent("screenshot.success", component)); - p_92311_.accept(Component.m_237110_("screenshot.success", component));
+ if (event.getResultMessage() != null) + if (event.getResultMessage() != null)
+ p_92311_.accept(event.getResultMessage()); + p_92311_.accept(event.getResultMessage());
+ else + else
+ p_92311_.accept(new TranslatableComponent("screenshot.success", component)); + p_92311_.accept(Component.m_237110_("screenshot.success", component));
} catch (Exception exception) { } catch (Exception exception) {
f_92276_.warn("Couldn't save screenshot", (Throwable)exception); f_92276_.warn("Couldn't save screenshot", (Throwable)exception);
p_92311_.accept(new TranslatableComponent("screenshot.failure", exception.getMessage())); p_92311_.accept(Component.m_237110_("screenshot.failure", exception.getMessage()));
@@ -5,8 +5,8 @@
public class BlockColors { public class BlockColors {
private static final int f_168640_ = -1; private static final int f_168640_ = -1;
- private final IdMapper<BlockColor> f_92571_ = new IdMapper<>(32); - private final IdMapper<BlockColor> f_92571_ = new IdMapper<>(32);
+ // FORGE: Use RegistryDelegates as non-Vanilla block ids are not constant + // FORGE: Use registry delegate as non-Vanilla block ids are not constant
+ private final java.util.Map<net.minecraftforge.registries.IRegistryDelegate<Block>, BlockColor> f_92571_ = new java.util.HashMap<>(); + private final java.util.Map<net.minecraft.core.Holder.Reference<Block>, BlockColor> f_92571_ = new java.util.HashMap<>();
private final Map<Block, Set<Property<?>>> f_92572_ = Maps.newHashMap(); private final Map<Block, Set<Property<?>>> f_92572_ = Maps.newHashMap();
public static BlockColors m_92574_() { public static BlockColors m_92574_() {
@@ -20,7 +20,7 @@
public int m_92582_(BlockState p_92583_, Level p_92584_, BlockPos p_92585_) { public int m_92582_(BlockState p_92583_, Level p_92584_, BlockPos p_92585_) {
- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92583_.m_60734_())); - BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92583_.m_60734_()));
+ BlockColor blockcolor = this.f_92571_.get(p_92583_.m_60734_().delegate); + BlockColor blockcolor = this.f_92571_.get(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(p_92583_.m_60734_()));
if (blockcolor != null) { if (blockcolor != null) {
return blockcolor.m_92566_(p_92583_, (BlockAndTintGetter)null, (BlockPos)null, 0); return blockcolor.m_92566_(p_92583_, (BlockAndTintGetter)null, (BlockPos)null, 0);
} else { } else {
@@ -29,14 +29,14 @@
public int m_92577_(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) { public int m_92577_(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) {
- BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92578_.m_60734_())); - BlockColor blockcolor = this.f_92571_.m_7942_(Registry.f_122824_.m_7447_(p_92578_.m_60734_()));
+ BlockColor blockcolor = this.f_92571_.get(p_92578_.m_60734_().delegate); + BlockColor blockcolor = this.f_92571_.get(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(p_92578_.m_60734_()));
return blockcolor == null ? -1 : blockcolor.m_92566_(p_92578_, p_92579_, p_92580_, p_92581_); return blockcolor == null ? -1 : blockcolor.m_92566_(p_92578_, p_92579_, p_92580_, p_92581_);
} }
public void m_92589_(BlockColor p_92590_, Block... p_92591_) { public void m_92589_(BlockColor p_92590_, Block... p_92591_) {
for(Block block : p_92591_) { for(Block block : p_92591_) {
- this.f_92571_.m_122664_(p_92590_, Registry.f_122824_.m_7447_(block)); - this.f_92571_.m_122664_(p_92590_, Registry.f_122824_.m_7447_(block));
+ this.f_92571_.put(block.delegate, p_92590_); + this.f_92571_.put(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(block), p_92590_);
} }
} }
@@ -1,18 +1,18 @@
--- a/net/minecraft/client/color/item/ItemColors.java --- a/net/minecraft/client/color/item/ItemColors.java
+++ b/net/minecraft/client/color/item/ItemColors.java +++ b/net/minecraft/client/color/item/ItemColors.java
@@ -24,7 +_,8 @@ @@ -25,7 +_,8 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class ItemColors { public class ItemColors {
private static final int f_168642_ = -1; private static final int f_168642_ = -1;
- private final IdMapper<ItemColor> f_92674_ = new IdMapper<>(32); - private final IdMapper<ItemColor> f_92674_ = new IdMapper<>(32);
+ // FORGE: Use RegistryDelegates as non-Vanilla item ids are not constant + // FORGE: Use registry delegate as non-Vanilla item ids are not constant
+ private final java.util.Map<net.minecraftforge.registries.IRegistryDelegate<Item>, ItemColor> f_92674_ = new java.util.HashMap<>(); + private final java.util.Map<net.minecraft.core.Holder.Reference<Item>, ItemColor> f_92674_ = new java.util.HashMap<>();
public static ItemColors m_92683_(BlockColors p_92684_) { public static ItemColors m_92683_(BlockColors p_92684_) {
ItemColors itemcolors = new ItemColors(); ItemColors itemcolors = new ItemColors();
@@ -84,17 +_,18 @@ @@ -88,17 +_,18 @@
itemcolors.m_92689_((p_92693_, p_92694_) -> { itemcolors.m_92689_((p_232352_, p_232353_) -> {
return p_92694_ == 0 ? -1 : MapItem.m_42918_(p_92693_); return p_232353_ == 0 ? -1 : MapItem.m_42918_(p_232352_);
}, Items.f_42573_); }, Items.f_42573_);
+ net.minecraftforge.client.ForgeHooksClient.onItemColorsInit(itemcolors, p_92684_); + net.minecraftforge.client.ForgeHooksClient.onItemColorsInit(itemcolors, p_92684_);
return itemcolors; return itemcolors;
@@ -20,14 +20,14 @@
public int m_92676_(ItemStack p_92677_, int p_92678_) { public int m_92676_(ItemStack p_92677_, int p_92678_) {
- ItemColor itemcolor = this.f_92674_.m_7942_(Registry.f_122827_.m_7447_(p_92677_.m_41720_())); - ItemColor itemcolor = this.f_92674_.m_7942_(Registry.f_122827_.m_7447_(p_92677_.m_41720_()));
+ ItemColor itemcolor = this.f_92674_.get(p_92677_.m_41720_().delegate); + ItemColor itemcolor = this.f_92674_.get(net.minecraftforge.registries.ForgeRegistries.ITEMS.getDelegateOrThrow(p_92677_.m_41720_()));
return itemcolor == null ? -1 : itemcolor.m_92671_(p_92677_, p_92678_); return itemcolor == null ? -1 : itemcolor.m_92671_(p_92677_, p_92678_);
} }
public void m_92689_(ItemColor p_92690_, ItemLike... p_92691_) { public void m_92689_(ItemColor p_92690_, ItemLike... p_92691_) {
for(ItemLike itemlike : p_92691_) { for(ItemLike itemlike : p_92691_) {
- this.f_92674_.m_122664_(p_92690_, Item.m_41393_(itemlike.m_5456_())); - this.f_92674_.m_122664_(p_92690_, Item.m_41393_(itemlike.m_5456_()));
+ this.f_92674_.put(itemlike.m_5456_().delegate, p_92690_); + this.f_92674_.put(net.minecraftforge.registries.ForgeRegistries.ITEMS.getDelegateOrThrow(itemlike.m_5456_()), p_92690_);
} }
} }
@@ -1,6 +1,6 @@
--- 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 @@ @@ -400,6 +_,7 @@
if (this.f_92986_.f_91076_ != null && this.f_92986_.f_91076_ instanceof LivingEntity && f >= 1.0F) { 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_91074_.m_36333_() > 5.0F;
flag &= this.f_92986_.f_91076_.m_6084_(); flag &= this.f_92986_.f_91076_.m_6084_();
@@ -8,7 +8,7 @@
} }
int j = this.f_92978_ / 2 - 7 + 16; int j = this.f_92978_ / 2 - 7 + 16;
@@ -463,6 +_,10 @@ @@ -452,6 +_,10 @@
for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
MobEffect mobeffect = mobeffectinstance.m_19544_(); MobEffect mobeffect = mobeffectinstance.m_19544_();
@@ -19,7 +19,7 @@
if (mobeffectinstance.m_19575_()) { if (mobeffectinstance.m_19575_()) {
int i = this.f_92977_; int i = this.f_92977_;
int j = 1; int j = 1;
@@ -500,6 +_,7 @@ @@ -489,6 +_,7 @@
RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, f1); RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, f1);
m_93200_(p_93029_, l + 3, i1 + 3, this.m_93252_(), 18, 18, textureatlassprite); m_93200_(p_93029_, l + 3, i1 + 3, this.m_93252_(), 18, 18, textureatlassprite);
}); });
@@ -27,12 +27,12 @@
} }
} }
@@ -620,12 +_,13 @@ @@ -609,12 +_,13 @@
public void m_93069_(PoseStack p_93070_) { public void m_93069_(PoseStack p_93070_) {
this.f_92986_.m_91307_().m_6180_("selectedItemName"); this.f_92986_.m_91307_().m_6180_("selectedItemName");
if (this.f_92993_ > 0 && !this.f_92994_.m_41619_()) { 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 = Component.m_237119_().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()); + MutableComponent mutablecomponent = Component.m_237119_().m_7220_(this.f_92994_.m_41786_()).m_130938_(this.f_92994_.m_41791_().getStyleModifier());
if (this.f_92994_.m_41788_()) { if (this.f_92994_.m_41788_()) {
mutablecomponent.m_130940_(ChatFormatting.ITALIC); mutablecomponent.m_130940_(ChatFormatting.ITALIC);
} }
@@ -43,7 +43,7 @@
int j = (this.f_92977_ - i) / 2; int j = (this.f_92977_ - i) / 2;
int k = this.f_92978_ - 59; int k = this.f_92978_ - 59;
if (!this.f_92986_.f_91072_.m_105205_()) { if (!this.f_92986_.f_91072_.m_105205_()) {
@@ -641,7 +_,13 @@ @@ -630,7 +_,13 @@
RenderSystem.m_69478_(); RenderSystem.m_69478_();
RenderSystem.m_69453_(); RenderSystem.m_69453_();
m_93172_(p_93070_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.f_92986_.f_91066_.m_92143_(0)); m_93172_(p_93070_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.f_92986_.f_91066_.m_92143_(0));
@@ -58,7 +58,7 @@
RenderSystem.m_69461_(); RenderSystem.m_69461_();
} }
} }
@@ -1153,7 +_,7 @@ @@ -1144,7 +_,7 @@
ItemStack itemstack = this.f_92986_.f_91074_.m_150109_().m_36056_(); ItemStack itemstack = this.f_92986_.f_91074_.m_150109_().m_36056_();
if (itemstack.m_41619_()) { if (itemstack.m_41619_()) {
this.f_92993_ = 0; this.f_92993_ = 0;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/AbstractWidget.java --- a/net/minecraft/client/gui/components/AbstractWidget.java
+++ b/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java
@@ -86,7 +_,7 @@ @@ -85,7 +_,7 @@
this.m_93228_(p_93676_, this.f_93620_, this.f_93621_, 0, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); this.m_93228_(p_93676_, this.f_93620_, this.f_93621_, 0, 46 + i * 20, this.f_93618_ / 2, this.f_93619_);
this.m_93228_(p_93676_, this.f_93620_ + this.f_93618_ / 2, this.f_93621_, 200 - this.f_93618_ / 2, 46 + i * 20, this.f_93618_ / 2, this.f_93619_); this.m_93228_(p_93676_, this.f_93620_ + this.f_93618_ / 2, this.f_93621_, 200 - this.f_93618_ / 2, 46 + i * 20, this.f_93618_ / 2, this.f_93619_);
this.m_7906_(p_93676_, minecraft, p_93677_, p_93678_); this.m_7906_(p_93676_, minecraft, p_93677_, p_93678_);
@@ -9,7 +9,7 @@
m_93215_(p_93676_, font, this.m_6035_(), this.f_93620_ + this.f_93618_ / 2, this.f_93621_ + (this.f_93619_ - 8) / 2, j | Mth.m_14167_(this.f_93625_ * 255.0F) << 24); m_93215_(p_93676_, font, this.m_6035_(), this.f_93620_ + this.f_93618_ / 2, this.f_93621_ + (this.f_93619_ - 8) / 2, j | Mth.m_14167_(this.f_93625_ * 255.0F) << 24);
} }
@@ -181,6 +_,10 @@ @@ -180,6 +_,10 @@
this.f_93618_ = p_93675_; this.f_93618_ = p_93675_;
} }
@@ -20,7 +20,7 @@
public void m_93650_(float p_93651_) { public void m_93650_(float p_93651_) {
this.f_93625_ = p_93651_; this.f_93625_ = p_93651_;
} }
@@ -203,6 +_,19 @@ @@ -202,6 +_,19 @@
protected void m_93692_(boolean p_93693_) { protected void m_93692_(boolean p_93693_) {
this.f_93616_ = p_93693_; this.f_93616_ = p_93693_;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/DebugScreenOverlay.java --- a/net/minecraft/client/gui/components/DebugScreenOverlay.java
+++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java +++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java
@@ -399,6 +_,7 @@ @@ -409,6 +_,7 @@
list.add(""); list.add("");
list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
list.add(String.valueOf((Object)Registry.f_122826_.m_7981_(entity.m_6095_()))); list.add(String.valueOf((Object)Registry.f_122826_.m_7981_(entity.m_6095_())));
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/gui/screens/DeathScreen.java --- a/net/minecraft/client/gui/screens/DeathScreen.java
+++ b/net/minecraft/client/gui/screens/DeathScreen.java +++ b/net/minecraft/client/gui/screens/DeathScreen.java
@@ -37,6 +_,7 @@ @@ -36,6 +_,7 @@
}))); })));
this.f_169295_.add(this.m_142416_(new Button(this.f_96543_ / 2 - 100, this.f_96544_ / 4 + 96, 200, 20, new TranslatableComponent("deathScreen.titleScreen"), (p_95925_) -> { this.f_169295_.add(this.m_142416_(new Button(this.f_96543_ / 2 - 100, this.f_96544_ / 4 + 96, 200, 20, Component.m_237115_("deathScreen.titleScreen"), (p_95925_) -> {
if (this.f_95908_) { if (this.f_95908_) {
+ m_95931_(true); + m_95931_(true);
this.m_95934_(); this.m_95934_();
} else { } else {
ConfirmScreen confirmscreen = new ConfirmScreen(this::m_95931_, new TranslatableComponent("deathScreen.quit.confirm"), TextComponent.f_131282_, new TranslatableComponent("deathScreen.titleScreen"), new TranslatableComponent("deathScreen.respawn")); ConfirmScreen confirmscreen = new ConfirmScreen(this::m_95931_, Component.m_237115_("deathScreen.quit.confirm"), CommonComponents.f_237098_, Component.m_237115_("deathScreen.titleScreen"), Component.m_237115_("deathScreen.respawn"));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/OptionsScreen.java --- a/net/minecraft/client/gui/screens/OptionsScreen.java
+++ b/net/minecraft/client/gui/screens/OptionsScreen.java +++ b/net/minecraft/client/gui/screens/OptionsScreen.java
@@ -141,4 +_,12 @@ @@ -140,4 +_,12 @@
m_93215_(p_96249_, this.f_96547_, this.f_96539_, this.f_96543_ / 2, 15, 16777215); m_93215_(p_96249_, this.f_96547_, this.f_96539_, this.f_96543_ / 2, 15, 16777215);
super.m_6305_(p_96249_, p_96250_, p_96251_, p_96252_); super.m_6305_(p_96249_, p_96250_, p_96251_, p_96252_);
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/Screen.java --- a/net/minecraft/client/gui/screens/Screen.java
+++ b/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java
@@ -127,7 +_,7 @@ @@ -126,7 +_,7 @@
} }
public void m_7379_() { public void m_7379_() {
@@ -9,7 +9,7 @@
} }
protected <T extends GuiEventListener & Widget & NarratableEntry> T m_142416_(T p_169406_) { protected <T extends GuiEventListener & Widget & NarratableEntry> T m_142416_(T p_169406_) {
@@ -164,15 +_,29 @@ @@ -163,15 +_,29 @@
this.f_169368_.clear(); this.f_169368_.clear();
} }
@@ -43,7 +43,7 @@
this.m_169383_(p_169389_, list, p_169392_, p_169393_); this.m_169383_(p_169389_, list, p_169392_, p_169393_);
} }
@@ -185,20 +_,44 @@ @@ -184,20 +_,44 @@
} }
public void m_96597_(PoseStack p_96598_, List<Component> p_96599_, int p_96600_, int p_96601_) { public void m_96597_(PoseStack p_96598_, List<Component> p_96599_, int p_96600_, int p_96601_) {
@@ -90,7 +90,7 @@
if (k > i) { if (k > i) {
i = k; i = k;
} }
@@ -206,8 +_,8 @@ @@ -205,8 +_,8 @@
j += clienttooltipcomponent.m_142103_(); j += clienttooltipcomponent.m_142103_();
} }
@@ -101,7 +101,7 @@
if (j2 + i > this.f_96543_) { if (j2 + i > this.f_96543_) {
j2 -= 28 + i; j2 -= 28 + i;
} }
@@ -228,15 +_,16 @@ @@ -231,15 +_,16 @@
RenderSystem.m_157427_(GameRenderer::m_172811_); RenderSystem.m_157427_(GameRenderer::m_172811_);
bufferbuilder.m_166779_(VertexFormat.Mode.QUADS, DefaultVertexFormat.f_85815_); bufferbuilder.m_166779_(VertexFormat.Mode.QUADS, DefaultVertexFormat.f_85815_);
Matrix4f matrix4f = p_169384_.m_85850_().m_85861_(); Matrix4f matrix4f = p_169384_.m_85850_().m_85861_();
@@ -127,7 +127,7 @@
RenderSystem.m_69482_(); RenderSystem.m_69482_();
RenderSystem.m_69472_(); RenderSystem.m_69472_();
RenderSystem.m_69478_(); RenderSystem.m_69478_();
@@ -251,7 +_,7 @@ @@ -253,7 +_,7 @@
for(int i2 = 0; i2 < p_169385_.size(); ++i2) { for(int i2 = 0; i2 < p_169385_.size(); ++i2) {
ClientTooltipComponent clienttooltipcomponent1 = p_169385_.get(i2); ClientTooltipComponent clienttooltipcomponent1 = p_169385_.get(i2);
@@ -136,7 +136,7 @@
l1 += clienttooltipcomponent1.m_142103_() + (i2 == 0 ? 2 : 0); l1 += clienttooltipcomponent1.m_142103_() + (i2 == 0 ? 2 : 0);
} }
@@ -261,7 +_,7 @@ @@ -263,7 +_,7 @@
for(int l2 = 0; l2 < p_169385_.size(); ++l2) { for(int l2 = 0; l2 < p_169385_.size(); ++l2) {
ClientTooltipComponent clienttooltipcomponent2 = p_169385_.get(l2); ClientTooltipComponent clienttooltipcomponent2 = p_169385_.get(l2);
@@ -145,20 +145,7 @@
l1 += clienttooltipcomponent2.m_142103_() + (l2 == 0 ? 2 : 0); l1 += clienttooltipcomponent2.m_142103_() + (l2 == 0 ? 2 : 0);
} }
@@ -355,9 +_,12 @@ @@ -363,9 +_,19 @@
}
public void m_96612_(String p_96613_, boolean p_96614_) {
+ p_96613_ = net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(p_96613_);
+ if (p_96613_.isEmpty()) return;
if (p_96614_) {
this.f_96541_.f_91065_.m_93076_().m_93783_(p_96613_);
}
+ if (net.minecraftforge.client.ClientCommandHandler.sendMessage(p_96613_)) return;
this.f_96541_.f_91074_.m_108739_(p_96613_);
}
@@ -368,11 +_,21 @@
this.f_96547_ = p_96607_.f_91062_; this.f_96547_ = p_96607_.f_91062_;
this.f_96543_ = p_96608_; this.f_96543_ = p_96608_;
this.f_96544_ = p_96609_; this.f_96544_ = p_96609_;
@@ -170,17 +157,15 @@
+ f_96540_.add(b); + f_96540_.add(b);
+ }; + };
+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Pre(this, this.f_96540_, add, this::m_169411_))) { + if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Pre(this, this.f_96540_, add, this::m_169411_))) {
this.m_169413_(); this.m_232761_();
this.m_7522_((GuiEventListener)null);
this.m_7856_();
this.m_169407_(false); this.m_169407_(false);
this.m_169378_(f_169370_); this.m_169378_(f_169370_);
+ } + }
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Post(this, this.f_96540_, add, this::m_169411_)); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Post(this, this.f_96540_, add, this::m_169411_));
} }
public List<? extends GuiEventListener> m_6702_() { protected void m_232761_() {
@@ -395,6 +_,7 @@ @@ -394,6 +_,7 @@
public void m_96558_(PoseStack p_96559_, int p_96560_) { public void m_96558_(PoseStack p_96559_, int p_96560_) {
if (this.f_96541_.f_91073_ != null) { if (this.f_96541_.f_91073_ != null) {
this.m_93179_(p_96559_, 0, 0, this.f_96543_, this.f_96544_, -1072689136, -804253680); this.m_93179_(p_96559_, 0, 0, this.f_96543_, this.f_96544_, -1072689136, -804253680);
@@ -188,7 +173,7 @@
} else { } else {
this.m_96626_(p_96560_); this.m_96626_(p_96560_);
} }
@@ -414,6 +_,7 @@ @@ -413,6 +_,7 @@
bufferbuilder.m_5483_((double)this.f_96543_, 0.0D, 0.0D).m_7421_((float)this.f_96543_ / 32.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); bufferbuilder.m_5483_((double)this.f_96543_, 0.0D, 0.0D).m_7421_((float)this.f_96543_ / 32.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_();
bufferbuilder.m_5483_(0.0D, 0.0D, 0.0D).m_7421_(0.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); bufferbuilder.m_5483_(0.0D, 0.0D, 0.0D).m_7421_(0.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_();
tesselator.m_85914_(); tesselator.m_85914_();
@@ -196,7 +181,7 @@
} }
public boolean m_7043_() { public boolean m_7043_() {
@@ -499,6 +_,10 @@ @@ -498,6 +_,10 @@
} }
public void m_7400_(List<Path> p_96591_) { public void m_7400_(List<Path> p_96591_) {
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/gui/screens/TitleScreen.java --- a/net/minecraft/client/gui/screens/TitleScreen.java
+++ b/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java
@@ -73,6 +_,7 @@ @@ -66,6 +_,7 @@
private TitleScreen.Warning32Bit f_210857_; private long f_96715_;
private RealmsClient f_210858_; @Nullable
private boolean f_210859_ = false; private TitleScreen.WarningLabel f_232768_;
+ private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification; + private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification;
public TitleScreen() { public TitleScreen() {
this(false); this(false);
@@ -131,11 +_,16 @@ @@ -110,11 +_,16 @@
int j = this.f_96543_ - i - 2; int j = this.f_96543_ - i - 2;
int k = 24; int k = 24;
int l = this.f_96544_ / 4 + 48; int l = this.f_96544_ / 4 + 48;
@@ -17,7 +17,7 @@
this.m_96772_(l, 24); this.m_96772_(l, 24);
} else { } else {
this.m_96763_(l, 24); this.m_96763_(l, 24);
+ modButton = this.m_142416_(new Button(this.f_96543_ / 2 - 100, l + 24 * 2, 98, 20, new TranslatableComponent("fml.menu.mods"), button -> { + modButton = this.m_142416_(new Button(this.f_96543_ / 2 - 100, l + 24 * 2, 98, 20, Component.m_237115_("fml.menu.mods"), button -> {
+ this.f_96541_.m_91152_(new net.minecraftforge.client.gui.ModListScreen(this)); + this.f_96541_.m_91152_(new net.minecraftforge.client.gui.ModListScreen(this));
+ })); + }));
} }
@@ -25,24 +25,24 @@
this.m_142416_(new ImageButton(this.f_96543_ / 2 - 124, l + 72 + 12, 20, 20, 0, 106, 20, Button.f_93617_, 256, 256, (p_96791_) -> { this.m_142416_(new ImageButton(this.f_96543_ / 2 - 124, l + 72 + 12, 20, 20, 0, 106, 20, Button.f_93617_, 256, 256, (p_96791_) -> {
this.f_96541_.m_91152_(new LanguageSelectScreen(this, this.f_96541_.f_91066_, this.f_96541_.m_91102_())); this.f_96541_.m_91152_(new LanguageSelectScreen(this, this.f_96541_.f_91066_, this.f_96541_.m_91102_()));
@@ -201,7 +_,7 @@ @@ -169,7 +_,7 @@
Screen screen = (Screen)(this.f_96541_.f_91066_.f_92083_ ? new JoinMultiplayerScreen(this) : new SafetyScreen(this)); Screen screen = (Screen)(this.f_96541_.f_91066_.f_92083_ ? new JoinMultiplayerScreen(this) : new SafetyScreen(this));
this.f_96541_.m_91152_(screen); this.f_96541_.m_91152_(screen);
}, button$ontooltip))).f_93623_ = flag; }, button$ontooltip))).f_93623_ = flag;
- (this.m_142416_(new Button(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20, new TranslatableComponent("menu.online"), (p_211788_) -> { - (this.m_142416_(new Button(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 2, 200, 20, Component.m_237115_("menu.online"), (p_210872_) -> {
+ (this.m_142416_(new Button(this.f_96543_ / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20, new TranslatableComponent("menu.online"), (p_96771_) -> { + (this.m_142416_(new Button(this.f_96543_ / 2 + 2, p_96764_ + p_96765_ * 2, 98, 20, Component.m_237115_("menu.online"), (p_96771_) -> {
this.m_96793_(); this.m_96793_();
}, button$ontooltip))).f_93623_ = flag; }, button$ontooltip))).f_93623_ = flag;
} }
@@ -331,6 +_,7 @@ @@ -298,6 +_,7 @@
this.f_210857_.f_210875_.m_6514_(p_96739_, this.f_210857_.f_210876_, this.f_210857_.f_210877_, 9, 16777215 | l); this.f_232768_.m_232790_(p_96739_, l);
} }
+ net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_96739_, this.f_96547_, this.f_96543_, this.f_96544_, l); + net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_96739_, this.f_96547_, this.f_96543_, this.f_96544_, l);
if (this.f_96721_ != null) { if (this.f_96721_ != null) {
p_96739_.m_85836_(); p_96739_.m_85836_();
p_96739_.m_85837_((double)(this.f_96543_ / 2 + 90), 70.0D, 0.0D); p_96739_.m_85837_((double)(this.f_96543_ / 2 + 90), 70.0D, 0.0D);
@@ -353,7 +_,14 @@ @@ -320,7 +_,14 @@
s = s + I18n.m_118938_("menu.modded"); s = s + I18n.m_118938_("menu.modded");
} }
@@ -58,7 +58,7 @@
for(GuiEventListener guieventlistener : this.m_6702_()) { for(GuiEventListener guieventlistener : this.m_6702_()) {
if (guieventlistener instanceof AbstractWidget) { if (guieventlistener instanceof AbstractWidget) {
@@ -365,6 +_,7 @@ @@ -332,6 +_,7 @@
if (this.m_96789_() && f1 >= 1.0F) { if (this.m_96789_() && f1 >= 1.0F) {
this.f_96726_.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); this.f_96726_.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_);
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
+++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
@@ -43,6 +_,7 @@ @@ -42,6 +_,7 @@
@Nullable @Nullable
private AdvancementTab f_97336_; private AdvancementTab f_97336_;
private boolean f_97337_; private boolean f_97337_;
@@ -8,7 +8,7 @@
public AdvancementsScreen(ClientAdvancements p_97340_) { public AdvancementsScreen(ClientAdvancements p_97340_) {
super(NarratorChatListener.f_93310_); super(NarratorChatListener.f_93310_);
@@ -58,7 +_,13 @@ @@ -57,7 +_,13 @@
} else { } else {
this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_97182_(), true); this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_97182_(), true);
} }
@@ -16,14 +16,14 @@
+ if (this.f_97335_.size() > AdvancementTabType.MAX_TABS) { + if (this.f_97335_.size() > AdvancementTabType.MAX_TABS) {
+ int guiLeft = (this.f_96543_ - 252) / 2; + int guiLeft = (this.f_96543_ - 252) / 2;
+ int guiTop = (this.f_96544_ - 140) / 2; + int guiTop = (this.f_96544_ - 140) / 2;
+ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent("<"), b -> tabPage = Math.max(tabPage - 1, 0 ))); + m_142416_(new net.minecraft.client.gui.components.Button(guiLeft, guiTop - 50, 20, 20, Component.m_237113_("<"), b -> tabPage = Math.max(tabPage - 1, 0 )));
+ m_142416_(new net.minecraft.client.gui.components.Button(guiLeft + 252 - 20, guiTop - 50, 20, 20, new net.minecraft.network.chat.TextComponent(">"), b -> tabPage = Math.min(tabPage + 1, maxPages))); + m_142416_(new net.minecraft.client.gui.components.Button(guiLeft + 252 - 20, guiTop - 50, 20, 20, Component.m_237113_(">"), b -> tabPage = Math.min(tabPage + 1, maxPages)));
+ maxPages = this.f_97335_.size() / AdvancementTabType.MAX_TABS; + maxPages = this.f_97335_.size() / AdvancementTabType.MAX_TABS;
+ } + }
} }
public void m_7861_() { public void m_7861_() {
@@ -76,7 +_,7 @@ @@ -75,7 +_,7 @@
int j = (this.f_96544_ - 140) / 2; int j = (this.f_96544_ - 140) / 2;
for(AdvancementTab advancementtab : this.f_97335_.values()) { for(AdvancementTab advancementtab : this.f_97335_.values()) {
@@ -32,19 +32,19 @@
this.f_97334_.m_104401_(advancementtab.m_97182_(), true); this.f_97334_.m_104401_(advancementtab.m_97182_(), true);
break; break;
} }
@@ -100,6 +_,11 @@ @@ -99,6 +_,11 @@
int i = (this.f_96543_ - 252) / 2; int i = (this.f_96543_ - 252) / 2;
int j = (this.f_96544_ - 140) / 2; int j = (this.f_96544_ - 140) / 2;
this.m_7333_(p_97361_); this.m_7333_(p_97361_);
+ if (maxPages != 0) { + if (maxPages != 0) {
+ net.minecraft.network.chat.Component page = new net.minecraft.network.chat.TextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); + net.minecraft.network.chat.Component page = Component.m_237113_(String.format("%d / %d", tabPage + 1, maxPages + 1));
+ int width = this.f_96547_.m_92852_(page); + int width = this.f_96547_.m_92852_(page);
+ this.f_96547_.m_92744_(p_97361_, page.m_7532_(), i + (252 / 2) - (width / 2), j - 44, -1); + this.f_96547_.m_92744_(p_97361_, page.m_7532_(), i + (252 / 2) - (width / 2), j - 44, -1);
+ } + }
this.m_97373_(p_97361_, p_97362_, p_97363_, i, j); this.m_97373_(p_97361_, p_97362_, p_97363_, i, j);
this.m_97356_(p_97361_, i, j); this.m_97356_(p_97361_, i, j);
this.m_97381_(p_97361_, p_97362_, p_97363_, i, j); this.m_97381_(p_97361_, p_97362_, p_97363_, i, j);
@@ -150,12 +_,14 @@ @@ -149,12 +_,14 @@
RenderSystem.m_157456_(0, f_97330_); RenderSystem.m_157456_(0, f_97330_);
for(AdvancementTab advancementtab : this.f_97335_.values()) { for(AdvancementTab advancementtab : this.f_97335_.values()) {
@@ -59,7 +59,7 @@
advancementtab1.m_97159_(p_97358_, p_97359_, this.f_96542_); advancementtab1.m_97159_(p_97358_, p_97359_, this.f_96542_);
} }
@@ -181,7 +_,7 @@ @@ -180,7 +_,7 @@
if (this.f_97335_.size() > 1) { if (this.f_97335_.size() > 1) {
for(AdvancementTab advancementtab : this.f_97335_.values()) { for(AdvancementTab advancementtab : this.f_97335_.values()) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/controls/KeyBindsList.java --- a/net/minecraft/client/gui/screens/controls/KeyBindsList.java
+++ b/net/minecraft/client/gui/screens/controls/KeyBindsList.java +++ b/net/minecraft/client/gui/screens/controls/KeyBindsList.java
@@ -53,7 +_,7 @@ @@ -51,7 +_,7 @@
} }
protected int m_5756_() { protected int m_5756_() {
@@ -9,7 +9,7 @@
} }
public int m_5759_() { public int m_5759_() {
@@ -109,7 +_,7 @@ @@ -107,7 +_,7 @@
KeyEntry(final KeyMapping p_193916_, final Component p_193917_) { KeyEntry(final KeyMapping p_193916_, final Component p_193917_) {
this.f_193910_ = p_193916_; this.f_193910_ = p_193916_;
this.f_193911_ = p_193917_; this.f_193911_ = p_193917_;
@@ -18,15 +18,15 @@
KeyBindsList.this.f_193858_.f_193975_ = p_193916_; KeyBindsList.this.f_193858_.f_193975_ = p_193916_;
}) { }) {
protected MutableComponent m_5646_() { protected MutableComponent m_5646_() {
@@ -117,6 +_,7 @@ @@ -115,6 +_,7 @@
} }
}; };
this.f_193913_ = new Button(0, 0, 50, 20, new TranslatableComponent("controls.reset"), (p_193935_) -> { this.f_193913_ = new Button(0, 0, 50, 20, Component.m_237115_("controls.reset"), (p_193935_) -> {
+ this.f_193910_.setToDefault(); + this.f_193910_.setToDefault();
KeyBindsList.this.f_93386_.f_91066_.m_92159_(p_193916_, p_193916_.m_90861_()); KeyBindsList.this.f_93386_.f_91066_.m_92159_(p_193916_, p_193916_.m_90861_());
KeyMapping.m_90854_(); KeyMapping.m_90854_();
}) { }) {
@@ -130,7 +_,7 @@ @@ -128,7 +_,7 @@
boolean flag = KeyBindsList.this.f_193858_.f_193975_ == this.f_193910_; boolean flag = KeyBindsList.this.f_193858_.f_193975_ == this.f_193910_;
float f = (float)(p_193926_ + 90 - KeyBindsList.this.f_193859_); float f = (float)(p_193926_ + 90 - KeyBindsList.this.f_193859_);
KeyBindsList.this.f_93386_.f_91062_.m_92889_(p_193923_, this.f_193911_, f, (float)(p_193925_ + p_193928_ / 2 - 9 / 2), 16777215); KeyBindsList.this.f_93386_.f_91062_.m_92889_(p_193923_, this.f_193911_, f, (float)(p_193925_ + p_193928_ / 2 - 9 / 2), 16777215);
@@ -35,7 +35,7 @@
this.f_193913_.f_93621_ = p_193925_; this.f_193913_.f_93621_ = p_193925_;
this.f_193913_.f_93623_ = !this.f_193910_.m_90864_(); this.f_193913_.f_93623_ = !this.f_193910_.m_90864_();
this.f_193913_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_); this.f_193913_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_);
@@ -138,11 +_,12 @@ @@ -136,11 +_,12 @@
this.f_193912_.f_93621_ = p_193925_; this.f_193912_.f_93621_ = p_193925_;
this.f_193912_.m_93666_(this.f_193910_.m_90863_()); this.f_193912_.m_93666_(this.f_193910_.m_90863_());
boolean flag1 = false; boolean flag1 = false;
@@ -49,9 +49,9 @@
} }
} }
} }
@@ -150,7 +_,7 @@ @@ -148,7 +_,7 @@
if (flag) { if (flag) {
this.f_193912_.m_93666_((new TextComponent("> ")).m_7220_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.YELLOW)).m_130946_(" <").m_130940_(ChatFormatting.YELLOW)); this.f_193912_.m_93666_(Component.m_237113_("> ").m_7220_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.YELLOW)).m_130946_(" <").m_130940_(ChatFormatting.YELLOW));
} else if (flag1) { } else if (flag1) {
- this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.RED)); - this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.RED));
+ this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED)); + this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED));
@@ -2,7 +2,7 @@
+++ b/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java +++ b/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java
@@ -31,7 +_,7 @@ @@ -31,7 +_,7 @@
this.m_7787_(this.f_193977_); this.m_7787_(this.f_193977_);
this.f_193978_ = this.m_142416_(new Button(this.f_96543_ / 2 - 155, this.f_96544_ - 29, 150, 20, new TranslatableComponent("controls.resetAll"), (p_193999_) -> { this.f_193978_ = this.m_142416_(new Button(this.f_96543_ / 2 - 155, this.f_96544_ - 29, 150, 20, Component.m_237115_("controls.resetAll"), (p_193999_) -> {
for(KeyMapping keymapping : this.f_96282_.f_92059_) { for(KeyMapping keymapping : this.f_96282_.f_92059_) {
- keymapping.m_90848_(keymapping.m_90861_()); - keymapping.m_90848_(keymapping.m_90861_());
+ keymapping.setToDefault(); + keymapping.setToDefault();
@@ -108,7 +108,7 @@
this.m_6597_(slot2, slot2.f_40219_, p_97814_, ClickType.QUICK_MOVE); this.m_6597_(slot2, slot2.f_40219_, p_97814_, ClickType.QUICK_MOVE);
} }
} }
@@ -496,7 +_,7 @@ @@ -495,7 +_,7 @@
this.m_6597_((Slot)null, -999, AbstractContainerMenu.m_38930_(2, this.f_97717_), ClickType.QUICK_CRAFT); this.m_6597_((Slot)null, -999, AbstractContainerMenu.m_38930_(2, this.f_97717_), ClickType.QUICK_CRAFT);
} else if (!this.f_97732_.m_142621_().m_41619_()) { } else if (!this.f_97732_.m_142621_().m_41619_()) {
@@ -117,7 +117,7 @@
this.m_6597_(slot, k, p_97814_, ClickType.CLONE); this.m_6597_(slot, k, p_97814_, ClickType.CLONE);
} else { } else {
boolean flag1 = k != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344)); boolean flag1 = k != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344));
@@ -538,34 +_,39 @@ @@ -542,34 +_,39 @@
} }
public boolean m_7933_(int p_97765_, int p_97766_, int p_97767_) { public boolean m_7933_(int p_97765_, int p_97766_, int p_97767_) {
@@ -164,13 +164,13 @@
this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, i, ClickType.SWAP); this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, i, ClickType.SWAP);
return true; return true;
} }
@@ -600,6 +_,18 @@ @@ -604,6 +_,18 @@
public T m_6262_() { public T m_6262_() {
return this.f_97732_; return this.f_97732_;
+ } + }
+ +
+ @javax.annotation.Nullable + @org.jetbrains.annotations.Nullable
+ public Slot getSlotUnderMouse() { return this.f_97734_; } + public Slot getSlotUnderMouse() { return this.f_97734_; }
+ public int getGuiLeft() { return f_97735_; } + public int getGuiLeft() { return f_97735_; }
+ public int getGuiTop() { return f_97736_; } + public int getGuiTop() { return f_97736_; }
Loaded 100 of 1485 files, more files were not shown because too many files have changed in this diff. Show more