Compare commits

..
20 Commits
Author SHA1 Message Date
LexManos b6e4191997 Add protection against large network channel lists 2026-10-14 19:37:35 -07:00
LexManos d01b4128b0 Fix legacy object holders not being fired in the registry specific codepath
Better optimize the scanning for object holders by unrolling streams.
2026-10-13 10:35:28 -07:00
BonsUnleashedandLexManos 6162ec30bd Store object holder handlers per registry name (#10899)
Co-authored-by: LexManos <[email protected]>
2026-10-12 16:19:07 -07:00
LexManos 96ffdf9ee5 Update SRGUtils and Fix new eclipse compiler issue 2026-10-12 16:19:05 -07:00
Paint_NinjaandMartijn van den Brand 23856b57a9 Fix IForgeBlockStateModel.getModelData not being called correct for #getParticleIcon (#10818) (#10874)
Co-authored-by: Martijn van den Brand <[email protected]>
2026-08-15 00:41:45 -07:00
Meme Man 855bafc581 Update equality check for RegistryObject to include RegistryObject#key. (#10867) 2026-08-04 19:09:43 +01:00
Matt a42ea9bc2c Add DeltaTracker (partialTick) context to PassDefinitions (#10831) (#10851) 2026-07-21 16:09:23 -07:00
Matt a6eea5a004 Toml parsing errors are now visible in the latest log (#10839) 2026-07-09 12:34:25 -07:00
Matt 451c3a1f0a Add support for multiple access transformer configs. 2026-03-23 12:14:09 -07:00
Jonathing a6f68087b4 Migrate the MDK to ForgeGradle 7
Backport of d29524b to 1.21.8
2026-03-18 22:49:16 +00:00
Paint_Ninja ae3985f882 Bump ASM to 9.9.1 and EventBus to 7.0.1 2026-03-17 20:05:22 +00:00
Paint_Ninja 0f6951b560 Skip processing vanilla classes in RuntimeDistCleaner when running on a client
Backport of #10682 to 1.21.8
2026-03-17 19:55:18 +00:00
LexManos 19f6b6c294 Update SecureModules to address ZipPath bug with brackets. Closes #10755 2026-01-20 18:23:14 -08:00
LexManos 9441128b1a Fix Entity patch line numbers 2026-01-15 12:42:59 -08:00
MattandLexManos b9d842a484 Optimize memory allocation for checking entity fluid collisions. Backport of #10745 (#10749)
Co-authored-by: LexManos <[email protected]>
2026-01-15 10:34:47 -08:00
LexManos eb884f4f61 Mark applyServerBinpatches as a dependency of BundleList. Fixes: #10729 2025-12-04 08:52:37 -08:00
LexManos 74d2f1c7c3 Migrate to Github Actions 2025-12-02 14:17:14 -08:00
cech12 e75f0b67fe Fixes shearing leads for custom shears (interacting with entity & leash knot) (#10706) 2025-11-19 17:39:39 -08:00
Matt fae5c92daf Fix ItemStack context in RenderTooltipEvent.Pre (#10655) (#10658) 2025-11-14 07:08:10 -08:00
Paint_Ninja 60110cd916 Fix implicit Bus.BOTH not working in @EventBusSubscriber, add additional validation in strict mode, partial backport of #10676 2025-10-05 15:15:25 +01:00
553 changed files with 7769 additions and 5854 deletions

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
name: Publish
on:
push:
branches: [ '1.21.8' ]
permissions:
contents: read
jobs:
build:
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main
with:
java: 21
gradle_setup: './gradlew setup'
gradle_tasks: 'build publish'
artifact_name: 'forge'
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}
PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }}
PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
SIGN_KEY_ALIAS: ${{ secrets.SIGN_KEY_ALIAS }}
SIGN_KEY_PASSWORD: ${{ secrets.SIGN_KEY_PASSWORD }}
SIGN_KEYSTORE_PASSWORD: ${{ secrets.SIGN_KEYSTORE_PASSWORD }}
SIGN_KEYSTORE_DATA: ${{ secrets.SIGN_KEYSTORE_DATA }}
+1 -1
View File
@@ -7,7 +7,7 @@ jobs:
name: Upload payload name: Upload payload
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/upload-artifact@v3 # Payload artifact is consumed in Actionable - uses: actions/upload-artifact@v4 # Payload artifact is consumed in Actionable
with: with:
name: payload name: payload
path: ${{ github.event_path }} path: ${{ github.event_path }}
@@ -7,7 +7,7 @@ jobs:
name: Upload payload name: Upload payload
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/upload-artifact@v3 # Payload artifact is consumed in Actionable - uses: actions/upload-artifact@v4 # Payload artifact is consumed in Actionable
with: with:
name: payload name: payload
path: ${{ github.event_path }} path: ${{ github.event_path }}
-104
View File
@@ -1,104 +0,0 @@
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<name>MinecraftForge_Forge Config DSL Script</name>
<groupId>MinecraftForge_Forge</groupId>
<artifactId>MinecraftForge_Forge_dsl</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>configs-dsl-kotlin-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<repositories>
<repository>
<id>jetbrains-all</id>
<url>https://download.jetbrains.com/teamcity-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>teamcity-server</id>
<url>https://teamcity.minecraftforge.net/app/dsl-plugins-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>JetBrains</id>
<url>https://download.jetbrains.com/teamcity-repository</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>${basedir}</sourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration/>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>teamcity-configs-maven-plugin</artifactId>
<version>${teamcity.dsl.version}</version>
<configuration>
<format>kotlin</format>
<dstDir>target/generated-configs</dstDir>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>configs-dsl-kotlin</artifactId>
<version>${teamcity.dsl.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>configs-dsl-kotlin-plugins</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-script-runtime</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
-193
View File
@@ -1,193 +0,0 @@
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues
import jetbrains.buildServer.configs.kotlin.*
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle
/*
The settings script is an entry point for defining a TeamCity
project hierarchy. The script should contain a single call to the
project() function with a Project instance or an init function as
an argument.
VcsRoots, BuildTypes, Templates, and subprojects can be
registered inside the project using the vcsRoot(), buildType(),
template(), and subProject() methods respectively.
To debug settings scripts in command-line, run the
mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate
command and attach your debugger to the port 8000.
To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
-> Tool Windows -> Maven Projects), find the generate task node
(Plugins -> teamcity-configs -> teamcity-configs:generate), the
'Debug' option is available in the context menu for the task.
*/
version = "2021.2"
project {
buildType(Build)
buildType(BuildSecondaryBranches)
buildType(PullRequests)
buildType(PullRequestChecks)
buildType(PullRequestCompatibility)
params {
text("docker_jdk_version", "21", label = "Gradle version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
text("docker_gradle_version", "8.7", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
text("git_main_branch", "1.21.x", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
text("git_branch_spec", """
+:refs/heads/(main*)
+:refs/heads/(master*)
+:refs/heads/(develop|release|staging|main|master)
+:refs/heads/(1.*)
""".trimIndent(), label = "The branch specification of the repository", description = "By default all main branches are build by the configuration. Modify this value to adapt the branches build.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
text("github_repository_name", "MinecraftForge", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `MinecraftForge` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
text("env.PUBLISHED_JAVA_ARTIFACT_ID", "forge", label = "Published artifact id", description = "The maven coordinate artifact id that has been published by this build. Can not be empty.", allowEmpty = false)
text("env.PUBLISHED_JAVA_GROUP", "net.minecraftforge", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false)
//These are references and not actually keys
password("env.CROWDIN_KEY", "credentialsJSON:a3102dbe-805d-4177-9f54-3d2c2eb08fd5", display = ParameterDisplay.HIDDEN)
password("env.KEYSTORE_URL", "credentialsJSON:a7ae1c82-8058-4061-8d12-7f6bc2618d2e", display = ParameterDisplay.HIDDEN)
password("env.KEYSTORE_PASSWORD", "credentialsJSON:d7b964e3-a1fd-47a8-b892-6f601fe47479", display = ParameterDisplay.HIDDEN)
text("additional_publishing_gradle_parameters", "-PcrowdinKey=%env.CROWDIN_KEY% -PkeystoreKeyPass=%env.KEYSTORE_PASSWORD% -PkeystoreStorePass=%env.KEYSTORE_PASSWORD% -Pkeystore=%env.KEYSTORE_URL%", label = "Additional gradle parameters for publish", description = "Contains the additional gradle parameters used during publishing.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
checkbox("should_execute_build", "false", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
checked = "true", unchecked = "false")
checkbox("should_execute_test", "false", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
checked = "true", unchecked = "false")
}
features {
githubIssues {
id = "MinecraftForge_MinecraftForge__IssueTracker"
displayName = "MinecraftForge/MinecraftForge"
repositoryURL = "https://github.com/MinecraftForge/MinecraftForge"
}
}
}
object Build : BuildType({
templates(AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"), AbsoluteId("MinecraftForge_PublishProjectUsingGradle"), AbsoluteId("MinecraftForge_TriggersStaticFilesWebpageGenerator"))
id("MinecraftForge_MinecraftForge__Build")
name = "Build"
description = "Builds and Publishes the main branches of the project."
})
object BuildSecondaryBranches : BuildType({
templates(AbsoluteId("MinecraftForge_ExcludesBuildingDefaultBranch"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"))
id("MinecraftForge_MinecraftForge__BuildSecondaryBranches")
name = "Build - Secondary Branches"
description = "Builds and Publishes the secondary branches of the project."
params {
text("git_branch_spec", """
+:refs/heads/(*)
-:refs/heads/noci*
""".trimIndent(), label = "The branch specification of the repository", description = "By default all main branches are build by the configuration. Modify this value to adapt the branches build.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
}
vcs {
branchFilter = """
+:*
-:1.*
-:<default>
""".trimIndent()
}
})
object PullRequests : BuildType({
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"))
id("MinecraftForge_MinecraftForge__PullRequests")
name = "Pull Requests"
description = "Builds pull requests for the project"
params {
checkbox("should_execute_build", "true", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
checked = "true", unchecked = "false")
text(
"gradle_build_task",
"assemble",
label = "Gradle build task to execute during build",
description = "Determines the build task that is executed to build the project.",
display = ParameterDisplay.HIDDEN,
allowEmpty = false
)
}
vcs {
branchFilter = """
+:*
-:1.*
-:<default>
""".trimIndent()
}
})
object PullRequestChecks : BuildType({
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"))
id("MinecraftForge_MinecraftForge__PullRequestChecks")
name = "Pull Requests (Checks)"
description = "Checks pull requests for the project"
steps {
gradle {
name = "Check"
id = "RUNNER_10_Check"
tasks = "checkAll"
gradleParams = "--continue %gradle_custom_args%"
enableStacktrace = true
dockerImage = "%docker_gradle_image%"
dockerRunParameters = """
-v "/opt/cache/agent/gradle:/home/gradle/.gradle"
-v "/opt/cache/shared/gradle:/home/gradle/rocache:ro"
--network=host
-u 1000:1000
%docker_additional_args%
""".trimIndent()
}
}
vcs {
branchFilter = """
+:*
-:1.*
-:<default>
""".trimIndent()
}
})
object PullRequestCompatibility : BuildType({
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"))
id("MinecraftForge_MinecraftForge__PullRequestCompatibility")
name = "Pull Requests (Compatibility)"
description = "Validates binary compatibility for pull requests made to the project"
steps {
gradle {
name = "Validate"
id = "RUNNER_10_Compatibility"
tasks = "checkJarCompatibility"
gradleParams = "--continue %gradle_custom_args%"
enableStacktrace = true
dockerImage = "%docker_gradle_image%"
dockerRunParameters = """
-v "/opt/cache/agent/gradle:/home/gradle/.gradle"
-v "/opt/cache/shared/gradle:/home/gradle/rocache:ro"
--network=host
-u 1000:1000
%docker_additional_args%
""".trimIndent()
}
}
vcs {
branchFilter = """
+:*
-:1.*
-:<default>
""".trimIndent()
}
})
-65
View File
@@ -1,65 +0,0 @@
Minecraft Forge: Credits/Thank You
Forge is a set of tools and modifications to the Minecraft base game code to assist
mod developers in creating new and exciting content. It has been in development for
several years now, but I would like to take this time thank a few people who have
helped it along its way.
First, the people who originally created the Forge projects way back in Minecraft
alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance
of me taking over the project, who knows what Minecraft modding would be today.
Secondly, someone who has worked with me, and developed some of the core features
that allow modding to be as functional, and as simple as it is, cpw. For developing
FML, which stabilized the client and server modding ecosystem. As well as the base
loading system that allows us to modify Minecraft's code as elegently as possible.
Mezz, who has stepped up as the issue and pull request manager. Helping to keep me
sane as well as guiding the community into creating better additions to Forge.
Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which
I am a part}. For creating some of the core tools needed to make Minecraft modding
both possible, and as stable as can be.
On that note, here is some specific information of the MCP data we use:
* Minecraft Coder Pack (MCP) *
Forge Mod Loader and Minecraft Forge have permission to distribute and automatically
download components of MCP and distribute MCP data files. This permission is not
transitive and others wishing to redistribute the Minecraft Forge source independently
should seek permission of MCP or remove the MCP data files and request their users
to download MCP separately.
And lastly, the countless community members who have spent time submitting bug reports,
pull requests, and just helping out the community in general. Thank you.
--LexManos
=========================================================================
This is Forge Mod Loader.
You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml
This minecraft mod is a clean open source implementation of a mod loader for minecraft servers
and minecraft clients.
The code is authored by cpw.
It began by partially implementing an API defined by the client side ModLoader, authored by Risugami.
https://www.minecraftforum.net/topic/75440-
This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader.
It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge.
https://minecraftforge.net/
Additionally, it contains an implementation of topological sort based on that
published at http://keithschwarz.com/interesting/code/?dir=topological-sort
It also contains code from the Maven project for performing versioned dependency
resolution. http://maven.apache.org/
It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/
with credit to it's authors.
Forge Mod Loader downloads components from the Minecraft Coder Pack
(http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team.
+2 -2
View File
@@ -7,8 +7,8 @@ plugins {
id 'net.minecraftforge.gradleutils' version '[2.6.4,2.7)' id 'net.minecraftforge.gradleutils' version '[2.6.4,2.7)'
id 'eclipse' id 'eclipse'
id 'de.undercouch.download' version '5.4.0' id 'de.undercouch.download' version '5.4.0'
id 'net.minecraftforge.gradle.patcher' version '[6.0.22,6.2)' apply false id 'net.minecraftforge.gradle.patcher' version '[6.0.54,6.2)' apply false
id 'net.minecraftforge.gradle.mcp' version '[6.0.22,6.2)' apply false id 'net.minecraftforge.gradle.mcp' version '[6.0.45,6.2)' apply false
id 'net.minecraftforge.gradlejarsigner' version '1.0.4' id 'net.minecraftforge.gradlejarsigner' version '1.0.4'
id 'org.barfuin.gradle.taskinfo' version '2.1.0' id 'org.barfuin.gradle.taskinfo' version '2.1.0'
} }
+3 -3
View File
@@ -4,9 +4,9 @@ repositories {
} }
dependencies { dependencies {
implementation 'org.ow2.asm:asm:9.8' implementation 'org.ow2.asm:asm:9.9.1'
implementation 'org.ow2.asm:asm-tree:9.8' implementation 'org.ow2.asm:asm-tree:9.9.1'
implementation 'net.minecraftforge:srgutils:0.5.10' implementation 'net.minecraftforge:srgutils:0.6.8'
implementation 'commons-io:commons-io:2.13.0' implementation 'commons-io:commons-io:2.13.0'
implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.google.code.gson:gson:2.10.1'
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.7.0.202309050840-r' implementation 'org.eclipse.jgit:org.eclipse.jgit:6.7.0.202309050840-r'
@@ -21,6 +21,8 @@ abstract class BundleList extends DefaultTask {
configure { configure {
dependsOn(project.tasks.universalJar) dependsOn(project.tasks.universalJar)
inputs.file(project.tasks.universalJar.archiveFile) inputs.file(project.tasks.universalJar.archiveFile)
dependsOn(project.tasks.applyServerBinPatches)
inputs.file(project.tasks.applyServerBinPatches.output)
} }
} }
+16 -8
View File
@@ -79,7 +79,6 @@ final String SPEC_VERSION = gitversion.info.tag
final def MCP_ARTIFACT = project(':mcp').mcp.config.get() final def MCP_ARTIFACT = project(':mcp').mcp.config.get()
final List<File> EXTRA_TXTS = [ final List<File> EXTRA_TXTS = [
rootProject.file('CREDITS.txt'),
rootProject.file('LICENSE.txt'), rootProject.file('LICENSE.txt'),
rootProject.tasks.createChangelog.outputFile rootProject.tasks.createChangelog.outputFile
] ]
@@ -415,7 +414,7 @@ tasks.register('extractInheritance', ExtractInheritance) {
} }
tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) { tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) {
jar = createClientOfficial.output jar = createClientOfficial.output
output = rootProject.file('forge-transformers/src/main/resources/coremods/finalize_spawn_targets.json') output = rootProject.file('src/main/resources/coremods/finalize_spawn_targets.json')
predicate = { predicate = {
parent, node, insn -> parent, node, insn ->
return 'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it. return 'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it.
@@ -926,23 +925,31 @@ tasks.register('installerJar', InstallerJar) {
jarSigner.sign(it) jarSigner.sign(it)
} }
final mdkGradleWrapper = tasks.register('mdkGradleWrapper', Wrapper) {
gradleVersion = '9.3.1'
}
tasks.register('mdkZip', Zip) { tasks.register('mdkZip', Zip) {
dependsOn mdkGradleWrapper
archiveBaseName = project.name archiveBaseName = project.name
archiveClassifier = 'mdk' archiveClassifier = 'mdk'
archiveVersion = project.version archiveVersion = project.version
destinationDirectory = file('build/libs') destinationDirectory = file('build/libs')
from rootProject.file('gradlew') from mdkGradleWrapper.map(Wrapper.&getScriptFile)
from rootProject.file('gradlew.bat') from mdkGradleWrapper.map(Wrapper.&getBatchScript)
from(EXTRA_TXTS) from(EXTRA_TXTS)
from(rootProject.file('gradle/')){ into('gradle/wrapper/') {
into('gradle/') from mdkGradleWrapper.map(Wrapper.&getJarFile)
from mdkGradleWrapper.map(Wrapper.&getPropertiesFile)
} }
from(rootProject.file('mdk/')){ from(rootProject.file('mdk/')){
rootProject.file('mdk/gitignore.txt').eachLine{ rootProject.file('mdk/gitignore.txt').eachLine {
if (!it.trim().isEmpty() && !it.trim().startsWith('#')) if (!it.trim().isEmpty() && !it.trim().startsWith('#'))
exclude it exclude it
} }
filter(ReplaceTokens, tokens: [ filter(ReplaceTokens, tokens: [
FORGE_VERSION: FORGE_VERSION, FORGE_VERSION: FORGE_VERSION,
FORGE_GROUP: project.group, FORGE_GROUP: project.group,
@@ -951,7 +958,8 @@ tasks.register('mdkZip', Zip) {
MAPPING_CHANNEL: MAPPING_CHANNEL, MAPPING_CHANNEL: MAPPING_CHANNEL,
MAPPING_VERSION: MAPPING_VERSION, MAPPING_VERSION: MAPPING_VERSION,
FORGE_SPEC_VERSION: SPEC_VERSION.split("\\.")[0], FORGE_SPEC_VERSION: SPEC_VERSION.split("\\.")[0],
MC_NEXT_VERSION: MC_NEXT_VERSION MC_NEXT_VERSION: MC_NEXT_VERSION,
EVENTBUS_VERSION: libs.versions.eventbus.get()
]) ])
rename 'gitignore\\.txt', '.gitignore' rename 'gitignore\\.txt', '.gitignore'
rename 'gitattributes\\.txt', '.gitattributes' rename 'gitattributes\\.txt', '.gitattributes'
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
for file in $(find repo | grep --invert-match -e md5 -e sha | grep -e .jar -e .zip); do
file_path=$(realpath $file)
file_name=$(basename $file)
echo "$file_name"
files=$(unzip -l $file | awk '{print $4}')
for f in $files; do
out="_actual/$file_name/$f"
parent=$(dirname "$out")
echo $out
if [ ! -d "$parent" ]; then
mkdir -p "$parent"
fi
if [[ $f == *.class ]]; then
javap -v -p jar:file://$file_path!/$f | tail -n +4 >$out.txt
elif [[ $f != */ && $f != "Name" && $f != "----" ]]; then
unzip -o -q $file $f -d _actual/$file_name
fi
done
done
@@ -358,7 +358,7 @@ public class ModLoader {
return completedStates.contains(state); return completedStates.contains(state);
} }
public static <T extends IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) { public <T extends IModBusEvent> void runEventGenerator(Function<ModContainer, T> generator) {
if (!loadingStateValid) { if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event generator to a broken mod state"); LOGGER.error("Cowardly refusing to send event generator to a broken mod state");
return; return;
@@ -367,7 +367,8 @@ public class ModLoader {
mod.acceptEvent(generator.apply(mod)); mod.acceptEvent(generator.apply(mod));
} }
public static <T extends IModBusEvent> void postEvent(T e) { public <T extends IModBusEvent> void postEvent(T e) {
var cls = e.getClass();
if (!loadingStateValid) { if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
return; return;
@@ -376,7 +377,7 @@ public class ModLoader {
mod.acceptEvent(e); mod.acceptEvent(e);
} }
public static <T extends IModBusEvent> T postEventWithReturn(T e) { public <T extends IModBusEvent> T postEventWithReturn(T e) {
if (!loadingStateValid) { if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
return e; return e;
@@ -387,14 +388,14 @@ public class ModLoader {
} }
@SuppressWarnings("removal") @SuppressWarnings("removal")
public static <T extends IModBusEvent> void postEventWrapContainerInModOrder(T event) { public <T extends IModBusEvent> void postEventWrapContainerInModOrder(T event) {
postEventWithWrapInModOrder(event, postEventWithWrapInModOrder(event,
(mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(mc),
(mc, e) -> ModLoadingContext.get().setActiveContainer(null) (mc, e) -> ModLoadingContext.get().setActiveContainer(null)
); );
} }
public static <T extends IModBusEvent> void postEventWithWrapInModOrder(T e, BiConsumer<ModContainer, T> pre, BiConsumer<ModContainer, T> post) { public <T extends IModBusEvent> void postEventWithWrapInModOrder(T e, BiConsumer<ModContainer, T> pre, BiConsumer<ModContainer, T> post) {
if (!loadingStateValid) { if (!loadingStateValid) {
LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName()); LOGGER.error("Cowardly refusing to send event {} to a broken mod state", e.getClass().getName());
return; return;
@@ -0,0 +1,131 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.fml.common.asm;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
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.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
/**
* Removes the final modifier from fields with the @ObjectHolder annotation, prevents the JITer from in lining them so our runtime replacements can work.
* Will also de-finalize all fields in on class level annotations.
*/
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.toUnmodifiableMap(VanillaObjectHolderData::holderClass, Function.identity()));
private static final Set<String> VANILLA_OBJECT_HOLDER_CLASSES = VANILLA_OBJECT_HOLDERS.keySet().stream()
.map(it -> it.replace('.', '/'))
.collect(Collectors.toUnmodifiableSet());
private static final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
private static final int PUBLIC_STATIC_FINAL_FLAGS = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
@Override
public String name() {
return "object_holder_definalize";
}
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.AFTER);
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
if (isEmpty)
return NAY;
// Let's skip processing classes that definitely don't have object holders
String internalName = classType.getInternalName();
// Forge classes that aren't in the debug package (that package is used for tests)
if (internalName.startsWith("net/minecraftforge/") && !internalName.substring(18).contains("debug"))
return NAY;
// Vanilla classes that don't have object holders
if (internalName.startsWith("com/mojang/"))
return NAY;
// ...except specific ones we added to the VANILLA_OBJECT_HOLDERS map
if (internalName.startsWith("net/minecraft/") && !VANILLA_OBJECT_HOLDER_CLASSES.contains(internalName))
return NAY;
return YAY;
}
private static boolean hasHolder(List<AnnotationNode> lst) {
return lst != null && lst.stream().anyMatch(n -> n.desc.equals(OBJECT_HOLDER));
}
@SuppressWarnings("unused")
private String getValue(List<AnnotationNode> lst)
{
AnnotationNode ann = lst.stream().filter(n -> n.desc.equals(OBJECT_HOLDER)).findFirst().get();
if (ann.values != null)
{
for (int x = 0; x < ann.values.size() - 1; x += 2) {
if (ann.values.get(x).equals("value")) {
return (String)ann.values.get(x + 1);
}
}
}
return null;
}
@Override
public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason)
{
final AtomicBoolean changes = new AtomicBoolean();
//Must be public static finals, and non-array objects
//Fix Annotated Fields before injecting from class level
classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L") && hasHolder(f.visibleAnnotations)).forEach(f ->
{
int prev = f.access;
f.access &= ~Opcodes.ACC_FINAL; //Strip final
f.access |= Opcodes.ACC_SYNTHETIC; //Add Synthetic so we can check in runtime. ? Good idea?
changes.compareAndSet(false, prev != f.access);
});
if (VANILLA_OBJECT_HOLDERS.containsKey(classType.getClassName())) //Class level, de-finalize all fields and add @ObjectHolder to them!
{
classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L")).forEach(f ->
{
int prev = f.access;
f.access &= ~Opcodes.ACC_FINAL;
f.access |= Opcodes.ACC_SYNTHETIC;
/*if (!hasHolder(f.visibleAnnotations)) //Add field level annotation, doesn't do anything until after we figure out how ASMDataTable is gatherered
{
if (value == null)
f.visitAnnotation(OBJECT_HOLDER, true);
else
f.visitAnnotation(OBJECT_HOLDER, true).visit("value", value + ":" + f.name.toLowerCase());
}*/
changes.compareAndSet(false, prev != f.access);
});
}
return changes.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE;
}
private record VanillaObjectHolderData(String holderClass, String registryName, String registryType) {}
}
@@ -7,9 +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.stream.Collectors;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.LoadingModList; import net.minecraftforge.fml.loading.LoadingModList;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
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;
@@ -58,10 +60,10 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
return NAY; return NAY;
String internalName = classType.getInternalName(); String internalName = classType.getInternalName();
if (internalName.startsWith("net/minecraft/client/model") || internalName.startsWith("net/minecraft/world")) if (internalName.startsWith("net/minecraftforge/") || internalName.startsWith("com/mojang/"))
return YAY; return NAY;
return NAY; return YAY;
} }
@Override @Override
@@ -73,6 +75,11 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName()))
return ComputeFlags.NO_REWRITE; return ComputeFlags.NO_REWRITE;
if (!classNode.name.startsWith("net/minecraft/")) {
LOGGER.warn("IExtensibleEnum found on non-Minecraft class: {}", classType.getClassName());
LOGGER.warn("This behaviour is deprecated for removal and will have no effect in a future MC release. Please use a record with static final field instances instead.");
}
Type array = Type.getType("[" + classType.getDescriptor()); Type array = Type.getType("[" + classType.getDescriptor());
String arrayDesc = array.getDescriptor(); String arrayDesc = array.getDescriptor();
@@ -174,7 +174,7 @@ public class FMLLoader {
} }
public static void addAccessTransformer(Path atPath, ModFile modName) { public static void addAccessTransformer(Path atPath, ModFile modName) {
LOGGER.debug(SCAN, "Adding Access Transformer in {}", modName.getFilePath()); LOGGER.debug(SCAN, "Adding Access Transformer {} in {}", atPath, modName.getFilePath());
accessTransformer.offerResource(atPath, modName.getFileName()); accessTransformer.offerResource(atPath, modName.getFileName());
} }
@@ -5,11 +5,13 @@
package net.minecraftforge.fml.loading; package net.minecraftforge.fml.loading;
import com.mojang.logging.LogUtils;
import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler; import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler;
import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModFile;
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModFile;
import org.slf4j.Logger;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -24,6 +26,7 @@ import java.util.stream.Collectors;
* loading package</em> * loading package</em>
*/ */
public class LoadingModList { public class LoadingModList {
private static final Logger LOGGER = LogUtils.getLogger();
private static LoadingModList INSTANCE; private static LoadingModList INSTANCE;
private final List<ModFileInfo> modFiles; private final List<ModFileInfo> modFiles;
private final List<ModInfo> sortedList; private final List<ModInfo> sortedList;
@@ -67,13 +70,22 @@ public class LoadingModList {
} }
public void addAccessTransformers() { public void addAccessTransformers() {
var errors = new ArrayList<EarlyLoadingException.ExceptionData>();
for (ModFileInfo modFile : modFiles) { for (ModFileInfo modFile : modFiles) {
ModFile mod = modFile.getFile(); ModFile mod = modFile.getFile();
var at = mod.getAccessTransformer().orElse(null); for (Path at : mod.getAccessTransformers()) {
if (at != null) { if (!Files.exists(at)) {
FMLLoader.addAccessTransformer(at, mod); var message = "Invalid mod file: " + modFile.getFile().getFileName() + ". Missing Access Transformer: " + at;
errors.add(new EarlyLoadingException.ExceptionData(message));
LOGGER.error(message);
} else {
FMLLoader.addAccessTransformer(at, mod);
}
} }
} }
if (!errors.isEmpty()) {
preLoadErrors.add(new EarlyLoadingException("Invalid Access Transformers", null, errors));
}
} }
public void addForScanning(BackgroundScanHandler backgroundScanHandler) { public void addForScanning(BackgroundScanHandler backgroundScanHandler) {
@@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.Marker; import org.slf4j.Marker;
import org.slf4j.MarkerFactory; import org.slf4j.MarkerFactory;
public class RuntimeDistCleaner implements ILaunchPluginService { public final class RuntimeDistCleaner implements ILaunchPluginService {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final Marker DISTXFORM = MarkerFactory.getMarker("DISTXFORM"); private static final Marker DISTXFORM = MarkerFactory.getMarker("DISTXFORM");
private static String DIST; private static String DIST;
@@ -52,6 +52,10 @@ public class RuntimeDistCleaner implements ILaunchPluginService {
if (internalName.startsWith("net/minecraftforge/")) if (internalName.startsWith("net/minecraftforge/"))
return NAY; return NAY;
// No Vanilla classes use @OnlyIn(Dist.SERVER), so we can skip them entirely when we're running on a client
if (FMLEnvironment.dist.isClient() && (internalName.startsWith("net/minecraft/") || internalName.startsWith("com/mojang/")))
return NAY;
return YAY; return YAY;
} }
@@ -50,6 +50,7 @@ public class ModFile implements IModFile {
private CompletableFuture<ModFileScanData> futureScanResult; private CompletableFuture<ModFileScanData> futureScanResult;
private List<CoreModFile> coreMods; private List<CoreModFile> coreMods;
private Path accessTransformer; private Path accessTransformer;
private List<Path> accessTransformers = Collections.emptyList();
static final Attributes.Name TYPE = new Attributes.Name("FMLModType"); static final Attributes.Name TYPE = new Attributes.Name("FMLModType");
private SecureJar.Status securityStatus; private SecureJar.Status securityStatus;
@@ -92,8 +93,14 @@ public class ModFile implements IModFile {
return modFileInfo.getMods(); return modFileInfo.getMods();
} }
/** @deprecated Use {@link #getAccessTransformers()} instead*/
@Deprecated(forRemoval=true, since="1.21.11")
public Optional<Path> getAccessTransformer() { public Optional<Path> getAccessTransformer() {
return Optional.ofNullable(Files.exists(accessTransformer) ? accessTransformer : null); return Optional.ofNullable(accessTransformer);
}
public List<Path> getAccessTransformers() {
return accessTransformers;
} }
public boolean identifyMods() { public boolean identifyMods() {
@@ -104,7 +111,28 @@ public class ModFile implements IModFile {
LOGGER.warn("Mod file {} contains javascript coremods! JS CoreMods are deprecated and will be removed in a future release. Consider using Mixin or ModLauncher transformers.", this.getFileName()); LOGGER.warn("Mod file {} contains javascript coremods! JS CoreMods are deprecated and will be removed in a future release. Consider using Mixin or ModLauncher transformers.", this.getFileName());
for (var mi : this.coreMods) for (var mi : this.coreMods)
LOGGER.debug(LogMarkers.LOADING, "Found coremod {}", mi.getPath()); LOGGER.debug(LogMarkers.LOADING, "Found coremod {}", mi.getPath());
this.accessTransformer = findResource("META-INF", "accesstransformer.cfg"); List<String> cfg;
// Note: Some mods may have invalid tomls copied from other projects.
// Unfortunately we must protect against those landmines.
try {
cfg = this.modFileInfo.getConfig().<List<String>>getConfigElement("accessTransformers").orElse(null);
} catch (Exception e) {
cfg = null;
LOGGER.warn("{} contains an invalid 'accessTransformers' TOML entry. Should be e.g. accessTransformers = [\"META-INF/accesstransformer.cfg\", \"META-INF/extra_at.cfg\"] or accessTransformers = [] for no ATs. Falling back to default.", this.getFileName());
}
if (cfg == null) {
var path = findResource("META-INF", "accesstransformer.cfg");
if (Files.exists(path)) {
this.accessTransformer = path;
this.accessTransformers = List.of(path);
}
} else if (!cfg.isEmpty()) {
var paths = new ArrayList<Path>(cfg.size());
for (var path : cfg) {
paths.add(getSecureJar().getPath(path.replace("\\","/")));
}
this.accessTransformers = List.copyOf(paths);
}
return true; return true;
} }
@@ -6,6 +6,7 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.electronwill.nightconfig.core.file.FileConfig; import com.electronwill.nightconfig.core.file.FileConfig;
import com.electronwill.nightconfig.core.io.ParsingException;
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 com.mojang.logging.LogUtils;
@@ -13,6 +14,7 @@ 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 net.minecraftforge.forgespi.locating.ModFileLoadingException;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -31,6 +33,7 @@ public class ModFileParser {
return parser.build(modFile); return parser.build(modFile);
} }
// Note: Although @Nullable, several other places in FML assume ModFileInfo is not null. Keep this in mind
public static @Nullable IModFileInfo modsTomlParser(final IModFile imodFile) { public static @Nullable IModFileInfo modsTomlParser(final IModFile imodFile) {
ModFile modFile = (ModFile) imodFile; ModFile modFile = (ModFile) imodFile;
LOGGER.debug(LogMarkers.LOADING,"Considering mod file candidate {}", modFile.getFilePath()); LOGGER.debug(LogMarkers.LOADING,"Considering mod file candidate {}", modFile.getFilePath());
@@ -41,10 +44,15 @@ public class ModFileParser {
} }
final FileConfig fileConfig = FileConfig.builder(modsjson).build(); final FileConfig fileConfig = FileConfig.builder(modsjson).build();
fileConfig.load(); try {
fileConfig.close(); fileConfig.load();
final NightConfigWrapper configWrapper = new NightConfigWrapper(fileConfig); fileConfig.close();
return new ModFileInfo(modFile, configWrapper, configWrapper::setFile); final NightConfigWrapper configWrapper = new NightConfigWrapper(fileConfig);
return new ModFileInfo(modFile, configWrapper, configWrapper::setFile);
} catch (ParsingException e) {
LOGGER.error("Mod candidate {} contains a corrupt or misconfigured toml.", modFile.getFileName());
throw new ModFileLoadingException("Mod candidate " + modFile.getFileName() + " contains a corrupt or misconfigured toml.");
}
} }
protected static List<CoreModFile> getCoreMods(final ModFile modFile) { protected static List<CoreModFile> getCoreMods(final ModFile modFile) {
@@ -1,4 +1,5 @@
net.minecraftforge.fml.loading.log4j.SLF4JFixerLaunchPluginService net.minecraftforge.fml.loading.log4j.SLF4JFixerLaunchPluginService
net.minecraftforge.fml.loading.RuntimeDistCleaner net.minecraftforge.fml.loading.RuntimeDistCleaner
net.minecraftforge.fml.common.asm.RuntimeEnumExtender net.minecraftforge.fml.common.asm.RuntimeEnumExtender
net.minecraftforge.fml.common.asm.ObjectHolderDefinalize
net.minecraftforge.fml.common.asm.CapabilityTokenSubclass net.minecraftforge.fml.common.asm.CapabilityTokenSubclass
@@ -107,7 +107,7 @@
{ {
"class": "net/minecraft/world/level/levelgen/PhantomSpawner", "class": "net/minecraft/world/level/levelgen/PhantomSpawner",
"methods": [ "methods": [
"tick(Lnet/minecraft/server/level/ServerLevel;Z)V" "tick(Lnet/minecraft/server/level/ServerLevel;ZZ)V"
] ]
}, },
{ {
+3 -3
View File
@@ -5,11 +5,11 @@ org.gradle.daemon=false
org.gradle.parallel=true org.gradle.parallel=true
JAVA_VERSION=21 JAVA_VERSION=21
MC_VERSION=1.21.10 MC_VERSION=1.21.8
MC_NEXT_VERSION=1.22 MC_NEXT_VERSION=1.22
MCP_VERSION=20251007.101210 MCP_VERSION=20250717.105350
MAPPING_CHANNEL=official MAPPING_CHANNEL=official
MAPPING_VERSION=1.21.10 MAPPING_VERSION=1.21.8
# Set to true before the first build of a new MC version, so we don't do compatibility checks # Set to true before the first build of a new MC version, so we don't do compatibility checks
CHECK_COMPATIBILITY=false CHECK_COMPATIBILITY=false
@@ -48,7 +48,7 @@ import java.util.stream.Collectors;
* annotations and passes the class instances to the {@link Bus} * annotations and passes the class instances to the {@link Bus}
* defined by the annotation. Defaults to {@code MinecraftForge#EVENT_BUS} * defined by the annotation. Defaults to {@code MinecraftForge#EVENT_BUS}
*/ */
public final class AutomaticEventSubscriber { public class AutomaticEventSubscriber {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
private static final Type AUTO_SUBSCRIBER = Type.getType(EventBusSubscriber.class); private static final Type AUTO_SUBSCRIBER = Type.getType(EventBusSubscriber.class);
private static final Type MOD_TYPE = Type.getType(Mod.class); private static final Type MOD_TYPE = Type.getType(Mod.class);
@@ -43,7 +43,7 @@ public class FMLModContainer extends ModContainer {
LOGGER.debug(LOADING,"Creating FMLModContainer instance for {}", className); LOGGER.debug(LOADING,"Creating FMLModContainer instance for {}", className);
this.scanResults = modFileScanResults; this.scanResults = modFileScanResults;
activityMap.put(ModLoadingStage.CONSTRUCT, this::constructMod); activityMap.put(ModLoadingStage.CONSTRUCT, this::constructMod);
this.eventBusGroup = BusGroup.create("modBusFor" + info.getModId(), IModBusEvent.class); this.eventBusGroup = BusGroup.create("modBusFor" + info.getModId());
this.contextExtension = () -> context; this.contextExtension = () -> context;
try { try {
var moduleName = info.getOwningFile().moduleName(); var moduleName = info.getOwningFile().moduleName();
+30 -201
View File
@@ -1,235 +1,64 @@
// This is a minimal setup of a Forge mod workspace.
// For complex examples (including AccessTransformers, Jar-in-Jar, and Mixin), see our examples repository.
// https://github.com/MinecraftForge/MDKExamples
plugins { plugins {
id 'eclipse' id 'java'
id 'idea' id 'idea'
id 'maven-publish' id 'eclipse'
id 'net.minecraftforge.gradle' version '[6.0.36,6.2)' id 'net.minecraftforge.gradle' version '[7.0.3,8)'
} }
version = mod_version version = '1.0.0'
group = mod_group_id group = 'com.example.examplemod'
base {
archivesName = mod_id
}
// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21. // Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
java.toolchain.languageVersion = JavaLanguageVersion.of(21) java.toolchain.languageVersion = JavaLanguageVersion.of(21)
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" // Include generated resources
sourceSets.main.resources { srcDir 'src/generated/resources' }
minecraft { minecraft {
// The mappings can be changed at any time and must be in the following format. mappings channel: 'official', version: '@MC_VERSION@'
// Channel: Version:
// official MCVersion Official field/method names from Mojang mapping files
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
//
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
//
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: mapping_channel, version: mapping_version
// Forge 1.20.6 and newer use official mappings at runtime, so we shouldn't reobf from official to SRG
reobf = false
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
// In most cases, it is not necessary to enable.
// enableEclipsePrepareRuns = true
// enableIdeaPrepareRuns = true
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
// The folder name can be set on a run configuration using the "folderName" property.
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
// generateRunFolders = true
// This property enables access transformers for use in development, applied to the Minecraft artifact.
// The access transformer file can be anywhere in the project.
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
// This default location is a best practice to automatically put the file in the right place in the final jar.
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs { runs {
// applies to all the run configs below
configureEach { configureEach {
workingDirectory project.file('run') workingDir = layout.projectDirectory.dir('run')
// Optional additional logging. The markers can be added/remove as needed, separated by commas. systemProperty 'eventbus.api.strictRuntimeChecks', 'true'
// "SCAN": For mods scan. systemProperty 'forge.enabledGameTestNamespaces', 'examplemod'
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
// property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
// Recommended for development - enables more descriptive errors at the cost of slower startup and registration.
property 'eventbus.api.strictRuntimeChecks', 'true'
// arg "-mixin.config=${mod_id}.mixins.json"
} }
client { register('client')
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', mod_id
}
server { register('server') {
property 'forge.enabledGameTestNamespaces', mod_id
args '--nogui' args '--nogui'
} }
// This run config launches GameTestServer and runs all registered gametests, then exits. register('gameTestServer')
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
property 'forge.enabledGameTestNamespaces', mod_id
}
data { register('data') {
// example of overriding the workingDirectory set in configureEach above workingDir = layout.projectDirectory.dir('run-data')
workingDirectory project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. args '--mod', 'examplemod', '--all', '--output', layout.projectDirectory.dir('src/generated/resources'), '--existing', layout.projectDirectory.dir('src/main/resources')
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
} }
} }
} }
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories { repositories {
// Put repositories for dependencies here minecraft.mavenizer(it) // In Kotlin, it = this
maven fg.forgeMaven
maven fg.minecraftLibsMaven
mavenCentral() mavenCentral()
maven {
name = 'Forge'
url = 'https://maven.minecraftforge.net'
}
maven {
name = 'Minecraft libraries'
url = 'https://libraries.minecraft.net'
}
exclusiveContent {
forRepository {
maven {
name = 'Sponge'
url = 'https://repo.spongepowered.org/repository/maven-public'
}
}
filter {
includeGroupAndSubgroups('org.spongepowered')
}
}
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
// flatDir {
// dir 'libs'
// }
} }
dependencies { dependencies {
// Specify the version of Minecraft to use. implementation minecraft.dependency('net.minecraftforge:forge:@MC_VERSION@-@FORGE_VERSION@')
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact. annotationProcessor 'net.minecraftforge:eventbus-validator:@EVENTBUS_VERSION@'
// The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// Forge 1.21.6+ uses EventBus 7, which shifts most of its runtime validation to compile-time via an annotation processor
// to improve performance in production environments. This line is required to enable said compile-time validation
// in your development environment, helping you catch issues early.
annotationProcessor 'net.minecraftforge:eventbus-validator:7.0-beta.12'
// Example mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources) {
var replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}
// Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar) {
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : mod_authors,
'Specification-Version' : '1', // We are version 1 of ourselves
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors
])
// attributes['MixinConfigs'] = "${mod_id}.mixins.json"
}
}
// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
register('mavenJava', MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
}
}
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation // Use the UTF-8 charset for Java compilation
} // This is done by default in Java 18+, but this ensures it no matter the Java or Gradle version
options.encoding = 'UTF-8'
// IntelliJ no longer downloads javadocs and sources by default, this tells Gradle to force IntelliJ to do it.
idea.module { downloadJavadoc = downloadSources = true }
eclipse {
// Run everytime eclipse builds the code
//autoBuildTasks genEclipseRuns
// Run when importing the project
synchronizationTasks 'genEclipseRuns'
}
// Merge the resources and classes into the same directory, because Java expects modules to be in a single directory.
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
sourceSets.each {
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
it.output.resourcesDir = dir
it.java.destinationDirectory = dir
} }
+4 -14
View File
@@ -1,13 +1,11 @@
Source installation information for modders Source installation information for modders
------------------------------------------- -------------------------------------------
This code follows the Minecraft Forge installation methodology. It will apply This code follows the Minecraft Forge installation methodology. It will apply
some small patches to the vanilla MCP source code, giving you and it access some small patches to the vanilla MCP source code, giving you and it access
to some of the data and functions you need to build a successful mod. to some of the data and functions you need to build a successful mod.
Note also that the patches are built against "un-renamed" MCP source code (aka Please note that this example MDK is a simple showcase for the most basic of mods.
SRG Names) - this means that you will not be able to read them directly against To see more examples see our dedicated examples repository under the "Additional Resources" section.
normal code.
Setup Process: Setup Process:
============================== ==============================
@@ -23,24 +21,16 @@ If you prefer to use Eclipse:
If you prefer to use IntelliJ: If you prefer to use IntelliJ:
1. Open IDEA, and import project. 1. Open IDEA, and import project.
2. Select your build.gradle file and have it import. 2. Select your build.gradle file and have it import.
3. Run the following command: `./gradlew genIntellijRuns` 3. Use the run tasks located under the "Slime Launcher" Gradle task group.
4. Refresh the Gradle Project in IDEA if required.
If at any point you are missing libraries in your IDE, or you've run into problems you can If at any point you are missing libraries in your IDE, or you've run into problems you can
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
(this does not affect your code) and then start the process again. (this does not affect your code) and then start the process again.
Mapping Names:
=============================
By default, the MDK is configured to use the official mapping names from Mojang for methods and fields
in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this
license, if you do not agree with it you can change your mapping names to other crowdsourced names in your
build.gradle. For the latest license text, refer to the mapping file itself, or the reference copy here:
https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
Additional Resources: Additional Resources:
========================= =========================
Community Documentation: https://docs.minecraftforge.net/en/latest/gettingstarted/ Community Documentation: https://docs.minecraftforge.net/en/latest/gettingstarted/
Additional Examples: https://github.com/MinecraftForge/MDKExamples
LexManos' Install Video: https://youtu.be/8VEdtQLuLO0 LexManos' Install Video: https://youtu.be/8VEdtQLuLO0
Forge Forums: https://forums.minecraftforge.net/ Forge Forums: https://forums.minecraftforge.net/
Forge Discord: https://discord.minecraftforge.net/ Forge Discord: https://discord.minecraftforge.net/
+1
View File
@@ -22,4 +22,5 @@ eclipse
run run
# Files from Forge MDK # Files from Forge MDK
forge_README.txt
forge*changelog.txt forge*changelog.txt
+7 -64
View File
@@ -1,66 +1,9 @@
# Sets default memory used for Gradle commands. Can be overridden by user or command line properties. org.gradle.caching=true
# This is required to provide enough memory for the Minecraft decompilation process. org.gradle.parallel=true
org.gradle.jvmargs=-Xmx5G org.gradle.configureondemand=true
org.gradle.daemon=false
# In the case that Gradle needs to fork to recompile, this will set the memory for that process. org.gradle.configuration-cache=true
systemProp.net.minecraftforge.gradle.repo.recompile.fork=true org.gradle.configuration-cache.parallel=true
systemProp.net.minecraftforge.gradle.repo.recompile.fork.args=-Xmx5G org.gradle.configuration-cache.problems=warn
# Opts-out of ForgeGradle automatically adding mavenCentral(), Forge's maven and MC libs maven to the repositories block net.minecraftforge.gradle.merge-source-sets=true
systemProp.net.minecraftforge.gradle.repo.attach=false
## Environment Properties
# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=@MC_VERSION@
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[@MC_VERSION@,@MC_NEXT_VERSION@)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=@FORGE_VERSION@
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[@FORGE_SPEC_VERSION@,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[@FORGE_SPEC_VERSION@,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
#
# | Channel | Version | |
# |-----------|----------------------|--------------------------------------------------------------------------------|
# | official | MCVersion | Official field/method names from Mojang mapping files |
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
#
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
#
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
mapping_channel=@MAPPING_CHANNEL@
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=@MAPPING_VERSION@
## Mod Properties
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=examplemod
# The human-readable display name for the mod.
mod_name=Example Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=1.0.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=com.example.examplemod
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=YourNameHere, OtherNameHere
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.
+3 -11
View File
@@ -1,13 +1,5 @@
pluginManagement { plugins {
repositories { id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
gradlePluginPortal()
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
}
} }
plugins { rootProject.name = 'examplemod'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0'
}
+36 -66
View File
@@ -1,73 +1,43 @@
# This is an example mods.toml file. It contains the data relating to the loading mods. # See https://docs.minecraftforge.net/en/1.21.x/gettingstarted/modfiles/#modstoml
# There are several mandatory fields (#mandatory), and many more that are optional (#optional). # There are lots of things you can do with the mods.toml, and not all fields are included with this MDK
# The overall format is standard TOML format, v0.5.0. # References: https://github.com/MinecraftForge/MDKExamples
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="${mod_license}"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN),
# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers.
#clientSideOnly=true #optional - defaults to false if absent
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="${mod_id}" #mandatory
# The version number of the mod
version="${mod_version}" #mandatory
# A display name for the mod
displayName="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="examplemod.png" #optional
# A text field displayed in the mod UI
#credits="" #optional
# A text field displayed in the mod UI
authors="${mod_authors}" #optional
# Display Test controls the display for your mod in the server connection screen
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
#displayTest="MATCH_VERSION" # if nothing is specified, MATCH_VERSION is the default when clientSideOnly=false, otherwise IGNORE_ALL_VERSION when clientSideOnly=true (#optional)
# The description text for the mod (multi line!) (#mandatory) modLoader="javafml"
description='''${mod_description}''' loaderVersion="[@FORGE_SPEC_VERSION@,)"
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. license="All Rights Reserved"
[[dependencies.${mod_id}]] #optional #issueTrackerURL="https://github.com/MyOrganization/MyMod/" #optional
# the modid of the dependency #clientSideOnly=true #optional, default=false
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified [[mods]]
mandatory=true #mandatory modId="examplemod"
# The version range of the dependency version="1.0.0"
versionRange="${forge_version_range}" #mandatory displayName="Example Mod"
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory #updateJSONURL="https://example.com/updates.json" #optional
# BEFORE - This mod is loaded BEFORE the dependency #displayURL="https://example.com/" #optional
# AFTER - This mod is loaded AFTER the dependency #logoFile="examplemod.png" #optional
#credits="" #optional
authors="YourNameHere, OtherNameHere" #optional
#displayTest="MATCH_VERSION" #optional, default=MATCH_VERSION when not clientSideOnly, else IGNORE_ALL_VERSION
# Access Transformers
# Optional, if not specified Forge will attempt to find the default META-INF/accesstransformer.cfg and silently continue if not found. May default to an empty list in a future MC.
# If you specify AT path strings in this list, Forge will attempt to load each of them and throw errors for any that aren't found.
# Specifying an empty list when your mod has no ATs is recommended to opt-out of the default for slightly better loading performance.
#accessTransformers = []
description='''Example mod description.
Newline characters can be used like this, and rendered on the mods screen properly.'''
[[dependencies.examplemod]] #recommended
modId="forge"
mandatory=true
versionRange="[@FORGE_SPEC_VERSION@,)"
ordering="NONE" ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side="BOTH" side="BOTH"
# Here's another dependency
[[dependencies.${mod_id}]] [[dependencies.examplemod]] #recommended
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version versionRange="[@MC_VERSION@,@MC_NEXT_VERSION@,)"
versionRange="${minecraft_version_range}"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.
#[features.${mod_id}]
#openGLVersion="[3.2,)"
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java --- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java
+++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java +++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java
@@ -131,6 +_,9 @@ @@ -132,6 +_,9 @@
GlStateManager._colorMask(true, true, true, true); GlStateManager._colorMask(true, true, true, true);
GlStateManager._clear(16384); GlStateManager._clear(16384);
GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0); GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0);
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlDevice.java --- a/com/mojang/blaze3d/opengl/GlDevice.java
+++ b/com/mojang/blaze3d/opengl/GlDevice.java +++ b/com/mojang/blaze3d/opengl/GlDevice.java
@@ -90,8 +_,15 @@ @@ -89,8 +_,15 @@
public GpuTexture createTexture( public GpuTexture createTexture(
@Nullable Supplier<String> p_397830_, int p_394481_, TextureFormat p_394839_, int p_391831_, int p_395609_, int p_407582_, int p_408928_ @Nullable Supplier<String> p_397830_, int p_394481_, TextureFormat p_394839_, int p_391831_, int p_395609_, int p_407582_, int p_408928_
) { ) {
@@ -17,7 +17,7 @@
); );
} }
@@ -99,6 +_,15 @@ @@ -98,6 +_,15 @@
public GpuTexture createTexture( public GpuTexture createTexture(
@Nullable String p_394142_, int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_ @Nullable String p_394142_, int p_395535_, TextureFormat p_394951_, int p_393944_, int p_392329_, int p_408015_, int p_406483_
) { ) {
@@ -33,7 +33,7 @@
if (p_406483_ < 1) { if (p_406483_ < 1) {
throw new IllegalArgumentException("mipLevels must be at least 1"); throw new IllegalArgumentException("mipLevels must be at least 1");
} else if (p_408015_ < 1) { } else if (p_408015_ < 1) {
@@ -149,11 +_,14 @@ @@ -148,11 +_,14 @@
GlStateManager._texImage2D( GlStateManager._texImage2D(
k, k,
l, l,
@@ -48,7 +48,7 @@
GlConst.toGlType(p_394951_), GlConst.toGlType(p_394951_),
null null
); );
@@ -164,11 +_,14 @@ @@ -163,11 +_,14 @@
GlStateManager._texImage2D( GlStateManager._texImage2D(
j, j,
i1, i1,
@@ -63,7 +63,7 @@
GlConst.toGlType(p_394951_), GlConst.toGlType(p_394951_),
null null
); );
@@ -181,7 +_,7 @@ @@ -180,7 +_,7 @@
} else if (j1 != 0) { } else if (j1 != 0) {
throw new IllegalStateException("OpenGL error " + j1); throw new IllegalStateException("OpenGL error " + j1);
} else { } else {
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/opengl/GlStateManager.java --- a/com/mojang/blaze3d/opengl/GlStateManager.java
+++ b/com/mojang/blaze3d/opengl/GlStateManager.java +++ b/com/mojang/blaze3d/opengl/GlStateManager.java
@@ -85,6 +_,11 @@ @@ -89,6 +_,11 @@
} }
} }
@@ -12,7 +12,7 @@
public static void _disableBlend() { public static void _disableBlend() {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
BLEND.mode.disable(); BLEND.mode.disable();
@@ -371,9 +_,17 @@ @@ -404,9 +_,17 @@
} }
} }
@@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/pipeline/RenderTarget.java --- a/com/mojang/blaze3d/pipeline/RenderTarget.java
+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java
@@ -86,7 +_,7 @@ @@ -92,7 +_,7 @@
this.width = p_83951_; this.width = p_83951_;
this.height = p_83952_; this.height = p_83952_;
if (this.useDepth) { if (this.useDepth) {
@@ -9,7 +9,7 @@
this.depthTextureView = gpudevice.createTextureView(this.depthTexture); this.depthTextureView = gpudevice.createTextureView(this.depthTexture);
this.depthTexture.setTextureFilter(FilterMode.NEAREST, false); this.depthTexture.setTextureFilter(FilterMode.NEAREST, false);
this.depthTexture.setAddressMode(AddressMode.CLAMP_TO_EDGE); this.depthTexture.setAddressMode(AddressMode.CLAMP_TO_EDGE);
@@ -155,5 +_,26 @@ @@ -166,5 +_,26 @@
@Nullable @Nullable
public GpuTextureView getDepthTextureView() { public GpuTextureView getDepthTextureView() {
return this.depthTextureView; return this.depthTextureView;
@@ -25,7 +25,7 @@
+ public void enableStencil() { + public void enableStencil() {
+ if (stencilEnabled) return; + if (stencilEnabled) return;
+ stencilEnabled = true; + stencilEnabled = true;
+ this.resize(width, height); + this.resize(viewWidth, viewHeight);
+ } + }
+ +
+ /** + /**
@@ -1,16 +1,16 @@
--- 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
@@ -91,7 +_,8 @@ @@ -88,7 +_,8 @@
GLFW.glfwWindowHint(139267, 3); GLFW.glfwWindowHint(139267, 2);
GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139272, 204801);
GLFW.glfwWindowHint(139270, 1); GLFW.glfwWindowHint(139270, 1);
- this.handle = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L); - this.window = GLFW.glfwCreateWindow(this.width, this.height, p_85376_, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, 0L);
+ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L); + this.window = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(()->this.width, ()->this.height, ()->p_85376_, ()->this.fullscreen && monitor != null ? monitor.getMonitor() : 0L);
+ if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(monitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) { + if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(monitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) {
if (monitor != null) { if (monitor != null) {
VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2; this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2;
@@ -103,6 +_,7 @@ @@ -100,6 +_,7 @@
this.windowedX = this.x = aint1[0]; this.windowedX = this.x = aint1[0];
this.windowedY = this.y = aint[0]; this.windowedY = this.y = aint[0];
} }
@@ -18,8 +18,8 @@
this.setMode(); this.setMode();
this.refreshFramebufferSize(); this.refreshFramebufferSize();
@@ -269,6 +_,9 @@ @@ -266,6 +_,9 @@
GLFW.glfwGetFramebufferSize(this.handle, aint, aint1); GLFW.glfwGetFramebufferSize(this.window, aint, aint1);
this.framebufferWidth = aint[0] > 0 ? aint[0] : 1; this.framebufferWidth = aint[0] > 0 ? aint[0] : 1;
this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1; this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1;
+ if (this.framebufferHeight == 0 || this.framebufferWidth == 0) { + if (this.framebufferHeight == 0 || this.framebufferWidth == 0) {
@@ -9,7 +9,7 @@
VertexConsumer addVertex(float p_344294_, float p_342213_, float p_344859_); VertexConsumer addVertex(float p_344294_, float p_342213_, float p_344859_);
VertexConsumer setColor(int p_342749_, int p_344324_, int p_343336_, int p_342831_); VertexConsumer setColor(int p_342749_, int p_344324_, int p_343336_, int p_342831_);
@@ -131,9 +_,11 @@ @@ -135,9 +_,11 @@
int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5); int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5);
int k1 = LightTexture.lightCoordsWithEmission(p_331444_[i1], l); int k1 = LightTexture.lightCoordsWithEmission(p_331444_[i1], l);
@@ -1,15 +1,15 @@
--- 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
@@ -20,7 +_,7 @@ @@ -21,7 +_,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@DontObfuscate @DontObfuscate
-public class VertexFormat { -public class VertexFormat {
+public class VertexFormat implements net.minecraftforge.client.extensions.IForgeVertexFormat { +public class VertexFormat implements net.minecraftforge.client.extensions.IForgeVertexFormat {
public static final int UNKNOWN_ELEMENT = -1; public static final int UNKNOWN_ELEMENT = -1;
private final List<VertexFormatElement> elements; private static final boolean USE_STAGING_BUFFER_WORKAROUND = Util.getPlatform() == Util.OS.WINDOWS && Util.isAarch64();
private final List<String> names; @Nullable
@@ -31,6 +_,7 @@ @@ -35,6 +_,7 @@
private GpuBuffer immediateDrawVertexBuffer; private GpuBuffer immediateDrawVertexBuffer;
@Nullable @Nullable
private GpuBuffer immediateDrawIndexBuffer; private GpuBuffer immediateDrawIndexBuffer;
@@ -17,7 +17,7 @@
VertexFormat(List<VertexFormatElement> p_343616_, List<String> p_345241_, IntList p_345522_, int p_344162_) { VertexFormat(List<VertexFormatElement> p_343616_, List<String> p_345241_, IntList p_345522_, int p_344162_) {
this.elements = p_343616_; this.elements = p_343616_;
@@ -43,6 +_,11 @@ @@ -47,6 +_,11 @@
int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1; int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1;
this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1; this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1;
} }
@@ -29,8 +29,8 @@
} }
public static VertexFormat.Builder builder() { public static VertexFormat.Builder builder() {
@@ -141,6 +_,9 @@ @@ -169,6 +_,9 @@
this.immediateDrawIndexBuffer = uploadToBuffer(this.immediateDrawIndexBuffer, p_391835_, 72, () -> "Immediate index buffer for " + this); );
return this.immediateDrawIndexBuffer; return this.immediateDrawIndexBuffer;
} }
+ +
@@ -4,12 +4,12 @@
} }
@Override @Override
+ public boolean keyPressed(net.minecraft.client.input.KeyEvent event) { + public boolean keyPressed(int key, int scanCode, int modifiers) {
+ if (event.key() == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { + if (key == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) {
+ minecraft.setScreen(this.nextScreen); + minecraft.setScreen(this.nextScreen);
+ return true; + return true;
+ } + }
+ return super.keyPressed(event); + return super.keyPressed(key, scanCode, modifiers);
+ } + }
+ +
+ @Override + @Override
@@ -1,6 +1,6 @@
--- a/net/minecraft/CrashReportCategory.java --- a/net/minecraft/CrashReportCategory.java
+++ b/net/minecraft/CrashReportCategory.java +++ b/net/minecraft/CrashReportCategory.java
@@ -116,8 +_,10 @@ @@ -112,8 +_,10 @@
if (astacktraceelement.length <= 0) { if (astacktraceelement.length <= 0) {
return 0; return 0;
} else { } else {
@@ -13,7 +13,7 @@
return this.stackTrace.length; return this.stackTrace.length;
} }
} }
@@ -164,16 +_,16 @@ @@ -160,16 +_,16 @@
if (this.stackTrace != null && this.stackTrace.length > 0) { if (this.stackTrace != null && this.stackTrace.length > 0) {
p_128169_.append("\nStacktrace:"); p_128169_.append("\nStacktrace:");
@@ -1,10 +1,10 @@
--- a/net/minecraft/SharedConstants.java --- a/net/minecraft/SharedConstants.java
+++ b/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java
@@ -224,6 +_,7 @@ @@ -175,6 +_,7 @@
} }
static { static {
+ if (System.getProperty("io.netty.leakDetection.level") == null) // Forge: allow level to be manually specified + if (System.getProperty("io.netty.leakDetection.level") == null) // Forge: allow level to be manually specified
ResourceLeakDetector.setLevel(NETTY_LEAK_DETECTION); ResourceLeakDetector.setLevel(NETTY_LEAK_DETECTION);
CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = COMMAND_STACK_TRACES; CommandSyntaxException.ENABLE_COMMAND_STACK_TRACES = false;
CommandSyntaxException.BUILT_IN_EXCEPTIONS = new BrigadierExceptions(); CommandSyntaxException.BUILT_IN_EXCEPTIONS = new BrigadierExceptions();
@@ -1,6 +1,6 @@
--- a/net/minecraft/Util.java --- a/net/minecraft/Util.java
+++ b/net/minecraft/Util.java +++ b/net/minecraft/Util.java
@@ -266,7 +_,7 @@ @@ -268,7 +_,7 @@
.getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().dataVersion().version())) .getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().dataVersion().version()))
.getChoiceType(p_137552_, p_137553_); .getChoiceType(p_137552_, p_137553_);
} catch (IllegalArgumentException illegalargumentexception) { } catch (IllegalArgumentException illegalargumentexception) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/Advancement.java --- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java
@@ -233,7 +_,11 @@ @@ -226,7 +_,11 @@
} }
public AdvancementHolder save(Consumer<AdvancementHolder> p_138390_, String p_138391_) { public AdvancementHolder save(Consumer<AdvancementHolder> p_138390_, String p_138391_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Camera.java --- a/net/minecraft/client/Camera.java
+++ b/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java
@@ -132,9 +_,13 @@ @@ -133,9 +_,13 @@
} }
protected void setRotation(float p_90573_, float p_90574_) { protected void setRotation(float p_90573_, float p_90574_) {
@@ -15,7 +15,7 @@
FORWARDS.rotate(this.rotation, this.forwards); FORWARDS.rotate(this.rotation, this.forwards);
UP.rotate(this.rotation, this.up); UP.rotate(this.rotation, this.up);
LEFT.rotate(this.rotation, this.left); LEFT.rotate(this.rotation, this.left);
@@ -250,6 +_,13 @@ @@ -251,6 +_,13 @@
public float getPartialTickTime() { public float getPartialTickTime() {
return this.partialTickTime; return this.partialTickTime;
@@ -1,27 +1,35 @@
--- a/net/minecraft/client/KeyMapping.java --- a/net/minecraft/client/KeyMapping.java
+++ b/net/minecraft/client/KeyMapping.java +++ b/net/minecraft/client/KeyMapping.java
@@ -19,9 +_,9 @@ @@ -15,9 +_,9 @@
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
-public class KeyMapping implements Comparable<KeyMapping> { -public class KeyMapping implements Comparable<KeyMapping> {
+public class KeyMapping implements Comparable<KeyMapping>, net.minecraftforge.client.extensions.IForgeKeyMapping { +public class KeyMapping implements Comparable<KeyMapping>, net.minecraftforge.client.extensions.IForgeKeyMapping {
private static final Map<String, KeyMapping> ALL = Maps.newHashMap(); private static final Map<String, KeyMapping> ALL = Maps.newHashMap();
- private static final Map<InputConstants.Key, List<KeyMapping>> MAP = Maps.newHashMap(); - private static final Map<InputConstants.Key, KeyMapping> MAP = Maps.newHashMap();
+ private static final net.minecraftforge.client.settings.KeyMappingLookup MAP = new net.minecraftforge.client.settings.KeyMappingLookup(); + private static final net.minecraftforge.client.settings.KeyMappingLookup MAP = new net.minecraftforge.client.settings.KeyMappingLookup();
private final String name; private static final Set<String> CATEGORIES = Sets.newHashSet();
private final InputConstants.Key defaultKey; public static final String CATEGORY_MOVEMENT = "key.categories.movement";
private final KeyMapping.Category category; public static final String CATEGORY_MISC = "key.categories.misc";
@@ -38,7 +_,7 @@ @@ -43,14 +_,14 @@
private int clickCount;
public static void click(InputConstants.Key p_90836_) {
- KeyMapping keymapping = MAP.get(p_90836_);
+ for (KeyMapping keymapping : MAP.getAll(p_90836_))
if (keymapping != null) {
keymapping.clickCount++;
}
} }
private static void forAllKeyMappings(InputConstants.Key p_424096_, Consumer<KeyMapping> p_427756_) { public static void set(InputConstants.Key p_90838_, boolean p_90839_) {
- List<KeyMapping> list = MAP.get(p_424096_); - KeyMapping keymapping = MAP.get(p_90838_);
+ List<KeyMapping> list = MAP.getAll(p_424096_); + for (KeyMapping keymapping : MAP.getAll(p_90838_))
if (list != null && !list.isEmpty()) { if (keymapping != null) {
for (KeyMapping keymapping : list) { keymapping.setDown(p_90839_);
p_427756_.accept(keymapping); }
@@ -100,7 +_,7 @@ @@ -101,7 +_,7 @@
} }
public boolean isDown() { public boolean isDown() {
@@ -29,26 +37,26 @@
+ return this.isDown && isConflictContextAndModifierActive(); + return this.isDown && isConflictContextAndModifierActive();
} }
public KeyMapping.Category getCategory() { public String getCategory() {
@@ -140,7 +_,16 @@ @@ -137,7 +_,16 @@
public int compareTo(KeyMapping p_90841_) { public int compareTo(KeyMapping p_90841_) {
return this.category == p_90841_.category return this.category.equals(p_90841_.category)
? I18n.get(this.name).compareTo(I18n.get(p_90841_.name)) ? I18n.get(this.name).compareTo(I18n.get(p_90841_.name))
- : Integer.compare(KeyMapping.Category.SORT_ORDER.indexOf(this.category), KeyMapping.Category.SORT_ORDER.indexOf(p_90841_.category)); - : CATEGORY_SORT_ORDER.get(this.category).compareTo(CATEGORY_SORT_ORDER.get(p_90841_.category));
+ : compareSort(this.category, p_90841_.category); + : compareSort(this.category, p_90841_.category);
+ } + }
+ +
+ private static int compareSort(Category c1, Category c2) { + private static int compareSort(String c1, String c2) {
+ int o1 = KeyMapping.Category.SORT_ORDER.indexOf(c1); + Integer o1 = CATEGORY_SORT_ORDER.get(c1);
+ int o2 = KeyMapping.Category.SORT_ORDER.indexOf(c2); + Integer o2 = CATEGORY_SORT_ORDER.get(c2);
+ if (o1 == -1 && o2 != -1) return 1; + if (o1 == null && o2 != null) return 1;
+ if (o1 != -1 && o2 == -1) return -1; + if (o1 != null && o2 == null) return -1;
+ if (o1 == -1 && o2 == -1) return I18n.get(c1.id().toLanguageKey("key.category")).compareTo(I18n.get(c1.id().toLanguageKey("key.category"))); + if (o1 == null && o2 == null) return I18n.get(c1).compareTo(I18n.get(c2));
+ return o1 - o2; + return o1.compareTo(o2);
} }
public static Supplier<Component> createNameSupplier(String p_90843_) { public static Supplier<Component> createNameSupplier(String p_90843_) {
@@ -149,6 +_,20 @@ @@ -146,6 +_,20 @@
} }
public boolean same(KeyMapping p_90851_) { public boolean same(KeyMapping p_90851_) {
@@ -69,7 +77,7 @@
return this.key.equals(p_90851_.key); return this.key.equals(p_90851_.key);
} }
@@ -167,11 +_,13 @@ @@ -164,11 +_,13 @@
} }
public Component getTranslatedKeyMessage() { public Component getTranslatedKeyMessage() {
@@ -84,14 +92,7 @@
} }
public String saveString() { public String saveString() {
@@ -183,12 +_,94 @@ @@ -182,5 +_,88 @@
}
private void registerMapping(InputConstants.Key p_423386_) {
- MAP.computeIfAbsent(p_423386_, p_420623_ -> new ArrayList<>()).add(this);
+ MAP.put(p_423386_, this);
}
@Nullable @Nullable
public static KeyMapping get(String p_378660_) { public static KeyMapping get(String p_378660_) {
return ALL.get(p_378660_); return ALL.get(p_378660_);
@@ -104,28 +105,28 @@
+ /** + /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext set. + * Convenience constructor for creating KeyBindings with keyConflictContext set.
+ */ + */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, Category category) { + public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, final InputConstants.Type inputType, final int keyCode, String category) {
+ this(description, keyConflictContext, inputType.getOrCreate(keyCode), category); + this(description, keyConflictContext, inputType.getOrCreate(keyCode), category);
+ } + }
+ +
+ /** + /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext set. + * Convenience constructor for creating KeyBindings with keyConflictContext set.
+ */ + */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, Category category) { + public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, InputConstants.Key keyCode, String category) {
+ this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category); + this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category);
+ } + }
+ +
+ /** + /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. + * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set.
+ */ + */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, Category category) { + public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, final InputConstants.Type inputType, final int keyCode, String category) {
+ this(description, keyConflictContext, keyModifier, inputType.getOrCreate(keyCode), category); + this(description, keyConflictContext, keyModifier, inputType.getOrCreate(keyCode), category);
+ } + }
+ +
+ /** + /**
+ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. + * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set.
+ */ + */
+ public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, Category category) { + public KeyMapping(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, InputConstants.Key keyCode, String category) {
+ this.name = description; + this.name = description;
+ this.key = keyCode; + this.key = keyCode;
+ this.defaultKey = keyCode; + this.defaultKey = keyCode;
@@ -137,6 +138,7 @@
+ this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; + this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE;
+ ALL.put(description, this); + ALL.put(description, this);
+ MAP.put(keyCode, this); + MAP.put(keyCode, this);
+ CATEGORIES.add(category);
+ } + }
+ +
+ @Override + @Override
@@ -178,5 +180,4 @@
+ +
+ MAP.put(keyCode, this); + MAP.put(keyCode, this);
} }
}
@OnlyIn(Dist.CLIENT)
@@ -1,34 +1,39 @@
--- a/net/minecraft/client/KeyboardHandler.java --- a/net/minecraft/client/KeyboardHandler.java
+++ b/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java
@@ -499,12 +_,12 @@ @@ -440,12 +_,12 @@
if (screen != null) { if (screen != null) {
try { try {
if (p_90895_ != 1 && p_90895_ != 2) { if (p_90897_ != 1 && p_90897_ != 2) {
- if (p_90895_ == 0 && screen.keyReleased(p_423534_)) { - if (p_90897_ == 0 && screen.keyReleased(p_90895_, p_90896_, p_90898_)) {
+ if (p_90895_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_423534_)) { + if (p_90897_ == 0 && net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleased(screen, p_90895_, p_90896_, p_90898_)) {
return; return;
} }
} else { } else {
screen.afterKeyboardAction(); screen.afterKeyboardAction();
- if (screen.keyPressed(p_423534_)) { - if (screen.keyPressed(p_90895_, p_90896_, p_90898_)) {
+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_423534_)) { + if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, p_90895_, p_90896_, p_90898_)) {
if (this.minecraft.screen == null) { return;
InputConstants.Key inputconstants$key = InputConstants.getKey(p_423534_); }
KeyMapping.set(inputconstants$key, false); }
@@ -568,6 +_,7 @@ @@ -504,6 +_,7 @@
} }
} }
} }
+ net.minecraftforge.client.ForgeHooksClient.onKeyInput(p_423534_, p_90895_); + net.minecraftforge.client.ForgeHooksClient.onKeyInput(p_90895_, p_90896_, p_90897_, p_90898_);
} }
} }
@@ -576,7 +_,7 @@ @@ -513,10 +_,10 @@
Screen screen = this.minecraft.screen;
if (screen != null && this.minecraft.getOverlay() == null) { if (screen != null && this.minecraft.getOverlay() == null) {
try { try {
- screen.charTyped(p_427531_); if (Character.isBmpCodePoint(p_90891_)) {
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, p_427531_); - screen.charTyped((char)p_90891_, p_90892_);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, (char)p_90891_, p_90892_);
} else if (Character.isValidCodePoint(p_90891_)) {
- screen.charTyped(Character.highSurrogate(p_90891_), p_90892_);
- screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.highSurrogate(p_90891_), p_90892_);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, Character.lowSurrogate(p_90891_), p_90892_);
}
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler"); CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler");
screen.fillCrashDetails(crashreport);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Minecraft.java --- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java
@@ -260,7 +_,7 @@ @@ -256,7 +_,7 @@
import org.slf4j.Logger; import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -8,8 +8,8 @@
+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 {
static Minecraft instance; static Minecraft instance;
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final int MAX_TICKS_PER_UPDATE = 10; public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX;
@@ -439,7 +_,6 @@ @@ -435,7 +_,6 @@
} }
}, Util.nonCriticalIoPool()); }, Util.nonCriticalIoPool());
LOGGER.info("Setting user: {}", this.user.getName()); LOGGER.info("Setting user: {}", this.user.getName());
@@ -17,19 +17,19 @@
this.demo = p_91084_.game.demo; this.demo = p_91084_.game.demo;
this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer;
this.allowsChat = !p_91084_.game.disableChat; this.allowsChat = !p_91084_.game.disableChat;
@@ -491,10 +_,9 @@ @@ -486,10 +_,9 @@
LOGGER.error("Couldn't set icon", (Throwable)ioexception); LOGGER.error("Couldn't set icon", (Throwable)ioexception);
} }
+ // FORGE: Move mouse and keyboard handler setup further below + // FORGE: Move mouse and keyboard handler setup further below
this.mouseHandler = new MouseHandler(this); this.mouseHandler = new MouseHandler(this);
- this.mouseHandler.setup(this.window); - this.mouseHandler.setup(this.window.getWindow());
this.keyboardHandler = new KeyboardHandler(this); this.keyboardHandler = new KeyboardHandler(this);
- this.keyboardHandler.setup(this.window); - this.keyboardHandler.setup(this.window.getWindow());
RenderSystem.initRenderer( RenderSystem.initRenderer(
this.window.handle(), this.window.getWindow(),
this.options.glDebugVerbosity, this.options.glDebugVerbosity,
@@ -505,6 +_,7 @@ @@ -500,6 +_,7 @@
LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions())); LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions()));
this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight()); this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight());
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
@@ -37,33 +37,33 @@
this.resourcePackRepository.reload(); this.resourcePackRepository.reload();
this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.options.loadSelectedResourcePacks(this.resourcePackRepository);
this.languageManager = new LanguageManager(this.options.languageCode, p_340763_ -> { this.languageManager = new LanguageManager(this.options.languageCode, p_340763_ -> {
@@ -593,6 +_,7 @@ @@ -578,6 +_,7 @@
this.particleResources = new ParticleResources(); this.blockEntityRenderDispatcher = new BlockEntityRenderDispatcher(this.font, this.modelManager.entityModels(), this.blockRenderer, this.itemModelResolver, this.itemRenderer, this.entityRenderDispatcher);
this.resourceManager.registerReloadListener(this.particleResources); this.resourceManager.registerReloadListener(this.blockEntityRenderDispatcher);
this.particleEngine = new ParticleEngine(this.level, this.particleResources); this.particleEngine = new ParticleEngine(this.level, this.textureManager);
+ net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleResources); + net.minecraftforge.client.ForgeHooksClient.onRegisterParticleProviders(this.particleEngine);
this.particleResources.onReload(this.particleEngine::clearParticles); this.resourceManager.registerReloadListener(this.particleEngine);
this.waypointStyles = new WaypointStyleManager(); this.paintingTextures = new PaintingTextureManager(this.textureManager);
this.resourceManager.registerReloadListener(this.waypointStyles); this.resourceManager.registerReloadListener(this.paintingTextures);
@@ -604,6 +_,9 @@ @@ -593,6 +_,9 @@
this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
this.resourceManager.registerReloadListener(this.regionalCompliancies); this.resourceManager.registerReloadListener(this.regionalCompliancies);
this.gui = new Gui(this); this.gui = new Gui(this);
+ // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them. + // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
+ this.mouseHandler.setup(this.window); + this.mouseHandler.setup(this.window.getWindow());
+ this.keyboardHandler.setup(this.window); + this.keyboardHandler.setup(this.window.getWindow());
this.debugRenderer = new DebugRenderer(this);
RealmsClient realmsclient = RealmsClient.getOrCreate(this); RealmsClient realmsclient = RealmsClient.getOrCreate(this);
this.realmsDataFetcher = new RealmsDataFetcher(realmsclient); this.realmsDataFetcher = new RealmsDataFetcher(realmsclient);
RenderSystem.setErrorCallback(this::onFullscreenError); @@ -626,6 +_,7 @@
@@ -636,6 +_,7 @@
} }
} }
+ net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager); + net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager);
this.window.updateVsync(this.options.enableVsync().get()); this.window.updateVsync(this.options.enableVsync().get());
this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get());
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get()); this.window.setDefaultErrorCallback();
@@ -659,16 +_,17 @@ @@ -648,16 +_,17 @@
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay);
this.setOverlay( this.setOverlay(
@@ -84,7 +84,7 @@
); );
this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.logPath()); this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.logPath());
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
@@ -787,6 +_,7 @@ @@ -759,6 +_,7 @@
StringBuilder stringbuilder = new StringBuilder("Minecraft"); StringBuilder stringbuilder = new StringBuilder("Minecraft");
if (checkModStatus().shouldReportAsModified()) { if (checkModStatus().shouldReportAsModified()) {
stringbuilder.append("*"); stringbuilder.append("*");
@@ -92,16 +92,16 @@
} }
stringbuilder.append(" "); stringbuilder.append(" ");
@@ -810,6 +_,8 @@ @@ -782,6 +_,8 @@
} }
private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) {
+ if ("0".equals(p_193587_.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam. + if ("0".equals(p_193587_.user.user.getAccessToken())) // Forge: We use "0" in dev. Short circuit to stop exception spam.
+ return UserApiService.OFFLINE; + return UserApiService.OFFLINE;
return p_193587_.game.offlineDeveloperMode ? UserApiService.OFFLINE : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); return p_193587_.user.user.getType() != User.Type.MSA
} ? UserApiService.OFFLINE
: p_193586_.createUserApiService(p_193587_.user.user.getAccessToken());
@@ -822,7 +_,7 @@ @@ -792,7 +_,7 @@
} }
private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) { private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) {
@@ -110,7 +110,7 @@
this.clearResourcePacksOnError(p_91240_, null, p_299515_); this.clearResourcePacksOnError(p_91240_, null, p_299515_);
} else { } else {
Util.throwAsRuntime(p_91240_); Util.throwAsRuntime(p_91240_);
@@ -1108,12 +_,6 @@ @@ -1078,12 +_,6 @@
LOGGER.error("setScreen called from non-game thread"); LOGGER.error("setScreen called from non-game thread");
} }
@@ -120,34 +120,34 @@
- this.setLastInputType(InputType.NONE); - this.setLastInputType(InputType.NONE);
- } - }
- -
if (p_91153_ == null) { if (p_91153_ == null && this.clientLevelTeardownInProgress) {
if (this.clientLevelTeardownInProgress) { throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); } else {
@@ -1132,6 +_,23 @@ @@ -1097,6 +_,23 @@
}
} }
}
+ net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this); + net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this);
+ Screen old = this.screen; + Screen old = this.screen;
+ if (p_91153_ != null) { + if (p_91153_ != null) {
+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, p_91153_); + var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenOpening(old, p_91153_);
+ if (event == null) return; + if (event == null) return;
+ p_91153_ = event; + p_91153_ = event;
+ }
+
+ if (p_91153_ != old) {
+ if (old != null) {
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
+ old.removed();
+ } else {
+ this.setLastInputType(InputType.NONE);
+ } + }
+ }
+ +
this.screen = p_91153_; + if (p_91153_ != old) {
if (this.screen != null) { + if (old != null) {
this.screen.added(); + net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenClose(old);
@@ -1214,6 +_,7 @@ + old.removed();
+ } else {
+ this.setLastInputType(InputType.NONE);
+ }
+ }
+
this.screen = p_91153_;
if (this.screen != null) {
this.screen.added();
@@ -1180,6 +_,7 @@
FreeTypeUtil.destroy(); FreeTypeUtil.destroy();
Util.shutdownExecutors(); Util.shutdownExecutors();
RenderSystem.getDevice().close(); RenderSystem.getDevice().close();
@@ -155,17 +155,19 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
LOGGER.error("Shutdown failure!", throwable); LOGGER.error("Shutdown failure!", throwable);
throw throwable; throw throwable;
@@ -1278,7 +_,9 @@ @@ -1248,9 +_,11 @@
RenderSystem.getDevice().createCommandEncoder().clearColorAndDepthTextures(rendertarget.getColorTexture(), 0, rendertarget.getDepthTexture(), 1.0); this.mouseHandler.handleAccumulatedMovement();
profilerfiller.push("gameRenderer"); profilerfiller.pop();
if (!this.noRender) { if (!this.noRender) {
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker);
profilerfiller.popPush("gameRenderer");
this.gameRenderer.render(this.deltaTracker, p_91384_); this.gameRenderer.render(this.deltaTracker, p_91384_);
profilerfiller.pop();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker);
} }
profilerfiller.popPush("blit"); profilerfiller.push("blit");
@@ -1388,10 +_,12 @@ @@ -1379,10 +_,12 @@
this.window.setGuiScale(i); this.window.setGuiScale(i);
if (this.screen != null) { if (this.screen != null) {
this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
@@ -178,7 +180,7 @@
this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight());
this.mouseHandler.setIgnoreFirstMove(); this.mouseHandler.setIgnoreFirstMove();
} }
@@ -1529,6 +_,7 @@ @@ -1520,6 +_,7 @@
} }
public void stop() { public void stop() {
@@ -186,7 +188,7 @@
this.running = false; this.running = false;
} }
@@ -1556,10 +_,18 @@ @@ -1547,10 +_,18 @@
if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockHitResult blockhitresult = (BlockHitResult)this.hitResult;
BlockPos blockpos = blockhitresult.getBlockPos(); BlockPos blockpos = blockhitresult.getBlockPos();
@@ -195,20 +197,20 @@
+ var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND); + var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND);
+ if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) { + if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) {
+ if (inputEvent.shouldSwingHand()) { + if (inputEvent.shouldSwingHand()) {
+ this.level.addBreakingBlockEffect(blockpos, blockhitresult); + this.particleEngine.addBlockHitEffects(blockpos, blockhitresult);
+ this.player.swing(InteractionHand.MAIN_HAND); + this.player.swing(InteractionHand.MAIN_HAND);
+ } + }
+ return; + return;
+ } + }
Direction direction = blockhitresult.getDirection(); Direction direction = blockhitresult.getDirection();
- if (this.gameMode.continueDestroyBlock(blockpos, direction)) { - if (this.gameMode.continueDestroyBlock(blockpos, direction)) {
- this.level.addBreakingBlockEffect(blockpos, direction); - this.particleEngine.crack(blockpos, direction);
+ if (this.gameMode.continueDestroyBlock(blockpos, direction) && inputEvent.shouldSwingHand()) { + if (this.gameMode.continueDestroyBlock(blockpos, direction) && inputEvent.shouldSwingHand()) {
+ this.level.addBreakingBlockEffect(blockpos, blockhitresult); + this.particleEngine.addBlockHitEffects(blockpos, blockhitresult);
this.player.swing(InteractionHand.MAIN_HAND); this.player.swing(InteractionHand.MAIN_HAND);
} }
} }
@@ -1587,6 +_,8 @@ @@ -1578,6 +_,8 @@
return false; return false;
} else { } else {
boolean flag = false; boolean flag = false;
@@ -217,7 +219,7 @@
switch (this.hitResult.getType()) { switch (this.hitResult.getType()) {
case ENTITY: case ENTITY:
this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity());
@@ -1594,7 +_,7 @@ @@ -1585,7 +_,7 @@
case BLOCK: case BLOCK:
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockHitResult blockhitresult = (BlockHitResult)this.hitResult;
BlockPos blockpos = blockhitresult.getBlockPos(); BlockPos blockpos = blockhitresult.getBlockPos();
@@ -226,7 +228,7 @@
this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection());
if (this.level.getBlockState(blockpos).isAir()) { if (this.level.getBlockState(blockpos).isAir()) {
flag = true; flag = true;
@@ -1607,8 +_,10 @@ @@ -1598,8 +_,10 @@
} }
this.player.resetAttackStrengthTicker(); this.player.resetAttackStrengthTicker();
@@ -237,7 +239,7 @@
this.player.swing(InteractionHand.MAIN_HAND); this.player.swing(InteractionHand.MAIN_HAND);
return flag; return flag;
} }
@@ -1624,6 +_,12 @@ @@ -1615,6 +_,12 @@
} }
for (InteractionHand interactionhand : InteractionHand.values()) { for (InteractionHand interactionhand : InteractionHand.values()) {
@@ -250,7 +252,7 @@
ItemStack itemstack = this.player.getItemInHand(interactionhand); ItemStack itemstack = this.player.getItemInHand(interactionhand);
if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { if (!itemstack.isItemEnabled(this.level.enabledFeatures())) {
return; return;
@@ -1644,7 +_,7 @@ @@ -1635,7 +_,7 @@
} }
if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { if (interactionresult instanceof InteractionResult.Success interactionresult$success2) {
@@ -259,7 +261,7 @@
this.player.swing(interactionhand); this.player.swing(interactionhand);
} }
@@ -1656,7 +_,7 @@ @@ -1647,7 +_,7 @@
int i = itemstack.getCount(); int i = itemstack.getCount();
InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult);
if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) { if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) {
@@ -268,7 +270,7 @@
this.player.swing(interactionhand); this.player.swing(interactionhand);
if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) { if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) {
this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand);
@@ -1672,6 +_,9 @@ @@ -1663,6 +_,9 @@
} }
} }
@@ -278,7 +280,7 @@
if (!itemstack.isEmpty() if (!itemstack.isEmpty()
&& this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { && this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) {
if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) {
@@ -1701,6 +_,8 @@ @@ -1692,6 +_,8 @@
} }
ProfilerFiller profilerfiller = Profiler.get(); ProfilerFiller profilerfiller = Profiler.get();
@@ -287,7 +289,7 @@
profilerfiller.push("gui"); profilerfiller.push("gui");
this.chatListener.tick(); this.chatListener.tick();
this.gui.tick(this.pause); this.gui.tick(this.pause);
@@ -1786,6 +_,7 @@ @@ -1778,6 +_,7 @@
this.tutorial.tick(); this.tutorial.tick();
@@ -295,7 +297,7 @@
try { try {
this.level.tick(() -> true); this.level.tick(() -> true);
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
@@ -1799,6 +_,7 @@ @@ -1791,6 +_,7 @@
throw new ReportedException(crashreport1); throw new ReportedException(crashreport1);
} }
@@ -303,7 +305,7 @@
} }
profilerfiller.popPush("animateTick"); profilerfiller.popPush("animateTick");
@@ -1823,6 +_,7 @@ @@ -1815,6 +_,7 @@
profilerfiller.popPush("keyboard"); profilerfiller.popPush("keyboard");
this.keyboardHandler.tick(); this.keyboardHandler.tick();
profilerfiller.pop(); profilerfiller.pop();
@@ -311,15 +313,15 @@
} }
private boolean isLevelRunningNormally() { private boolean isLevelRunningNormally() {
@@ -2041,6 +_,7 @@ @@ -2031,6 +_,7 @@
} }
public void setLevel(ClientLevel p_91157_) { public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_335893_) {
+ if (this.level != null) net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level); + if (this.level != null) net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
this.updateScreenAndTick(new ReceivingLevelScreen(() -> false, p_335893_));
this.level = p_91157_; this.level = p_91157_;
this.updateLevelInEngines(p_91157_); this.updateLevelInEngines(p_91157_);
} @@ -2068,6 +_,7 @@
@@ -2094,6 +_,7 @@
IntegratedServer integratedserver = this.singleplayerServer; IntegratedServer integratedserver = this.singleplayerServer;
this.singleplayerServer = null; this.singleplayerServer = null;
this.gameRenderer.resetData(); this.gameRenderer.resetData();
@@ -327,27 +329,27 @@
this.gameMode = null; this.gameMode = null;
this.narrator.clear(); this.narrator.clear();
this.clientLevelTeardownInProgress = true; this.clientLevelTeardownInProgress = true;
@@ -2101,6 +_,7 @@ @@ -2075,6 +_,7 @@
try { try {
this.updateScreenAndTick(p_335030_);
if (this.level != null) { if (this.level != null) {
this.gui.onDisconnected();
+ net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level); + net.minecraftforge.event.ForgeEventFactory.onLevelUnload(this.level);
} if (integratedserver != null) {
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("waitForServer");
@@ -2088,6 +_,7 @@
if (integratedserver != null) { this.gui.onDisconnected();
@@ -2113,6 +_,7 @@ this.isLocalServer = false;
}
profilerfiller.pop();
+ net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level); + net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level);
} }
this.setScreenAndShow(p_335030_); this.level = null;
@@ -2254,6 +_,7 @@ @@ -2236,6 +_,7 @@
private void pickBlock() { private void pickBlock() {
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInputPickBlock(this.options.keyPickItem)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInputPickBlock(this.options.keyPickItem)) return;
boolean flag = this.hasControlDown(); boolean flag = Screen.hasControlDown();
switch (this.hitResult) { switch (this.hitResult) {
case BlockHitResult blockhitresult: case BlockHitResult blockhitresult:
@@ -1,40 +1,40 @@
--- a/net/minecraft/client/MouseHandler.java --- a/net/minecraft/client/MouseHandler.java
+++ b/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java
@@ -87,6 +_,7 @@ @@ -90,6 +_,7 @@
this.activeButton = null; this.activeButton = -1;
} }
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(mousebuttoninfo, p_423948_)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return;
if (this.minecraft.getOverlay() == null) { if (this.minecraft.getOverlay() == null) {
if (this.minecraft.screen == null) { if (this.minecraft.screen == null) {
if (!this.mouseGrabbed && flag) { if (!this.mouseGrabbed && flag) {
@@ -103,7 +_,7 @@ @@ -103,7 +_,7 @@
screen.afterMouseAction();
try { try {
long i = Util.getMillis(); - if (screen.mouseClicked(d0, d1, i)) {
boolean flag1 = i - this.lastClickTime < 250L && this.lastClickButton == mousebuttonevent.button(); + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, i)) {
- if (screen.mouseClicked(mousebuttonevent, flag1)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, mousebuttonevent, flag1)) {
this.lastClickTime = i;
this.lastClickButton = mousebuttoninfo.button();
return; return;
@@ -118,7 +_,7 @@ }
} catch (Throwable throwable1) {
@@ -116,7 +_,7 @@
} }
} else { } else {
try { try {
- if (screen.mouseReleased(mousebuttonevent)) { - if (screen.mouseReleased(d0, d1, i)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, mousebuttonevent)) { + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, i)) {
return; return;
} }
} catch (Throwable throwable) { } catch (Throwable throwable) {
@@ -148,6 +_,7 @@ @@ -150,6 +_,7 @@
KeyMapping.click(inputconstants$key);
} }
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(mousebuttoninfo, p_423948_);
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(p_91532_, p_91533_, p_91534_);
} }
@@ -204,7 +_,9 @@ public void fillMousePositionDetails(CrashReportCategory p_398230_, Window p_398216_) {
@@ -189,7 +_,9 @@
if (this.minecraft.screen != null) { if (this.minecraft.screen != null) {
double d3 = this.getScaledXPos(this.minecraft.getWindow()); double d3 = this.getScaledXPos(this.minecraft.getWindow());
double d4 = this.getScaledYPos(this.minecraft.getWindow()); double d4 = this.getScaledYPos(this.minecraft.getWindow());
@@ -45,7 +45,7 @@
this.minecraft.screen.afterMouseAction(); this.minecraft.screen.afterMouseAction();
} else if (this.minecraft.player != null) { } else if (this.minecraft.player != null) {
Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2); Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2);
@@ -213,6 +_,7 @@ @@ -198,6 +_,7 @@
} }
int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; int i = vector2i.y == 0 ? -vector2i.x : vector2i.y;
@@ -53,16 +53,16 @@
if (this.minecraft.player.isSpectator()) { if (this.minecraft.player.isSpectator()) {
if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i);
@@ -321,7 +_,7 @@ @@ -303,7 +_,7 @@
double d5 = getScaledYPos(window, this.accumulatedDY); double d5 = getScaledYPos(window, this.accumulatedDY);
try { try {
- screen.mouseDragged(new MouseButtonEvent(d2, d3, this.activeButton), d4, d5); - screen.mouseDragged(d2, d3, this.activeButton, d4, d5);
+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(d2, d3, this.activeButton), d4, d5); + net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, d2, d3, this.activeButton, d4, d5);
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler");
screen.fillCrashDetails(crashreport1); screen.fillCrashDetails(crashreport1);
@@ -408,6 +_,14 @@ @@ -393,6 +_,14 @@
public double ypos() { public double ypos() {
return this.ypos; return this.ypos;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Options.java --- a/net/minecraft/client/Options.java
+++ b/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java
@@ -709,7 +_,8 @@ @@ -671,7 +_,8 @@
}, },
new OptionInstance.LazyEnum<>( new OptionInstance.LazyEnum<>(
() -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(), () -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(),
@@ -10,7 +10,7 @@
? Optional.empty() ? Optional.empty()
: Optional.of(p_232011_), : Optional.of(p_232011_),
Codec.STRING Codec.STRING
@@ -743,6 +_,7 @@ @@ -705,6 +_,7 @@
); );
public boolean syncWrites; public boolean syncWrites;
public boolean startedCleanly = true; public boolean startedCleanly = true;
@@ -18,7 +18,7 @@
public OptionInstance<Boolean> darkMojangStudiosBackground() { public OptionInstance<Boolean> darkMojangStudiosBackground() {
return this.darkMojangStudiosBackground; return this.darkMojangStudiosBackground;
@@ -1150,6 +_,7 @@ @@ -1088,6 +_,7 @@
} }
public Options(Minecraft p_92138_, File p_92139_) { public Options(Minecraft p_92138_, File p_92139_) {
@@ -26,7 +26,7 @@
this.minecraft = p_92138_; this.minecraft = p_92138_;
this.optionsFile = new File(p_92139_, "options.txt"); this.optionsFile = new File(p_92139_, "options.txt");
boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L;
@@ -1290,15 +_,28 @@ @@ -1222,15 +_,28 @@
this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly); this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly);
p_168428_.process("showNowPlayingToast", this.showNowPlayingToast); p_168428_.process("showNowPlayingToast", this.showNowPlayingToast);
p_168428_.process("musicFrequency", this.musicFrequency); p_168428_.process("musicFrequency", this.musicFrequency);
@@ -56,7 +56,7 @@
for (SoundSource soundsource : SoundSource.values()) { for (SoundSource soundsource : SoundSource.values()) {
p_168428_.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource)); p_168428_.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource));
} }
@@ -1313,6 +_,10 @@ @@ -1245,6 +_,10 @@
} }
public void load() { public void load() {
@@ -67,7 +67,7 @@
try { try {
if (!this.optionsFile.exists()) { if (!this.optionsFile.exists()) {
return; return;
@@ -1337,7 +_,8 @@ @@ -1269,7 +_,8 @@
this.graphicsMode.set(isTrue(optional.get()) ? GraphicsStatus.FANCY : GraphicsStatus.FAST); this.graphicsMode.set(isTrue(optional.get()) ? GraphicsStatus.FANCY : GraphicsStatus.FAST);
} }
@@ -77,7 +77,7 @@
new Options.FieldAccess() { new Options.FieldAccess() {
@Nullable @Nullable
private String getValue(String p_394210_) { private String getValue(String p_394210_) {
@@ -1418,6 +_,17 @@ @@ -1350,6 +_,17 @@
); );
compoundtag1.getString("fullscreenResolution").ifPresent(p_389133_ -> this.fullscreenVideoModeString = p_389133_); compoundtag1.getString("fullscreenResolution").ifPresent(p_389133_ -> this.fullscreenVideoModeString = p_389133_);
KeyMapping.resetMapping(); KeyMapping.resetMapping();
@@ -95,7 +95,7 @@
} catch (Exception exception) { } catch (Exception exception) {
LOGGER.error("Failed to load options", (Throwable)exception); LOGGER.error("Failed to load options", (Throwable)exception);
} }
@@ -1445,9 +_,11 @@ @@ -1377,9 +_,11 @@
public void save() { public void save() {
try (final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) { try (final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
printwriter.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version()); printwriter.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version());
@@ -107,7 +107,7 @@
printwriter.print(p_168491_); printwriter.print(p_168491_);
printwriter.print(':'); printwriter.print(':');
} }
@@ -1503,6 +_,12 @@ @@ -1435,6 +_,12 @@
if (s != null) { if (s != null) {
printwriter.println("fullscreenResolution:" + s); printwriter.println("fullscreenResolution:" + s);
} }
@@ -120,7 +120,7 @@
} catch (Exception exception) { } catch (Exception exception) {
LOGGER.error("Failed to save options", (Throwable)exception); LOGGER.error("Failed to save options", (Throwable)exception);
} }
@@ -1541,6 +_,7 @@ @@ -1473,6 +_,7 @@
} }
public void broadcastOptions() { public void broadcastOptions() {
@@ -128,7 +128,7 @@
if (this.minecraft.player != null) { if (this.minecraft.player != null) {
this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation());
} }
@@ -1654,6 +_,23 @@ @@ -1586,6 +_,23 @@
public static Component genericValueLabel(Component p_231901_, int p_231902_) { public static Component genericValueLabel(Component p_231901_, int p_231902_) {
return genericValueLabel(p_231901_, Component.literal(Integer.toString(p_231902_))); return genericValueLabel(p_231901_, Component.literal(Integer.toString(p_231902_)));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/ToggleKeyMapping.java --- a/net/minecraft/client/ToggleKeyMapping.java
+++ b/net/minecraft/client/ToggleKeyMapping.java +++ b/net/minecraft/client/ToggleKeyMapping.java
@@ -31,7 +_,7 @@ @@ -17,7 +_,7 @@
@Override @Override
public void setDown(boolean p_92534_) { public void setDown(boolean p_92534_) {
if (this.needsToggle.getAsBoolean()) { if (this.needsToggle.getAsBoolean()) {
@@ -9,7 +9,7 @@
super.setDown(!this.isDown()); super.setDown(!this.isDown());
} }
} else { } else {
@@ -56,5 +_,9 @@ @@ -27,5 +_,9 @@
protected void reset() { protected void reset() {
super.setDown(false); super.setDown(false);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/ItemModelGenerators.java --- a/net/minecraft/client/data/models/ItemModelGenerators.java
+++ b/net/minecraft/client/data/models/ItemModelGenerators.java +++ b/net/minecraft/client/data/models/ItemModelGenerators.java
@@ -882,6 +_,9 @@ @@ -871,6 +_,9 @@
this.declareCustomModelItem(Items.COD); this.declareCustomModelItem(Items.COD);
this.declareCustomModelItem(Items.FEATHER); this.declareCustomModelItem(Items.FEATHER);
this.declareCustomModelItem(Items.LEAD); this.declareCustomModelItem(Items.LEAD);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/Font.java --- a/net/minecraft/client/gui/Font.java
+++ b/net/minecraft/client/gui/Font.java +++ b/net/minecraft/client/gui/Font.java
@@ -31,7 +_,7 @@ @@ -32,7 +_,7 @@
import org.joml.Matrix4f; import org.joml.Matrix4f;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -9,7 +9,7 @@
private final SubtitleOverlay subtitleOverlay; private final SubtitleOverlay subtitleOverlay;
private final SpectatorGui spectatorGui; private final SpectatorGui spectatorGui;
private final PlayerTabOverlay tabList; private final PlayerTabOverlay tabList;
@@ -196,6 +_,7 @@ @@ -194,6 +_,7 @@
() -> new JumpableVehicleBarRenderer(p_330021_) () -> new JumpableVehicleBarRenderer(p_330021_)
); );
this.resetTitleTimes(); this.resetTitleTimes();
@@ -17,10 +17,10 @@
} }
public void resetTitleTimes() { public void resetTitleTimes() {
@@ -206,6 +_,10 @@ @@ -204,6 +_,10 @@
public void render(GuiGraphics p_282884_, DeltaTracker p_342095_) { public void render(GuiGraphics p_282884_, DeltaTracker p_342095_) {
if (!(this.minecraft.screen instanceof LevelLoadingScreen)) { if (this.minecraft.screen == null || !(this.minecraft.screen instanceof ReceivingLevelScreen)) {
+ if (Boolean.valueOf(true)) { + if (Boolean.valueOf(true)) {
+ net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.beginRender(p_282884_, p_342095_); + net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.beginRender(p_282884_, p_342095_);
+ return; + return;
@@ -28,7 +28,7 @@
if (!this.minecraft.options.hideGui) { if (!this.minecraft.options.hideGui) {
this.renderCameraOverlays(p_282884_, p_342095_); this.renderCameraOverlays(p_282884_, p_342095_);
this.renderCrosshair(p_282884_, p_342095_); this.renderCrosshair(p_282884_, p_342095_);
@@ -389,7 +_,7 @@ @@ -377,7 +_,7 @@
int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window)); int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window)); int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
p_329202_.nextStratum(); p_329202_.nextStratum();
@@ -37,7 +37,7 @@
} }
} }
@@ -477,6 +_,8 @@ @@ -472,6 +_,8 @@
for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
Holder<MobEffect> holder = mobeffectinstance.getEffect(); Holder<MobEffect> holder = mobeffectinstance.getEffect();
@@ -46,7 +46,7 @@
if (mobeffectinstance.showIcon()) { if (mobeffectinstance.showIcon()) {
int k = p_282812_.guiWidth(); int k = p_282812_.guiWidth();
int l = 1; int l = 1;
@@ -507,6 +_,7 @@ @@ -502,6 +_,7 @@
} }
} }
@@ -54,7 +54,7 @@
p_282812_.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f)); p_282812_.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f));
} }
} }
@@ -603,6 +_,10 @@ @@ -598,6 +_,10 @@
} }
public void renderSelectedItemName(GuiGraphics p_283501_) { public void renderSelectedItemName(GuiGraphics p_283501_) {
@@ -65,7 +65,7 @@
Profiler.get().push("selectedItemName"); Profiler.get().push("selectedItemName");
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
MutableComponent mutablecomponent = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color()); MutableComponent mutablecomponent = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color());
@@ -610,9 +_,13 @@ @@ -605,9 +_,13 @@
mutablecomponent.withStyle(ChatFormatting.ITALIC); mutablecomponent.withStyle(ChatFormatting.ITALIC);
} }
@@ -81,7 +81,7 @@
if (!this.minecraft.gameMode.canHurtPlayer()) { if (!this.minecraft.gameMode.canHurtPlayer()) {
k += 14; k += 14;
} }
@@ -623,7 +_,7 @@ @@ -618,7 +_,7 @@
} }
if (l > 0) { if (l > 0) {
@@ -90,7 +90,7 @@
} }
} }
@@ -1151,7 +_,7 @@ @@ -1146,7 +_,7 @@
ItemStack itemstack = this.minecraft.player.getInventory().getSelectedItem(); ItemStack itemstack = this.minecraft.player.getInventory().getSelectedItem();
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {
this.toolHighlightTimer = 0; this.toolHighlightTimer = 0;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/GuiGraphics.java --- a/net/minecraft/client/gui/GuiGraphics.java
+++ b/net/minecraft/client/gui/GuiGraphics.java +++ b/net/minecraft/client/gui/GuiGraphics.java
@@ -83,7 +_,7 @@ @@ -72,7 +_,7 @@
import org.joml.Vector3f; import org.joml.Vector3f;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -9,7 +9,7 @@
private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2;
private final Minecraft minecraft; private final Minecraft minecraft;
private final Matrix3x2fStack pose; private final Matrix3x2fStack pose;
@@ -950,6 +_,7 @@ @@ -875,6 +_,7 @@
CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item");
CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered");
crashreportcategory.setDetail("Item Type", () -> String.valueOf(p_283653_.getItem())); crashreportcategory.setDetail("Item Type", () -> String.valueOf(p_283653_.getItem()));
@@ -17,7 +17,7 @@
crashreportcategory.setDetail("Item Components", () -> String.valueOf(p_283653_.getComponents())); crashreportcategory.setDetail("Item Components", () -> String.valueOf(p_283653_.getComponents()));
crashreportcategory.setDetail("Item Foil", () -> String.valueOf(p_283653_.hasFoil())); crashreportcategory.setDetail("Item Foil", () -> String.valueOf(p_283653_.hasFoil()));
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
@@ -968,6 +_,7 @@ @@ -893,6 +_,7 @@
this.renderItemCooldown(p_283349_, p_282641_, p_282146_); this.renderItemCooldown(p_283349_, p_282641_, p_282146_);
this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_); this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_);
this.pose.popMatrix(); this.pose.popMatrix();
@@ -25,7 +25,7 @@
} }
} }
@@ -979,21 +_,30 @@ @@ -904,21 +_,30 @@
this.setTooltipForNextFrame(this.minecraft.font, p_407686_, DefaultTooltipPositioner.INSTANCE, p_410475_, p_407139_, false); this.setTooltipForNextFrame(this.minecraft.font, p_407686_, DefaultTooltipPositioner.INSTANCE, p_410475_, p_407139_, false);
} }
@@ -58,7 +58,7 @@
this.setTooltipForNextFrameInternal(p_407847_, list, p_409369_, p_407472_, DefaultTooltipPositioner.INSTANCE, p_410303_, false); this.setTooltipForNextFrameInternal(p_407847_, list, p_409369_, p_407472_, DefaultTooltipPositioner.INSTANCE, p_410303_, false);
} }
@@ -1006,7 +_,22 @@ @@ -931,7 +_,22 @@
} }
public void setComponentTooltipForNextFrame(Font p_406239_, List<Component> p_410275_, int p_410594_, int p_409343_) { public void setComponentTooltipForNextFrame(Font p_406239_, List<Component> p_410275_, int p_410594_, int p_409343_) {
@@ -82,11 +82,31 @@
} }
public void setComponentTooltipForNextFrame(Font p_408650_, List<Component> p_407512_, int p_406019_, int p_408123_, @Nullable ResourceLocation p_409993_) { public void setComponentTooltipForNextFrame(Font p_408650_, List<Component> p_407512_, int p_406019_, int p_408123_, @Nullable ResourceLocation p_409993_) {
@@ -1069,11 +_,13 @@ @@ -981,9 +_,14 @@
ClientTooltipPositioner p_409451_,
@Nullable ResourceLocation p_409298_
) { ) {
+ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(this.tooltipStack, this, p_283678_, p_281696_, guiWidth(), guiHeight(), p_282716_, p_283128_, p_409451_); if (!p_409928_.isEmpty()) {
if (this.deferredTooltip == null || p_410618_) {
- this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_407676_);
+ final var stackContext = this.tooltipStack;
+ this.deferredTooltip = () -> this.renderTooltip(p_406605_, p_409928_, p_407794_, p_408784_, p_408798_, p_407676_, stackContext);
}
}
+ }
+
+ public void renderTooltip(Font p_283128_, List<ClientTooltipComponent> p_282716_, int p_283678_, int p_281696_, ClientTooltipPositioner p_409451_, @Nullable ResourceLocation p_409298_) {
+ renderTooltip(p_283128_, p_282716_, p_283678_, p_281696_, p_409451_, p_409298_, ItemStack.EMPTY);
}
public void renderTooltip(
@@ -992,13 +_,16 @@
int p_283678_,
int p_281696_,
ClientTooltipPositioner p_409451_,
- @Nullable ResourceLocation p_409298_
+ @Nullable ResourceLocation p_409298_,
+ ItemStack itemStack
) {
+ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemStack, this, p_283678_, p_281696_, guiWidth(), guiHeight(), p_282716_, p_283128_, p_409451_, p_409298_);
+ if (preEvent == null) return; + if (preEvent == null) return;
int i = 0; int i = 0;
int j = p_282716_.size() == 1 ? -2 : 0; int j = p_282716_.size() == 1 ? -2 : 0;
@@ -97,7 +117,7 @@
if (k > i) { if (k > i) {
i = k; i = k;
} }
@@ -1083,16 +_,17 @@ @@ -1008,16 +_,17 @@
int l1 = i; int l1 = i;
int i2 = j; int i2 = j;
@@ -107,8 +127,8 @@
int i1 = vector2ic.y(); int i1 = vector2ic.y();
this.pose.pushMatrix(); this.pose.pushMatrix();
- TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, p_409298_); - TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, p_409298_);
+ var background_event = net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTooltipBackground(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282716_, p_409298_); + var background = net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTooltipBackground(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282716_, preEvent.getBackground());
+ TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, background_event.getBackground()); + TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, background.getBackground());
int j1 = i1; int j1 = i1;
for (int k1 = 0; k1 < p_282716_.size(); k1++) { for (int k1 = 0; k1 < p_282716_.size(); k1++) {
@@ -118,7 +138,7 @@
j1 += clienttooltipcomponent1.getHeight(p_283128_) + (k1 == 0 ? 2 : 0); j1 += clienttooltipcomponent1.getHeight(p_283128_) + (k1 == 0 ? 2 : 0);
} }
@@ -1100,7 +_,7 @@ @@ -1025,7 +_,7 @@
for (int j2 = 0; j2 < p_282716_.size(); j2++) { for (int j2 = 0; j2 < p_282716_.size(); j2++) {
ClientTooltipComponent clienttooltipcomponent2 = p_282716_.get(j2); ClientTooltipComponent clienttooltipcomponent2 = p_282716_.get(j2);
@@ -127,7 +147,7 @@
j1 += clienttooltipcomponent2.getHeight(p_283128_) + (j2 == 0 ? 2 : 0); j1 += clienttooltipcomponent2.getHeight(p_283128_) + (j2 == 0 ? 2 : 0);
} }
@@ -1315,6 +_,14 @@ @@ -1222,6 +_,14 @@
public void submitProfilerChartRenderState(List<ResultField> p_408565_, int p_410147_, int p_406156_, int p_407365_, int p_408180_) { public void submitProfilerChartRenderState(List<ResultField> p_408565_, int p_410147_, int p_406156_, int p_407365_, int p_408180_) {
this.guiRenderState.submitPicturesInPictureState(new GuiProfilerChartRenderState(p_408565_, p_410147_, p_406156_, p_407365_, p_408180_, this.scissorStack.peek())); this.guiRenderState.submitPicturesInPictureState(new GuiProfilerChartRenderState(p_408565_, p_410147_, p_406156_, p_407365_, p_408180_, this.scissorStack.peek()));
@@ -141,4 +161,4 @@
+ return this.scissorStack; + return this.scissorStack;
} }
public TextureAtlasSprite getSprite(Material p_430745_) { @OnlyIn(Dist.CLIENT)
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/components/AbstractButton.java --- a/net/minecraft/client/gui/components/AbstractButton.java
+++ b/net/minecraft/client/gui/components/AbstractButton.java +++ b/net/minecraft/client/gui/components/AbstractButton.java
@@ -41,7 +_,7 @@ @@ -38,7 +_,7 @@
this.getHeight(), this.getHeight(),
ARGB.white(this.alpha) ARGB.white(this.alpha)
); );
- int i = ARGB.color(this.alpha, this.active ? -1 : -6250336); - int i = ARGB.color(this.alpha, this.active ? -1 : -6250336);
+ int i = getFGColor(); + int i = getFGColor();
this.renderString(p_281670_, minecraft.font, i); this.renderString(p_281670_, minecraft.font, i);
if (this.isHovered()) { }
p_281670_.requestCursor(this.isActive() ? CursorTypes.POINTING_HAND : CursorTypes.NOT_ALLOWED);
@@ -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
@@ -238,6 +_,25 @@ @@ -236,6 +_,25 @@
this.focused = p_93693_; this.focused = p_93693_;
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/Button.java --- a/net/minecraft/client/gui/components/Button.java
+++ b/net/minecraft/client/gui/components/Button.java +++ b/net/minecraft/client/gui/components/Button.java
@@ -32,6 +_,12 @@ @@ -31,6 +_,12 @@
this.createNarration = p_259552_; this.createNarration = p_259552_;
} }
@@ -11,9 +11,9 @@
+ } + }
+ +
@Override @Override
public void onPress(InputWithModifiers p_424878_) { public void onPress() {
this.onPress.onPress(this); this.onPress.onPress(this);
@@ -96,9 +_,12 @@ @@ -95,9 +_,12 @@
} }
public Button build() { public Button build() {
@@ -0,0 +1,101 @@
--- a/net/minecraft/client/gui/components/DebugScreenOverlay.java
+++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java
@@ -139,9 +_,9 @@
@Nullable
private CompletableFuture<LevelChunk> serverChunk;
private boolean renderDebug;
- private boolean renderProfilerChart;
- private boolean renderFpsCharts;
- private boolean renderNetworkCharts;
+ protected boolean renderProfilerChart;
+ protected boolean renderFpsCharts;
+ protected boolean renderNetworkCharts;
private final LocalSampleLogger frameTimeLogger = new LocalSampleLogger(1);
private final LocalSampleLogger tickTimeLogger = new LocalSampleLogger(TpsDebugDimensions.values().length);
private final LocalSampleLogger pingLogger = new LocalSampleLogger(1);
@@ -183,15 +_,19 @@
this.clientChunk = null;
}
- public void render(GuiGraphics p_281427_) {
- ProfilerFiller profilerfiller = Profiler.get();
- profilerfiller.push("debug");
+ protected void update() {
Entity entity = this.minecraft.getCameraEntity();
this.block = entity.pick(20.0, 0.0F, false);
this.liquid = entity.pick(20.0, 0.0F, true);
+ }
+
+ protected void drawText(ProfilerFiller profilerfiller, GuiGraphics p_281427_) {
this.drawGameInformation(p_281427_);
this.drawSystemInformation(p_281427_);
p_281427_.nextStratum();
+ }
+
+ protected void drawFPSCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) {
this.profilerPieChart.setBottomOffset(10);
if (this.renderFpsCharts) {
int i = p_281427_.guiWidth();
@@ -204,7 +_,9 @@
this.profilerPieChart.setBottomOffset(this.tpsChart.getFullHeight());
}
+ }
+ protected void drawNetworkCharts(ProfilerFiller profilerfiller, GuiGraphics p_281427_) {
if (this.renderNetworkCharts) {
int l = p_281427_.guiWidth();
int i1 = l / 2;
@@ -220,12 +_,22 @@
try (Zone zone = profilerfiller.zone("profilerPie")) {
this.profilerPieChart.render(p_281427_);
}
+ }
+
+ public void render(GuiGraphics p_281427_) {
+ ProfilerFiller profilerfiller = Profiler.get();
+ profilerfiller.push("debug");
+ this.update();
+
+ this.drawText(profilerfiller, p_281427_);
+ this.drawFPSCharts(profilerfiller, p_281427_);
+ this.drawNetworkCharts(profilerfiller, p_281427_);
profilerfiller.pop();
}
- protected void drawGameInformation(GuiGraphics p_281525_) {
- List<String> list = this.getGameInformation();
+ protected List<String> getOverlayHelp() {
+ List<String> list = Lists.newArrayList();
list.add("");
boolean flag = this.minecraft.getSingleplayerServer() != null;
list.add(
@@ -239,11 +_,18 @@
+ (this.renderNetworkCharts ? " visible" : " hidden")
);
list.add("For help: press F3 + Q");
- this.renderLines(p_281525_, list, true);
+ return list;
+ }
+ protected void drawGameInformation(GuiGraphics p_281525_) {
+ List<String> list = this.getGameInformation();
+ list.addAll(this.getOverlayHelp());
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281525_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, true);
+ this.renderLines(p_281525_, list, true);
}
protected void drawSystemInformation(GuiGraphics p_281261_) {
List<String> list = this.getSystemInformation();
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeDebugEvent(p_281261_, minecraft.getWindow(), minecraft.getDeltaTracker().getRealtimeDeltaTicks(), list, false);
this.renderLines(p_281261_, list, false);
}
@@ -597,6 +_,7 @@
list.add("");
list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType())));
+ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location()));
}
return list;
@@ -1,10 +0,0 @@
--- a/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java
+++ b/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java
@@ -25,6 +_,7 @@
if (entity != null) {
list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType())));
+ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location()));
}
p_426755_.addToGroup(GROUP, list);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/render/GuiRenderer.java --- a/net/minecraft/client/gui/render/GuiRenderer.java
+++ b/net/minecraft/client/gui/render/GuiRenderer.java +++ b/net/minecraft/client/gui/render/GuiRenderer.java
@@ -146,6 +_,7 @@ @@ -134,6 +_,7 @@
builder.put((Class<? extends PictureInPictureRenderState>)pictureinpicturerenderer.getRenderStateClass(), pictureinpicturerenderer); builder.put((Class<? extends PictureInPictureRenderState>)pictureinpicturerenderer.getRenderStateClass(), pictureinpicturerenderer);
} }
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/gui/screens/ChatScreen.java --- a/net/minecraft/client/gui/screens/ChatScreen.java
+++ b/net/minecraft/client/gui/screens/ChatScreen.java +++ b/net/minecraft/client/gui/screens/ChatScreen.java
@@ -115,6 +_,7 @@ @@ -89,6 +_,7 @@
} else if (p_426273_.isConfirmation()) { return true;
} else if (p_95591_ == 257 || p_95591_ == 335) {
this.handleChatInput(this.input.getValue(), true); this.handleChatInput(this.input.getValue(), true);
this.exitReason = ChatScreen.ExitReason.DONE;
+ if (this.minecraft.screen == this) // FORGE: Prevent closing the screen if another screen has been opened. + if (this.minecraft.screen == this) // FORGE: Prevent closing the screen if another screen has been opened.
this.minecraft.setScreen(null); this.minecraft.setScreen(null);
return true; return true;
} else { } else if (p_95591_ == 265) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/ConnectScreen.java --- a/net/minecraft/client/gui/screens/ConnectScreen.java
+++ b/net/minecraft/client/gui/screens/ConnectScreen.java +++ b/net/minecraft/client/gui/screens/ConnectScreen.java
@@ -103,6 +_,8 @@ @@ -102,6 +_,8 @@
} }
if (optional.isEmpty()) { if (optional.isEmpty()) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/LoadingOverlay.java --- a/net/minecraft/client/gui/screens/LoadingOverlay.java
+++ b/net/minecraft/client/gui/screens/LoadingOverlay.java +++ b/net/minecraft/client/gui/screens/LoadingOverlay.java
@@ -62,6 +_,8 @@ @@ -61,6 +_,8 @@
return p_169325_ & 16777215 | p_169326_ << 24; return p_169325_ & 16777215 | p_169326_ << 24;
} }
@@ -9,7 +9,7 @@
@Override @Override
public void render(GuiGraphics p_281839_, int p_282704_, int p_283650_, float p_283394_) { public void render(GuiGraphics p_281839_, int p_282704_, int p_283650_, float p_283394_) {
int i = p_281839_.guiWidth(); int i = p_281839_.guiWidth();
@@ -102,6 +_,7 @@ @@ -97,6 +_,7 @@
f2 = 1.0F; f2 = 1.0F;
} }
@@ -17,7 +17,7 @@
int l2 = (int)(p_281839_.guiWidth() * 0.5); int l2 = (int)(p_281839_.guiWidth() * 0.5);
int i1 = (int)(p_281839_.guiHeight() * 0.5); int i1 = (int)(p_281839_.guiHeight() * 0.5);
double d0 = Math.min(p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25; double d0 = Math.min(p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25;
@@ -117,6 +_,7 @@ @@ -112,12 +_,14 @@
if (f < 1.0F) { if (f < 1.0F) {
this.drawProgressBar(p_281839_, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F)); this.drawProgressBar(p_281839_, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F));
} }
@@ -25,19 +25,18 @@
if (f >= 2.0F) { if (f >= 2.0F) {
this.minecraft.setOverlay(null); this.minecraft.setOverlay(null);
@@ -126,6 +_,7 @@ }
@Override
public void tick() { if (this.fadeOutStart == -1L && this.reload.isDone() && (!this.fadeIn || f1 >= 2.0F)) {
if (this.fadeOutStart == -1L && this.reload.isDone() && this.isReadyToFadeOut()) {
+ this.fadeOutStart = Util.getMillis(); // Forge: Moved up to guard against inf loops caused by callback + this.fadeOutStart = Util.getMillis(); // Forge: Moved up to guard against inf loops caused by callback
try { try {
this.reload.checkExceptions(); this.reload.checkExceptions();
this.onFinish.accept(Optional.empty()); this.onFinish.accept(Optional.empty());
@@ -133,7 +_,6 @@ @@ -125,7 +_,6 @@
this.onFinish.accept(Optional.of(throwable)); this.onFinish.accept(Optional.of(throwable));
} }
- this.fadeOutStart = Util.getMillis(); - this.fadeOutStart = Util.getMillis();
if (this.minecraft.screen != null) { if (this.minecraft.screen != null) {
Window window = this.minecraft.getWindow(); this.minecraft.screen.init(this.minecraft, p_281839_.guiWidth(), p_281839_.guiHeight());
this.minecraft.screen.init(this.minecraft, window.getGuiScaledWidth(), window.getGuiScaledHeight()); }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/PauseScreen.java --- a/net/minecraft/client/gui/screens/PauseScreen.java
+++ b/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java
@@ -103,6 +_,7 @@ @@ -105,6 +_,7 @@
} else { } else {
gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this))); gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this)));
} }
@@ -9,7 +9,7 @@
} }
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T p_169406_) { protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T p_169406_) {
@@ -343,8 +_,10 @@ @@ -339,8 +_,10 @@
this.width = p_96608_; this.width = p_96608_;
this.height = p_96609_; this.height = p_96609_;
if (!this.initialized) { if (!this.initialized) {
@@ -20,7 +20,7 @@
} else { } else {
this.repositionElements(); this.repositionElements();
} }
@@ -361,8 +_,10 @@ @@ -353,8 +_,10 @@
protected void rebuildWidgets() { protected void rebuildWidgets() {
this.clearWidgets(); this.clearWidgets();
this.clearFocus(); this.clearFocus();
@@ -31,16 +31,15 @@
} }
protected void fadeWidgets(float p_409453_) { protected void fadeWidgets(float p_409453_) {
@@ -402,6 +_,8 @@ @@ -389,6 +_,7 @@
this.renderMenuBackground(p_283688_);
}
this.renderBlurredBackground(p_283688_);
this.renderMenuBackground(p_283688_);
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, p_283688_); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderScreenBackground(this, p_283688_);
+
this.minecraft.gui.renderDeferredSubtitles();
} }
@@ -484,6 +_,19 @@ protected void renderBlurredBackground(GuiGraphics p_407253_) {
@@ -492,6 +_,19 @@
} }
public void onFilesDrop(List<Path> p_96591_) { public void onFilesDrop(List<Path> p_96591_) {
@@ -1,6 +1,6 @@
--- 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
@@ -55,6 +_,7 @@ @@ -54,6 +_,7 @@
private boolean fading; private boolean fading;
private long fadeInStart; private long fadeInStart;
private final LogoRenderer logoRenderer; private final LogoRenderer logoRenderer;
@@ -8,7 +8,7 @@
public TitleScreen() { public TitleScreen() {
this(false); this(false);
@@ -107,11 +_,15 @@ @@ -106,11 +_,15 @@
int j = this.width - i - 2; int j = this.width - i - 2;
int k = 24; int k = 24;
int l = this.height / 4 + 48; int l = this.height / 4 + 48;
@@ -24,7 +24,7 @@
l = this.createTestWorldButton(l, 24); l = this.createTestWorldButton(l, 24);
SpriteIconButton spriteiconbutton = this.addRenderableWidget( SpriteIconButton spriteiconbutton = this.addRenderableWidget(
@@ -178,7 +_,7 @@ @@ -175,7 +_,7 @@
}).bounds(this.width / 2 - 100, i = p_96764_ + p_96765_, 200, 20).tooltip(tooltip).build()).active = flag; }).bounds(this.width / 2 - 100, i = p_96764_ + p_96765_, 200, 20).tooltip(tooltip).build()).active = flag;
this.addRenderableWidget( this.addRenderableWidget(
Button.builder(Component.translatable("menu.online"), p_325369_ -> this.minecraft.setScreen(new RealmsMainScreen(this))) Button.builder(Component.translatable("menu.online"), p_325369_ -> this.minecraft.setScreen(new RealmsMainScreen(this)))
@@ -33,7 +33,7 @@
.tooltip(tooltip) .tooltip(tooltip)
.build() .build()
) )
@@ -298,9 +_,18 @@ @@ -295,9 +_,18 @@
s = s + I18n.get("menu.modded"); s = s + I18n.get("menu.modded");
} }
@@ -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
@@ -53,6 +_,7 @@ @@ -51,6 +_,7 @@
@Nullable @Nullable
private AdvancementTab selectedTab; private AdvancementTab selectedTab;
private boolean isScrolling; private boolean isScrolling;
@@ -8,7 +8,7 @@
public AdvancementsScreen(ClientAdvancements p_97340_) { public AdvancementsScreen(ClientAdvancements p_97340_) {
this(p_97340_, null); this(p_97340_, null);
@@ -66,6 +_,19 @@ @@ -64,6 +_,19 @@
@Override @Override
protected void init() { protected void init() {
@@ -28,16 +28,16 @@
this.layout.addTitleHeader(TITLE, this.font); this.layout.addTitleHeader(TITLE, this.font);
this.tabs.clear(); this.tabs.clear();
this.selectedTab = null; this.selectedTab = null;
@@ -110,7 +_,7 @@ @@ -108,7 +_,7 @@
int j = (this.height - 140) / 2; int j = (this.height - 140) / 2;
for (AdvancementTab advancementtab : this.tabs.values()) { for (AdvancementTab advancementtab : this.tabs.values()) {
- if (advancementtab.isMouseOver(i, j, p_431395_.x(), p_431395_.y())) { - if (advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) {
+ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, p_431395_.x(), p_431395_.y())) { + if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, p_97343_, p_97344_)) {
this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true); this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true);
break; break;
} }
@@ -185,10 +_,12 @@ @@ -183,10 +_,12 @@
p_283395_.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, p_281890_, p_282532_, 0.0F, 0.0F, 252, 140, 256, 256); p_283395_.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, p_281890_, p_282532_, 0.0F, 0.0F, 252, 140, 256, 256);
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab advancementtab : this.tabs.values()) { for (AdvancementTab advancementtab : this.tabs.values()) {
@@ -50,7 +50,7 @@
advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_); advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_);
} }
} }
@@ -207,6 +_,7 @@ @@ -205,6 +_,7 @@
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab advancementtab : this.tabs.values()) { for (AdvancementTab advancementtab : this.tabs.values()) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
@@ -105,6 +_,7 @@ @@ -107,6 +_,7 @@
int i = this.leftPos; int i = this.leftPos;
int j = this.topPos; int j = this.topPos;
super.render(p_409971_, p_409213_, p_408205_, p_408282_); super.render(p_409971_, p_409213_, p_408205_, p_408282_);
@@ -8,7 +8,7 @@
p_409971_.pose().pushMatrix(); p_409971_.pose().pushMatrix();
p_409971_.pose().translate(i, j); p_409971_.pose().translate(i, j);
this.renderLabels(p_409971_, p_409213_, p_408205_); this.renderLabels(p_409971_, p_409213_, p_408205_);
@@ -117,6 +_,8 @@ @@ -119,6 +_,8 @@
this.onStopHovering(slot); this.onStopHovering(slot);
} }
@@ -17,7 +17,7 @@
p_409971_.pose().popMatrix(); p_409971_.pose().popMatrix();
} }
@@ -200,7 +_,7 @@ @@ -202,7 +_,7 @@
ItemStack itemstack = this.hoveredSlot.getItem(); ItemStack itemstack = this.hoveredSlot.getItem();
if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(itemstack)) { if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(itemstack)) {
p_283594_.setTooltipForNextFrame( p_283594_.setTooltipForNextFrame(
@@ -26,7 +26,7 @@
); );
} }
} }
@@ -216,7 +_,8 @@ @@ -218,7 +_,8 @@
private void renderFloatingItem(GuiGraphics p_282567_, ItemStack p_281330_, int p_281772_, int p_281689_, @Nullable String p_282568_) { private void renderFloatingItem(GuiGraphics p_282567_, ItemStack p_281330_, int p_281772_, int p_281689_, @Nullable String p_282568_) {
p_282567_.renderItem(p_281330_, p_281772_, p_281689_); p_282567_.renderItem(p_281330_, p_281772_, p_281689_);
@@ -36,84 +36,87 @@
} }
protected void renderLabels(GuiGraphics p_281635_, int p_282681_, int p_283686_) { protected void renderLabels(GuiGraphics p_281635_, int p_282681_, int p_283686_) {
@@ -317,7 +_,8 @@ @@ -319,7 +_,8 @@
if (super.mouseClicked(p_427253_, p_427622_)) { if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) {
return true; return true;
} else { } else {
- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_427253_) && this.minecraft.player.hasInfiniteMaterials(); - boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.player.hasInfiniteMaterials();
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(p_427253_.button()); + InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_);
+ boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials(); + boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey);
Slot slot = this.getHoveredSlot(p_427253_.x(), p_427253_.y()); Slot slot = this.getHoveredSlot(p_97748_, p_97749_);
this.doubleclick = this.lastClickSlot == slot && p_427622_; long i = Util.getMillis();
this.skipNextRelease = false; this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == p_97750_;
@@ -327,6 +_,7 @@ @@ -330,6 +_,7 @@
int i = this.leftPos; int j = this.leftPos;
int j = this.topPos; int k = this.topPos;
boolean flag1 = this.hasClickedOutside(p_427253_.x(), p_427253_.y(), i, j); boolean flag1 = this.hasClickedOutside(p_97748_, p_97749_, j, k, p_97750_);
+ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries + if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int k = -1; int l = -1;
if (slot != null) { if (slot != null) {
k = slot.index; l = slot.index;
@@ -352,7 +_,7 @@ @@ -355,7 +_,7 @@
} }
} else if (!this.isQuickCrafting) { } else if (!this.isQuickCrafting) {
if (this.menu.getCarried().isEmpty()) { if (this.menu.getCarried().isEmpty()) {
- if (flag) { - if (flag) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, k, p_427253_.button(), ClickType.CLONE); this.slotClicked(slot, l, p_97750_, ClickType.CLONE);
} else { } else {
boolean flag2 = k != -999 && p_427253_.hasShiftDown(); boolean flag2 = l != -999
@@ -376,7 +_,7 @@ @@ -383,7 +_,7 @@
this.quickCraftingType = 0; this.quickCraftingType = 0;
} else if (p_427253_.button() == 1) { } else if (p_97750_ == 1) {
this.quickCraftingType = 1; this.quickCraftingType = 1;
- } else if (flag) { - } else if (flag) {
+ } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.quickCraftingType = 2; this.quickCraftingType = 2;
} }
} }
@@ -453,10 +_,13 @@ @@ -459,10 +_,13 @@
@Override @Override
public boolean mouseReleased(MouseButtonEvent p_430939_) { public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) {
+ super.mouseReleased(p_430939_); //Forge, Call parent to release buttons + super.mouseReleased(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons
Slot slot = this.getHoveredSlot(p_430939_.x(), p_430939_.y()); Slot slot = this.getHoveredSlot(p_97812_, p_97813_);
int i = this.leftPos; int i = this.leftPos;
int j = this.topPos; int j = this.topPos;
boolean flag = this.hasClickedOutside(p_430939_.x(), p_430939_.y(), i, j); boolean flag = this.hasClickedOutside(p_97812_, p_97813_, i, j, p_97814_);
+ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries + if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(p_430939_.button()); + InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97814_);
int k = -1; int k = -1;
if (slot != null) { if (slot != null) {
k = slot.index; k = slot.index;
@@ -473,7 +_,7 @@ @@ -479,7 +_,7 @@
if (slot2 != null if (slot2 != null
&& slot2.mayPickup(this.minecraft.player) && slot2.mayPickup(this.minecraft.player)
&& slot2.hasItem() && slot2.hasItem()
- && slot2.container == slot.container - && slot2.container == slot.container
+ && slot2.isSameInventory(slot) + && slot2.isSameInventory(slot)
&& AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) {
this.slotClicked(slot2, slot2.index, p_430939_.button(), ClickType.QUICK_MOVE); this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE);
} }
@@ -538,7 +_,7 @@ @@ -545,7 +_,7 @@
this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT);
} else if (!this.menu.getCarried().isEmpty()) { } else if (!this.menu.getCarried().isEmpty()) {
- if (this.minecraft.options.keyPickItem.matchesMouse(p_430939_)) { - if (this.minecraft.options.keyPickItem.matchesMouse(p_97814_)) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, k, p_430939_.button(), ClickType.CLONE); this.slotClicked(slot, k, p_97814_, ClickType.CLONE);
} else { } else {
boolean flag1 = k != -999 && p_430939_.hasShiftDown(); boolean flag1 = k != -999
@@ -609,7 +_,7 @@ @@ -622,9 +_,10 @@
public boolean keyPressed(KeyEvent p_424324_) {
if (super.keyPressed(p_424324_)) { @Override
public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) {
+ InputConstants.Key mouseKey = InputConstants.getKey(p_97765_, p_97766_);
if (super.keyPressed(p_97765_, p_97766_, p_97767_)) {
return true; return true;
- } else if (this.minecraft.options.keyInventory.matches(p_424324_)) { - } else if (this.minecraft.options.keyInventory.matches(p_97765_, p_97766_)) {
+ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(com.mojang.blaze3d.platform.InputConstants.getKey(p_424324_))) { + } else if (this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey)) {
this.onClose(); this.onClose();
return true; return true;
} else { } else {
@@ -688,6 +_,13 @@ @@ -698,6 +_,13 @@
super.onClose(); super.onClose();
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
@@ -116,6 +_,8 @@ @@ -113,6 +_,8 @@
private final Set<TagKey<Item>> visibleTags = new HashSet<>(); private final Set<TagKey<Item>> visibleTags = new HashSet<>();
private final boolean displayOperatorCreativeTab; private final boolean displayOperatorCreativeTab;
private final EffectsInInventory effects; private final EffectsInInventory effects;
@@ -9,7 +9,7 @@
public CreativeModeInventoryScreen(LocalPlayer p_344408_, FeatureFlagSet p_260074_, boolean p_259569_) { public CreativeModeInventoryScreen(LocalPlayer p_344408_, FeatureFlagSet p_260074_, boolean p_259569_) {
super(new CreativeModeInventoryScreen.ItemPickerMenu(p_344408_), p_344408_.getInventory(), CommonComponents.EMPTY); super(new CreativeModeInventoryScreen.ItemPickerMenu(p_344408_), p_344408_.getInventory(), CommonComponents.EMPTY);
@@ -164,7 +_,7 @@ @@ -161,7 +_,7 @@
private void refreshCurrentTabContents(Collection<ItemStack> p_261591_) { private void refreshCurrentTabContents(Collection<ItemStack> p_261591_) {
int i = this.menu.getRowIndexForScroll(this.scrollOffs); int i = this.menu.getRowIndexForScroll(this.scrollOffs);
this.menu.items.clear(); this.menu.items.clear();
@@ -18,7 +18,7 @@
this.refreshSearchResults(); this.refreshSearchResults();
} else { } else {
this.menu.items.addAll(p_261591_); this.menu.items.addAll(p_261591_);
@@ -332,6 +_,36 @@ @@ -329,6 +_,36 @@
protected void init() { protected void init() {
if (this.minecraft.player.hasInfiniteMaterials()) { if (this.minecraft.player.hasInfiniteMaterials()) {
super.init(); super.init();
@@ -55,8 +55,8 @@
this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search")); this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search"));
this.searchBox.setMaxLength(50); this.searchBox.setMaxLength(50);
this.searchBox.setBordered(false); this.searchBox.setBordered(false);
@@ -378,7 +_,7 @@ @@ -375,7 +_,7 @@
public boolean charTyped(CharacterEvent p_424087_) { public boolean charTyped(char p_98521_, int p_98522_) {
if (this.ignoreTextInput) { if (this.ignoreTextInput) {
return false; return false;
- } else if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) { - } else if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) {
@@ -64,16 +64,16 @@
return false; return false;
} else { } else {
String s = this.searchBox.getValue(); String s = this.searchBox.getValue();
@@ -397,7 +_,7 @@ @@ -394,7 +_,7 @@
@Override @Override
public boolean keyPressed(KeyEvent p_429237_) { public boolean keyPressed(int p_98547_, int p_98548_, int p_98549_) {
this.ignoreTextInput = false; this.ignoreTextInput = false;
- if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) { - if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) {
+ if (!selectedTab.hasSearchBar()) { + if (!selectedTab.hasSearchBar()) {
if (this.minecraft.options.keyChat.matches(p_429237_)) { if (this.minecraft.options.keyChat.matches(p_98547_, p_98548_)) {
this.ignoreTextInput = true; this.ignoreTextInput = true;
this.selectTab(CreativeModeTabs.searchTab()); this.selectTab(CreativeModeTabs.searchTab());
@@ -433,6 +_,7 @@ @@ -430,6 +_,7 @@
} }
private void refreshSearchResults() { private void refreshSearchResults() {
@@ -81,7 +81,7 @@
this.menu.items.clear(); this.menu.items.clear();
this.visibleTags.clear(); this.visibleTags.clear();
String s = this.searchBox.getValue(); String s = this.searchBox.getValue();
@@ -445,10 +_,10 @@ @@ -442,10 +_,10 @@
SearchTree<ItemStack> searchtree; SearchTree<ItemStack> searchtree;
if (s.startsWith("#")) { if (s.startsWith("#")) {
s = s.substring(1); s = s.substring(1);
@@ -94,7 +94,7 @@
} }
this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT))); this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT)));
@@ -480,7 +_,8 @@ @@ -477,7 +_,8 @@
@Override @Override
protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) { protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) {
if (selectedTab.showTitle()) { if (selectedTab.showTitle()) {
@@ -104,17 +104,17 @@
} }
} }
@@ -490,7 +_,7 @@ @@ -487,7 +_,7 @@
double d0 = p_430803_.x() - this.leftPos; double d0 = p_98531_ - this.leftPos;
double d1 = p_430803_.y() - this.topPos; double d1 = p_98532_ - this.topPos;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
+ for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) {
if (this.checkTabClicked(creativemodetab, d0, d1)) { if (this.checkTabClicked(creativemodetab, d0, d1)) {
return true; return true;
} }
@@ -512,7 +_,7 @@ @@ -509,7 +_,7 @@
double d1 = p_423848_.y() - this.topPos; double d1 = p_98623_ - this.topPos;
this.scrolling = false; this.scrolling = false;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
@@ -122,7 +122,7 @@
if (this.checkTabClicked(creativemodetab, d0, d1)) { if (this.checkTabClicked(creativemodetab, d0, d1)) {
this.selectTab(creativemodetab); this.selectTab(creativemodetab);
return true; return true;
@@ -606,13 +_,15 @@ @@ -603,13 +_,15 @@
this.originalSlots = null; this.originalSlots = null;
} }
@@ -139,7 +139,7 @@
this.refreshSearchResults(); this.refreshSearchResults();
} else { } else {
@@ -676,7 +_,14 @@ @@ -673,7 +_,14 @@
super.render(p_283000_, p_281317_, p_282770_, p_281295_); super.render(p_283000_, p_281317_, p_282770_, p_281295_);
this.effects.renderTooltip(p_283000_, p_281317_, p_282770_); this.effects.renderTooltip(p_283000_, p_281317_, p_282770_);
@@ -155,7 +155,7 @@
if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) {
break; break;
} }
@@ -700,7 +_,7 @@ @@ -697,7 +_,7 @@
public List<Component> getTooltipFromContainerItem(ItemStack p_281769_) { public List<Component> getTooltipFromContainerItem(ItemStack p_281769_) {
boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot;
boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY;
@@ -164,7 +164,7 @@
TooltipFlag.Default tooltipflag$default = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; TooltipFlag.Default tooltipflag$default = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL;
TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default; TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default;
List<Component> list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag); List<Component> list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag);
@@ -721,7 +_,7 @@ @@ -718,7 +_,7 @@
int i = 1; int i = 1;
for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
@@ -173,7 +173,7 @@
list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
} }
} }
@@ -732,7 +_,7 @@ @@ -729,7 +_,7 @@
@Override @Override
protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) {
@@ -182,7 +182,7 @@
if (creativemodetab != selectedTab) { if (creativemodetab != selectedTab) {
this.renderTabButton(p_282663_, creativemodetab); this.renderTabButton(p_282663_, creativemodetab);
} }
@@ -748,6 +_,7 @@ @@ -745,6 +_,7 @@
p_282663_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15); p_282663_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15);
} }
@@ -190,7 +190,7 @@
this.renderTabButton(p_282663_, selectedTab); this.renderTabButton(p_282663_, selectedTab);
if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) {
InventoryScreen.renderEntityInInventoryFollowsMouse( InventoryScreen.renderEntityInInventoryFollowsMouse(
@@ -766,7 +_,7 @@ @@ -763,7 +_,7 @@
} }
private int getTabX(CreativeModeTab p_260136_) { private int getTabX(CreativeModeTab p_260136_) {
@@ -199,7 +199,7 @@
int j = 27; int j = 27;
int k = 27 * i; int k = 27 * i;
if (p_260136_.isAlignedRight()) { if (p_260136_.isAlignedRight()) {
@@ -778,7 +_,7 @@ @@ -775,7 +_,7 @@
private int getTabY(CreativeModeTab p_260181_) { private int getTabY(CreativeModeTab p_260181_) {
int i = 0; int i = 0;
@@ -208,7 +208,7 @@
i -= 32; i -= 32;
} else { } else {
i += this.imageHeight; i += this.imageHeight;
@@ -806,8 +_,8 @@ @@ -803,8 +_,8 @@
protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) { protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) {
boolean flag = p_283489_ == selectedTab; boolean flag = p_283489_ == selectedTab;
@@ -219,7 +219,7 @@
int j = this.leftPos + this.getTabX(p_283489_); int j = this.leftPos + this.getTabX(p_283489_);
int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4));
ResourceLocation[] aresourcelocation; ResourceLocation[] aresourcelocation;
@@ -817,6 +_,7 @@ @@ -814,6 +_,7 @@
aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS; aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS;
} }
@@ -227,7 +227,7 @@
p_283590_.blitSprite(RenderPipelines.GUI_TEXTURED, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); p_283590_.blitSprite(RenderPipelines.GUI_TEXTURED, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32);
int l = j + 13 - 8; int l = j + 13 - 8;
int i1 = k + 16 - 8 + (flag1 ? 1 : -1); int i1 = k + 16 - 8 + (flag1 ? 1 : -1);
@@ -853,6 +_,14 @@ @@ -850,6 +_,14 @@
} }
} }
@@ -242,7 +242,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
static class CustomCreativeSlot extends Slot { static class CustomCreativeSlot extends Slot {
public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) {
@@ -1034,6 +_,22 @@ @@ -1031,6 +_,22 @@
@Override @Override
public boolean mayPickup(Player p_98665_) { public boolean mayPickup(Player p_98665_) {
return this.target.mayPickup(p_98665_); return this.target.mayPickup(p_98665_);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java
@@ -107,7 +_,7 @@ @@ -106,7 +_,7 @@
int l1 = 86 - this.font.width(s); int l1 = 86 - this.font.width(s);
FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1); FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1);
int i2 = -9937334; int i2 = -9937334;
@@ -9,7 +9,7 @@
p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19);
p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); p_282430_.blitSprite(RenderPipelines.GUI_TEXTURED, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16);
p_282430_.drawWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, ARGB.opaque((i2 & 16711422) >> 1), false); p_282430_.drawWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, ARGB.opaque((i2 & 16711422) >> 1), false);
@@ -158,13 +_,16 @@ @@ -157,13 +_,16 @@
.registryAccess() .registryAccess()
.lookupOrThrow(Registries.ENCHANTMENT) .lookupOrThrow(Registries.ENCHANTMENT)
.get(this.menu.enchantClue[j]); .get(this.menu.enchantClue[j]);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java --- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java +++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java
@@ -230,6 +_,14 @@ @@ -229,6 +_,14 @@
} else { } else {
p_281357_.renderItemDecorations(this.font, p_282046_, p_282403_, p_283601_, p_282046_.getCount() == 1 ? "1" : null); p_281357_.renderItemDecorations(this.font, p_282046_, p_282403_, p_283601_, p_282046_.getCount() == 1 ? "1" : null);
p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_ + 14, p_283601_, p_283466_.getCount() == 1 ? "1" : null); p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_ + 14, p_283601_, p_283466_.getCount() == 1 ? "1" : null);
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
+++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
@@ -363,6 +_,8 @@ @@ -371,6 +_,8 @@
p_425273_.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), p_424268_, p_430737_); p_281406_.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), p_283567_, p_282864_);
} }
+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, p_425273_, this.getContentX(), this.getContentY(), this.getContentWidth(), p_424268_ - this.getContentX(), p_430737_ - this.getContentY()); + net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.screen, serverData, p_281406_, p_281363_, p_282921_, p_283596_, p_283567_ - p_281363_, p_282864_ - p_282921_);
+ +
if (this.minecraft.options.touchscreen().get() || p_425246_) { if (this.minecraft.options.touchscreen().get() || p_282999_) {
p_425273_.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544); p_281406_.fill(p_281363_, p_282921_, p_281363_ + 32, p_282921_ + 32, -1601138544);
int i1 = p_424268_ - this.getContentX(); int l = p_283567_ - p_281363_;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java --- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java +++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
@@ -115,9 +_,10 @@ @@ -148,9 +_,10 @@
this.name = p_343976_; this.name = p_343976_;
this.changeButton = Button.builder(p_343976_, p_342196_ -> { this.changeButton = Button.builder(p_343976_, p_342196_ -> {
KeyBindsList.this.keyBindsScreen.selectedKey = p_343088_; KeyBindsList.this.keyBindsScreen.selectedKey = p_343088_;
@@ -12,7 +12,7 @@
.createNarration( .createNarration(
p_342179_ -> p_343088_.isUnbound() p_342179_ -> p_343088_.isUnbound()
? Component.translatable("narrator.controls.unbound", p_343976_) ? Component.translatable("narrator.controls.unbound", p_343976_)
@@ -125,7 +_,7 @@ @@ -158,7 +_,7 @@
) )
.build(); .build();
this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_357685_ -> { this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_357685_ -> {
@@ -21,13 +21,12 @@
KeyBindsList.this.resetMappingAndUpdateButtons(); KeyBindsList.this.resetMappingAndUpdateButtons();
}).bounds(0, 0, 50, 20).createNarration(p_344192_ -> Component.translatable("narrator.controls.reset", p_343976_)).build(); }).bounds(0, 0, 50, 20).createNarration(p_344192_ -> Component.translatable("narrator.controls.reset", p_343976_)).build();
this.refreshEntry(); this.refreshEntry();
@@ -166,7 +_,8 @@ @@ -210,7 +_,7 @@
MutableComponent mutablecomponent = Component.empty(); MutableComponent mutablecomponent = Component.empty();
if (!this.key.isUnbound()) { if (!this.key.isUnbound()) {
for (KeyMapping keymapping : KeyBindsList.this.minecraft.options.keyMappings) { for (KeyMapping keymapping : KeyBindsList.this.minecraft.options.keyMappings) {
- if (keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault())) { - if (keymapping != this.key && this.key.same(keymapping)) {
+ var vanillConflict = keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault()); + if ((keymapping != this.key && this.key.same(keymapping)) || keymapping.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G
+ if (vanillConflict || keymapping.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G
if (this.hasCollision) { if (this.hasCollision) {
mutablecomponent.append(", "); mutablecomponent.append(", ");
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java --- a/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java +++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java
@@ -43,7 +_,7 @@ @@ -41,7 +_,7 @@
protected void addFooter() { protected void addFooter() {
this.resetButton = Button.builder(Component.translatable("controls.resetAll"), p_343640_ -> { this.resetButton = Button.builder(Component.translatable("controls.resetAll"), p_343640_ -> {
for (KeyMapping keymapping : this.options.keyMappings) { for (KeyMapping keymapping : this.options.keyMappings) {
@@ -9,37 +9,37 @@
} }
this.keyBindsList.resetMappingAndUpdateButtons(); this.keyBindsList.resetMappingAndUpdateButtons();
@@ -75,11 +_,12 @@ @@ -73,11 +_,12 @@
public boolean keyPressed(KeyEvent p_424487_) { public boolean keyPressed(int p_342715_, int p_342862_, int p_345515_) {
if (this.selectedKey != null) { if (this.selectedKey != null) {
if (p_424487_.isEscape()) { if (p_342715_ == 256) {
- this.selectedKey.setKey(InputConstants.UNKNOWN); - this.selectedKey.setKey(InputConstants.UNKNOWN);
+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.UNKNOWN); + this.selectedKey.setKeyModifierAndCode(null, InputConstants.UNKNOWN);
} else { } else {
- this.selectedKey.setKey(InputConstants.getKey(p_424487_)); - this.selectedKey.setKey(InputConstants.getKey(p_342715_, p_342862_));
+ this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_424487_)); + this.selectedKey.setKeyModifierAndCode(null, InputConstants.getKey(p_342715_, p_342862_));
} }
+ if (p_424487_.isEscape() || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey())) + if (p_342715_ == 256 || !net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.selectedKey.getKey()))
this.selectedKey = null; this.selectedKey = null;
this.lastKeySelection = Util.getMillis(); this.lastKeySelection = Util.getMillis();
this.keyBindsList.resetMappingAndUpdateButtons(); this.keyBindsList.resetMappingAndUpdateButtons();
@@ -102,5 +_,18 @@ @@ -100,5 +_,18 @@
} }
this.resetButton.active = flag; this.resetButton.active = flag;
+ } + }
+ +
+ @Override + @Override
+ public boolean keyReleased(KeyEvent event) { + public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
+ // Forge: We wait for a second key above if the first press is a modifier + // Forge: We wait for a second key above if the first press is a modifier
+ // but if they release the modifier then set it explicitly. + // but if they release the modifier then set it explicitly.
+ var key = InputConstants.getKey(event); + var key = InputConstants.getKey(keyCode, scanCode);
+ if (this.selectedKey != null && this.selectedKey.getKey() == key) { + if (this.selectedKey != null && this.selectedKey.getKey() == key) {
+ this.selectedKey = null; + this.selectedKey = null;
+ this.lastKeySelection = Util.getMillis(); + this.lastKeySelection = Util.getMillis();
+ this.keyBindsList.resetMappingAndUpdateButtons(); + this.keyBindsList.resetMappingAndUpdateButtons();
+ } + }
+ return super.keyReleased(event); + return super.keyReleased(keyCode, scanCode, modifiers);
} }
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java --- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
+++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java +++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
@@ -108,6 +_,10 @@ @@ -106,6 +_,10 @@
boolean canMoveUp(); boolean canMoveUp();
boolean canMoveDown(); boolean canMoveDown();
@@ -11,7 +11,7 @@
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -207,6 +_,11 @@ @@ -205,6 +_,11 @@
@Override @Override
public void moveDown() { public void moveDown() {
this.move(1); this.move(1);
@@ -0,0 +1,11 @@
--- a/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java
+++ b/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java
@@ -159,7 +_,7 @@
TransferableSelectionList.PackEntry transferableselectionlist$packentry = p_100014_.getSelected();
String s = transferableselectionlist$packentry == null ? "" : transferableselectionlist$packentry.getPackId();
p_100014_.setSelected(null);
- p_100015_.forEach(
+ p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach(
p_404866_ -> {
TransferableSelectionList.PackEntry transferableselectionlist$packentry1 = new TransferableSelectionList.PackEntry(
this.minecraft, p_100014_, p_404866_
@@ -1,11 +0,0 @@
--- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
+++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
@@ -64,7 +_,7 @@
Component component = Component.empty().append(this.title).withStyle(ChatFormatting.UNDERLINE, ChatFormatting.BOLD);
this.addEntry(new TransferableSelectionList.HeaderEntry(this.minecraft.font, component), (int)(9.0F * 1.5F));
this.setSelected(null);
- p_429245_.forEach(p_430444_ -> {
+ p_429245_.filter(PackSelectionModel.Entry::notHidden).forEach(p_430444_ -> {
TransferableSelectionList.PackEntry transferableselectionlist$packentry = new TransferableSelectionList.PackEntry(this.minecraft, this, p_430444_);
this.addEntry(transferableselectionlist$packentry);
if (p_430177_ != null && p_430177_.getId().equals(p_430444_.getId())) {
@@ -1,7 +1,7 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
@@ -329,6 +_,8 @@ @@ -329,6 +_,8 @@
this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); this.minecraft.forceSetScreen(new GenericMessageScreen(Component.translatable("selectWorld.resource_load")));
PackRepository packrepository = ServerPacksSource.createPackRepository(p_333651_); PackRepository packrepository = ServerPacksSource.createPackRepository(p_333651_);
+ net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(p_333651_, p_333651_.getLevelDirectory()); + net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(p_333651_, p_333651_.getLevelDirectory());
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java --- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
@@ -79,6 +_,7 @@ @@ -75,6 +_,7 @@
static final ResourceLocation JOIN_HIGHLIGHTED_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join_highlighted"); static final ResourceLocation JOIN_HIGHLIGHTED_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join_highlighted");
static final ResourceLocation JOIN_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join"); static final ResourceLocation JOIN_SPRITE = ResourceLocation.withDefaultNamespace("world_list/join");
static final Logger LOGGER = LogUtils.getLogger(); static final Logger LOGGER = LogUtils.getLogger();
@@ -8,31 +8,31 @@
static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED); static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED);
static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED); static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED);
static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD); static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD);
@@ -494,6 +_,19 @@ @@ -400,6 +_,7 @@
p_281612_.drawString(this.minecraft.font, s1, p_282820_ + 32 + 3, p_283181_ + 9 + 3, -8355712);
p_281612_.drawString(this.minecraft.font, component, p_282820_ + 32 + 3, p_283181_ + 9 + 9 + 3, -8355712);
p_281612_.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32);
+ renderExperimentalWarning(p_281612_, p_283204_, p_283025_, p_283181_, p_282820_);
if (this.minecraft.options.touchscreen().get() || p_283396_) {
p_281612_.fill(p_282820_, p_283181_, p_282820_ + 32, p_283181_ + 32, -1601138544);
int j = p_283204_ - p_282820_;
@@ -450,6 +_,19 @@
p_281612_.blitSprite(RenderPipelines.GUI_TEXTURED, resourcelocation, p_282820_, p_283181_, 32, 32);
}
} }
} + }
+
+ // FORGE: Patch in experimental warning icon for worlds in the world selection screen + // FORGE: Patch in experimental warning icon for worlds in the world selection screen
+ private void renderExperimentalWarning(GuiGraphics guiGraphics, int mouseX, int mouseY, int top, int left) { + private void renderExperimentalWarning(GuiGraphics guiGraphics, int mouseX, int mouseY, int top, int left) {
+ if (this.summary.isLifecycleExperimental()) { + if (this.summary.isLifecycleExperimental()) {
+ int leftStart = left + this.list.getRowWidth(); + int leftStart = left + WorldSelectionList.this.getRowWidth();
+ guiGraphics.blit(RenderPipelines.GUI_TEXTURED, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); + guiGraphics.blit(RenderPipelines.GUI_TEXTURED, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32);
+ if (this.list.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { + if (WorldSelectionList.this.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) {
+ var font = Minecraft.getInstance().font; + var font = Minecraft.getInstance().font;
+ List<net.minecraft.util.FormattedCharSequence> tooltip = font.split(Component.translatable("forge.experimentalsettings.tooltip"), 200); + List<net.minecraft.util.FormattedCharSequence> tooltip = font.split(Component.translatable("forge.experimentalsettings.tooltip"), 200);
+ guiGraphics.setTooltipForNextFrame(font, tooltip, mouseX, mouseY); + guiGraphics.setTooltipForNextFrame(font, tooltip, mouseX, mouseY);
+ } + }
+ } + }
+ } }
+
@Override @Override
public Component getNarration() {
Component component = Component.translatable(
@@ -520,6 +_,7 @@
this.infoText.setPosition(i, this.getContentY() + 9 + 9 + 3);
this.infoText.render(p_424437_, p_425443_, p_425024_, p_424775_);
p_424437_.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), this.getContentX(), this.getContentY(), 0.0F, 0.0F, 32, 32, 32, 32);
+ renderExperimentalWarning(p_424437_, p_425443_, p_425024_, this.getContentY(), this.getContentX());
if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && (this.minecraft.options.touchscreen().get() || p_430261_)) {
p_424437_.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
int j = p_425443_ - this.getContentX();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/main/Main.java --- a/net/minecraft/client/main/Main.java
+++ b/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java
@@ -116,8 +_,8 @@ @@ -123,8 +_,8 @@
CrashReport.preload(); CrashReport.preload();
logger = LogUtils.getLogger(); logger = LogUtils.getLogger();
s1 = "Bootstrap"; s1 = "Bootstrap";
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/model/HumanoidModel.java --- a/net/minecraft/client/model/HumanoidModel.java
+++ b/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java
@@ -290,6 +_,8 @@ @@ -255,6 +_,8 @@
case BRUSH: case BRUSH:
this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5); this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5);
this.rightArm.yRot = 0.0F; this.rightArm.yRot = 0.0F;
@@ -9,7 +9,7 @@
} }
} }
@@ -334,6 +_,8 @@ @@ -299,6 +_,8 @@
case BRUSH: case BRUSH:
this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5); this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5);
this.leftArm.yRot = 0.0F; this.leftArm.yRot = 0.0F;
@@ -18,7 +18,7 @@
} }
} }
@@ -402,7 +_,7 @@ @@ -377,7 +_,7 @@
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -27,7 +27,7 @@
EMPTY(false), EMPTY(false),
ITEM(false), ITEM(false),
BLOCK(false), BLOCK(false),
@@ -418,10 +_,28 @@ @@ -393,10 +_,28 @@
private ArmPose(final boolean p_102896_) { private ArmPose(final boolean p_102896_) {
this.twoHanded = p_102896_; this.twoHanded = p_102896_;
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/model/geom/LayerDefinitions.java --- a/net/minecraft/client/model/geom/LayerDefinitions.java
+++ b/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java
@@ -506,6 +_,7 @@ @@ -505,6 +_,7 @@
builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition57); builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition60);
} }
}); });
+ net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder);
ImmutableMap<ModelLayerLocation, LayerDefinition> immutablemap = builder.build(); ImmutableMap<ModelLayerLocation, LayerDefinition> immutablemap = builder.build();
List<ModelLayerLocation> list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).toList(); List<ModelLayerLocation> list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).collect(Collectors.toList());
if (!list.isEmpty()) { if (!list.isEmpty()) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/model/geom/ModelLayers.java --- a/net/minecraft/client/model/geom/ModelLayers.java
+++ b/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java
@@ -328,15 +_,18 @@ @@ -336,15 +_,18 @@
} }
public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) { public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) {
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java --- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java
@@ -160,6 +_,7 @@ @@ -153,6 +_,7 @@
@Override @Override
public void handleCustomPayload(ClientboundCustomPayloadPacket p_298103_) { public void handleCustomPayload(ClientboundCustomPayloadPacket p_298103_) {
+ if (net.minecraftforge.common.ForgeHooks.onCustomPayload(p_298103_.payload(), this.connection)) return; + if (net.minecraftforge.common.ForgeHooks.onCustomPayload(p_298103_.payload(), this.connection)) return;
CustomPacketPayload custompacketpayload = p_298103_.payload(); CustomPacketPayload custompacketpayload = p_298103_.payload();
if (!(custompacketpayload instanceof DiscardedPayload)) { if (!(custompacketpayload instanceof DiscardedPayload)) {
PacketUtils.ensureRunningOnSameThread(p_298103_, this, this.minecraft.packetProcessor()); PacketUtils.ensureRunningOnSameThread(p_298103_, this, this.minecraft);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java --- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java
@@ -184,6 +_,7 @@ @@ -157,6 +_,7 @@
return true; return true;
} }
})); }));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
@@ -214,6 +_,7 @@ @@ -208,6 +_,7 @@
Component component = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED; Component component = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED;
if (this.serverData != null && this.serverData.isRealm()) { if (this.serverData != null && this.serverData.isRealm()) {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_.reason(), CommonComponents.GUI_BACK)); this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_.reason(), CommonComponents.GUI_BACK));
@@ -8,7 +8,7 @@
} else { } else {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_)); this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, p_342266_));
} }
@@ -238,6 +_,7 @@ @@ -232,6 +_,7 @@
@Override @Override
public void handleCustomQuery(ClientboundCustomQueryPacket p_104545_) { public void handleCustomQuery(ClientboundCustomQueryPacket p_104545_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientLevel.java --- a/net/minecraft/client/multiplayer/ClientLevel.java
+++ b/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java
@@ -145,6 +_,7 @@ @@ -130,6 +_,7 @@
p_389331_.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_194177_ -> this.calculateBlockTint(p_194177_, BiomeColors.FOLIAGE_COLOR_RESOLVER))); p_389331_.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_194177_ -> this.calculateBlockTint(p_194177_, BiomeColors.FOLIAGE_COLOR_RESOLVER)));
p_389331_.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_389335_ -> this.calculateBlockTint(p_389335_, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER))); p_389331_.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_389335_ -> this.calculateBlockTint(p_389335_, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER)));
p_389331_.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER))); p_389331_.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER)));
@@ -8,7 +8,7 @@
}); });
private final ClientChunkCache chunkSource; private final ClientChunkCache chunkSource;
private final Deque<Runnable> lightUpdateQueue = Queues.newArrayDeque(); private final Deque<Runnable> lightUpdateQueue = Queues.newArrayDeque();
@@ -156,6 +_,8 @@ @@ -139,6 +_,8 @@
private final int seaLevel; private final int seaLevel;
private boolean tickDayTime; private boolean tickDayTime;
private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT);
@@ -16,8 +16,8 @@
+ private final net.minecraftforge.client.model.data.ModelDataManager modelDataManager = new net.minecraftforge.client.model.data.ModelDataManager(this); + private final net.minecraftforge.client.model.data.ModelDataManager modelDataManager = new net.minecraftforge.client.model.data.ModelDataManager(this);
public void handleBlockChangedAck(int p_233652_) { public void handleBlockChangedAck(int p_233652_) {
if (SharedConstants.DEBUG_BLOCK_BREAK) { this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this);
@@ -239,6 +_,8 @@ @@ -217,6 +_,8 @@
this.serverSimulationDistance = p_364305_; this.serverSimulationDistance = p_364305_;
this.updateSkyBrightness(); this.updateSkyBrightness();
this.prepareWeather(); this.prepareWeather();
@@ -26,7 +26,7 @@
} }
public void queueLightUpdate(Runnable p_194172_) { public void queueLightUpdate(Runnable p_194172_) {
@@ -343,6 +_,7 @@ @@ -299,6 +_,7 @@
p_104640_.setOldPosAndRot(); p_104640_.setOldPosAndRot();
p_104640_.tickCount++; p_104640_.tickCount++;
Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString());
@@ -34,7 +34,7 @@
p_104640_.tick(); p_104640_.tick();
Profiler.get().pop(); Profiler.get().pop();
@@ -394,8 +_,10 @@ @@ -350,8 +_,10 @@
} }
public void addEntity(Entity p_104741_) { public void addEntity(Entity p_104741_) {
@@ -45,7 +45,7 @@
} }
public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) { public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) {
@@ -576,6 +_,12 @@ @@ -532,6 +_,12 @@
float p_263349_, float p_263349_,
long p_263408_ long p_263408_
) { ) {
@@ -58,7 +58,7 @@
if (p_394722_ == this.minecraft.player) { if (p_394722_ == this.minecraft.player) {
this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_); this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_);
} }
@@ -585,6 +_,12 @@ @@ -541,6 +_,12 @@
public void playSeededSound( public void playSeededSound(
@Nullable Entity p_263536_, Entity p_396496_, Holder<SoundEvent> p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_ @Nullable Entity p_263536_, Entity p_396496_, Holder<SoundEvent> p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_
) { ) {
@@ -71,48 +71,8 @@
if (p_263536_ == this.minecraft.player) { if (p_263536_ == this.minecraft.player) {
this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_396496_, p_263509_)); this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_396496_, p_263509_));
} }
@@ -1032,7 +_,7 @@ @@ -991,6 +_,16 @@
this.connection.registerForCleaning(p_396040_);
@Override
public void addDestroyBlockEffect(BlockPos p_171667_, BlockState p_171668_) {
- if (!p_171668_.isAir() && p_171668_.shouldSpawnTerrainParticles()) {
+ if (!p_171668_.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_171668_).addDestroyEffects(p_171668_, this, p_171667_, this.minecraft.particleEngine)) {
VoxelShape voxelshape = p_171668_.getShape(this, p_171667_);
double d0 = 0.25;
voxelshape.forAllBoxes(
@@ -1067,6 +_,7 @@
p_171668_,
p_171667_
)
+ .updateSprite(p_171668_, p_171667_)
);
}
}
@@ -1076,6 +_,13 @@
}
}
+ public void addBreakingBlockEffect(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) {
+ var state = this.getBlockState(pos);
+ if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(state).addHitEffects(state, this, target, this.minecraft.particleEngine))
+ addBreakingBlockEffect(pos, target.getDirection());
+ }
+
+ /** @deprecated Forge - Use crack(BlockPos, BlockHitResult) as it has more context and gives more control to modders */
public void addBreakingBlockEffect(BlockPos p_425440_, Direction p_431745_) {
BlockState blockstate = this.getBlockState(p_425440_);
if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) {
@@ -1111,7 +_,7 @@
d0 = i + aabb.maxX + 0.1F;
}
- this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_425440_).setPower(0.2F).scale(0.6F));
+ this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_425440_).updateSprite(blockstate, p_425440_).setPower(0.2F).scale(0.6F));
}
}
@@ -1175,6 +_,16 @@
this.explosionTracker.track(p_429129_, p_428744_, p_431051_, p_431683_);
} }
+ @Override + @Override
@@ -128,7 +88,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static class ClientLevelData implements WritableLevelData { public static class ClientLevelData implements WritableLevelData {
private final boolean hardcore; private final boolean hardcore;
@@ -1256,6 +_,7 @@ @@ -1079,6 +_,7 @@
} }
public void setDifficulty(Difficulty p_104852_) { public void setDifficulty(Difficulty p_104852_) {
@@ -136,7 +96,7 @@
this.difficulty = p_104852_; this.difficulty = p_104852_;
} }
@@ -1298,6 +_,12 @@ @@ -1121,6 +_,12 @@
break; break;
default: default:
} }
@@ -149,7 +109,7 @@
} }
public void onTrackingEnd(Entity p_171716_) { public void onTrackingEnd(Entity p_171716_) {
@@ -1310,6 +_,15 @@ @@ -1133,6 +_,15 @@
ClientLevel.this.dragonParts.removeAll(Arrays.asList(enderdragon.getSubEntities())); ClientLevel.this.dragonParts.removeAll(Arrays.asList(enderdragon.getSubEntities()));
break; break;
default: default:
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/multiplayer/ClientPacketListener.java --- a/net/minecraft/client/multiplayer/ClientPacketListener.java
+++ b/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java
@@ -514,6 +_,7 @@ @@ -528,6 +_,7 @@
this.debugSubscriber.clear();
this.minecraft.levelRenderer.debugRenderer.refreshRendererList(); this.minecraft.debugRenderer.clear();
this.minecraft.player.resetPos(); this.minecraft.player.resetPos();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().connection); + net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogin(this.minecraft.gameMode, this.minecraft.player, this.minecraft.getConnection().connection);
this.minecraft.player.setId(p_105030_.playerId()); this.minecraft.player.setId(p_105030_.playerId());
this.level.addEntity(this.minecraft.player); this.level.addEntity(this.minecraft.player);
this.minecraft.player.input = new KeyboardInput(this.minecraft.options); this.minecraft.player.input = new KeyboardInput(this.minecraft.options);
@@ -1321,6 +_,8 @@ @@ -1315,6 +_,8 @@
localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes()); localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes());
} }
@@ -17,7 +17,7 @@
this.level.addEntity(localplayer1); this.level.addEntity(localplayer1);
localplayer1.input = new KeyboardInput(this.minecraft.options); localplayer1.input = new KeyboardInput(this.minecraft.options);
this.minecraft.gameMode.adjustPlayer(localplayer1); this.minecraft.gameMode.adjustPlayer(localplayer1);
@@ -1469,7 +_,7 @@ @@ -1462,7 +_,7 @@
ProblemReporter.ScopedCollector problemreporter$scopedcollector = new ProblemReporter.ScopedCollector(p_404890_.problemPath(), LOGGER); ProblemReporter.ScopedCollector problemreporter$scopedcollector = new ProblemReporter.ScopedCollector(p_404890_.problemPath(), LOGGER);
try { try {
@@ -26,10 +26,10 @@
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
try { try {
problemreporter$scopedcollector.close(); problemreporter$scopedcollector.close();
@@ -1646,7 +_,9 @@ @@ -1630,7 +_,9 @@
@Override @Override
public void handleCommands(ClientboundCommandsPacket p_104990_) { public void handleCommands(ClientboundCommandsPacket p_104990_) {
PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft.packetProcessor()); PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft);
- this.commands = new CommandDispatcher<>(p_104990_.getRoot(CommandBuildContext.simple(this.registryAccess, this.enabledFeatures), COMMAND_NODE_BUILDER)); - this.commands = new CommandDispatcher<>(p_104990_.getRoot(CommandBuildContext.simple(this.registryAccess, this.enabledFeatures), COMMAND_NODE_BUILDER));
+ var context = CommandBuildContext.simple(this.registryAccess, this.enabledFeatures); + var context = CommandBuildContext.simple(this.registryAccess, this.enabledFeatures);
+ this.commands = new CommandDispatcher<>(p_104990_.getRoot(context, COMMAND_NODE_BUILDER)); + this.commands = new CommandDispatcher<>(p_104990_.getRoot(context, COMMAND_NODE_BUILDER));
@@ -37,7 +37,7 @@
} }
@Override @Override
@@ -1747,6 +_,7 @@ @@ -1731,6 +_,7 @@
if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) { if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) {
recipeupdatelistener.recipesUpdated(); recipeupdatelistener.recipesUpdated();
} }
@@ -45,7 +45,7 @@
} }
@Override @Override
@@ -1785,6 +_,8 @@ @@ -1769,6 +_,8 @@
this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures);
List<ItemStack> list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); List<ItemStack> list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems());
this.searchTrees.updateCreativeTags(list1); this.searchTrees.updateCreativeTags(list1);
@@ -54,7 +54,7 @@
} }
@Override @Override
@@ -2614,6 +_,8 @@ @@ -2617,6 +_,8 @@
} }
public void sendChat(String p_249888_) { public void sendChat(String p_249888_) {
@@ -63,7 +63,7 @@
Instant instant = Instant.now(); Instant instant = Instant.now();
long i = Crypt.SaltSupplier.getLong(); long i = Crypt.SaltSupplier.getLong();
LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate(); LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate();
@@ -2622,6 +_,7 @@ @@ -2625,6 +_,7 @@
} }
public void sendCommand(String p_250092_) { public void sendCommand(String p_250092_) {
@@ -71,7 +71,7 @@
SignableCommand<ClientSuggestionProvider> signablecommand = SignableCommand.of(this.commands.parse(p_250092_, this.suggestionsProvider)); SignableCommand<ClientSuggestionProvider> signablecommand = SignableCommand.of(this.commands.parse(p_250092_, this.suggestionsProvider));
if (signablecommand.arguments().isEmpty()) { if (signablecommand.arguments().isEmpty()) {
this.send(new ServerboundChatCommandPacket(p_250092_)); this.send(new ServerboundChatCommandPacket(p_250092_));
@@ -2638,6 +_,7 @@ @@ -2641,6 +_,7 @@
} }
public void sendUnattendedCommand(String p_407213_, @Nullable Screen p_406262_) { public void sendUnattendedCommand(String p_407213_, @Nullable Screen p_406262_) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java --- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
+++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
@@ -112,6 +_,7 @@ @@ -111,6 +_,7 @@
} }
public boolean destroyBlock(BlockPos p_105268_) { public boolean destroyBlock(BlockPos p_105268_) {
@@ -8,7 +8,7 @@
if (this.minecraft.player.blockActionRestricted(this.minecraft.level, p_105268_, this.localPlayerMode)) { if (this.minecraft.player.blockActionRestricted(this.minecraft.level, p_105268_, this.localPlayerMode)) {
return false; return false;
} else { } else {
@@ -126,9 +_,8 @@ @@ -125,9 +_,8 @@
} else if (blockstate.isAir()) { } else if (blockstate.isAir()) {
return false; return false;
} else { } else {
@@ -19,15 +19,15 @@
if (flag) { if (flag) {
block.destroy(level, p_105268_, blockstate); block.destroy(level, p_105268_, blockstate);
} }
@@ -157,6 +_,7 @@ @@ -148,6 +_,7 @@
} BlockState blockstate = this.minecraft.level.getBlockState(p_105270_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F);
this.startPrediction(this.minecraft.level, p_233757_ -> { this.startPrediction(this.minecraft.level, p_233757_ -> {
+ if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105270_, p_105271_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK)) + if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105270_, p_105271_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK))
this.destroyBlock(p_105270_); this.destroyBlock(p_105270_);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_);
}); });
@@ -170,6 +_,7 @@ @@ -157,15 +_,18 @@
this.connection this.connection
.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_)); .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_));
} }
@@ -35,7 +35,6 @@
BlockState blockstate1 = this.minecraft.level.getBlockState(p_105270_); BlockState blockstate1 = this.minecraft.level.getBlockState(p_105270_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate1, 0.0F); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate1, 0.0F);
@@ -180,9 +_,11 @@
this.startPrediction(this.minecraft.level, p_233728_ -> { this.startPrediction(this.minecraft.level, p_233728_ -> {
boolean flag = !blockstate1.isAir(); boolean flag = !blockstate1.isAir();
if (flag && this.destroyProgress == 0.0F) { if (flag && this.destroyProgress == 0.0F) {
@@ -47,7 +46,7 @@
if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) { if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) {
this.destroyBlock(p_105270_); this.destroyBlock(p_105270_);
} else { } else {
@@ -193,6 +_,7 @@ @@ -176,6 +_,7 @@
this.destroyTicks = 0.0F; this.destroyTicks = 0.0F;
this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage()); this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage());
} }
@@ -55,15 +54,15 @@
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233728_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233728_);
}); });
@@ -233,6 +_,7 @@ @@ -208,6 +_,7 @@
} BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F);
this.startPrediction(this.minecraft.level, p_233753_ -> { this.startPrediction(this.minecraft.level, p_233753_ -> {
+ if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105284_, p_105285_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK)) + if (!net.minecraftforge.event.ForgeEventFactory.isLeftClickBlockCancelled(this.minecraft.player, p_105284_, p_105285_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK))
this.destroyBlock(p_105284_); this.destroyBlock(p_105284_);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_);
}); });
@@ -245,7 +_,7 @@ @@ -220,7 +_,7 @@
} else { } else {
this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_); this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_);
if (this.destroyTicks % 4.0F == 0.0F) { if (this.destroyTicks % 4.0F == 0.0F) {
@@ -72,15 +71,15 @@
this.minecraft this.minecraft
.getSoundManager() .getSoundManager()
.play( .play(
@@ -262,6 +_,7 @@ @@ -237,6 +_,7 @@
this.destroyTicks++; this.destroyTicks++;
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F));
+ if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, p_105284_, p_105285_).getUseItem().isDenied()) return true; + if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, p_105284_, p_105285_).getUseItem().isDenied()) return true;
if (this.destroyProgress >= 1.0F) { if (this.destroyProgress >= 1.0F) {
this.isDestroying = false; this.isDestroying = false;
if (SharedConstants.DEBUG_BLOCK_BREAK) { this.startPrediction(this.minecraft.level, p_233739_ -> {
@@ -304,7 +_,7 @@ @@ -275,7 +_,7 @@
private boolean sameDestroyTarget(BlockPos p_105282_) { private boolean sameDestroyTarget(BlockPos p_105282_) {
ItemStack itemstack = this.minecraft.player.getMainHandItem(); ItemStack itemstack = this.minecraft.player.getMainHandItem();
@@ -89,7 +88,7 @@
} }
private void ensureHasSentCarriedItem() { private void ensureHasSentCarriedItem() {
@@ -332,12 +_,23 @@ @@ -303,12 +_,23 @@
private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) { private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) {
BlockPos blockpos = p_233749_.getBlockPos(); BlockPos blockpos = p_233749_.getBlockPos();
ItemStack itemstack = p_233747_.getItemInHand(p_233748_); ItemStack itemstack = p_233747_.getItemInHand(p_233748_);
@@ -115,7 +114,7 @@
BlockState blockstate = this.minecraft.level.getBlockState(blockpos); BlockState blockstate = this.minecraft.level.getBlockState(blockpos);
if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) { if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) {
return InteractionResult.FAIL; return InteractionResult.FAIL;
@@ -358,8 +_,10 @@ @@ -329,8 +_,10 @@
} }
} }
@@ -128,7 +127,7 @@
InteractionResult interactionresult2; InteractionResult interactionresult2;
if (p_233747_.hasInfiniteMaterials()) { if (p_233747_.hasInfiniteMaterials()) {
int i = itemstack.getCount(); int i = itemstack.getCount();
@@ -393,6 +_,11 @@ @@ -364,6 +_,11 @@
mutableobject.setValue(InteractionResult.PASS); mutableobject.setValue(InteractionResult.PASS);
return serverbounduseitempacket; return serverbounduseitempacket;
} else { } else {
@@ -140,7 +139,7 @@
InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_); InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_);
ItemStack itemstack1; ItemStack itemstack1;
if (interactionresult instanceof InteractionResult.Success interactionresult$success) { if (interactionresult instanceof InteractionResult.Success interactionresult$success) {
@@ -403,6 +_,9 @@ @@ -374,6 +_,9 @@
if (itemstack1 != itemstack) { if (itemstack1 != itemstack) {
p_233722_.setItemInHand(p_233723_, itemstack1); p_233722_.setItemInHand(p_233723_, itemstack1);
@@ -150,7 +149,7 @@
} }
mutableobject.setValue(interactionresult); mutableobject.setValue(interactionresult);
@@ -434,6 +_,10 @@ @@ -405,6 +_,10 @@
public InteractionResult interact(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) { public InteractionResult interact(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) {
this.ensureHasSentCarriedItem(); this.ensureHasSentCarriedItem();
this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105228_, p_105227_.isShiftKeyDown(), p_105229_)); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105228_, p_105227_.isShiftKeyDown(), p_105229_));
@@ -161,7 +160,7 @@
return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.interactOn(p_105228_, p_105229_)); return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.interactOn(p_105228_, p_105229_));
} }
@@ -441,6 +_,10 @@ @@ -412,6 +_,10 @@
this.ensureHasSentCarriedItem(); this.ensureHasSentCarriedItem();
Vec3 vec3 = p_105233_.getLocation().subtract(p_105232_.getX(), p_105232_.getY(), p_105232_.getZ()); Vec3 vec3 = p_105233_.getLocation().subtract(p_105232_.getX(), p_105232_.getY(), p_105232_.getZ());
this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105232_, p_105231_.isShiftKeyDown(), p_105234_, vec3)); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105232_, p_105231_.isShiftKeyDown(), p_105234_, vec3));
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/PlayerInfo.java --- a/net/minecraft/client/multiplayer/PlayerInfo.java
+++ b/net/minecraft/client/multiplayer/PlayerInfo.java +++ b/net/minecraft/client/multiplayer/PlayerInfo.java
@@ -76,6 +_,7 @@ @@ -88,6 +_,7 @@
} }
protected void setGameMode(GameType p_105318_) { protected void setGameMode(GameType p_105318_) {
@@ -1,8 +1,8 @@
--- a/net/minecraft/client/multiplayer/ServerData.java --- a/net/minecraft/client/multiplayer/ServerData.java
+++ b/net/minecraft/client/multiplayer/ServerData.java +++ b/net/minecraft/client/multiplayer/ServerData.java
@@ -38,6 +_,7 @@ @@ -37,6 +_,7 @@
private byte[] iconBytes;
private ServerData.Type type; private ServerData.Type type;
private int acceptedCodeOfConduct;
private ServerData.State state = ServerData.State.INITIAL; private ServerData.State state = ServerData.State.INITIAL;
+ public net.minecraftforge.client.ExtendedServerListData forgeData = null; + public net.minecraftforge.client.ExtendedServerListData forgeData = null;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ServerStatusPinger.java --- a/net/minecraft/client/multiplayer/ServerStatusPinger.java
+++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java +++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java
@@ -107,6 +_,7 @@ @@ -99,6 +_,7 @@
p_105461_.run(); p_105461_.run();
} }
}); });
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/chat/ChatListener.java --- a/net/minecraft/client/multiplayer/chat/ChatListener.java
+++ b/net/minecraft/client/multiplayer/chat/ChatListener.java +++ b/net/minecraft/client/multiplayer/chat/ChatListener.java
@@ -133,7 +_,9 @@ @@ -124,7 +_,9 @@
Instant instant = Instant.now(); Instant instant = Instant.now();
this.handleMessage(null, () -> { this.handleMessage(null, () -> {
Component component = p_251256_.decorate(p_250375_); Component component = p_251256_.decorate(p_250375_);
@@ -11,7 +11,7 @@
this.narrateChatMessage(p_251256_, p_250375_); this.narrateChatMessage(p_251256_, p_250375_);
this.logSystemMessage(component, instant); this.logSystemMessage(component, instant);
this.previousMessageTime = Util.getMillis(); this.previousMessageTime = Util.getMillis();
@@ -152,12 +_,16 @@ @@ -143,12 +_,16 @@
MessageSignature messagesignature = p_249430_.signature(); MessageSignature messagesignature = p_249430_.signature();
FilterMask filtermask = p_249430_.filterMask(); FilterMask filtermask = p_249430_.filterMask();
if (filtermask.isEmpty()) { if (filtermask.isEmpty()) {
@@ -30,7 +30,7 @@
this.narrateChatMessage(p_251766_, component); this.narrateChatMessage(p_251766_, component);
} }
} }
@@ -190,6 +_,8 @@ @@ -181,6 +_,8 @@
public void handleSystemMessage(Component p_240522_, boolean p_240642_) { public void handleSystemMessage(Component p_240522_, boolean p_240642_) {
if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(p_240522_))) { if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(p_240522_))) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/FireworkParticles.java --- a/net/minecraft/client/particle/FireworkParticles.java
+++ b/net/minecraft/client/particle/FireworkParticles.java +++ b/net/minecraft/client/particle/FireworkParticles.java
@@ -268,6 +_,10 @@ @@ -263,6 +_,10 @@
intlist = IntList.of(DyeColor.BLACK.getFireworkColor()); intlist = IntList.of(DyeColor.BLACK.getFireworkColor());
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java --- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java
+++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java +++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java
@@ -114,6 +_,7 @@ @@ -104,6 +_,7 @@
this.x = this.xStart + this.xd * f; this.x = this.xStart + this.xd * f;
this.y = this.yStart + this.yd * f - f1 * 1.2F; this.y = this.yStart + this.yd * f - f1 * 1.2F;
this.z = this.zStart + this.zd * f; this.z = this.zStart + this.zd * f;
@@ -1,9 +1,17 @@
--- a/net/minecraft/client/particle/Particle.java --- a/net/minecraft/client/particle/Particle.java
+++ b/net/minecraft/client/particle/Particle.java +++ b/net/minecraft/client/particle/Particle.java
@@ -207,6 +_,10 @@ @@ -248,6 +_,18 @@
return Optional.empty(); return Optional.empty();
} }
+ /**
+ * Forge added method that controls if a particle should be culled to it's bounding box.
+ * Default behaviour is culling enabled
+ */
+ public boolean shouldCull() {
+ return true;
+ }
+
+ public net.minecraft.world.phys.Vec3 getPos() { + public net.minecraft.world.phys.Vec3 getPos() {
+ return new net.minecraft.world.phys.Vec3(this.x, this.y, this.z); + return new net.minecraft.world.phys.Vec3(this.x, this.y, this.z);
+ } + }
@@ -1,29 +1,148 @@
--- a/net/minecraft/client/particle/ParticleEngine.java --- a/net/minecraft/client/particle/ParticleEngine.java
+++ b/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java
@@ -26,7 +_,7 @@ @@ -72,10 +_,10 @@
public class ParticleEngine { private static final int MAX_PARTICLES_PER_LAYER = 16384;
private static final List<ParticleRenderType> RENDER_ORDER = List.of(ParticleRenderType.SINGLE_QUADS, ParticleRenderType.ITEM_PICKUP, ParticleRenderType.ELDER_GUARDIANS); private static final List<ParticleRenderType> RENDER_ORDER = List.of(ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT);
protected ClientLevel level; protected ClientLevel level;
- private final Map<ParticleRenderType, ParticleGroup<?>> particles = Maps.newIdentityHashMap(); - private final Map<ParticleRenderType, Queue<Particle>> particles = Maps.newIdentityHashMap();
+ private final Map<ParticleRenderType, ParticleGroup<?>> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER)); + private final Map<ParticleRenderType, Queue<Particle>> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER));
private final Queue<TrackingEmitter> trackingEmitters = Queues.newArrayDeque(); private final Queue<TrackingEmitter> trackingEmitters = Queues.newArrayDeque();
private final RandomSource random = RandomSource.create();
- private final Int2ObjectMap<ParticleProvider<?>> providers = new Int2ObjectOpenHashMap<>();
+ private final Map<ResourceLocation, ParticleProvider<?>> providers = new java.util.HashMap<>();
private final Queue<Particle> particlesToAdd = Queues.newArrayDeque(); private final Queue<Particle> particlesToAdd = Queues.newArrayDeque();
private final Object2IntOpenHashMap<ParticleLimit> trackedParticleCounts = new Object2IntOpenHashMap<>(); private final Map<ResourceLocation, ParticleEngine.MutableSpriteSet> spriteSets = Maps.newHashMap();
@@ -63,7 +_,7 @@ private final TextureAtlas textureAtlas;
@@ -205,10 +_,14 @@
this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
+ @Deprecated
public <T extends ParticleOptions> void register(ParticleType<T> p_107382_, ParticleProvider<T> p_107383_) {
- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_107382_), p_107383_);
+ this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107382_), p_107383_);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
+ @Deprecated
public <T extends ParticleOptions> void register(ParticleType<T> p_273423_, ParticleProvider.Sprite<T> p_273134_) {
this.register(
p_273423_,
@@ -225,10 +_,12 @@
);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
+ @Deprecated
public <T extends ParticleOptions> void register(ParticleType<T> p_107379_, ParticleEngine.SpriteParticleRegistration<T> p_107380_) {
ParticleEngine.MutableSpriteSet particleengine$mutablespriteset = new ParticleEngine.MutableSpriteSet();
this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), particleengine$mutablespriteset);
- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_107379_), p_107380_.create(particleengine$mutablespriteset));
+ this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), p_107380_.create(particleengine$mutablespriteset));
}
@Override
@@ -348,7 +_,7 @@
private <T extends ParticleOptions> Particle makeParticle( private <T extends ParticleOptions> Particle makeParticle(
T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_ T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_
) { ) {
- ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.resourceManager.getProviders().get(BuiltInRegistries.PARTICLE_TYPE.getId(p_107396_.getType())); - ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.providers.get(BuiltInRegistries.PARTICLE_TYPE.getId(p_107396_.getType()));
+ ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.resourceManager.getProvider(p_107396_.getType()); + ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.providers.get(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107396_.getType()));
return particleprovider == null return particleprovider == null
? null ? null
: particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_, this.random); : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_);
@@ -123,7 +_,7 @@ @@ -424,28 +_,36 @@
}
} }
public void extract(ParticlesRenderState p_423938_, Frustum p_424803_, Camera p_430521_, float p_426823_) { + /**@deprecated Forge: use {@link #render(Camera, float, net.minecraft.client.renderer.culling.Frustum)} with Frustum as additional parameter*/
+ @Deprecated
public void render(Camera p_107340_, float p_107341_, MultiBufferSource.BufferSource p_377798_) {
- for (ParticleRenderType particlerendertype : RENDER_ORDER) { - for (ParticleRenderType particlerendertype : RENDER_ORDER) {
+ for (ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom ParticleRenderType's + render(p_107340_, p_107341_, p_377798_, null);
ParticleGroup<?> particlegroup = this.particles.get(particlerendertype); + }
if (particlegroup != null && !particlegroup.isEmpty()) { +
p_423938_.add(particlegroup.extractRenderState(p_424803_, p_430521_, p_426823_)); + public void render(Camera p_107340_, float p_107341_, MultiBufferSource.BufferSource p_377798_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum) {
+ for (ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom IParticleRenderType's
+ if (particlerendertype.renderType() == null) continue;
Queue<Particle> queue = this.particles.get(particlerendertype);
if (queue != null && !queue.isEmpty()) {
- renderParticleType(p_107340_, p_107341_, p_377798_, particlerendertype, queue);
+ renderParticleType(p_107340_, p_107341_, p_377798_, particlerendertype, queue, frustum);
}
}
Queue<Particle> queue1 = this.particles.get(ParticleRenderType.CUSTOM);
if (queue1 != null && !queue1.isEmpty()) {
- renderCustomParticles(p_107340_, p_107341_, p_377798_, queue1);
+ renderCustomParticles(p_107340_, p_107341_, p_377798_, queue1, frustum);
}
p_377798_.endBatch();
}
private static void renderParticleType(
- Camera p_376120_, float p_375470_, MultiBufferSource.BufferSource p_377543_, ParticleRenderType p_378369_, Queue<Particle> p_376283_
+ Camera p_376120_, float p_375470_, MultiBufferSource.BufferSource p_377543_, ParticleRenderType p_378369_, Queue<Particle> p_376283_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum
) {
VertexConsumer vertexconsumer = p_377543_.getBuffer(Objects.requireNonNull(p_378369_.renderType()));
for (Particle particle : p_376283_) {
+ if (frustum != null && particle.shouldCull() && !frustum.isVisible(particle.getBoundingBox())) continue;
try {
particle.render(vertexconsumer, p_376120_, p_375470_);
} catch (Throwable throwable) {
@@ -458,10 +_,11 @@
}
}
- private static void renderCustomParticles(Camera p_377913_, float p_376893_, MultiBufferSource.BufferSource p_376978_, Queue<Particle> p_375784_) {
+ private static void renderCustomParticles(Camera p_377913_, float p_376893_, MultiBufferSource.BufferSource p_376978_, Queue<Particle> p_375784_, @Nullable net.minecraft.client.renderer.culling.Frustum frustum) {
PoseStack posestack = new PoseStack();
for (Particle particle : p_375784_) {
+ if (frustum != null && particle.shouldCull() && !frustum.isVisible(particle.getBoundingBox())) continue;
try {
particle.renderCustom(posestack, p_376978_, p_377913_, p_376893_);
} catch (Throwable throwable) {
@@ -481,7 +_,7 @@
}
public void destroy(BlockPos p_107356_, BlockState p_107357_) {
- if (!p_107357_.isAir() && p_107357_.shouldSpawnTerrainParticles()) {
+ if (!p_107357_.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_107357_).addDestroyEffects(p_107357_, this.level, p_107356_, this)) {
VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_);
double d0 = 0.25;
voxelshape.forAllBoxes(
@@ -514,6 +_,7 @@
p_107357_,
p_107356_
)
+ .updateSprite(p_107357_, p_107356_)
);
}
}
@@ -523,6 +_,13 @@
}
}
+ public void addBlockHitEffects(BlockPos pos, net.minecraft.world.phys.BlockHitResult target) {
+ var state = level.getBlockState(pos);
+ if (!net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(state).addHitEffects(state, level, target, this))
+ crack(pos, target.getDirection());
+ }
+
+ @Deprecated // Forge - Use addBlockHitEffects as it has more context and gives more control to modders
public void crack(BlockPos p_107368_, Direction p_107369_) {
BlockState blockstate = this.level.getBlockState(p_107368_);
if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) {
@@ -558,7 +_,7 @@
d0 = i + aabb.maxX + 0.1F;
}
- this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).setPower(0.2F).scale(0.6F));
+ this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).updateSprite(blockstate, p_107368_).setPower(0.2F).scale(0.6F));
}
}
@@ -1,43 +0,0 @@
--- a/net/minecraft/client/particle/ParticleResources.java
+++ b/net/minecraft/client/particle/ParticleResources.java
@@ -45,6 +_,7 @@
private static final FileToIdConverter PARTICLE_LISTER = FileToIdConverter.json("particles");
private final Map<ResourceLocation, ParticleResources.MutableSpriteSet> spriteSets = Maps.newHashMap();
private final Int2ObjectMap<ParticleProvider<?>> providers = new Int2ObjectOpenHashMap<>();
+ private final Map<ResourceLocation, ParticleProvider<?>> providersByName = new java.util.HashMap<>();
@Nullable
private Runnable onReload;
@@ -174,14 +_,17 @@
this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
public <T extends ParticleOptions> void register(ParticleType<T> p_427222_, ParticleProvider<T> p_423729_) {
this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_427222_), p_423729_);
+ this.providersByName.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_427222_), p_423729_);
}
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
public <T extends ParticleOptions> void register(ParticleType<T> p_427223_, ParticleResources.SpriteParticleRegistration<T> p_423156_) {
ParticleResources.MutableSpriteSet particleresources$mutablespriteset = new ParticleResources.MutableSpriteSet();
this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_427223_), particleresources$mutablespriteset);
- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(p_427223_), p_423156_.create(particleresources$mutablespriteset));
+ register(p_427223_, p_423156_.create(particleresources$mutablespriteset));
}
@Override
@@ -274,8 +_,13 @@
}
}
+ /** @deprecated Use getProvider(ProviderType) as these ids may not be in sync with servers */
public Int2ObjectMap<ParticleProvider<?>> getProviders() {
return this.providers;
+ }
+
+ public <T extends ParticleOptions> ParticleProvider<T> getProvider(ParticleType<T> type) {
+ return (ParticleProvider<T>)this.providersByName.get(BuiltInRegistries.PARTICLE_TYPE.getKey(type));
}
@OnlyIn(Dist.CLIENT)
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/PortalParticle.java --- a/net/minecraft/client/particle/PortalParticle.java
+++ b/net/minecraft/client/particle/PortalParticle.java +++ b/net/minecraft/client/particle/PortalParticle.java
@@ -91,6 +_,7 @@ @@ -80,6 +_,7 @@
this.x = this.xStart + this.xd * f2; this.x = this.xStart + this.xd * f2;
this.y = this.yStart + this.yd * f2 + (1.0F - f); this.y = this.yStart + this.yd * f2 + (1.0F - f);
this.z = this.zStart + this.zd * f2; this.z = this.zStart + this.zd * f2;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/ReversePortalParticle.java --- a/net/minecraft/client/particle/ReversePortalParticle.java
+++ b/net/minecraft/client/particle/ReversePortalParticle.java +++ b/net/minecraft/client/particle/ReversePortalParticle.java
@@ -42,6 +_,7 @@ @@ -31,6 +_,7 @@
this.x = this.x + this.xd * f; this.x = this.x + this.xd * f;
this.y = this.y + this.yd * f; this.y = this.y + this.yd * f;
this.z = this.z + this.zd * f; this.z = this.z + this.zd * f;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/VibrationSignalParticle.java --- a/net/minecraft/client/particle/VibrationSignalParticle.java
+++ b/net/minecraft/client/particle/VibrationSignalParticle.java +++ b/net/minecraft/client/particle/VibrationSignalParticle.java
@@ -80,6 +_,7 @@ @@ -76,6 +_,7 @@
this.x = Mth.lerp(d0, this.x, vec3.x()); this.x = Mth.lerp(d0, this.x, vec3.x());
this.y = Mth.lerp(d0, this.y, vec3.y()); this.y = Mth.lerp(d0, this.y, vec3.y());
this.z = Mth.lerp(d0, this.z, vec3.z()); this.z = Mth.lerp(d0, this.z, vec3.z());
Loaded 100 of 553 files, more files were not shown because too many files have changed in this diff. Show more