diff --git a/.gitignore b/.gitignore index 73173af0a6..1d703c8706 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,6 @@ /projects/mcp/ /projects/clean/ /projects/forge/ -/projects/fmlonly/ #/patches/* #occupational hazards diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 6e351cd133..0000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,125 +0,0 @@ -@Library('forge-shared-library')_ - -pipeline { - options { - disableConcurrentBuilds() - } - agent { - docker { - image 'gradle:7-jdk16' - //args '-v forgegc:/home/gradle/.gradle_cache/' - } - } - environment { - GRADLE_ARGS = '--no-daemon --console=plain' // No daemon for now as FG3 kinda derps. //'-Dorg.gradle.daemon.idletimeout=5000' - DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook') - DISCORD_PREFIX = "Job: Forge Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}" - JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png' - } - - stages { - stage('notify_start') { - when { - not { - changeRequest() - } - } - steps { - discordSend( - title: "${DISCORD_PREFIX} Started", - successful: true, - result: 'ABORTED', //White border - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - /* - stage('pull_cache') { - steps { - sh 'cp -r /home/gradle/.gradle_cache/jdks/ /home/gradle/.gradle/jdks/' - sh 'cp -r /home/gradle/.gradle_cache/wrapper/ /home/gradle/.gradle/wrapper/' - sh 'cp -r /home/gradle/.gradle_cache/caches/ /home/gradle/.gradle/caches/' - } - } - */ - stage('setup') { - steps { - withGradle { - sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue setup' - } - script { - env.MYVERSION = sh(returnStdout: true, script: './gradlew :forge:properties -q | grep "^version:" | cut -d" " -f2').trim() - env.FMLONLY_VERSION = sh(returnStdout: true, script: './gradlew :fmlonly:properties -q | grep "^version:" | cut -d" " -f2').trim() - } - } - } - stage('changelog') { - when { - not { - changeRequest() - } - } - steps { - writeChangelog(currentBuild, 'build/changelog.txt') - } - } - stage('publish') { - when { - not { - changeRequest() - } - } - environment { - CROWDIN = credentials('forge-crowdin') - KEYSTORE = credentials('forge-jenkins-keystore-old') - KEYSTORE_KEYPASS = credentials('forge-jenkins-keystore-old-keypass') - KEYSTORE_STOREPASS = credentials('forge-jenkins-keystore-old-keypass') - } - steps { - withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) { - withGradle { - sh './gradlew ${GRADLE_ARGS} publish -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}' - } - } - } - post { - success { - build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote net.minecraftforge:forge ${env.MYVERSION} latest")], propagate: false, wait: false - build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote net.minecraftforge:fmlonly ${env.FMLONLY_VERSION} latest")], propagate: false, wait: false - } - } - } - stage('test_publish_pr') { //Publish to local repo to test full process, but don't include credentials so it can't sign/publish to maven - when { - changeRequest() - } - environment { - CROWDIN = credentials('forge-crowdin') - } - steps { - withGradle { - sh './gradlew ${GRADLE_ARGS} publish -PcrowdinKey=${CROWDIN}' - } - } - } - } - post { - always { - script { - archiveArtifacts artifacts: 'projects/forge/build/libs/**/*.*', fingerprint: true, onlyIfSuccessful: true, allowEmptyArchive: true - - if (env.CHANGE_ID == null) { // This is unset for non-PRs - discordSend( - title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}", - description: '```\n' + getChanges(currentBuild) + '\n```', - successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"), - result: currentBuild.currentResult, - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - } - } -} diff --git a/build.gradle b/build.gradle index 0ad03c1982..9fe9ede03c 100644 --- a/build.gradle +++ b/build.gradle @@ -43,10 +43,10 @@ ext { ] } MAPPING_CHANNEL = 'official' - MAPPING_VERSION = '1.20.1' - MC_VERSION = '1.20.1' + MC_VERSION = '1.20.2-pre1' + MAPPING_VERSION = MC_VERSION MC_NEXT_VERSION = '1.21' - MCP_VERSION = '20230612.114412' + MCP_VERSION = '20230906.154413' SNAPSHOT = false SPI_VERSION = '7.0.1' @@ -72,11 +72,11 @@ ext { // To use a version newer than the version manifest JSON, the dependency must be added to the installer configuration MOJANG_LOGGING_VERSION = '1.1.1' LOG4J_VERSION = '2.19.0' - GUAVA_VERSION = '31.1-jre' - GSON_VERSION = '2.10' + GUAVA_VERSION = '32.1.2-jre' + GSON_VERSION = '2.10.1' APACHE_COMMONS_LANG3_VERSION = '3.12.0' JOPT_SIMPLE_VERSION = '5.0.4' - COMMONS_IO_VERSION = '2.11.0' + COMMONS_IO_VERSION = '2.13.0' GIT_INFO = gradleutils.gitInfo VERSION = gradleutils.getFilteredMCTagOffsetBranchVersion(true, '[0-9]', MC_VERSION) @@ -86,7 +86,7 @@ ext { BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.1.1:fatjar' INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.3.0' JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4' - FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all' + FART = 'net.minecraftforge:ForgeAutoRenamingTool:1.0.5:all' MIN_TAG_FOR_CHANGELOG = '41.0' } @@ -489,7 +489,7 @@ def sharedFmlonlyForge = { Project prj -> run.property 'org.lwjgl.system.SharedLibraryExtractDirectory', 'lwjgl_dll' run.args '--username', 'Dev' run.args '--version', prj.name - run.args '--uuid', '0' + //run.args '--uuid', '0' run.args '--accessToken', '0' run.args '--userType', 'mojang' run.args '--versionType', 'release' @@ -562,329 +562,6 @@ def sharedFmlonlyForge = { Project prj -> } } -def symlink = file("$rootDir/fmlonly/src/fmlcommon") -def symlinkValid = symlink.exists() && symlink.directory - -if (symlinkValid) -project(':fmlonly') { - evaluationDependsOn(':mcp') - apply plugin: 'java-library' - apply plugin: 'net.minecraftforge.gradle.patcher' - - ext { - MCP_ARTIFACT = project(':mcp').mcp.config.get() - PACKED_DEPS = [':fmlcore:jar', ':fmlloader:jar', ':fmlearlydisplay:jar', ':javafmllanguage:jar', ':lowcodelanguage:jar', ':mclanguage:jar'] - MAVEN_PATH = "${group.replace('.', '/')}/${project.name}/${VERSION}" - } - - sourceSets { - main { - java { - srcDirs = ["$rootDir/fmlonly/src/fmlcommon/java", "$rootDir/fmlonly/src/main/java"] - } - resources { - srcDirs = ["$rootDir/fmlonly/src/fmlcommon/resources", "$rootDir/fmlonly/src/main/resources"] - } - } - } - - configurations { - moduleonly - installer { - // Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it. - transitive = false - } - api.extendsFrom(installer) - } - - // TODO: Better coordination between project dependencies and the installer. - dependencies { - implementation project(':fmlcore') - implementation project(':fmlloader') - implementation project(':fmlearlydisplay') - implementation project(':javafmllanguage') - implementation project(':lowcodelanguage') - implementation project(':mclanguage') - runtimeOnly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}" - } - dependencies sharedDeps - - patcher { - parent = project(':mcp') - mcVersion = MC_VERSION - patchedSrc = file('src/main/java') - - mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION - runs { - fmlonly_client { - args '--launchTarget', 'fmlclientdev' - ideaModule "${rootProject.name}.${project.name}.main" - - mods { - minecraft { source sourceSets.main } - } - } - fmlonly_server { - args '--launchTarget', 'fmlserverdev' - ideaModule "${rootProject.name}.${project.name}.main" - - mods { - minecraft { source sourceSets.main } - } - } - } - } - - sharedFmlonlyForge.call(project) - - task launcherJson(type: LauncherJson) { - packedDependencies = [':fmlloader:jar',':fmlearlydisplay:jar'] - doFirst { - def fmlonly_client = project(':fmlonly').patcher.runs.fmlonly_client - json = [ - _comment_: comment, - id: id, - time: timestamp, - releaseTime: timestamp, - type: 'release', - mainClass: 'cpw.mods.bootstraplauncher.BootstrapLauncher', - inheritsFrom: MC_VERSION, - logging: {}, - arguments: [ - game: ['--launchTarget', 'fmlclient', - '--fml.forgeVersion', FORGE_VERSION, - '--fml.mcVersion', MC_VERSION, - '--fml.forgeGroup', project.group, - '--fml.mcpVersion', MCP_VERSION], - jvm: ["-DignoreList=${fmlonly_client.properties.ignoreList},\${version_name}.jar", - "-DmergeModules=${fmlonly_client.properties.mergeModules}", - '-DlibraryDirectory=${library_directory}', - '-p', Util.getArtifacts(project, configurations.moduleonly, false).values().collect{"\${library_directory}/${it.downloads.artifact.path}"}.join('${classpath_separator}'), - '--add-modules', 'ALL-MODULE-PATH', - // Additions to these JVM module args should be mirrored to server_files/args.txt and other similar blocks in the buildscript - '--add-opens', 'java.base/java.util.jar=cpw.mods.securejarhandler', - '--add-opens', 'java.base/java.lang.invoke=cpw.mods.securejarhandler', - '--add-exports', 'java.base/sun.security.util=cpw.mods.securejarhandler', - '--add-exports', 'jdk.naming.dns/com.sun.jndi.dns=java.naming' - ] - ], - libraries: [] - ] - } - } - - task installerJson(type: InstallerJson, dependsOn: 'signUniversalJar') { - icon = rootProject.file('icon.ico') - packedDependencies = PACKED_DEPS - - doFirst { - def libs = libraries - json = [ - _comment_: launcherJson.comment, - spec: 1, - profile: project.name, - version: launcherJson.id, - path: null, - minecraft: MC_VERSION, - serverJarPath: '{LIBRARY_DIR}/net/minecraft/server/{MINECRAFT_VERSION}/server-{MINECRAFT_VERSION}.jar', - welcome: "Welcome to the simple FML installer.", - data: [ - MAPPINGS: [ - client: "[${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:mappings@txt]", - server: "[${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:mappings@txt]" - ], - MOJMAPS: [ - client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:mappings@txt]", - server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:mappings@txt]" - ], - MERGED_MAPPINGS: [ - client: "[${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:mappings-merged@txt]", - server: "[${MCP_ARTIFACT.group}:${MCP_ARTIFACT.name}:${MCP_ARTIFACT.version}:mappings-merged@txt]" - ], - MC_UNPACKED: [ - client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:unpacked]", - server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:unpacked]" - ], - MC_SLIM: [ - client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:slim]", - server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:slim]" - ], - MC_SLIM_SHA: [ - client: "'${downloadClientSlim.output.get().asFile.sha1()}'", - server: "'${downloadServerSlim.output.get().asFile.sha1()}'" - ], - MC_EXTRA: [ - client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:extra]", - server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:extra]" - ], - MC_EXTRA_SHA: [ - client: "'${downloadClientExtra.output.get().asFile.sha1()}'", - server: "'${downloadServerExtra.output.get().asFile.sha1()}'" - ], - MC_SRG: [ - client: "[net.minecraft:client:${MC_VERSION}-${MCP_VERSION}:srg]", - server: "[net.minecraft:server:${MC_VERSION}-${MCP_VERSION}:srg]" - ], - /*MC_SRG_SHA: [ - client: "'${createClientSRG.output.sha1()}'", - server: "'${createServerSRG.output.sha1()}'" - ],*/ - MCP_VERSION: [ - client: "'${MCP_VERSION}'", - server: "'${MCP_VERSION}'" - ] - ], - processors: [ - [ - sides: ['server'], - jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), - args: [ - '--task', 'EXTRACT_FILES', - '--archive', '{INSTALLER}', - - '--from', 'data/run.sh', - '--to', '{ROOT}/run.sh', - '--exec', '{ROOT}/run.sh', - //'--from', "data/run_fml_${VERSION.replace('-', '_').sh", - //'--to', '{ROOT}/run_fml_${VERSION.replace('-', '_').sh', - //'--exec', '{ROOT}/run_fml_${VERSION.replace('-', '_').sh', - - '--from', 'data/run.bat', - '--to', '{ROOT}/run.bat', - //'--from', 'data/run_fml_${VERSION.replace('-', '_').bat', - //'--to', '{ROOT}/run_fml_${VERSION.replace('-', '_').bat', - - '--from', 'data/user_jvm_args.txt', - '--to', '{ROOT}/user_jvm_args.txt', - '--optional', '{ROOT}/user_jvm_args.txt', - - '--from', 'data/win_args.txt', - '--to', "{ROOT}/libraries/${MAVEN_PATH}/win_args.txt", - - '--from', 'data/unix_args.txt', - '--to', "{ROOT}/libraries/${MAVEN_PATH}/unix_args.txt" - ] - ], [ - sides: ['server'], - jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), - args: [ - '--task', 'BUNDLER_EXTRACT', - '--input', '{MINECRAFT_JAR}', - '--output', '{ROOT}/libraries/', - '--libraries' - ] - ], [ - sides: ['server'], - jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), - args: [ - '--task', 'BUNDLER_EXTRACT', - '--input', '{MINECRAFT_JAR}', - '--output', '{MC_UNPACKED}', - '--jar-only' - ] - ], [ - jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), - args: [ - '--task', 'MCP_DATA', - '--input', "[${MCP_ARTIFACT.descriptor}]", - '--output', '{MAPPINGS}', - '--key', 'mappings' - ] - ], [ - jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), - args: [ - '--task', 'DOWNLOAD_MOJMAPS', - '--version', MC_VERSION, - '--side', '{SIDE}', - '--output', '{MOJMAPS}' - ] - ], [ - jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), - args: [ - '--task', 'MERGE_MAPPING', - '--left', '{MAPPINGS}', - '--right', '{MOJMAPS}', - '--output', '{MERGED_MAPPINGS}', - '--classes', '--reverse-right' - ] - ], [ - sides: ['client'], - jar: JAR_SPLITTER, - classpath: getClasspath(project, libs, JAR_SPLITTER), - args: [ - '--input', '{MINECRAFT_JAR}', - '--slim', '{MC_SLIM}', - '--extra', '{MC_EXTRA}', - '--srg', '{MERGED_MAPPINGS}' - ], - outputs: [ - '{MC_SLIM}': '{MC_SLIM_SHA}', - '{MC_EXTRA}': '{MC_EXTRA_SHA}' - ] - ], [ - sides: ['server'], - jar: JAR_SPLITTER, - classpath: getClasspath(project, libs, JAR_SPLITTER), - args: [ - '--input', '{MC_UNPACKED}', - '--slim', '{MC_SLIM}', - '--extra', '{MC_EXTRA}', - '--srg', '{MERGED_MAPPINGS}' - ], - outputs: [ - '{MC_SLIM}': '{MC_SLIM_SHA}', - '{MC_EXTRA}': '{MC_EXTRA_SHA}' - ] - ], [ - jar: FART, - classpath: getClasspath(project, libs, FART), - args: [ - '--input', '{MC_SLIM}', - '--output', '{MC_SRG}', - '--names', '{MERGED_MAPPINGS}', - '--ann-fix', '--ids-fix', '--src-fix', '--record-fix' - ]/*, - outputs: [ - '{MC_SRG}': '{MC_SRG_SHA}' - ] - */ - ] - ] - ] - getClasspath(project, libs, MCP_ARTIFACT.descriptor) //Tell it to download mcp_config - } - } - - task installerJar(type: InstallerJar) { - packedDependencies = PACKED_DEPS - from(extraTxts) - //TODO: make FML installer logo? - from(rootProject.file('/forge_installer_logo.png')) { - rename { 'big_logo.png' } - } - } - - publishing { - publications { - mavenJava(MavenPublication) { - artifact universalJar - artifact installerJar - artifact userdevJar - artifact sourcesJar - } - } - } - - // Since we need the modules in the bootstrap, we need to make sure they are compiled before we do each run - afterEvaluate { prepareRuns.dependsOn(PACKED_DEPS) } -} - project(':forge') { evaluationDependsOn(':clean') apply plugin: 'java-library' @@ -1381,6 +1058,8 @@ project(':forge') { doFirst { def libs = libraries + def INSTALLER_TOOLS_CLASSPATH = getClasspath(project, libs, INSTALLER_TOOLS) + def JAR_SPLITTER_CLASSPATH = getClasspath(project, libs, JAR_SPLITTER) json = [ _comment_: launcherJson.comment, spec: 1, @@ -1451,7 +1130,7 @@ project(':forge') { [ sides: ['server'], jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), + classpath: INSTALLER_TOOLS_CLASSPATH, args: [ '--task', 'EXTRACT_FILES', '--archive', '{INSTALLER}', @@ -1481,7 +1160,7 @@ project(':forge') { ], [ sides: ['server'], jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), + classpath: INSTALLER_TOOLS_CLASSPATH, args: [ '--task', 'BUNDLER_EXTRACT', '--input', '{MINECRAFT_JAR}', @@ -1491,7 +1170,7 @@ project(':forge') { ], [ sides: ['server'], jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), + classpath: INSTALLER_TOOLS_CLASSPATH, args: [ '--task', 'BUNDLER_EXTRACT', '--input', '{MINECRAFT_JAR}', @@ -1500,7 +1179,7 @@ project(':forge') { ] ], [ jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), + classpath: INSTALLER_TOOLS_CLASSPATH, args: [ '--task', 'MCP_DATA', '--input', "[${MCP_ARTIFACT.descriptor}]", @@ -1509,7 +1188,7 @@ project(':forge') { ] ], [ jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), + classpath: INSTALLER_TOOLS_CLASSPATH, args: [ '--task', 'DOWNLOAD_MOJMAPS', '--version', MC_VERSION, @@ -1518,7 +1197,7 @@ project(':forge') { ] ], [ jar: INSTALLER_TOOLS, - classpath: getClasspath(project, libs, INSTALLER_TOOLS), + classpath: INSTALLER_TOOLS_CLASSPATH, args: [ '--task', 'MERGE_MAPPING', '--left', '{MAPPINGS}', @@ -1529,7 +1208,7 @@ project(':forge') { ], [ sides: ['client'], jar: JAR_SPLITTER, - classpath: getClasspath(project, libs, JAR_SPLITTER), + classpath: JAR_SPLITER_CLASSPATH, args: [ '--input', '{MINECRAFT_JAR}', '--slim', '{MC_SLIM}', @@ -1543,7 +1222,7 @@ project(':forge') { ], [ sides: ['server'], jar: JAR_SPLITTER, - classpath: getClasspath(project, libs, JAR_SPLITTER), + classpath: JAR_SPLITTER_CLASSPATH, args: [ '--input', '{MC_UNPACKED}', '--slim', '{MC_SLIM}', @@ -1788,8 +1467,6 @@ project(':forge') { //evaluationDependsOnChildren() task setup() { //These must be strings so that we can do lazy resolution. Else we need evaluationDependsOnChildren above dependsOn ':clean:extractMapped' - if (symlinkValid) - dependsOn ':fmlonly:extractMapped' dependsOn ':forge:extractMapped' } @@ -1798,18 +1475,14 @@ task doChecks { dependsOn ':forge:publish' } -if (symlinkValid) - project.gradle.startParameter.excludedTaskNames.add(':fmlonly:genPatches') project.gradle.startParameter.excludedTaskNames.add(':clean:genPatches') -//Also output FMLOnly when building a version. if (System.env.TEAMCITY_VERSION) { //Only setup the CI environment if and only if the environment variables are set. tasks.configureTeamCity { doLast { println "##teamcity[buildNumber '${project(':forge').version}']" println "##teamcity[setParameter name='env.PUBLISHED_JAVA_ARTIFACT_VERSION' value='${project(':forge').version}']" - println "##teamcity[setParameter name='env.PUBLISHED_JAVA_FML_ARTIFACT_VERSION' value='${project(':fmlonly').version}']" } } } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientDevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientDevLaunchHandler.java deleted file mode 100644 index fa3c585e10..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientDevLaunchHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import net.minecraftforge.api.distmarker.Dist; - -public class FMLClientDevLaunchHandler extends CommonDevLaunchHandler { - @Override public String name() { return "fmlclientdev"; } - @Override public Dist getDist() { return Dist.CLIENT; } - - @Override - public void devService(String[] arguments, ModuleLayer layer) throws Throwable { - clientService(arguments, layer); - } -} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientLaunchHandler.java deleted file mode 100644 index f75cefbea0..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientLaunchHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import java.nio.file.Path; -import java.util.List; -import java.util.stream.Stream; - -import net.minecraftforge.fml.loading.LibraryFinder; -import net.minecraftforge.fml.loading.VersionInfo; - -public class FMLClientLaunchHandler extends CommonClientLaunchHandler { - @Override public String name() { return "fmlclient"; } - - @Override - protected void processMCStream(VersionInfo versionInfo, Stream.Builder mc, Stream.Builder> mods) { - var fmlonly = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "fmlonly", "", "universal", versionInfo.mcAndForgeVersion()); - mods.add(List.of(fmlonly)); - } -} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientUserdevLaunchHandler.java deleted file mode 100644 index 90c9a6da96..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLClientUserdevLaunchHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import net.minecraftforge.api.distmarker.Dist; - -public class FMLClientUserdevLaunchHandler extends FMLUserdevLaunchHandler { - @Override - public String name() { return "fmlclientuserdev"; } - - @Override - public Dist getDist() { return Dist.CLIENT; } - - @Override - protected void devService(String[] arguments, ModuleLayer layer) throws Throwable { - clientService(arguments, layer); - } -} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLDataUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLDataUserdevLaunchHandler.java deleted file mode 100644 index 9dc2d79aa6..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLDataUserdevLaunchHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import net.minecraftforge.api.distmarker.Dist; - -public class FMLDataUserdevLaunchHandler extends FMLUserdevLaunchHandler { - @Override - public String name() { return "fmldatauserdev"; } - - @Override - public Dist getDist() { return Dist.CLIENT; } - - @Override - public boolean isData() { return true; } - - @Override - public void devService(String[] arguments, ModuleLayer layer) throws Throwable { - dataService(arguments, layer); - } -} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerDevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerDevLaunchHandler.java deleted file mode 100644 index 6f39657a2c..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerDevLaunchHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import net.minecraftforge.api.distmarker.Dist; - -public class FMLServerDevLaunchHandler extends CommonDevLaunchHandler { - @Override public String name() { return "fmlserverdev"; } - @Override public Dist getDist() { return Dist.DEDICATED_SERVER; } - - @Override - public void devService(String[] arguments, ModuleLayer layer) throws Throwable { - serverService(arguments, layer); - } -} \ No newline at end of file diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerLaunchHandler.java deleted file mode 100644 index 4ae35fd75e..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerLaunchHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import cpw.mods.modlauncher.api.ILaunchHandlerService; -import net.minecraftforge.fml.loading.LibraryFinder; -import net.minecraftforge.fml.loading.VersionInfo; - -import java.nio.file.Path; -import java.util.List; -import java.util.function.BiPredicate; -import java.util.stream.Stream; - -public class FMLServerLaunchHandler extends CommonServerLaunchHandler implements ILaunchHandlerService { - @Override public String name() { return "fmlserver"; } - - @Override - protected BiPredicate processMCStream(VersionInfo versionInfo, Stream.Builder mc, BiPredicate filter, Stream.Builder> mods) { - var fmlonly = LibraryFinder.findPathForMaven(versionInfo.forgeGroup(), "fmlonly", "", "universal", versionInfo.mcAndForgeVersion()); - mods.add(List.of(fmlonly)); - return filter; - } -} diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerUserdevLaunchHandler.java deleted file mode 100644 index b12acc19b0..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLServerUserdevLaunchHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import net.minecraftforge.api.distmarker.Dist; - -public class FMLServerUserdevLaunchHandler extends FMLUserdevLaunchHandler { - @Override public String name() { return "fmlserveruserdev"; } - @Override public Dist getDist() { return Dist.DEDICATED_SERVER; } - - @Override - public void devService(String[] arguments, ModuleLayer layer) throws Throwable { - serverService(arguments, layer); - } -} \ No newline at end of file diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLUserdevLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLUserdevLaunchHandler.java deleted file mode 100644 index 0653675265..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/FMLUserdevLaunchHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fml.loading.targets; - -import net.minecraftforge.fml.loading.VersionInfo; - -import java.nio.file.Path; -import java.util.List; -import java.util.stream.Stream; - -public abstract class FMLUserdevLaunchHandler extends CommonUserdevLaunchHandler { - @Override - protected void processStreams(String[] classpath, VersionInfo versionInfo, Stream.Builder mc, Stream.Builder> mods) { - var fmlonly = findJarOnClasspath(classpath, "fmlonly-" + versionInfo.mcAndForgeVersion()); - mc.add(fmlonly); - } -} diff --git a/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService index 4958918533..f0cc3caef5 100644 --- a/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService +++ b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService @@ -1,11 +1,3 @@ -net.minecraftforge.fml.loading.targets.FMLClientLaunchHandler -net.minecraftforge.fml.loading.targets.FMLClientDevLaunchHandler -net.minecraftforge.fml.loading.targets.FMLClientUserdevLaunchHandler -net.minecraftforge.fml.loading.targets.FMLServerLaunchHandler -net.minecraftforge.fml.loading.targets.FMLServerDevLaunchHandler -net.minecraftforge.fml.loading.targets.FMLServerUserdevLaunchHandler -net.minecraftforge.fml.loading.targets.FMLDataUserdevLaunchHandler - net.minecraftforge.fml.loading.targets.ForgeClientLaunchHandler net.minecraftforge.fml.loading.targets.ForgeClientDevLaunchHandler net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler diff --git a/fmlonly/src/fmlcommon b/fmlonly/src/fmlcommon deleted file mode 120000 index ce217f86dd..0000000000 --- a/fmlonly/src/fmlcommon +++ /dev/null @@ -1 +0,0 @@ -../../src/fmlcommon/ \ No newline at end of file diff --git a/fmlonly/src/main/java/net/minecraftforge/fmlonly/FMLOnlyBindings.java b/fmlonly/src/main/java/net/minecraftforge/fmlonly/FMLOnlyBindings.java deleted file mode 100644 index 49bf17aa08..0000000000 --- a/fmlonly/src/main/java/net/minecraftforge/fmlonly/FMLOnlyBindings.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Minecraft Forge - Forge Development LLC - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fmlonly; - -import net.minecraftforge.eventbus.api.BusBuilder; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.I18NParser; -import net.minecraftforge.fml.IBindingsProvider; -import net.minecraftforge.fml.config.IConfigEvent; -import net.minecraftforge.fml.event.config.ModConfigEvent; - -import java.util.Arrays; -import java.util.Objects; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public class FMLOnlyBindings implements IBindingsProvider { - private static final IEventBus DUMMYFORGEBUS = BusBuilder.builder().build(); - - @Override - public Supplier getForgeBusSupplier() { - return ()->DUMMYFORGEBUS; - } - - @Override - public Supplier getMessageParser() { - return ()->new I18NParser() { - @Override - public String parseMessage(final String i18nMessage, final Object... args) { - return i18nMessage + Arrays.stream(args).map(Objects::toString).collect(Collectors.joining(",", "[", "]")); - } - - @Override - public String stripControlCodes(final String toStrip) { - return toStrip; - } - }; - } - - @Override - public Supplier getConfigConfiguration() { - return ()->new IConfigEvent.ConfigConfig(ModConfigEvent.Loading::new, ModConfigEvent.Reloading::new, ModConfigEvent.Unloading::new); - } -} diff --git a/fmlonly/src/main/java/net/minecraftforge/fmlonly/FMLOnlyMod.java b/fmlonly/src/main/java/net/minecraftforge/fmlonly/FMLOnlyMod.java deleted file mode 100644 index 006bcdebab..0000000000 --- a/fmlonly/src/main/java/net/minecraftforge/fmlonly/FMLOnlyMod.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Minecraft Forge - Forge Development LLC - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fmlonly; - -import net.minecraftforge.fml.common.Mod; - -@Mod("fmlonly") -public class FMLOnlyMod {} diff --git a/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java b/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java deleted file mode 100644 index afbbe21032..0000000000 --- a/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Minecraft Forge - Forge Development LLC - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fmlonlyclient; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.ClientPackSource; -import net.minecraft.server.packs.repository.PackRepository; -import net.minecraft.server.packs.resources.PreparableReloadListener; -import net.minecraft.server.packs.resources.ReloadableResourceManager; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.LoadingFailedException; -import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.fml.ModWorkManager; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; - -@OnlyIn(Dist.CLIENT) -public class ClientModLoader -{ - private static boolean loading; - private static Minecraft mc; - private static boolean loadingComplete; - private static LoadingFailedException error; - - public static void begin(final Minecraft minecraft, final PackRepository defaultResourcePacks, final ReloadableResourceManager mcResourceManager) - { - // force log4j to shutdown logging in a shutdown hook. This is because we disable default shutdown hook so the server properly logs it's shutdown - Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown)); - loading = true; - ClientModLoader.mc = minecraft; - createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{})).run(); - mcResourceManager.registerReloadListener(ClientModLoader::onResourceReload); - } - - private static CompletableFuture onResourceReload(final PreparableReloadListener.PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller prepareProfiler, final ProfilerFiller executeProfiler, final Executor asyncExecutor, final Executor syncExecutor) { - return CompletableFuture.runAsync(createRunnableWithCatch(() -> startModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor)), ModWorkManager.parallelExecutor()) - .thenCompose(stage::wait) - .thenRunAsync(() -> finishModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor), ModWorkManager.parallelExecutor()); - } - - private static Runnable createRunnableWithCatch(Runnable r) { - return ()-> { - if (loadingComplete) return; - try { - r.run(); - } catch (LoadingFailedException e) { - if (error == null) error = e; - } - }; - } - - private static void startModLoading(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor) { - if (error!=null) throw error; - createRunnableWithCatch(() -> ModLoader.get().loadMods(syncExecutor, parallelExecutor, ()->{})).run(); - } - - private static void finishModLoading(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor) - { - if (error!=null) throw error; - createRunnableWithCatch(() -> ModLoader.get().finishMods(syncExecutor, parallelExecutor, ()->{})).run(); - loading = false; - loadingComplete = true; - // reload game settings on main thread - syncExecutor.execute(()->mc.options.load()); - } - - public static boolean isLoading() - { - return loading; - } -} diff --git a/fmlonly/src/main/java/net/minecraftforge/fmlonlyserver/ServerModLoader.java b/fmlonly/src/main/java/net/minecraftforge/fmlonlyserver/ServerModLoader.java deleted file mode 100644 index 5c4d0648aa..0000000000 --- a/fmlonly/src/main/java/net/minecraftforge/fmlonlyserver/ServerModLoader.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Minecraft Forge - Forge Development LLC - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.fmlonlyserver; - -import joptsimple.OptionParser; -import net.minecraftforge.fml.LoadingFailedException; -import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.fml.ModLoadingWarning; -import net.minecraftforge.fml.ModWorkManager; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.File; -import java.util.List; - -import static net.minecraftforge.fml.Logging.LOADING; - -public class ServerModLoader -{ - private static final Logger LOGGER = LogManager.getLogger(); - private static boolean hasErrors = false; - - public static void addOptions(OptionParser parser) - { - // We consume this argument as we use it in the launcher and the client side. - parser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File(".")); - } - - public static void load() - { - try - { - ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), () -> {}); - ModLoader.get().loadMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), () -> {}); - ModLoader.get().finishMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), () -> {}); - } catch (LoadingFailedException error) - { - ServerModLoader.hasErrors = true; - throw error; - } - List warnings = ModLoader.get().getWarnings(); - if (!warnings.isEmpty()) - { - LOGGER.warn(LOADING, "Mods loaded with {} warnings", warnings.size()); - warnings.forEach(warning -> LOGGER.warn(LOADING, warning.formatToString())); - } - } - - public static boolean hasErrors() - { - return ServerModLoader.hasErrors; - } -} diff --git a/fmlonly/src/main/resources/META-INF/coremods.json b/fmlonly/src/main/resources/META-INF/coremods.json deleted file mode 100644 index c970162923..0000000000 --- a/fmlonly/src/main/resources/META-INF/coremods.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "load_fml_client": "coremods/load_fml_client.js", - "load_fml_server": "coremods/load_fml_server.js" -} \ No newline at end of file diff --git a/fmlonly/src/main/resources/META-INF/mods.toml b/fmlonly/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 2c6e362090..0000000000 --- a/fmlonly/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,16 +0,0 @@ -modLoader="javafml" -loaderVersion="[24,]" -issueTrackerURL="https://www.minecraftforge.net/" -license="LGPL v2.1" - -[[mods]] -modId="fmlonly" -# We use the global forge version -version="${global.forgeVersion}" -updateJSONURL="https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json" -displayName="Forge" -credits="Anyone who has contributed on Github and supports our development" -authors="LexManos,cpw" -description=''' - Forge, a broad compatibility API. - ''' diff --git a/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider b/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider deleted file mode 100644 index e442ddc508..0000000000 --- a/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider +++ /dev/null @@ -1 +0,0 @@ -net.minecraftforge.fmlonly.FMLOnlyBindings \ No newline at end of file diff --git a/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider b/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider deleted file mode 100644 index 16864dc762..0000000000 --- a/fmlonly/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider +++ /dev/null @@ -1 +0,0 @@ -net.minecraftforge.fml.core.ModStateProvider \ No newline at end of file diff --git a/fmlonly/src/main/resources/coremods/load_fml_client.js b/fmlonly/src/main/resources/coremods/load_fml_client.js deleted file mode 100644 index 8f4ba409c4..0000000000 --- a/fmlonly/src/main/resources/coremods/load_fml_client.js +++ /dev/null @@ -1,36 +0,0 @@ -var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI') -var Opcodes = Java.type('org.objectweb.asm.Opcodes') - -function initializeCoreMod() { - return { - 'minecraft': { - 'target': { - 'type': 'METHOD', - 'class': 'net.minecraft.client.Minecraft', - 'methodName': '', - 'methodDesc': '(Lnet/minecraft/client/main/GameConfig;)V' - }, - 'transformer': function(methodNode) { - //print(ASMAPI.methodNodeToString(methodNode)) - var meth = ASMAPI.getMethodNode(); - var resourcePackRepository = ASMAPI.mapField("f_91038_") - var resourceManager = ASMAPI.mapField("f_91036_") - - meth.visitVarInsn(Opcodes.ALOAD, 0); - meth.visitVarInsn(Opcodes.ALOAD, 0); - meth.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", resourcePackRepository, "Lnet/minecraft/server/packs/repository/PackRepository;"); - meth.visitVarInsn(Opcodes.ALOAD, 0); - meth.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/client/Minecraft", resourceManager, "Lnet/minecraft/server/packs/resources/ReloadableResourceManager;"); - meth.visitMethodInsn(Opcodes.INVOKESTATIC, "net/minecraftforge/fmlonlyclient/ClientModLoader", "begin", "(Lnet/minecraft/client/Minecraft;Lnet/minecraft/server/packs/repository/PackRepository;Lnet/minecraft/server/packs/resources/ReloadableResourceManager;)V", false) - for (var i=0; i' && ain.desc == '()V') { - // Inject after the STORE - methodNode.instructions.insert(methodNode.instructions.get(i + 1), methOptions.instructions); - } else if (ain.getOpcode() == Opcodes.INVOKESTATIC && ain.owner == 'net/minecraft/Util' && ain.name == ASMAPI.mapMethod('m_137584_') /* startTimerHackThread */ && ain.desc == '()V') { - methodNode.instructions.insert(ain, meth.instructions); - break; // By this point we've already reached the first injection point so break - } - } - return methodNode; - } - }, - } -} diff --git a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch index e269d84127..ac425d04a3 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java -@@ -83,7 +_,8 @@ +@@ -81,7 +_,8 @@ GLFW.glfwWindowHint(139267, 2); GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139270, 1); @@ -10,15 +10,15 @@ if (monitor != null) { VideoMode videomode = monitor.m_84948_(this.f_85355_ ? this.f_85354_ : Optional.empty()); this.f_85350_ = this.f_85357_ = monitor.m_84951_() + videomode.m_85332_() / 2 - this.f_85359_ / 2; -@@ -95,6 +_,7 @@ +@@ -93,6 +_,7 @@ this.f_85350_ = this.f_85357_ = aint1[0]; this.f_85351_ = this.f_85358_ = aint[0]; } + } GLFW.glfwMakeContextCurrent(this.f_85349_); - Locale locale = Locale.getDefault(Category.FORMAT); -@@ -238,6 +_,7 @@ + GL.createCapabilities(); +@@ -242,6 +_,7 @@ GLFW.glfwGetFramebufferSize(this.f_85349_, aint, aint1); this.f_85361_ = aint[0] > 0 ? aint[0] : 1; this.f_85362_ = aint1[0] > 0 ? aint1[0] : 1; diff --git a/patches/minecraft/com/mojang/math/Transformation.java.patch b/patches/minecraft/com/mojang/math/Transformation.java.patch index 441d972424..629e264531 100644 --- a/patches/minecraft/com/mojang/math/Transformation.java.patch +++ b/patches/minecraft/com/mojang/math/Transformation.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/math/Transformation.java +++ b/com/mojang/math/Transformation.java -@@ -14,7 +_,7 @@ +@@ -13,7 +_,7 @@ import org.joml.Vector3f; import org.joml.Vector3fc; @@ -9,7 +9,7 @@ private final Matrix4f f_121078_; public static final Codec f_268453_ = RecordCodecBuilder.create((p_269604_) -> { return p_269604_.group(ExtraCodecs.f_252432_.fieldOf("translation").forGetter((p_269599_) -> { -@@ -163,6 +_,19 @@ +@@ -156,6 +_,19 @@ public int hashCode() { return Objects.hash(this.f_121078_); } diff --git a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch index 400d2f8632..294c71ecaa 100644 --- a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java -@@ -68,6 +_,15 @@ +@@ -61,6 +_,15 @@ return Component.m_237119_().m_7220_(this.f_200947_.f_287789_).m_130946_(": ").m_7220_(this.f_200947_.f_287787_); } @@ -14,5 +14,5 @@ + } + public void m_88315_(GuiGraphics p_283497_, int p_88680_, int p_88681_, float p_88682_) { - this.m_280273_(p_283497_); - p_283497_.m_280653_(this.f_96547_, this.f_200947_.f_287789_, this.f_96543_ / 2, 80, 16777215); + super.m_88315_(p_283497_, p_88680_, p_88681_, p_88682_); + p_283497_.m_280653_(this.f_96547_, this.f_200947_.f_287789_, this.f_96543_ / 2, 80, -1); diff --git a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch deleted file mode 100644 index 515f84357f..0000000000 --- a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java -+++ b/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java -@@ -45,9 +_,9 @@ - } - }; - private final RealmsNotificationsScreen.DataFetcherConfiguration f_273849_ = new RealmsNotificationsScreen.DataFetcherConfiguration() { -- public DataFetcher.Subscription m_274316_(RealmsDataFetcher p_275731_) { -- DataFetcher.Subscription datafetcher$subscription = p_275731_.f_238549_.m_239139_(); -- RealmsNotificationsScreen.this.m_274585_(p_275731_, datafetcher$subscription); -+ public DataFetcher.Subscription m_274316_(RealmsDataFetcher p_275318_) { -+ DataFetcher.Subscription datafetcher$subscription = p_275318_.f_238549_.m_239139_(); -+ RealmsNotificationsScreen.this.m_274585_(p_275318_, datafetcher$subscription); - return datafetcher$subscription; - } - diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index eec4c0f201..bcf2b8db04 100644 --- a/patches/minecraft/net/minecraft/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -210,6 +_,7 @@ +@@ -212,6 +_,7 @@ } static { diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/Util.java.patch index 96a308ef35..d886eaa589 100644 --- a/patches/minecraft/net/minecraft/Util.java.patch +++ b/patches/minecraft/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -171,6 +_,11 @@ +@@ -172,6 +_,11 @@ return 255; } @@ -12,7 +12,7 @@ public static ExecutorService m_183991_() { return f_137444_; } -@@ -239,7 +_,7 @@ +@@ -240,7 +_,7 @@ try { type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_183709_().m_183476_().m_193006_())).getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { diff --git a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch index 99f9099a92..eac52a8a9b 100644 --- a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch +++ b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch @@ -1,26 +1,17 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java -@@ -150,7 +_,7 @@ - return this.f_138305_; +@@ -62,7 +_,14 @@ + return jsonobject; } -- public static class Builder { -+ public static class Builder implements net.minecraftforge.common.extensions.IForgeAdvancementBuilder { - @Nullable - private ResourceLocation f_138332_; - @Nullable -@@ -340,7 +_,14 @@ - return "Task Advancement{parentId=" + this.f_138332_ + ", display=" + this.f_138334_ + ", rewards=" + this.f_138335_ + ", criteria=" + this.f_138336_ + ", requirements=" + Arrays.deepToString(this.f_138337_) + ", sends_telemetry_event=" + this.f_285655_ + "}"; - } - -+ /** @deprecated Forge: use {@linkplain #fromJson(JsonObject, DeserializationContext, net.minecraftforge.common.crafting.conditions.ICondition.IContext) overload with context}. */ -+ @Deprecated - public static Advancement.Builder m_138380_(JsonObject p_138381_, DeserializationContext p_138382_) { -+ return fromJson(p_138381_, p_138382_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY); -+ } ++ /** @deprecated Forge: use {@linkplain #fromJson(JsonObject, DeserializationContext, net.minecraftforge.common.crafting.conditions.ICondition.IContext) overload with context}. */ ++ @Deprecated + public static Advancement m_294730_(JsonObject p_300691_, DeserializationContext p_300053_) { ++ return fromJson(p_300691_, p_300053_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY); ++ } + -+ public static Advancement.Builder fromJson(JsonObject p_138381_, DeserializationContext p_138382_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { -+ if ((p_138381_ = net.minecraftforge.common.crafting.ConditionalAdvancement.processConditional(p_138381_, context)) == null) return null; - ResourceLocation resourcelocation = p_138381_.has("parent") ? new ResourceLocation(GsonHelper.m_13906_(p_138381_, "parent")) : null; - DisplayInfo displayinfo = p_138381_.has("display") ? DisplayInfo.m_14981_(GsonHelper.m_13930_(p_138381_, "display")) : null; - AdvancementRewards advancementrewards = p_138381_.has("rewards") ? AdvancementRewards.m_9991_(GsonHelper.m_13930_(p_138381_, "rewards")) : AdvancementRewards.f_9978_; ++ public static Advancement fromJson(JsonObject p_300691_, DeserializationContext p_300053_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { ++ //if ((p_300691_ = net.minecraftforge.common.crafting.ConditionalAdvancement.processConditional(p_300691_, context)) == null) return null; + Optional optional = p_300691_.has("parent") ? Optional.of(new ResourceLocation(GsonHelper.m_13906_(p_300691_, "parent"))) : Optional.empty(); + Optional optional1 = p_300691_.has("display") ? Optional.of(DisplayInfo.m_14981_(GsonHelper.m_13930_(p_300691_, "display"))) : Optional.empty(); + AdvancementRewards advancementrewards = p_300691_.has("rewards") ? AdvancementRewards.m_9991_(GsonHelper.m_13930_(p_300691_, "rewards")) : AdvancementRewards.f_9978_; diff --git a/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch index bea6c2f864..cc4f00ad72 100644 --- a/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch +++ b/patches/minecraft/net/minecraft/advancements/critereon/ItemPredicate.java.patch @@ -1,47 +1,11 @@ --- a/net/minecraft/advancements/critereon/ItemPredicate.java +++ b/net/minecraft/advancements/critereon/ItemPredicate.java -@@ -29,6 +_,8 @@ - import net.minecraft.world.level.ItemLike; - - public class ItemPredicate { -+ private static final Map> custom_predicates = new java.util.HashMap<>(); -+ private static final Map> unmod_predicates = java.util.Collections.unmodifiableMap(custom_predicates); - public static final ItemPredicate f_45028_ = new ItemPredicate(); - @Nullable - private final TagKey f_45029_; -@@ -81,7 +_,7 @@ +@@ -50,7 +_,7 @@ return false; } else { - if (this.f_45033_.length > 0) { + if (!this.f_45033_.isEmpty()) { - Map map = EnchantmentHelper.m_44882_(p_45050_.m_41785_()); + Map map = p_45050_.getAllEnchantments(); for(EnchantmentPredicate enchantmentpredicate : this.f_45033_) { if (!enchantmentpredicate.m_30476_(map)) { -@@ -108,6 +_,11 @@ - public static ItemPredicate m_45051_(@Nullable JsonElement p_45052_) { - if (p_45052_ != null && !p_45052_.isJsonNull()) { - JsonObject jsonobject = GsonHelper.m_13918_(p_45052_, "item"); -+ if (jsonobject.has("type")) { -+ final ResourceLocation rl = new ResourceLocation(GsonHelper.m_13906_(jsonobject, "type")); -+ if (custom_predicates.containsKey(rl)) return custom_predicates.get(rl).apply(jsonobject); -+ else throw new JsonSyntaxException("There is no ItemPredicate of type "+rl); -+ } - MinMaxBounds.Ints minmaxbounds$ints = MinMaxBounds.Ints.m_55373_(jsonobject.get("count")); - MinMaxBounds.Ints minmaxbounds$ints1 = MinMaxBounds.Ints.m_55373_(jsonobject.get("durability")); - if (jsonobject.has("data")) { -@@ -215,6 +_,14 @@ - } else { - return new ItemPredicate[0]; - } -+ } -+ -+ public static void register(ResourceLocation name, java.util.function.Function deserializer) { -+ custom_predicates.put(name, deserializer); -+ } -+ -+ public static Map> getPredicates() { -+ return unmod_predicates; - } - - public static class Builder { diff --git a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch b/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch index 410833f64a..5a141ce438 100644 --- a/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch +++ b/patches/minecraft/net/minecraft/client/ClientRecipeBook.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/client/ClientRecipeBook.java +++ b/net/minecraft/client/ClientRecipeBook.java -@@ -54,7 +_,7 @@ - for(Recipe recipe : p_90643_) { +@@ -56,7 +_,7 @@ + Recipe recipe = recipeholder.f_291008_(); if (!recipe.m_5598_() && !recipe.m_142505_()) { - RecipeBookCategories recipebookcategories = m_90646_(recipe); + RecipeBookCategories recipebookcategories = m_90646_(recipeholder); - String s = recipe.m_6076_(); -+ String s = recipe.m_6076_().isEmpty() ? recipe.m_6423_().toString() : recipe.m_6076_(); // FORGE: Group value defaults to the recipe's ID if the recipe's explicit group is empty. ++ String s = recipe.m_6076_().isEmpty() ? recipeholder.f_291676_().toString() : recipe.m_6076_(); // FORGE: Group value defaults to the recipe's ID if the recipe's explicit group is empty. if (s.isEmpty()) { map.computeIfAbsent(recipebookcategories, (p_90645_) -> { return Lists.newArrayList(); -@@ -141,6 +_,8 @@ +@@ -144,6 +_,8 @@ } else if (recipetype == RecipeType.f_44113_) { return RecipeBookCategories.SMITHING; } else { -+ RecipeBookCategories categories = net.minecraftforge.client.RecipeBookManager.findCategories((RecipeType) recipetype, p_90647_); ++ RecipeBookCategories categories = net.minecraftforge.client.RecipeBookManager.findCategories((RecipeType) recipetype, p_299041_); + if (categories != null) return categories; f_90618_.warn("Unknown recipe category: {}/{}", LogUtils.defer(() -> { - return BuiltInRegistries.f_256990_.m_7981_(p_90647_.m_6671_()); - }), LogUtils.defer(p_90647_::m_6423_)); + return BuiltInRegistries.f_256990_.m_7981_(recipe.m_6671_()); + }), LogUtils.defer(p_299041_::f_291676_)); diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index 4c2d018d8d..55b5eea050 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -329,7 +_,9 @@ +@@ -340,7 +_,9 @@ } } @@ -11,7 +11,7 @@ if (this.f_90867_.f_91066_.f_92105_.m_90832_(p_90895_, p_90896_)) { this.f_90867_.m_91268_().m_85438_(); this.f_90867_.f_91066_.m_231829_().m_231514_(this.f_90867_.m_91268_().m_85440_()); -@@ -347,6 +_,8 @@ +@@ -358,6 +_,8 @@ }); return; } @@ -19,8 +19,8 @@ + ((KeyBindsScreen)this.f_90867_.f_91080_).f_193975_ = null; //Forge: Unset pure modifiers. } - if (this.f_90867_.m_240477_().m_93316_()) { -@@ -369,11 +_,15 @@ + if (this.f_90867_.m_240477_().m_93316_() && this.f_90867_.f_91066_.m_292959_().m_231551_()) { +@@ -380,11 +_,15 @@ Screen.m_96579_(() -> { if (p_90897_ != 1 && p_90897_ != 2) { if (p_90897_ == 0) { @@ -38,8 +38,8 @@ } }, "keyPressed event handler", screen.getClass().getCanonicalName()); -@@ -424,22 +_,26 @@ - } +@@ -443,22 +_,26 @@ + this.f_90867_.m_91111_(p_90895_ - 48); } } - diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 4c1fddc5b7..16edc79eea 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -249,7 +_,7 @@ +@@ -251,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,15 +9,15 @@ static Minecraft f_90981_; private static final Logger f_90982_ = LogUtils.getLogger(); public static final boolean f_91002_ = Util.m_137581_() == Util.OS.OSX; -@@ -413,7 +_,6 @@ +@@ -421,7 +_,6 @@ + }, Util.m_183992_()); this.f_193584_ = this.m_193585_(this.f_231338_, p_91084_); - this.f_90998_ = p_91084_.f_101905_.f_101942_; f_90982_.info("Setting user: {}", (Object)this.f_90998_.m_92546_()); - f_90982_.debug("(Session ID is {})", (Object)this.f_90998_.m_92544_()); this.f_91033_ = p_91084_.f_101908_.f_101926_; this.f_91034_ = !p_91084_.f_101908_.f_101929_; this.f_91035_ = !p_91084_.f_101908_.f_101930_; -@@ -449,15 +_,15 @@ +@@ -457,15 +_,15 @@ } this.f_90990_.m_85380_(this.f_91066_.m_232035_().m_231551_()); @@ -35,7 +35,7 @@ this.f_91038_.m_10506_(); this.f_91066_.m_92145_(this.f_91038_); this.f_91039_ = new LanguageManager(this.f_91066_.f_92075_); -@@ -504,10 +_,13 @@ +@@ -511,10 +_,13 @@ this.f_91063_ = new GameRenderer(this, this.f_90994_.m_234586_(), this.f_91036_, this.f_90993_); this.f_91036_.m_7217_(this.f_91063_.m_247116_()); this.f_91060_ = new LevelRenderer(this, this.f_90994_, this.f_167845_, this.f_90993_); @@ -50,7 +50,7 @@ this.f_91036_.m_7217_(this.f_91061_); this.f_91053_ = new PaintingTextureManager(this.f_90987_); this.f_91036_.m_7217_(this.f_91053_); -@@ -516,7 +_,10 @@ +@@ -525,7 +_,10 @@ this.f_91047_ = new GpuWarnlistManager(); this.f_91036_.m_7217_(this.f_91047_); this.f_91036_.m_7217_(this.f_205120_); @@ -62,7 +62,7 @@ this.f_91064_ = new DebugRenderer(this); RealmsClient realmsclient = RealmsClient.m_239151_(this); this.f_238717_ = new RealmsDataFetcher(realmsclient); -@@ -536,6 +_,7 @@ +@@ -545,6 +_,7 @@ TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false); } @@ -70,52 +70,25 @@ this.f_90990_.m_85409_(this.f_91066_.m_231817_().m_231551_()); this.f_90990_.m_85424_(this.f_91066_.m_232123_().m_231551_()); this.f_90990_.m_85426_(); -@@ -554,7 +_,7 @@ - this.f_167847_.m_168557_(ResourceLoadStateTracker.ReloadReason.INITIAL, list); +@@ -564,7 +_,7 @@ ReloadInstance reloadinstance = this.f_91036_.m_142463_(Util.m_183991_(), this, f_90983_, list); GameLoadTimesEvent.f_285635_.m_285833_(TelemetryProperty.f_285629_); -- this.m_91150_(new LoadingOverlay(this, reloadinstance, (p_210745_) -> { -+ this.m_91150_(net.minecraftforge.fml.loading.ImmediateWindowHandler.loadingOverlay(()->this, ()->reloadinstance, (p_210745_) -> { - Util.m_137521_(p_210745_, this::m_91239_, () -> { - if (SharedConstants.f_136183_) { - this.m_91273_(); -@@ -562,20 +_,23 @@ - + Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.f_278410_); +- this.m_91150_(new LoadingOverlay(this, reloadinstance, (p_296164_) -> { ++ this.m_91150_(net.minecraftforge.fml.loading.ImmediateWindowHandler.loadingOverlay(() -> this, () -> reloadinstance, (p_296164_) -> { + Util.m_137521_(p_296164_, (p_296162_) -> { + this.m_91239_(p_296162_, minecraft$gameloadcookie); + }, () -> { +@@ -575,7 +_,7 @@ this.f_167847_.m_168556_(); - this.m_286052_(); -+ if (net.minecraftforge.client.loading.ClientModLoader.completeModLoading()) -+ return; // Do not overwrite the error screen if there are errors -+ // FORGE: Move opening initial screen to after startup and events are enabled -+ if (this.m_239929_()) { -+ this.m_91152_(BanNoticeScreen.m_239967_((p_278873_) -> { -+ if (p_278873_) { -+ Util.m_137581_().m_137646_("https://aka.ms/mcjavamoderation"); -+ } -+ -+ this.m_278684_(realmsclient, reloadinstance, p_91084_.f_278410_); -+ }, this.m_239210_())); -+ } else { -+ this.m_278684_(realmsclient, reloadinstance, p_91084_.f_278410_); -+ } + this.m_293750_(minecraft$gameloadcookie); }); - }, false)); + }, false).get()); this.f_278504_ = QuickPlayLog.m_278648_(p_91084_.f_278410_.f_278493_()); -- if (this.m_239929_()) { -- this.m_91152_(BanNoticeScreen.m_239967_((p_278873_) -> { -- if (p_278873_) { -- Util.m_137581_().m_137646_("https://aka.ms/mcjavamoderation"); -- } -- -- this.m_278684_(realmsclient, reloadinstance, p_91084_.f_278410_); -- }, this.m_239210_())); -- } else { -- this.m_278684_(realmsclient, reloadinstance, p_91084_.f_278410_); -- } - } -@@ -611,7 +_,7 @@ +@@ -673,7 +_,7 @@ private String m_91270_() { StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (m_193589_().m_184597_()) { @@ -124,7 +97,7 @@ } stringbuilder.append(" "); -@@ -635,6 +_,8 @@ +@@ -698,6 +_,8 @@ private UserApiService m_193585_(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { try { @@ -133,30 +106,30 @@ return p_193586_.createUserApiService(p_193587_.f_101905_.f_101942_.m_92547_()); } catch (AuthenticationException authenticationexception) { f_90982_.error("Failed to verify authentication", (Throwable)authenticationexception); -@@ -647,7 +_,7 @@ +@@ -710,7 +_,7 @@ } - private void m_91239_(Throwable p_91240_) { + private void m_91239_(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) { - if (this.f_91038_.m_10523_().size() > 1) { + if (this.f_91038_.m_10524_().stream().anyMatch(e -> !e.m_10449_())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any. - this.m_91241_(p_91240_, (Component)null); + this.m_91241_(p_91240_, (Component)null, p_299515_); } else { Util.m_137559_(p_91240_); -@@ -739,7 +_,10 @@ +@@ -802,7 +_,10 @@ } public void m_91271_() { -- this.f_90997_.m_235232_(SearchRegistry.f_119941_, (p_231389_) -> { +- this.f_90997_.m_235232_(SearchRegistry.f_119941_, (p_231451_) -> { + var nameSearchKeys = net.minecraftforge.client.CreativeModeTabSearchRegistry.getNameSearchKeys(); + var tagSearchKeys = net.minecraftforge.client.CreativeModeTabSearchRegistry.getTagSearchKeys(); + for (var nameSearchKey : nameSearchKeys.values()) -+ this.f_90997_.m_235232_(nameSearchKey, (p_231389_) -> { ++ this.f_90997_.m_235232_(nameSearchKey, (p_231451_) -> { return new FullTextSearchTree<>((p_210797_) -> { - return p_210797_.m_41651_((Player)null, TooltipFlag.Default.f_256752_.m_257777_()).stream().map((p_210807_) -> { - return ChatFormatting.m_126649_(p_210807_.getString()).trim(); -@@ -750,7 +_,8 @@ + return p_210797_.m_41651_((Player)null, TooltipFlag.Default.f_256752_.m_257777_()).stream().map((p_231455_) -> { + return ChatFormatting.m_126649_(p_231455_.getString()).trim(); +@@ -813,14 +_,18 @@ return Stream.of(BuiltInRegistries.f_257033_.m_7981_(p_91317_.m_41720_())); - }, p_231389_); + }, p_231451_); }); - this.f_90997_.m_235232_(SearchRegistry.f_119942_, (p_231430_) -> { + for (var tagSearchKey : tagSearchKeys.values()) @@ -164,9 +137,6 @@ return new IdSearchTree<>((p_231353_) -> { return p_231353_.m_204131_().map(TagKey::f_203868_); }, p_231430_); -@@ -770,9 +_,12 @@ - }); - }, p_231451_); }); - CreativeModeTabs.m_258007_().m_257882_((p_255439_) -> { - this.m_231374_(SearchRegistry.f_119941_, p_255439_); @@ -180,7 +150,7 @@ }); } -@@ -824,13 +_,13 @@ +@@ -872,13 +_,13 @@ Bootstrap.m_135875_(p_91333_.m_127526_()); if (p_91333_.m_127527_() != null) { Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.m_127527_()); @@ -197,7 +167,7 @@ } } -@@ -954,10 +_,6 @@ +@@ -1003,10 +_,6 @@ f_90982_.error("setScreen called from non-game thread"); } @@ -208,27 +178,27 @@ if (p_91153_ == null && this.f_91073_ == null) { p_91153_ = new TitleScreen(); } else if (p_91153_ == null && this.f_91074_.m_21224_()) { -@@ -968,6 +_,19 @@ +@@ -1017,6 +_,19 @@ } } + net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this); + Screen old = this.f_91080_; + if (p_91153_ != null) { -+ var event = new net.minecraftforge.client.event.ScreenEvent.Opening(old, p_91153_); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; -+ p_91153_ = event.getNewScreen(); ++ var event = net.minecraftforge.event.ForgeEventFactory.onScreenOpening(old, p_91153_); ++ if (event == null) return; ++ p_91153_ = event; + } + + if (old != null && p_91153_ != old) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.Closing(old)); ++ net.minecraftforge.event.ForgeEventFactory.onScreenClose(old); + old.m_7861_(); + } + this.f_91080_ = p_91153_; if (this.f_91080_ != null) { this.f_91080_.m_274333_(); -@@ -1113,9 +_,12 @@ +@@ -1163,9 +_,12 @@ RenderSystem.enableCull(); this.f_91026_.m_7238_(); if (!this.f_91079_) { @@ -241,7 +211,7 @@ } if (this.f_91056_ != null) { -@@ -1240,10 +_,12 @@ +@@ -1286,10 +_,12 @@ this.f_90990_.m_85378_((double)i); if (this.f_91080_ != null) { this.f_91080_.m_6574_(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_()); @@ -254,15 +224,15 @@ this.f_91063_.m_109097_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_()); this.f_91067_.m_91599_(); } -@@ -1517,6 +_,7 @@ +@@ -1563,6 +_,7 @@ } public void m_91395_() { -+ if (this.m_91396_()) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.GameShuttingDownEvent()); ++ if (this.m_91396_()) net.minecraftforge.event.ForgeEventFactory.onGameShuttingDown(); this.f_91019_ = false; } -@@ -1546,10 +_,18 @@ +@@ -1592,10 +_,18 @@ if (p_91387_ && this.f_91077_ != null && this.f_91077_.m_6662_() == HitResult.Type.BLOCK) { BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; BlockPos blockpos = blockhitresult.m_82425_(); @@ -284,7 +254,7 @@ this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); } } -@@ -1578,6 +_,8 @@ +@@ -1624,6 +_,8 @@ return false; } else { boolean flag = false; @@ -293,7 +263,7 @@ switch (this.f_91077_.m_6662_()) { case ENTITY: this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_()); -@@ -1585,7 +_,7 @@ +@@ -1631,7 +_,7 @@ case BLOCK: BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; BlockPos blockpos = blockhitresult.m_82425_(); @@ -302,7 +272,7 @@ this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_()); if (this.f_91073_.m_8055_(blockpos).m_60795_()) { flag = true; -@@ -1598,8 +_,10 @@ +@@ -1644,8 +_,10 @@ } this.f_91074_.m_36334_(); @@ -313,7 +283,7 @@ this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); return flag; } -@@ -1615,6 +_,11 @@ +@@ -1661,6 +_,11 @@ } for(InteractionHand interactionhand : InteractionHand.values()) { @@ -325,7 +295,7 @@ ItemStack itemstack = this.f_91074_.m_21120_(interactionhand); if (!itemstack.m_246617_(this.f_91073_.m_246046_())) { return; -@@ -1635,7 +_,7 @@ +@@ -1681,7 +_,7 @@ } if (interactionresult.m_19077_()) { @@ -334,7 +304,7 @@ this.f_91074_.m_6674_(interactionhand); } -@@ -1647,7 +_,7 @@ +@@ -1693,7 +_,7 @@ int i = itemstack.m_41613_(); InteractionResult interactionresult1 = this.f_91072_.m_233732_(this.f_91074_, interactionhand, blockhitresult); if (interactionresult1.m_19077_()) { @@ -343,7 +313,7 @@ this.f_91074_.m_6674_(interactionhand); if (!itemstack.m_41619_() && (itemstack.m_41613_() != i || this.f_91072_.m_105290_())) { this.f_91063_.f_109055_.m_109320_(interactionhand); -@@ -1663,6 +_,9 @@ +@@ -1709,6 +_,9 @@ } } @@ -353,7 +323,7 @@ if (!itemstack.m_41619_()) { InteractionResult interactionresult2 = this.f_91072_.m_233721_(this.f_91074_, interactionhand); if (interactionresult2.m_19077_()) { -@@ -1689,6 +_,8 @@ +@@ -1735,6 +_,8 @@ --this.f_91011_; } @@ -362,7 +332,7 @@ this.f_91026_.m_6180_("gui"); this.f_240378_.m_240688_(); this.f_91065_.m_193832_(this.f_91012_); -@@ -1780,6 +_,7 @@ +@@ -1823,6 +_,7 @@ this.f_91005_.m_120596_(); @@ -370,7 +340,7 @@ try { this.f_91073_.m_104726_(() -> { return true; -@@ -1795,6 +_,7 @@ +@@ -1838,6 +_,7 @@ throw new ReportedException(crashreport); } @@ -378,7 +348,7 @@ } this.f_91026_.m_6182_("animateTick"); -@@ -1814,6 +_,8 @@ +@@ -1857,6 +_,8 @@ this.f_91026_.m_6182_("keyboard"); this.f_91068_.m_90931_(); this.f_91026_.m_7238_(); @@ -387,7 +357,7 @@ } private boolean m_91278_() { -@@ -2011,6 +_,7 @@ +@@ -2053,6 +_,7 @@ } public void m_91156_(ClientLevel p_91157_) { @@ -395,7 +365,7 @@ ProgressScreen progressscreen = new ProgressScreen(true); progressscreen.m_6309_(Component.m_237115_("connect.joining")); this.m_91362_(progressscreen); -@@ -2044,10 +_,12 @@ +@@ -2086,10 +_,12 @@ IntegratedServer integratedserver = this.f_91007_; this.f_91007_ = null; this.f_91063_.m_109150_(); @@ -408,7 +378,7 @@ if (integratedserver != null) { this.f_91026_.m_6180_("waitForServer"); -@@ -2061,6 +_,7 @@ +@@ -2103,6 +_,7 @@ this.f_243981_.m_246151_(); this.f_91065_.m_93089_(); this.f_91010_ = false; @@ -416,7 +386,7 @@ } this.f_91073_ = null; -@@ -2167,6 +_,7 @@ +@@ -2227,6 +_,7 @@ private void m_91280_() { if (this.f_91077_ != null && this.f_91077_.m_6662_() != HitResult.Type.MISS) { @@ -424,7 +394,7 @@ boolean flag = this.f_91074_.m_150110_().f_35937_; BlockEntity blockentity = null; HitResult.Type hitresult$type = this.f_91077_.m_6662_(); -@@ -2179,10 +_,7 @@ +@@ -2239,10 +_,7 @@ } Block block = blockstate.m_60734_(); @@ -436,7 +406,7 @@ if (flag && Screen.m_96637_() && blockstate.m_155947_()) { blockentity = this.f_91073_.m_7702_(blockpos); -@@ -2193,7 +_,7 @@ +@@ -2253,7 +_,7 @@ } Entity entity = ((EntityHitResult)this.f_91077_).m_82443_(); @@ -445,7 +415,7 @@ if (itemstack == null) { return; } -@@ -2732,6 +_,19 @@ +@@ -2788,6 +_,19 @@ public void m_91312_(int p_91313_) { this.f_91051_.m_119410_(p_91313_); diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch index 24a71833e9..ca13b2e2b5 100644 --- a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -1,85 +1,75 @@ --- a/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java -@@ -73,6 +_,7 @@ +@@ -74,6 +_,7 @@ this.f_91510_ = -1; } -+ if (net.minecraftforge.client.ForgeHooksClient.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return; ++ if (net.minecraftforge.event.ForgeEventFactory.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return; boolean[] aboolean = new boolean[]{false}; if (this.f_91503_.m_91265_() == null) { if (this.f_91503_.f_91080_ == null) { -@@ -86,11 +_,19 @@ +@@ -87,11 +_,19 @@ if (flag) { screen.m_169415_(); Screen.m_96579_(() -> { - aboolean[0] = screen.m_6375_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPre(screen, d0, d1, i); ++ aboolean[0] = net.minecraftforge.event.ForgeEventFactory.onScreenMouseClickedPre(screen, d0, d1, i); + if (!aboolean[0]) { + aboolean[0] = this.f_91503_.f_91080_.m_6375_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPost(screen, d0, d1, i, aboolean[0]); ++ aboolean[0] = net.minecraftforge.event.ForgeEventFactory.onScreenMouseClickedPost(screen, d0, d1, i, aboolean[0]); + } }, "mouseClicked event handler", screen.getClass().getCanonicalName()); } else { Screen.m_96579_(() -> { - aboolean[0] = screen.m_6348_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPre(screen, d0, d1, i); ++ aboolean[0] = net.minecraftforge.event.ForgeEventFactory.onScreenMouseReleasedPre(screen, d0, d1, i); + if (!aboolean[0]) { + aboolean[0] = this.f_91503_.f_91080_.m_6348_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPost(screen, d0, d1, i, aboolean[0]); ++ aboolean[0] = net.minecraftforge.event.ForgeEventFactory.onScreenMouseReleasedPost(screen, d0, d1, i, aboolean[0]); + } }, "mouseReleased event handler", screen.getClass().getCanonicalName()); } } -@@ -114,19 +_,26 @@ - } +@@ -116,6 +_,7 @@ } } -- -+ net.minecraftforge.client.ForgeHooksClient.onMouseButtonPost(p_91532_, p_91533_, p_91534_); + ++ net.minecraftforge.event.ForgeEventFactory.onMouseButtonPost(p_91532_, p_91533_, p_91534_); } } - private void m_91526_(long p_91527_, double p_91528_, double p_91529_) { - if (p_91527_ == Minecraft.m_91087_().m_91268_().m_85439_()) { -- double d0 = (this.f_91503_.f_91066_.m_231821_().m_231551_() ? Math.signum(p_91529_) : p_91529_) * this.f_91503_.f_91066_.m_232122_().m_231551_(); -+ // FORGE: Allows for Horizontal Scroll to be recognized as Vertical Scroll - Fixes MC-121772 -+ double offset = p_91529_; -+ if (Minecraft.f_91002_ && p_91529_ == 0) { -+ offset = p_91528_; -+ } -+ double d0 = (this.f_91503_.f_91066_.m_231821_().m_231551_() ? Math.signum(offset) : offset) * this.f_91503_.f_91066_.m_232122_().m_231551_(); - if (this.f_91503_.m_91265_() == null) { +@@ -129,8 +_,10 @@ if (this.f_91503_.f_91080_ != null) { - double d1 = this.f_91507_ * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_(); - double d2 = this.f_91508_ * (double)this.f_91503_.m_91268_().m_85446_() / (double)this.f_91503_.m_91268_().m_85444_(); -- this.f_91503_.f_91080_.m_6050_(d1, d2, d0); + double d3 = this.f_91507_ * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_(); + double d4 = this.f_91508_ * (double)this.f_91503_.m_91268_().m_85446_() / (double)this.f_91503_.m_91268_().m_85444_(); +- this.f_91503_.f_91080_.m_6050_(d3, d4, d1, d2); this.f_91503_.f_91080_.m_169415_(); -+ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPre(this, this.f_91503_.f_91080_, d0)) return; -+ if (this.f_91503_.f_91080_.m_6050_(d1, d2, d0)) return; -+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPost(this, this.f_91503_.f_91080_, d0); ++ if (net.minecraftforge.event.ForgeEventFactory.onScreenMouseScrollPre(this.f_91503_.f_91080_, d3, d4, d1, d2)) return; ++ if (this.f_91503_.f_91080_.m_6050_(d3, d4, d1, d2)) return; ++ net.minecraftforge.event.ForgeEventFactory.onScreenMouseScrollPost(this.f_91503_.f_91080_, d3, d4, d1, d2); } else if (this.f_91503_.f_91074_ != null) { - if (this.f_91518_ != 0.0D && Math.signum(d0) != Math.signum(this.f_91518_)) { - this.f_91518_ = 0.0D; -@@ -139,6 +_,7 @@ - } - - this.f_91518_ -= (double)i; -+ if (net.minecraftforge.client.ForgeHooksClient.onMouseScroll(this, d0)) return; + if (this.f_291070_ != 0.0D && Math.signum(d1) != Math.signum(this.f_291070_)) { + this.f_291070_ = 0.0D; +@@ -151,6 +_,7 @@ + this.f_291070_ -= (double)j; + this.f_291867_ -= (double)i; + int k = i == 0 ? -j : i; ++ if (net.minecraftforge.event.ForgeEventFactory.onMouseScroll(this, d1, d2)) return; if (this.f_91503_.f_91074_.m_5833_()) { if (this.f_91503_.f_91065_.m_93085_().m_94768_()) { - this.f_91503_.f_91065_.m_93085_().m_205380_(-i); -@@ -207,7 +_,9 @@ + this.f_91503_.f_91065_.m_93085_().m_205380_(-k); +@@ -219,7 +_,9 @@ double d2 = (p_91563_ - this.f_91507_) * (double)this.f_91503_.m_91268_().m_85445_() / (double)this.f_91503_.m_91268_().m_85443_(); double d3 = (p_91564_ - this.f_91508_) * (double)this.f_91503_.m_91268_().m_85446_() / (double)this.f_91503_.m_91268_().m_85444_(); Screen.m_96579_(() -> { - screen.m_7979_(d0, d1, this.f_91510_, d2, d3); -+ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPre(screen, d0, d1, this.f_91510_, d2, d3)) return; ++ if (net.minecraftforge.event.ForgeEventFactory.onScreenMouseDragPre(screen, d0, d1, this.f_91510_, d2, d3)) return; + if (screen.m_7979_(d0, d1, this.f_91510_, d2, d3)) return; -+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPost(screen, d0, d1, this.f_91510_, d2, d3); ++ net.minecraftforge.event.ForgeEventFactory.onScreenMouseDragPost(screen, d0, d1, this.f_91510_, d2, d3); }, "mouseDragged event handler", screen.getClass().getCanonicalName()); } -@@ -290,6 +_,14 @@ +@@ -302,6 +_,14 @@ public double m_91594_() { return this.f_91508_; diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch index 31c95f1198..92b25e4750 100644 --- a/patches/minecraft/net/minecraft/client/Options.java.patch +++ b/patches/minecraft/net/minecraft/client/Options.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java -@@ -545,7 +_,8 @@ +@@ -507,7 +_,8 @@ }, new OptionInstance.LazyEnum<>(() -> { return Stream.concat(Stream.of(""), Minecraft.m_91087_().m_91106_().m_194525_().stream()).toList(); }, (p_232011_) -> { - return Minecraft.m_91087_().m_91396_() && p_232011_ != "" && !Minecraft.m_91087_().m_91106_().m_194525_().contains(p_232011_) ? Optional.empty() : Optional.of(p_232011_); + // FORGE: fix incorrect string comparison - PR #8767 + return Minecraft.m_91087_().m_91396_() && (p_232011_ == null || !p_232011_.isEmpty()) && !Minecraft.m_91087_().m_91106_().m_194525_().contains(p_232011_) ? Optional.empty() : Optional.of(p_232011_); - }, Codec.STRING), "", (p_275584_) -> { + }, Codec.STRING), "", (p_299350_) -> { SoundManager soundmanager = Minecraft.m_91087_().m_91106_(); soundmanager.m_194526_(); -@@ -869,6 +_,7 @@ +@@ -835,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -18,7 +18,7 @@ this.f_92060_ = p_92138_; this.f_92110_ = new File(p_92139_, "options.txt"); boolean flag = p_92138_.m_91103_(); -@@ -990,11 +_,21 @@ +@@ -957,11 +_,21 @@ p_168428_.m_213982_("telemetryOptInExtra", this.f_260461_); this.f_263744_ = p_168428_.m_142682_("onboardAccessibility", this.f_263744_); @@ -42,7 +42,7 @@ } } -@@ -1013,6 +_,9 @@ +@@ -980,6 +_,9 @@ } public void m_92140_() { @@ -52,7 +52,7 @@ try { if (!this.f_92110_.exists()) { return; -@@ -1041,7 +_,8 @@ +@@ -1008,7 +_,8 @@ } } @@ -62,15 +62,15 @@ @Nullable private String m_168458_(String p_168459_) { return compoundtag1.m_128441_(p_168459_) ? compoundtag1.m_128461_(p_168459_) : null; -@@ -1204,6 +_,7 @@ +@@ -1181,6 +_,7 @@ } public void m_92172_() { + if (net.minecraftforge.client.loading.ClientModLoader.isLoading()) return; //Don't save settings before mods add keybindigns and the like to prevent them from being deleted. if (this.f_92060_.f_91074_ != null) { - int i = 0; - -@@ -1268,6 +_,23 @@ + this.f_92060_.f_91074_.f_108617_.m_295327_(new ServerboundClientInformationPacket(this.m_294596_())); + } +@@ -1239,6 +_,23 @@ } p_92146_.m_10509_(set); diff --git a/patches/minecraft/net/minecraft/client/User.java.patch b/patches/minecraft/net/minecraft/client/User.java.patch deleted file mode 100644 index ea069ae3cb..0000000000 --- a/patches/minecraft/net/minecraft/client/User.java.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/net/minecraft/client/User.java -+++ b/net/minecraft/client/User.java -@@ -21,8 +_,22 @@ - private final Optional f_193796_; - private final Optional f_193797_; - private final User.Type f_92538_; -+ /** Forge: Cache of the local session's GameProfile properties. */ -+ private com.mojang.authlib.properties.PropertyMap properties; - - public User(String p_193799_, String p_193800_, String p_193801_, Optional p_193802_, Optional p_193803_, User.Type p_193804_) { -+ if (p_193799_ == null || p_193799_.isEmpty()) { -+ p_193799_ = "MissingName"; -+ p_193800_ = p_193801_ = "NotValid"; -+ org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger(getClass().getName()); -+ logger.warn("========================================================="); -+ logger.warn("WARNING!! the username was not set for this session, typically"); -+ logger.warn("this means you installed Forge incorrectly. We have set your"); -+ logger.warn("name to \"MissingName\" and your session to nothing. Please"); -+ logger.warn("check your installation and post a console log from the launcher"); -+ logger.warn("when asking for help!"); -+ logger.warn("========================================================="); -+ } - this.f_92535_ = p_193799_; - this.f_92536_ = p_193800_; - this.f_92537_ = p_193801_; -@@ -64,8 +_,22 @@ - } - } - -+ //For internal use only. Modders should never need to use this. -+ public void setProperties(com.mojang.authlib.properties.PropertyMap properties) { -+ if (this.properties == null) -+ this.properties = properties; -+ } -+ -+ public boolean hasCachedProperties() { -+ return properties != null; -+ } -+ - public GameProfile m_92548_() { -- return new GameProfile(this.m_240411_(), this.m_92546_()); -+ // FORGE: Add cached GameProfile properties to returned GameProfile. This helps to cut down on calls to the session service. -+ GameProfile ret = new GameProfile(this.m_240411_(), this.m_92546_()); -+ if (this.properties != null) -+ ret.getProperties().putAll(this.properties); -+ return ret; - } - - public User.Type m_168638_() { diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index 3e9fb12347..c130702696 100644 --- a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java -@@ -424,6 +_,8 @@ +@@ -453,6 +_,8 @@ for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { MobEffect mobeffect = mobeffectinstance.m_19544_(); @@ -9,7 +9,7 @@ if (mobeffectinstance.m_19575_()) { int i = this.f_92977_; int j = 1; -@@ -452,6 +_,7 @@ +@@ -481,6 +_,7 @@ } } @@ -17,7 +17,7 @@ TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.m_118732_(mobeffect); int i1 = j; float f1 = f; -@@ -572,16 +_,21 @@ +@@ -601,16 +_,21 @@ } public void m_280295_(GuiGraphics p_283501_) { @@ -42,7 +42,7 @@ if (!this.f_92986_.f_91072_.m_105205_()) { k += 14; } -@@ -593,7 +_,13 @@ +@@ -622,7 +_,13 @@ if (l > 0) { p_283501_.m_280509_(j - 2, k - 2, j + i + 2, k + 9 + 2, this.f_92986_.f_91066_.m_92143_(0)); @@ -57,7 +57,7 @@ } } -@@ -1037,7 +_,7 @@ +@@ -1069,7 +_,7 @@ ItemStack itemstack = this.f_92986_.f_91074_.m_150109_().m_36056_(); if (itemstack.m_41619_()) { this.f_92993_ = 0; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch index 9cc6bf9c3d..20de32b85b 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/GuiGraphics.java +++ b/net/minecraft/client/gui/GuiGraphics.java -@@ -56,7 +_,7 @@ +@@ -55,7 +_,7 @@ import org.joml.Vector2ic; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ public static final float f_289044_ = 10000.0F; public static final float f_289038_ = -10000.0F; private static final int f_279564_ = 2; -@@ -270,6 +_,11 @@ +@@ -271,6 +_,11 @@ } public int m_280056_(Font p_283343_, @Nullable String p_281896_, int p_283569_, int p_283418_, int p_281560_, boolean p_282130_) { @@ -21,7 +21,7 @@ if (p_281896_ == null) { return 0; } else { -@@ -284,6 +_,11 @@ +@@ -285,6 +_,11 @@ } public int m_280649_(Font p_282636_, FormattedCharSequence p_281596_, int p_281586_, int p_282816_, int p_281743_, boolean p_282394_) { @@ -33,27 +33,7 @@ int i = p_282636_.m_272191_(p_281596_, (float)p_281586_, (float)p_282816_, p_281743_, p_282394_, this.f_279612_.m_85850_().m_252922_(), this.f_279627_, Font.DisplayMode.NORMAL, 0, 15728880); this.m_286081_(); return i; -@@ -405,6 +_,10 @@ - } - - public void m_280543_(ResourceLocation p_283059_, int p_283575_, int p_283192_, int p_281790_, int p_283642_, int p_282691_, int p_281912_, int p_281728_, int p_282324_) { -+ blitRepeating(p_283059_, p_283575_, p_283192_, p_281790_, p_283642_, p_282691_, p_281912_, p_281728_, p_282324_, 256, 256); -+ } -+ -+ public void blitRepeating(ResourceLocation p_283059_, int p_283575_, int p_283192_, int p_281790_, int p_283642_, int p_282691_, int p_281912_, int p_281728_, int p_282324_, int textureWidth, int textureHeight) { - int i = p_283575_; - - int j; -@@ -417,7 +_,7 @@ - for(IntIterator intiterator1 = m_280358_(p_283642_, p_282324_); intiterator1.hasNext(); l += i1) { - i1 = intiterator1.nextInt(); - int j1 = (p_282324_ - i1) / 2; -- this.m_280218_(p_283059_, i, l, p_282691_ + k, p_281912_ + j1, j, i1); -+ this.m_280163_(p_283059_, i, l, p_282691_ + k, p_281912_ + j1, j, i1, textureWidth, textureHeight); - } - } - -@@ -477,6 +_,7 @@ +@@ -511,6 +_,7 @@ crashreportcategory.m_128165_("Item Type", () -> { return String.valueOf((Object)p_281675_.m_41720_()); }); @@ -61,7 +41,7 @@ crashreportcategory.m_128165_("Item Damage", () -> { return String.valueOf(p_281675_.m_41773_()); }); -@@ -524,18 +_,26 @@ +@@ -558,18 +_,26 @@ } this.f_279612_.m_85849_(); @@ -92,7 +72,7 @@ this.m_280497_(p_283128_, list, p_283678_, p_281696_, DefaultTooltipPositioner.f_262752_); } -@@ -544,7 +_,15 @@ +@@ -578,7 +_,15 @@ } public void m_280666_(Font p_282739_, List p_281832_, int p_282191_, int p_282446_) { @@ -109,7 +89,7 @@ } public void m_280245_(Font p_282192_, List p_282297_, int p_281680_, int p_283325_) { -@@ -557,11 +_,13 @@ +@@ -591,11 +_,13 @@ private void m_280497_(Font p_282675_, List p_282615_, int p_283230_, int p_283417_, ClientTooltipPositioner p_282442_) { if (!p_282615_.isEmpty()) { @@ -124,7 +104,7 @@ if (k > i) { i = k; } -@@ -571,20 +_,21 @@ +@@ -605,20 +_,21 @@ int i2 = i; int j2 = j; @@ -149,7 +129,7 @@ k1 += clienttooltipcomponent1.m_142103_() + (l1 == 0 ? 2 : 0); } -@@ -592,7 +_,7 @@ +@@ -626,7 +_,7 @@ for(int k2 = 0; k2 < p_282615_.size(); ++k2) { ClientTooltipComponent clienttooltipcomponent2 = p_282615_.get(k2); diff --git a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch deleted file mode 100644 index 4abbeaf088..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/MapRenderer.java -+++ b/net/minecraft/client/gui/MapRenderer.java -@@ -118,6 +_,7 @@ - - for(MapDecoration mapdecoration : this.f_93280_.m_164811_()) { - if (!p_93294_ || mapdecoration.m_77809_()) { -+ if (mapdecoration.render(k)) { k++; continue; } - p_93292_.m_85836_(); - p_93292_.m_252880_(0.0F + (float)mapdecoration.m_77804_() / 2.0F + 64.0F, 0.0F + (float)mapdecoration.m_77805_() / 2.0F + 64.0F, -0.02F); - p_93292_.m_252781_(Axis.f_252403_.m_252977_((float)(mapdecoration.m_77806_() * 360) / 16.0F)); diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch index 1d8c12905a..798695e504 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractButton.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/components/AbstractButton.java +++ b/net/minecraft/client/gui/components/AbstractButton.java -@@ -32,7 +_,7 @@ +@@ -29,7 +_,7 @@ RenderSystem.enableDepthTest(); - p_281670_.m_280027_(f_93617_, this.m_252754_(), this.m_252907_(), this.m_5711_(), this.m_93694_(), 20, 4, 200, 20, 0, this.m_274533_()); + p_281670_.m_292816_(f_290895_.m_295557_(this.f_93623_, this.m_198029_()), this.m_252754_(), this.m_252907_(), this.m_5711_(), this.m_93694_()); p_281670_.m_280246_(1.0F, 1.0F, 1.0F, 1.0F); - int i = this.f_93623_ ? 16777215 : 10526880; + int i = getFGColor(); - this.m_280139_(p_281670_, minecraft.f_91062_, i | Mth.m_14167_(this.f_93625_ * 255.0F) << 24); + this.m_280465_(p_281670_, minecraft.f_91062_, i | Mth.m_14167_(this.f_93625_ * 255.0F) << 24); } diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch index e904c8ddcd..43fcd2911a 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/AbstractSelectionList.java +++ b/net/minecraft/client/gui/components/AbstractSelectionList.java -@@ -514,6 +_,13 @@ +@@ -504,6 +_,13 @@ return new ScreenRectangle(this.f_93393_, this.f_93390_, this.f_93392_ - this.f_93393_, this.f_93391_ - this.f_93390_); } diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch index ace12d969d..7978199a73 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -1,22 +1,9 @@ --- a/net/minecraft/client/gui/components/AbstractWidget.java +++ b/net/minecraft/client/gui/components/AbstractWidget.java -@@ -234,6 +_,10 @@ - this.f_93618_ = p_93675_; - } - -+ public void setHeight(int value) { -+ this.f_93619_ = value; -+ } -+ - public void m_93650_(float p_93651_) { - this.f_93625_ = p_93651_; - } -@@ -264,6 +_,19 @@ - - public void m_93692_(boolean p_93693_) { +@@ -259,6 +_,19 @@ this.f_93616_ = p_93693_; -+ } -+ + } + + public static final int UNSET_FG_COLOR = -1; + protected int packedFGColor = UNSET_FG_COLOR; + public int getFGColor() { @@ -28,6 +15,8 @@ + } + public void clearFGColor() { + this.packedFGColor = UNSET_FG_COLOR; - } - ++ } ++ public NarratableEntry.NarrationPriority m_142684_() { + if (this.m_93696_()) { + return NarratableEntry.NarrationPriority.FOCUSED; diff --git a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch index 3f877377da..1c27b56004 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/BossHealthOverlay.java +++ b/net/minecraft/client/gui/components/BossHealthOverlay.java -@@ -33,13 +_,16 @@ +@@ -36,13 +_,16 @@ for(LerpingBossEvent lerpingbossevent : this.f_93699_.values()) { int k = i / 2 - 91; diff --git a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch index adb59159d5..8abdbd6691 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -1,6 +1,19 @@ --- a/net/minecraft/client/gui/components/DebugScreenOverlay.java +++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java -@@ -403,6 +_,7 @@ +@@ -93,9 +_,9 @@ + @Nullable + private CompletableFuture f_94036_; + private boolean f_291101_; +- private boolean f_291871_; +- private boolean f_290551_; +- private boolean f_291005_; ++ protected boolean f_291871_; ++ protected boolean f_290551_; ++ protected boolean f_291005_; + private final SampleLogger f_291039_ = new SampleLogger(); + private final SampleLogger f_291524_ = new SampleLogger(); + private final SampleLogger f_290653_ = new SampleLogger(); +@@ -430,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); list.add(String.valueOf((Object)BuiltInRegistries.f_256780_.m_7981_(entity.m_6095_()))); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch index 779ef5682f..fe826713f8 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/ChatScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/ChatScreen.java +++ b/net/minecraft/client/gui/screens/ChatScreen.java -@@ -225,7 +_,7 @@ +@@ -224,7 +_,7 @@ this.f_96541_.f_91074_.f_108617_.m_246175_(p_242400_); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch index 65ce1ac876..d535a7622c 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/ConnectScreen.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/gui/screens/ConnectScreen.java +++ b/net/minecraft/client/gui/screens/ConnectScreen.java -@@ -86,6 +_,8 @@ +@@ -84,6 +_,8 @@ } - if (!optional.isPresent()) { + if (optional.isEmpty()) { + ConnectScreen.f_95683_.error("Couldn't connect to server: Unknown host \"{}\"", p_249536_.m_171863_()); + net.minecraftforge.network.DualStackUtils.logInitialPreferences(); p_251955_.execute(() -> { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch index 627561fede..dec3aa8c4d 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/gui/screens/OptionsScreen.java +++ b/net/minecraft/client/gui/screens/OptionsScreen.java -@@ -151,6 +_,14 @@ - super.m_88315_(p_283520_, p_281826_, p_283378_, p_281975_); +@@ -150,6 +_,14 @@ + p_283520_.m_280653_(this.f_96547_, this.f_96539_, this.f_96543_ / 2, 15, 16777215); } + @Override diff --git a/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch index fb933db63d..0af93af62d 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/PauseScreen.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java -@@ -82,6 +_,7 @@ +@@ -88,6 +_,7 @@ } else { gridlayout$rowhelper.m_264139_(this.m_262456_(f_262254_, SocialInteractionsScreen::new)); } + gridlayout$rowhelper.m_264108_(Button.m_253074_(Component.m_237115_("fml.menu.mods"), button -> this.f_96541_.m_91152_(new net.minecraftforge.client.gui.ModListScreen(this))).m_252780_(f_262268_).m_253136_(), 2); - Component component = this.f_96541_.m_91090_() ? f_262217_ : f_262246_; + Component component = this.f_96541_.m_91090_() ? f_262217_ : CommonComponents.f_290546_; this.f_252482_ = gridlayout$rowhelper.m_264108_(Button.m_253074_(component, (p_280815_) -> { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch index 574caf362b..e243e03018 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java -@@ -205,7 +_,7 @@ +@@ -207,7 +_,7 @@ } public void m_7379_() { @@ -9,7 +9,7 @@ } protected T m_142416_(T p_169406_) { -@@ -317,7 +_,10 @@ +@@ -319,7 +_,10 @@ this.f_96543_ = p_96608_; this.f_96544_ = p_96609_; if (!this.f_267454_) { @@ -20,7 +20,7 @@ } else { this.m_267719_(); } -@@ -330,7 +_,10 @@ +@@ -332,7 +_,10 @@ protected void m_232761_() { this.m_169413_(); this.m_264131_(); @@ -31,15 +31,15 @@ } public List m_6702_() { -@@ -352,6 +_,7 @@ - public void m_280273_(GuiGraphics p_283688_) { +@@ -354,6 +_,7 @@ + public void m_280273_(GuiGraphics p_283688_, int p_299421_, int p_298679_, float p_297268_) { if (this.f_96541_.f_91073_ != null) { - p_283688_.m_280024_(0, 0, this.f_96543_, this.f_96544_, -1072689136, -804253680); + this.m_293900_(p_283688_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.BackgroundRendered(this, p_283688_)); } else { this.m_280039_(p_283688_); } -@@ -363,6 +_,7 @@ +@@ -369,6 +_,7 @@ int i = 32; p_282281_.m_280398_(f_279548_, 0, 0, 0, 0.0F, 0.0F, this.f_96543_, this.f_96544_, 32, 32); p_282281_.m_280246_(1.0F, 1.0F, 1.0F, 1.0F); @@ -47,7 +47,7 @@ } public boolean m_7043_() { -@@ -456,6 +_,10 @@ +@@ -462,6 +_,10 @@ public void m_7400_(List p_96591_) { } @@ -58,7 +58,7 @@ private void m_169380_(long p_169381_, boolean p_169382_) { this.f_169377_ = Util.m_137550_() + p_169381_; if (p_169382_) { -@@ -622,5 +_,13 @@ +@@ -628,5 +_,13 @@ this.f_169421_ = p_169425_; this.f_169422_ = p_169426_; } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch index 4ab9762b48..54f7b0c5c8 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java -@@ -63,6 +_,7 @@ +@@ -64,6 +_,7 @@ @Nullable private TitleScreen.WarningLabel f_232768_; private final LogoRenderer f_263781_; @@ -8,7 +8,7 @@ public TitleScreen() { this(false); -@@ -113,11 +_,15 @@ +@@ -114,11 +_,15 @@ int j = this.f_96543_ - i - 2; int k = 24; int l = this.f_96544_ / 4 + 48; @@ -22,9 +22,9 @@ } + modUpdateNotification = net.minecraftforge.client.gui.TitleScreenModUpdateIndicator.init(this, modButton); - this.m_142416_(new ImageButton(this.f_96543_ / 2 - 124, l + 72 + 12, 20, 20, 0, 106, 20, Button.f_93617_, 256, 256, (p_280830_) -> { + SpriteIconButton spriteiconbutton = this.m_142416_(CommonButtons.m_292713_(20, (p_280830_) -> { this.f_96541_.m_91152_(new LanguageSelectScreen(this, this.f_96541_.f_91066_, this.f_96541_.m_91102_())); -@@ -162,7 +_,7 @@ +@@ -164,7 +_,7 @@ }).m_252987_(this.f_96543_ / 2 - 100, p_96764_ + p_96765_ * 1, 200, 20).m_257505_(tooltip).m_253136_())).f_93623_ = flag; (this.m_142416_(Button.m_253074_(Component.m_237115_("menu.online"), (p_210872_) -> { this.m_96793_(); @@ -33,7 +33,7 @@ } @Nullable -@@ -244,6 +_,7 @@ +@@ -248,6 +_,7 @@ this.f_232768_.m_280409_(p_282860_, i); } @@ -41,7 +41,7 @@ if (this.f_96721_ != null) { this.f_96721_.m_280672_(p_282860_, this.f_96543_, this.f_96547_, i); } -@@ -259,7 +_,14 @@ +@@ -263,7 +_,14 @@ s = s + I18n.m_118938_("menu.modded"); } @@ -57,7 +57,7 @@ for(GuiEventListener guieventlistener : this.m_6702_()) { if (guieventlistener instanceof AbstractWidget) { -@@ -272,6 +_,7 @@ +@@ -276,6 +_,7 @@ RenderSystem.enableDepthTest(); this.f_96726_.m_88315_(p_282860_, p_281753_, p_283539_, p_282628_); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch index 70588843b8..3f650e905e 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java -@@ -36,6 +_,7 @@ +@@ -38,6 +_,7 @@ private int f_97141_ = Integer.MIN_VALUE; private float f_97142_; private boolean f_97143_; + private int page; - public AdvancementTab(Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, Advancement p_97149_, DisplayInfo p_97150_) { + public AdvancementTab(Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, AdvancementNode p_297568_, DisplayInfo p_97150_) { this.f_97126_ = p_97145_; -@@ -50,6 +_,15 @@ - this.m_97175_(this.f_97134_, p_97149_); +@@ -52,6 +_,15 @@ + this.m_97175_(this.f_97134_, p_297568_.m_295246_()); } -+ public AdvancementTab(Minecraft mc, AdvancementsScreen screen, AdvancementTabType type, int index, int page, Advancement adv, DisplayInfo info) { ++ public AdvancementTab(Minecraft mc, AdvancementsScreen screen, AdvancementTabType type, int index, int page, AdvancementNode adv, DisplayInfo info) { + this(mc, screen, type, index, adv, info); + this.page = page; + } @@ -24,14 +24,14 @@ public AdvancementTabType m_169538_() { return this.f_97128_; } -@@ -143,8 +_,8 @@ +@@ -146,8 +_,8 @@ return null; } else { for(AdvancementTabType advancementtabtype : AdvancementTabType.values()) { - if (p_97173_ < advancementtabtype.m_97210_()) { -- return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_, p_97174_, p_97174_.m_138320_()); +- return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_, p_299876_, optional.get()); + if ((p_97173_ % AdvancementTabType.MAX_TABS) < advancementtabtype.m_97210_()) { -+ return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_ % AdvancementTabType.MAX_TABS, p_97173_ / AdvancementTabType.MAX_TABS, p_97174_, p_97174_.m_138320_()); ++ return new AdvancementTab(p_97171_, p_97172_, advancementtabtype, p_97173_ % AdvancementTabType.MAX_TABS, p_97173_ / AdvancementTabType.MAX_TABS, p_299876_, optional.get()); } p_97173_ -= advancementtabtype.m_97210_(); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch index 90fb0f7d61..aaf4306457 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java -@@ -12,6 +_,7 @@ - LEFT(0, 64, 32, 28, 5), - RIGHT(96, 64, 32, 28, 5); +@@ -13,6 +_,7 @@ + LEFT(new AdvancementTabType.Sprites(new ResourceLocation("advancements/tab_left_top_selected"), new ResourceLocation("advancements/tab_left_middle_selected"), new ResourceLocation("advancements/tab_left_bottom_selected")), new AdvancementTabType.Sprites(new ResourceLocation("advancements/tab_left_top"), new ResourceLocation("advancements/tab_left_middle"), new ResourceLocation("advancements/tab_left_bottom")), 32, 28, 5), + RIGHT(new AdvancementTabType.Sprites(new ResourceLocation("advancements/tab_right_top_selected"), new ResourceLocation("advancements/tab_right_middle_selected"), new ResourceLocation("advancements/tab_right_bottom_selected")), new AdvancementTabType.Sprites(new ResourceLocation("advancements/tab_right_top"), new ResourceLocation("advancements/tab_right_middle"), new ResourceLocation("advancements/tab_right_bottom")), 32, 28, 5); + public static final int MAX_TABS = java.util.Arrays.stream(values()).mapToInt(e -> e.f_97199_).sum(); - private final int f_97195_; - private final int f_97196_; + private final AdvancementTabType.Sprites f_291110_; + private final AdvancementTabType.Sprites f_291777_; private final int f_97197_; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch index 05336765b7..0838731a77 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java -@@ -41,6 +_,7 @@ +@@ -42,6 +_,7 @@ @Nullable private AdvancementTab f_97336_; private boolean f_97337_; @@ -8,9 +8,9 @@ public AdvancementsScreen(ClientAdvancements p_97340_) { super(GameNarrator.f_93310_); -@@ -56,7 +_,15 @@ +@@ -58,7 +_,15 @@ } else { - this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_97182_(), true); + this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_293004_().m_295246_(), true); } - + if (this.f_97335_.size() > AdvancementTabType.MAX_TABS) { @@ -25,19 +25,19 @@ } public void m_7861_() { -@@ -74,7 +_,7 @@ +@@ -76,7 +_,7 @@ int j = (this.f_96544_ - 140) / 2; for(AdvancementTab advancementtab : this.f_97335_.values()) { - if (advancementtab.m_97154_(i, j, p_97343_, p_97344_)) { + if (advancementtab.getPage() == tabPage && advancementtab.m_97154_(i, j, p_97343_, p_97344_)) { - this.f_97334_.m_104401_(advancementtab.m_97182_(), true); + this.f_97334_.m_104401_(advancementtab.m_293004_().m_295246_(), true); break; } -@@ -98,9 +_,15 @@ +@@ -100,9 +_,15 @@ int i = (this.f_96543_ - 252) / 2; int j = (this.f_96544_ - 140) / 2; - this.m_280273_(p_282589_); + this.m_280273_(p_282589_, p_282255_, p_283354_, p_283123_); + if (maxPages != 0) { + net.minecraft.network.chat.Component page = Component.m_237113_(String.format("%d / %d", tabPage + 1, maxPages + 1)); + int width = this.f_96547_.m_92852_(page); @@ -50,7 +50,7 @@ } public boolean m_7979_(double p_97347_, double p_97348_, int p_97349_, double p_97350_, double p_97351_) { -@@ -135,10 +_,12 @@ +@@ -146,10 +_,12 @@ p_283395_.m_280218_(f_97329_, p_281890_, p_282532_, 0, 0, 252, 140); if (this.f_97335_.size() > 1) { for(AdvancementTab advancementtab : this.f_97335_.values()) { @@ -63,7 +63,7 @@ advancementtab1.m_280485_(p_283395_, p_281890_, p_282532_); } } -@@ -158,7 +_,7 @@ +@@ -169,7 +_,7 @@ if (this.f_97335_.size() > 1) { for(AdvancementTab advancementtab : this.f_97335_.values()) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch index 3040e59985..038a72155d 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -3,12 +3,12 @@ @@ -90,6 +_,7 @@ int i = this.f_97735_; int j = this.f_97736_; - this.m_7286_(p_283479_, p_281886_, p_283661_, p_281248_); + super.m_88315_(p_283479_, p_283661_, p_281248_, p_281886_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ContainerScreenEvent.Render.Background(this, p_283479_, p_283661_, p_281248_)); RenderSystem.disableDepthTest(); - super.m_88315_(p_283479_, p_283661_, p_281248_, p_281886_); p_283479_.m_280168_().m_85836_(); -@@ -107,12 +_,13 @@ + p_283479_.m_280168_().m_252880_((float)i, (float)j, 0.0F); +@@ -106,12 +_,13 @@ int l = slot.f_40220_; int i1 = slot.f_40221_; if (this.f_97734_.m_280329_()) { @@ -23,7 +23,7 @@ ItemStack itemstack = this.f_97711_.m_41619_() ? this.f_97732_.m_142621_() : this.f_97711_; if (!itemstack.m_41619_()) { int l1 = 8; -@@ -149,13 +_,16 @@ +@@ -153,13 +_,16 @@ } public static void m_280359_(GuiGraphics p_283692_, int p_281453_, int p_281915_, int p_283504_) { @@ -42,7 +42,7 @@ } } -@@ -168,7 +_,8 @@ +@@ -172,7 +_,8 @@ p_282567_.m_280168_().m_85836_(); p_282567_.m_280168_().m_252880_(0.0F, 0.0F, 232.0F); p_282567_.m_280480_(p_281330_, p_281772_, p_281689_); @@ -52,7 +52,7 @@ p_282567_.m_280168_().m_85849_(); } -@@ -270,7 +_,8 @@ +@@ -274,7 +_,8 @@ if (super.m_6375_(p_97748_, p_97749_, p_97750_)) { return true; } else { @@ -62,7 +62,7 @@ Slot slot = this.m_97744_(p_97748_, p_97749_); long i = Util.m_137550_(); this.f_97723_ = this.f_97709_ == slot && i - this.f_97721_ < 250L && this.f_97722_ == p_97750_; -@@ -281,6 +_,7 @@ +@@ -285,6 +_,7 @@ int j = this.f_97735_; int k = this.f_97736_; boolean flag1 = this.m_7467_(p_97748_, p_97749_, j, k, p_97750_); @@ -70,7 +70,7 @@ int l = -1; if (slot != null) { l = slot.f_40219_; -@@ -306,7 +_,7 @@ +@@ -310,7 +_,7 @@ } } else if (!this.f_97738_) { if (this.f_97732_.m_142621_().m_41619_()) { @@ -79,7 +79,7 @@ this.m_6597_(slot, l, p_97750_, ClickType.CLONE); } else { boolean flag2 = l != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344)); -@@ -330,7 +_,7 @@ +@@ -334,7 +_,7 @@ this.f_97717_ = 0; } else if (p_97750_ == 1) { this.f_97717_ = 1; @@ -88,7 +88,7 @@ this.f_97717_ = 2; } } -@@ -399,10 +_,13 @@ +@@ -403,10 +_,13 @@ } public boolean m_6348_(double p_97812_, double p_97813_, int p_97814_) { @@ -102,7 +102,7 @@ int k = -1; if (slot != null) { k = slot.f_40219_; -@@ -416,7 +_,7 @@ +@@ -420,7 +_,7 @@ if (m_96638_()) { if (!this.f_97724_.m_41619_()) { for(Slot slot2 : this.f_97732_.f_38839_) { @@ -111,7 +111,7 @@ this.m_6597_(slot2, slot2.f_40219_, p_97814_, ClickType.QUICK_MOVE); } } -@@ -479,7 +_,7 @@ +@@ -483,7 +_,7 @@ this.m_6597_((Slot)null, -999, AbstractContainerMenu.m_38930_(2, this.f_97717_), ClickType.QUICK_CRAFT); } else if (!this.f_97732_.m_142621_().m_41619_()) { @@ -120,7 +120,7 @@ this.m_6597_(slot, k, p_97814_, ClickType.CLONE); } else { boolean flag1 = k != -999 && (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340) || InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 344)); -@@ -526,34 +_,39 @@ +@@ -530,34 +_,39 @@ } public boolean m_7933_(int p_97765_, int p_97766_, int p_97767_) { @@ -167,7 +167,7 @@ this.m_6597_(this.f_97734_, this.f_97734_.f_40219_, i, ClickType.SWAP); return true; } -@@ -588,6 +_,18 @@ +@@ -592,6 +_,18 @@ public T m_6262_() { return this.f_97732_; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch index 56a4f889ed..8b3fc4ae21 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java -@@ -74,6 +_,8 @@ +@@ -79,6 +_,8 @@ private boolean f_98515_; private final Set> f_98516_ = new HashSet<>(); private final boolean f_256872_; @@ -9,7 +9,7 @@ public CreativeModeInventoryScreen(Player p_259788_, FeatureFlagSet p_260074_, boolean p_259569_) { super(new CreativeModeInventoryScreen.ItemPickerMenu(p_259788_), p_259788_.m_150109_(), CommonComponents.f_237098_); -@@ -107,7 +_,7 @@ +@@ -112,7 +_,7 @@ private void m_257687_(Collection p_261591_) { int i = this.f_97732_.m_257485_(this.f_98508_); (this.f_97732_).f_98639_.clear(); @@ -18,7 +18,7 @@ this.m_98630_(); } else { (this.f_97732_).f_98639_.addAll(p_261591_); -@@ -263,6 +_,34 @@ +@@ -266,6 +_,34 @@ protected void m_7856_() { if (this.f_96541_.f_91072_.m_105290_()) { super.m_7856_(); @@ -53,7 +53,7 @@ this.f_98510_ = new EditBox(this.f_96547_, this.f_97735_ + 82, this.f_97736_ + 6, 80, 9, Component.m_237115_("itemGroup.search")); this.f_98510_.m_94199_(50); this.f_98510_.m_94182_(false); -@@ -308,7 +_,7 @@ +@@ -311,7 +_,7 @@ public boolean m_5534_(char p_98521_, int p_98522_) { if (this.f_98514_) { return false; @@ -62,7 +62,7 @@ return false; } else { String s = this.f_98510_.m_94155_(); -@@ -326,7 +_,7 @@ +@@ -329,7 +_,7 @@ public boolean m_7933_(int p_98547_, int p_98548_, int p_98549_) { this.f_98514_ = false; @@ -71,7 +71,7 @@ if (this.f_96541_.f_91066_.f_92098_.m_90832_(p_98547_, p_98548_)) { this.f_98514_ = true; this.m_98560_(CreativeModeTabs.m_258007_()); -@@ -361,6 +_,7 @@ +@@ -364,6 +_,7 @@ } private void m_98630_() { @@ -79,7 +79,7 @@ (this.f_97732_).f_98639_.clear(); this.f_98516_.clear(); String s = this.f_98510_.m_94155_(); -@@ -370,10 +_,10 @@ +@@ -373,10 +_,10 @@ SearchTree searchtree; if (s.startsWith("#")) { s = s.substring(1); @@ -92,7 +92,7 @@ } (this.f_97732_).f_98639_.addAll(searchtree.m_6293_(s.toLowerCase(Locale.ROOT))); -@@ -405,7 +_,8 @@ +@@ -408,7 +_,8 @@ protected void m_280003_(GuiGraphics p_283168_, int p_281774_, int p_281466_) { if (f_98507_.m_40789_()) { @@ -102,7 +102,7 @@ } } -@@ -415,7 +_,7 @@ +@@ -418,7 +_,7 @@ double d0 = p_98531_ - (double)this.f_97735_; double d1 = p_98532_ - (double)this.f_97736_; @@ -111,7 +111,7 @@ if (this.m_98562_(creativemodetab, d0, d1)) { return true; } -@@ -436,7 +_,7 @@ +@@ -439,7 +_,7 @@ double d1 = p_98623_ - (double)this.f_97736_; this.f_98509_ = false; @@ -120,7 +120,7 @@ if (this.m_98562_(creativemodetab, d0, d1)) { this.m_98560_(creativemodetab); return true; -@@ -454,6 +_,7 @@ +@@ -457,6 +_,7 @@ private void m_98560_(CreativeModeTab p_98561_) { CreativeModeTab creativemodetab = f_98507_; f_98507_ = p_98561_; @@ -128,7 +128,7 @@ this.f_97737_.clear(); (this.f_97732_).f_98639_.clear(); this.m_238391_(); -@@ -530,13 +_,15 @@ +@@ -533,13 +_,15 @@ this.f_98511_ = null; } @@ -145,8 +145,8 @@ this.m_98630_(); } else { -@@ -593,7 +_,7 @@ - this.m_280273_(p_283000_); +@@ -595,7 +_,7 @@ + public void m_88315_(GuiGraphics p_283000_, int p_281317_, int p_282770_, float p_281295_) { super.m_88315_(p_283000_, p_281317_, p_282770_, p_281295_); - for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257388_()) { @@ -154,7 +154,7 @@ if (this.m_280537_(p_283000_, creativemodetab, p_281317_, p_282770_)) { break; } -@@ -603,13 +_,22 @@ +@@ -605,13 +_,22 @@ p_283000_.m_280557_(this.f_96547_, f_98506_, p_281317_, p_282770_); } @@ -178,7 +178,7 @@ TooltipFlag.Default tooltipflag$default = this.f_96541_.f_91066_.f_92125_ ? TooltipFlag.Default.f_256730_ : TooltipFlag.Default.f_256752_; TooltipFlag tooltipflag = flag ? tooltipflag$default.m_257777_() : tooltipflag$default; List list = p_281769_.m_41651_(this.f_96541_.f_91074_, tooltipflag); -@@ -629,7 +_,7 @@ +@@ -631,7 +_,7 @@ int i = 1; for(CreativeModeTab creativemodetab : CreativeModeTabs.m_257388_()) { @@ -187,7 +187,7 @@ list1.add(i++, creativemodetab.m_40786_().m_6881_().m_130940_(ChatFormatting.BLUE)); } } -@@ -639,21 +_,22 @@ +@@ -641,13 +_,13 @@ } protected void m_7286_(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { @@ -203,17 +203,15 @@ this.f_98510_.m_88315_(p_282663_, p_282089_, p_282249_, p_282504_); int j = this.f_97735_ + 175; int k = this.f_97736_ + 18; - int i = k + 112; - if (f_98507_.m_40791_()) { -- p_282663_.m_280218_(f_98504_, j, k + (int)((float)(i - k - 17) * this.f_98508_), 232 + (this.m_98631_() ? 0 : 12), 0, 12, 15); -+ p_282663_.m_280218_(f_98507_.getTabsImage(), j, k + (int)((float)(i - k - 17) * this.f_98508_), 232 + (this.m_98631_() ? 0 : 12), 0, 12, 15); +@@ -657,6 +_,7 @@ + p_282663_.m_292816_(resourcelocation, j, k + (int)((float)(i - k - 17) * this.f_98508_), 12, 15); } + if (currentPage.getVisibleTabs().contains(f_98507_)) //Forge: only display tab selection when the selected tab is on the current page this.m_280560_(p_282663_, f_98507_); if (f_98507_.m_257962_() == CreativeModeTab.Type.INVENTORY) { - InventoryScreen.m_274545_(p_282663_, this.f_97735_ + 88, this.f_97736_ + 45, 20, (float)(this.f_97735_ + 88 - p_282089_), (float)(this.f_97736_ + 45 - 30 - p_282249_), this.f_96541_.f_91074_); -@@ -662,7 +_,7 @@ + InventoryScreen.m_274545_(p_282663_, this.f_97735_ + 73, this.f_97736_ + 6, this.f_97735_ + 105, this.f_97736_ + 49, 20, 0.0625F, (float)p_282089_, (float)p_282249_, this.f_96541_.f_91074_); +@@ -665,7 +_,7 @@ } private int m_258094_(CreativeModeTab p_260136_) { @@ -222,7 +220,7 @@ int j = 27; int k = 27 * i; if (p_260136_.m_6563_()) { -@@ -674,7 +_,7 @@ +@@ -677,7 +_,7 @@ private int m_257995_(CreativeModeTab p_260181_) { int i = 0; @@ -231,7 +229,7 @@ i -= 32; } else { i += this.f_97727_; -@@ -702,8 +_,8 @@ +@@ -705,8 +_,8 @@ protected void m_280560_(GuiGraphics p_283590_, CreativeModeTab p_283489_) { boolean flag = p_283489_ == f_98507_; @@ -239,20 +237,18 @@ - int i = p_283489_.m_257903_(); + boolean flag1 = currentPage.isTop(p_283489_); + int i = currentPage.getColumn(p_283489_); - int j = i * 26; - int k = 0; - int l = this.f_97735_ + this.m_258094_(p_283489_); -@@ -720,7 +_,8 @@ - i1 += this.f_97727_ - 4; + int j = this.f_97735_ + this.m_258094_(p_283489_); + int k = this.f_97736_ - (flag1 ? 28 : -(this.f_97727_ - 4)); + ResourceLocation[] aresourcelocation; +@@ -716,6 +_,7 @@ + aresourcelocation = flag ? f_291557_ : f_291303_; } -- p_283590_.m_280218_(f_98504_, l, i1, j, k, 26, 32); + com.mojang.blaze3d.systems.RenderSystem.enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. -+ p_283590_.m_280218_(p_283489_.getTabsImage(), l, i1, j, k, 26, 32); + p_283590_.m_292816_(aresourcelocation[Mth.m_14045_(i, 0, aresourcelocation.length)], j, k, 26, 32); p_283590_.m_280168_().m_85836_(); p_283590_.m_280168_().m_252880_(0.0F, 0.0F, 100.0F); - l += 5; -@@ -763,6 +_,14 @@ +@@ -759,6 +_,14 @@ } @@ -267,7 +263,7 @@ @OnlyIn(Dist.CLIENT) static class CustomCreativeSlot extends Slot { public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { -@@ -930,6 +_,22 @@ +@@ -926,6 +_,22 @@ public boolean m_8010_(Player p_98665_) { return this.f_98655_.m_8010_(p_98665_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch index 778c8461fc..da1c8e4b80 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -@@ -41,12 +_,17 @@ +@@ -45,12 +_,17 @@ Collection collection = this.f_96541_.f_91074_.m_21220_(); if (!collection.isEmpty() && j >= 32) { boolean flag = j >= 120; @@ -19,7 +19,7 @@ this.m_280172_(p_281945_, i, k, iterable, flag); this.m_280301_(p_281945_, i, k, iterable, flag); if (flag) { -@@ -92,6 +_,11 @@ +@@ -96,6 +_,11 @@ int i = this.f_97736_; for(MobEffectInstance mobeffectinstance : p_282642_) { @@ -31,7 +31,7 @@ MobEffect mobeffect = mobeffectinstance.m_19544_(); TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.m_118732_(mobeffect); p_282745_.m_280159_(p_282521_ + (p_281536_ ? 6 : 7), i + 7, 0, 18, 18, textureatlassprite); -@@ -104,6 +_,11 @@ +@@ -108,6 +_,11 @@ int i = this.f_97736_; for(MobEffectInstance mobeffectinstance : p_281986_) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch index 201c2fe9f7..85d050bd71 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java -@@ -88,7 +_,7 @@ +@@ -93,7 +_,7 @@ int l1 = 86 - this.f_96547_.m_92895_(s); FormattedText formattedtext = EnchantmentNames.m_98734_().m_98737_(this.f_96547_, l1); int i2 = 6839882; - if ((k < l + 1 || this.f_96541_.f_91074_.f_36078_ < k1) && !this.f_96541_.f_91074_.m_150110_().f_35937_) { + if (((k < l + 1 || this.f_96541_.f_91074_.f_36078_ < k1) && !this.f_96541_.f_91074_.m_150110_().f_35937_) || this.f_97732_.f_39447_[l] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels - p_282430_.m_280218_(f_98747_, i1, j + 14 + 19 * l, 0, 185, 108, 19); - p_282430_.m_280218_(f_98747_, i1 + 1, j + 15 + 19 * l, 16 * l, 239, 16, 16); + p_282430_.m_292816_(f_291504_, i1, j + 14 + 19 * l, 108, 19); + p_282430_.m_292816_(f_291094_[l], i1 + 1, j + 15 + 19 * l, 16, 16); p_282430_.m_280554_(this.f_96547_, formattedtext, j1, j + 16 + 19 * l, l1, (i2 & 16711422) >> 1); -@@ -150,10 +_,13 @@ +@@ -154,10 +_,13 @@ Enchantment enchantment = Enchantment.m_44697_((this.f_97732_).f_39447_[j]); int l = (this.f_97732_).f_39448_[j]; int i1 = j + 1; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/InventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/InventoryScreen.java.patch deleted file mode 100644 index df988c3700..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/InventoryScreen.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/client/gui/screens/inventory/InventoryScreen.java -+++ b/net/minecraft/client/gui/screens/inventory/InventoryScreen.java -@@ -93,6 +_,13 @@ - public static void m_274545_(GuiGraphics p_282802_, int p_275688_, int p_275245_, int p_275535_, float p_275604_, float p_275546_, LivingEntity p_275689_) { - float f = (float)Math.atan((double)(p_275604_ / 40.0F)); - float f1 = (float)Math.atan((double)(p_275546_ / 40.0F)); -+ // Forge: Allow passing in direct angle components instead of mouse position -+ renderEntityInInventoryFollowsAngle(p_282802_, p_275688_, p_275245_, p_275535_, f, f1, p_275689_); -+ } -+ -+ public static void renderEntityInInventoryFollowsAngle(GuiGraphics p_282802_, int p_275688_, int p_275245_, int p_275535_, float angleXComponent, float angleYComponent, LivingEntity p_275689_) { -+ float f = angleXComponent; -+ float f1 = angleYComponent; - Quaternionf quaternionf = (new Quaternionf()).rotateZ((float)Math.PI); - Quaternionf quaternionf1 = (new Quaternionf()).rotateX(f1 * 20.0F * ((float)Math.PI / 180F)); - quaternionf.mul(quaternionf1); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch index 88a450ed5e..0e7ccba1fe 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java +++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java -@@ -229,7 +_,12 @@ +@@ -236,7 +_,12 @@ p_281357_.m_280370_(this.f_96547_, p_283466_, p_282403_, p_283601_); } else { p_281357_.m_280302_(this.f_96547_, p_282046_, p_282403_, p_283601_, p_282046_.m_41613_() == 1 ? "1" : null); @@ -13,4 +13,4 @@ + p_281357_.m_280168_().m_85849_(); p_281357_.m_280168_().m_85836_(); p_281357_.m_280168_().m_252880_(0.0F, 0.0F, 300.0F); - p_281357_.m_280398_(f_99113_, p_282403_ + 7, p_283601_ + 12, 0, 0.0F, 176.0F, 9, 2, 512, 256); + p_281357_.m_295520_(f_291695_, p_282403_ + 7, p_283601_ + 12, 0, 9, 2); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch index 36b0bceb96..f9042d2063 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java +++ b/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java -@@ -283,6 +_,11 @@ +@@ -281,6 +_,11 @@ } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch index be1df6e391..e3e40ad2f1 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java -@@ -318,6 +_,8 @@ +@@ -346,6 +_,8 @@ this.f_99855_.m_99707_(list1); } -+ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.f_99855_, f_99857_, p_281406_, p_281363_, p_282921_, p_283596_, i1, j1); ++ net.minecraftforge.client.ForgeHooksClient.drawForgePingInfo(this.f_99855_, f_99857_, p_281406_, p_281363_, p_282921_, p_283596_, l, i1); + if (this.f_99856_.f_91066_.m_231828_().m_231551_() || p_282999_) { p_281406_.m_280509_(p_281363_, p_282921_, p_281363_ + 32, p_282921_ + 32, -1601138544); - int k1 = p_283567_ - p_281363_; + int j1 = p_283567_ - p_281363_; diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch index fdcab4e002..a2daf44f72 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java +++ b/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java -@@ -130,10 +_,10 @@ +@@ -138,10 +_,10 @@ TransferableSelectionList.PackEntry transferableselectionlist$packentry = p_100014_.m_93511_(); String s = transferableselectionlist$packentry == null ? "" : transferableselectionlist$packentry.m_264411_(); p_100014_.m_6987_((TransferableSelectionList.PackEntry)null); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch index 744e7bf26d..57962feb95 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java +++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java -@@ -104,7 +_,7 @@ +@@ -106,7 +_,7 @@ this.m_5674_(); this.f_100279_.clear(); @@ -9,7 +9,7 @@ this.f_100279_.add(new RecipeBookTabButton(recipebookcategories)); } -@@ -294,7 +_,7 @@ +@@ -309,7 +_,7 @@ } if (itemstack != null && this.f_100272_.f_91080_ != null) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch index f84e4b6ec5..3a554c498b 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -120,6 +_,7 @@ +@@ -121,6 +_,7 @@ public static void m_232896_(Minecraft p_232897_, @Nullable Screen p_232898_) { m_232899_(p_232897_, f_232866_); - PackRepository packrepository = new PackRepository(new ServerPacksSource()); + PackRepository packrepository = new PackRepository(new ServerPacksSource(p_232897_.m_294312_())); + net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(net.minecraft.server.packs.PackType.SERVER_DATA, packrepository::addPackFinder)); WorldLoader.InitConfig worldloader$initconfig = m_245574_(packrepository, WorldDataConfiguration.f_244649_); CompletableFuture completablefuture = WorldLoader.m_214362_(worldloader$initconfig, (p_247792_) -> { return new WorldLoader.DataLoadOutput<>(new CreateWorldScreen.DataPackReloadCookie(new WorldGenSettings(WorldOptions.m_247394_(), WorldPresets.m_246552_(p_247792_.f_244104_())), p_247792_.f_244127_()), p_247792_.f_243759_()); -@@ -367,7 +_,7 @@ +@@ -364,7 +_,7 @@ if (p_269627_) { p_270552_.accept(this.f_267389_.m_267573_().f_243842_()); } else { @@ -17,10 +17,10 @@ } }, Component.m_237115_("dataPack.validation.failed"), CommonComponents.f_237098_, Component.m_237115_("dataPack.validation.back"), Component.m_237115_("dataPack.validation.reset"))); -@@ -481,6 +_,7 @@ +@@ -478,6 +_,7 @@ if (path != null) { if (this.f_100832_ == null) { - this.f_100832_ = ServerPacksSource.m_245786_(path); + this.f_100832_ = ServerPacksSource.m_245786_(path, this.f_291518_); + net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); this.f_100832_.m_10506_(); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch index 60435120fe..f346aabec9 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java -@@ -68,6 +_,7 @@ +@@ -74,6 +_,7 @@ + static final Logger f_101645_ = LogUtils.getLogger(); static final DateFormat f_101646_ = new SimpleDateFormat(); private static final ResourceLocation f_101647_ = new ResourceLocation("textures/misc/unknown_server.png"); - static final ResourceLocation f_101648_ = new ResourceLocation("textures/gui/world_selection.png"); + private static final ResourceLocation FORGE_EXPERIMENTAL_WARNING_ICON = new ResourceLocation("forge","textures/gui/experimental_warning.png"); static final Component f_101649_ = Component.m_237115_("selectWorld.tooltip.fromNewerVersion1").m_130940_(ChatFormatting.RED); static final Component f_101650_ = Component.m_237115_("selectWorld.tooltip.fromNewerVersion2").m_130940_(ChatFormatting.RED); static final Component f_101651_ = Component.m_237115_("selectWorld.tooltip.snapshot1").m_130940_(ChatFormatting.GOLD); -@@ -361,6 +_,7 @@ +@@ -362,6 +_,7 @@ RenderSystem.enableBlend(); p_281612_.m_280163_(this.f_101698_.m_289196_(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); RenderSystem.disableBlend(); @@ -16,7 +16,7 @@ if (this.f_101693_.f_91066_.m_231828_().m_231551_() || p_283396_) { p_281612_.m_280509_(p_282820_, p_283181_, p_282820_ + 32, p_283181_ + 32, -1601138544); int j = p_283204_ - p_282820_; -@@ -604,6 +_,19 @@ +@@ -608,6 +_,19 @@ public boolean m_214209_() { return !this.f_101695_.m_164916_(); diff --git a/patches/minecraft/net/minecraft/client/main/Main.java.patch b/patches/minecraft/net/minecraft/client/main/Main.java.patch index 42168455d8..c1495a4354 100644 --- a/patches/minecraft/net/minecraft/client/main/Main.java.patch +++ b/patches/minecraft/net/minecraft/client/main/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -147,8 +_,8 @@ +@@ -150,8 +_,8 @@ } CrashReport.m_127529_(); @@ -9,4 +9,4 @@ + net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(()->Bootstrap.m_135870_(), net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); Bootstrap.m_135889_(); Util.m_137584_(); - String s13 = optionspec25.value(optionset); + String s12 = optionspec25.value(optionset); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index 542ee5dcdb..971a62968e 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java @@ -60,6 +_,7 @@ - int i = this.f_104410_.m_104481_(p_104456_, p_104457_); + int i = this.f_104410_.m_104481_(p_298665_.f_45578_, p_298665_.f_45579_); LevelChunk levelchunk = this.f_104410_.m_104479_(i); - if (m_104438_(levelchunk, p_104456_, p_104457_)) { + if (m_104438_(levelchunk, p_298665_.f_45578_, p_298665_.f_45579_)) { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.level.ChunkEvent.Unload(levelchunk)); this.f_104410_.m_104487_(i, levelchunk, (LevelChunk)null); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch new file mode 100644 index 0000000000..774457e4f6 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java ++++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +@@ -89,6 +_,7 @@ + } + + public void m_293213_(ClientboundCustomPayloadPacket p_298103_) { ++ if (net.minecraftforge.network.NetworkHooks.onCustomPayload(p_298103_, this.f_290549_)) return; + CustomPacketPayload custompacketpayload = p_298103_.f_291001_(); + if (!(custompacketpayload instanceof DiscardedPayload)) { + PacketUtils.m_131363_(p_298103_, this, this.f_291812_); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch index 1850fe0da5..55f97013d8 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java -@@ -129,6 +_,7 @@ +@@ -133,6 +_,7 @@ this.f_104521_.accept(Component.m_237115_("connect.joining")); - this.f_104523_ = p_104547_.m_134774_(); - this.f_104522_.m_129498_(ConnectionProtocol.PLAY); + GameProfile gameprofile = p_104547_.m_134774_(); + this.f_104522_.m_129512_(new ServerboundLoginAcknowledgedPacket()); + net.minecraftforge.network.NetworkHooks.handleClientLoginSuccess(this.f_104522_); - this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_243717_, this.f_104523_, this.f_104519_.m_261007_().m_285995_(this.f_260722_, this.f_260612_, this.f_285614_))); - } - -@@ -136,7 +_,7 @@ - if (this.f_104520_ != null && this.f_104520_ instanceof RealmsScreen) { + this.f_104522_.m_129505_(new ClientConfigurationPacketListenerImpl(this.f_104519_, this.f_104522_, new CommonListenerCookie(gameprofile, this.f_104519_.m_261007_().m_285995_(this.f_260722_, this.f_260612_, this.f_285614_), ClientRegistryLayer.m_245874_().m_247579_(), FeatureFlags.f_244332_, (String)null, this.f_243717_, this.f_104520_))); + this.f_104522_.m_129512_(new ServerboundCustomPayloadPacket(new BrandPayload(ClientBrandRetriever.getClientModName()))); + this.f_104522_.m_129512_(new ServerboundClientInformationPacket(this.f_104519_.f_91066_.m_294596_())); +@@ -142,7 +_,7 @@ + if (this.f_243717_ != null && this.f_243717_.m_295074_()) { this.f_104519_.m_91152_(new DisconnectedRealmsScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_)); } else { - this.f_104519_.m_91152_(new DisconnectedScreen(this.f_104520_, CommonComponents.f_130661_, p_104543_)); @@ -17,11 +17,11 @@ } } -@@ -157,6 +_,7 @@ +@@ -163,6 +_,7 @@ } public void m_7254_(ClientboundCustomQueryPacket p_104545_) { + if (net.minecraftforge.network.NetworkHooks.onCustomPayload(p_104545_, this.f_104522_)) return; this.f_104521_.accept(Component.m_237115_("connect.negotiating")); - this.f_104522_.m_129512_(new ServerboundCustomQueryPacket(p_104545_.m_134755_(), (FriendlyByteBuf)null)); + this.f_104522_.m_129512_(new ServerboundCustomQueryAnswerPacket(p_104545_.f_134745_(), (CustomQueryAnswerPayload)null)); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch index d76e41074c..cca1044bb7 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -33,7 +33,7 @@ p_104640_.m_8119_(); this.m_46473_().m_7238_(); -@@ -327,8 +_,10 @@ +@@ -328,8 +_,10 @@ } private void m_104739_(int p_104740_, Entity p_104741_) { @@ -44,7 +44,7 @@ } public void m_171642_(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -455,6 +_,12 @@ +@@ -456,6 +_,12 @@ } public void m_262808_(@Nullable Player p_263381_, double p_263372_, double p_263404_, double p_263365_, Holder p_263335_, SoundSource p_263417_, float p_263416_, float p_263349_, long p_263408_) { @@ -57,7 +57,7 @@ if (p_263381_ == this.f_104565_.f_91074_) { this.m_233602_(p_263372_, p_263404_, p_263365_, p_263335_.m_203334_(), p_263417_, p_263416_, p_263349_, false, p_263408_); } -@@ -462,6 +_,12 @@ +@@ -463,6 +_,12 @@ } public void m_213890_(@Nullable Player p_263514_, Entity p_263536_, Holder p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_) { @@ -70,7 +70,7 @@ if (p_263514_ == this.f_104565_.f_91074_) { this.f_104565_.m_91106_().m_120367_(new EntityBoundSoundInstance(p_263518_.m_203334_(), p_263487_, p_263538_, p_263524_, p_263536_, p_263509_)); } -@@ -899,6 +_,7 @@ +@@ -900,6 +_,7 @@ } public void m_104851_(Difficulty p_104852_) { @@ -78,7 +78,7 @@ this.f_104840_ = p_104852_; } -@@ -936,14 +_,46 @@ +@@ -937,14 +_,46 @@ ClientLevel.this.f_104566_.add((AbstractClientPlayer)p_171712_); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index 872012aacd..d8b08099f5 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -1,91 +1,73 @@ --- a/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java -@@ -412,6 +_,7 @@ +@@ -386,6 +_,7 @@ - this.f_104888_.f_91064_.m_113434_(); - this.f_104888_.f_91074_.m_172530_(); -+ net.minecraftforge.client.ForgeHooksClient.firePlayerLogin(this.f_104888_.f_91072_, this.f_104888_.f_91074_, this.f_104888_.m_91403_().f_104885_); + this.f_291812_.f_91064_.m_113434_(); + this.f_291812_.f_91074_.m_172530_(); ++ net.minecraftforge.client.ForgeHooksClient.firePlayerLogin(this.f_291812_.f_91072_, this.f_291812_.f_91074_, this.f_291812_.m_91403_().f_290549_); int i = p_105030_.f_132360_(); - this.f_104888_.f_91074_.m_20234_(i); - this.f_104889_.m_104630_(i, this.f_104888_.f_91074_); -@@ -425,6 +_,7 @@ - this.f_104888_.f_91074_.m_287199_(p_105030_.f_286971_()); - this.f_104888_.f_91072_.m_171805_(p_105030_.f_132363_(), p_105030_.f_132364_()); - this.f_104888_.f_91066_.m_193770_(p_105030_.f_132370_()); -+ net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(f_104885_, "PLAY_TO_SERVER"); - this.f_104888_.f_91066_.m_92172_(); - this.f_104885_.m_129512_(new ServerboundCustomPayloadPacket(ServerboundCustomPayloadPacket.f_133979_, (new FriendlyByteBuf(Unpooled.buffer())).m_130070_(ClientBrandRetriever.getClientModName()))); + this.f_291812_.f_91074_.m_20234_(i); + this.f_104889_.m_104630_(i, this.f_291812_.f_91074_); +@@ -400,6 +_,7 @@ + this.f_291812_.f_91074_.m_287199_(commonplayerspawninfo.f_291470_()); + this.f_291812_.f_91072_.m_171805_(commonplayerspawninfo.f_291098_(), commonplayerspawninfo.f_290730_()); + this.f_291812_.f_91066_.m_193770_(p_105030_.f_132370_()); ++ net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(f_290549_, "PLAY_TO_SERVER"); this.f_252517_ = null; -@@ -1069,8 +_,10 @@ + this.f_244346_ = new LastSeenMessagesTracker(20); + this.f_244113_ = MessageSignatureCache.m_246587_(); +@@ -1026,7 +_,9 @@ localplayer1.m_21204_().m_22159_(localplayer.m_21204_()); } + localplayer1.updateSyncFields(localplayer); // Forge: fix MC-10657 localplayer1.m_172530_(); - localplayer1.m_108748_(s); -+ net.minecraftforge.client.ForgeHooksClient.firePlayerRespawn(this.f_104888_.f_91072_, localplayer, localplayer1, localplayer1.f_108617_.f_104885_); ++ net.minecraftforge.client.ForgeHooksClient.firePlayerRespawn(this.f_291812_.f_91072_, localplayer, localplayer1, localplayer1.f_108617_.f_290549_); this.f_104889_.m_104630_(i, localplayer1); localplayer1.m_146922_(-180.0F); - localplayer1.f_108618_ = new KeyboardInput(this.f_104888_.f_91066_); -@@ -1180,10 +_,7 @@ - PacketUtils.m_131363_(p_104976_, this, this.f_104888_); + localplayer1.f_108618_ = new KeyboardInput(this.f_291812_.f_91066_); +@@ -1135,10 +_,7 @@ + PacketUtils.m_131363_(p_104976_, this, this.f_291812_); BlockPos blockpos = p_104976_.m_131704_(); - this.f_104888_.f_91073_.m_141902_(blockpos, p_104976_.m_195645_()).ifPresent((p_205557_) -> { + this.f_291812_.f_91073_.m_141902_(blockpos, p_104976_.m_195645_()).ifPresent((p_205557_) -> { - CompoundTag compoundtag = p_104976_.m_131708_(); - if (compoundtag != null) { - p_205557_.m_142466_(compoundtag); - } -+ p_205557_.onDataPacket(f_104885_, p_104976_); ++ p_205557_.onDataPacket(f_290549_, p_104976_); - if (p_205557_ instanceof CommandBlockEntity && this.f_104888_.f_91080_ instanceof CommandBlockEditScreen) { - ((CommandBlockEditScreen)this.f_104888_.f_91080_).m_98398_(); -@@ -1329,7 +_,9 @@ + if (p_205557_ instanceof CommandBlockEntity && this.f_291812_.f_91080_ instanceof CommandBlockEditScreen) { + ((CommandBlockEditScreen)this.f_291812_.f_91080_).m_98398_(); +@@ -1286,7 +_,9 @@ public void m_7443_(ClientboundCommandsPacket p_104990_) { - PacketUtils.m_131363_(p_104990_, this, this.f_104888_); -- this.f_104899_ = new CommandDispatcher<>(p_104990_.m_237624_(CommandBuildContext.m_255418_(this.f_104903_.m_247579_(), this.f_244039_))); -+ var context = CommandBuildContext.m_255418_(this.f_104903_.m_247579_(), this.f_244039_); + PacketUtils.m_131363_(p_104990_, this, this.f_291812_); +- this.f_104899_ = new CommandDispatcher<>(p_104990_.m_237624_(CommandBuildContext.m_255418_(this.f_104903_, this.f_244039_))); ++ var context = CommandBuildContext.m_255418_(this.f_104903_, this.f_244039_); + this.f_104899_ = new CommandDispatcher<>(p_104990_.m_237624_(context)); + this.f_104899_ = net.minecraftforge.client.ClientCommandHandler.mergeServerCommands(this.f_104899_, context); } public void m_7183_(ClientboundStopSoundPacket p_105116_) { -@@ -1348,6 +_,7 @@ - ClientRecipeBook clientrecipebook = this.f_104888_.f_91074_.m_108631_(); - clientrecipebook.m_266394_(this.f_104900_.m_44051_(), this.f_104888_.f_91073_.m_9598_()); - this.f_104888_.m_231374_(SearchRegistry.f_119943_, clientrecipebook.m_90639_()); +@@ -1304,6 +_,7 @@ + this.f_104900_.m_44024_(p_105132_.m_133644_()); + ClientRecipeBook clientrecipebook = this.f_291812_.f_91074_.m_108631_(); + clientrecipebook.m_266394_(this.f_104900_.m_44051_(), this.f_291812_.f_91073_.m_9598_()); + net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated(this.f_104900_); } public void m_7244_(ClientboundPlayerLookAtPacket p_105054_) { -@@ -1443,7 +_,8 @@ +@@ -1402,7 +_,8 @@ Blocks.m_50758_(); } - CreativeModeTabs.m_258007_().m_257466_(); + CreativeModeTabs.m_257478_().stream().filter(net.minecraft.world.item.CreativeModeTab::hasSearchBar).forEach(net.minecraft.world.item.CreativeModeTab::m_257466_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.f_104903_.m_247579_(), true, f_104885_.m_129531_())); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.TagsUpdatedEvent(this.f_104903_, true, f_290549_.m_129531_())); } - public void m_241155_(ClientboundUpdateEnabledFeaturesPacket p_251591_) { -@@ -1855,6 +_,7 @@ - } - - public void m_7413_(ClientboundCustomPayloadPacket p_105004_) { -+ if (net.minecraftforge.network.NetworkHooks.onCustomPayload(p_105004_, this.f_104885_)) return; - PacketUtils.m_131363_(p_105004_, this, this.f_104888_); - ResourceLocation resourcelocation = p_105004_.m_132042_(); - FriendlyByteBuf friendlybytebuf = null; -@@ -2052,7 +_,7 @@ - int j5 = friendlybytebuf.m_130242_(); - this.f_104888_.f_91064_.f_173815_.m_173830_(positionsource, j5); - } else { -- f_104883_.warn("Unknown custom packed identifier: {}", (Object)resourcelocation); -+ f_104883_.warn("Unknown custom packet identifier: {}", (Object)resourcelocation); - } - } finally { - if (friendlybytebuf != null) { -@@ -2399,6 +_,8 @@ + public void m_142234_(ClientboundPlayerCombatEndPacket p_171771_) { +@@ -2095,6 +_,8 @@ } public void m_246175_(String p_249888_) { @@ -94,7 +76,7 @@ Instant instant = Instant.now(); long i = Crypt.SaltSupplier.m_216113_(); LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.f_244346_.m_246442_(); -@@ -2407,6 +_,7 @@ +@@ -2103,6 +_,7 @@ } public void m_246623_(String p_250092_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index 8699d5d616..bef2a37632 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -29,7 +29,7 @@ }); @@ -149,15 +_,19 @@ if (this.f_105196_) { - this.f_105190_.m_104955_(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.f_105191_, p_105271_)); + this.f_105190_.m_295327_(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.f_105191_, p_105271_)); } + net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.f_105189_.f_91074_, p_105270_, p_105271_, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK); @@ -161,7 +161,7 @@ @@ -382,6 +_,9 @@ this.m_105297_(); Vec3 vec3 = p_105233_.m_82450_().m_82492_(p_105232_.m_20185_(), p_105232_.m_20186_(), p_105232_.m_20189_()); - this.f_105190_.m_104955_(ServerboundInteractPacket.m_179612_(p_105232_, p_105231_.m_6144_(), p_105234_, vec3)); + this.f_105190_.m_295327_(ServerboundInteractPacket.m_179612_(p_105232_, p_105231_.m_6144_(), p_105234_, vec3)); + if (this.f_105197_ == GameType.SPECTATOR) return InteractionResult.PASS; // don't fire for spectators to match non-specific EntityInteract + InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAt(p_105231_, p_105232_, p_105233_, p_105234_); + if(cancelResult != null) return cancelResult; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch index 7820480d4f..0e06890919 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/PlayerInfo.java +++ b/net/minecraft/client/multiplayer/PlayerInfo.java -@@ -74,6 +_,7 @@ +@@ -89,6 +_,7 @@ } protected void m_105317_(GameType p_105318_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch index c7d8bd426f..b489830aee 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch @@ -2,9 +2,9 @@ +++ b/net/minecraft/client/multiplayer/ServerData.java @@ -32,6 +_,7 @@ private byte[] f_271511_; - private boolean f_105373_; + private ServerData.Type f_291831_; private boolean f_242950_; + public net.minecraftforge.client.ExtendedServerListData forgeData = null; - public ServerData(String p_105375_, String p_105376_, boolean p_105377_) { + public ServerData(String p_105375_, String p_105376_, ServerData.Type p_297678_) { this.f_105362_ = p_105375_; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch index 8ec08429b7..54171431c1 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerStatusPinger.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ServerStatusPinger.java +++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java -@@ -116,6 +_,7 @@ +@@ -105,6 +_,7 @@ } }); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch index 04d8c240fd..fc3ccac956 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/chat/ChatListener.java +++ b/net/minecraft/client/multiplayer/chat/ChatListener.java -@@ -104,7 +_,9 @@ +@@ -119,7 +_,9 @@ Instant instant = Instant.now(); this.m_246163_((MessageSignature)null, () -> { Component component = p_251256_.m_240977_(p_250375_); @@ -11,7 +11,7 @@ this.m_241119_(p_251256_, p_250375_); this.m_240498_(component, instant); this.f_240659_ = Util.m_137550_(); -@@ -121,12 +_,16 @@ +@@ -136,12 +_,16 @@ MessageSignature messagesignature = p_249430_.f_244279_(); FilterMask filtermask = p_249430_.f_242992_(); if (filtermask.m_243095_()) { @@ -30,7 +30,7 @@ this.m_241119_(p_251766_, component); } } -@@ -159,6 +_,8 @@ +@@ -174,6 +_,8 @@ public void m_240494_(Component p_240522_, boolean p_240642_) { if (!this.f_240348_.f_91066_.m_231833_().m_231551_() || !this.f_240348_.m_91246_(this.m_240473_(p_240522_))) { diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index 99385b8353..a4fa28939b 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -91,7 +91,7 @@ } public void m_107355_(BlockPos p_107356_, BlockState p_107357_) { -- if (!p_107357_.m_60795_() && p_107357_.m_245147_()) { +- if (!p_107357_.m_60795_() && p_107357_.m_295777_()) { + if (!p_107357_.m_60795_() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_107357_).addDestroyEffects(p_107357_, this.f_107287_, p_107356_, this)) { VoxelShape voxelshape = p_107357_.m_60808_(this.f_107287_, p_107356_); double d0 = 0.25D; diff --git a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch index 4ab28232ef..9fb5d39e03 100644 --- a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch @@ -13,7 +13,7 @@ public static class Provider implements ParticleProvider { public Particle m_6966_(BlockParticleOption p_108304_, ClientLevel p_108305_, double p_108306_, double p_108307_, double p_108308_, double p_108309_, double p_108310_, double p_108311_) { BlockState blockstate = p_108304_.m_123642_(); -- return !blockstate.m_60795_() && !blockstate.m_60713_(Blocks.f_50110_) ? new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate) : null; +- return !blockstate.m_60795_() && !blockstate.m_60713_(Blocks.f_50110_) && blockstate.m_295777_() ? new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate) : null; + return !blockstate.m_60795_() && !blockstate.m_60713_(Blocks.f_50110_) ? (new TerrainParticle(p_108305_, p_108306_, p_108307_, p_108308_, p_108309_, p_108310_, p_108311_, blockstate)).updateSprite(blockstate, p_108304_.getPos()) : null; } + } diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index 4aae4ddda4..5951792fdd 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -147,6 +_,6 @@ +@@ -93,6 +_,6 @@ } } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index eff35cb17a..2e83bc2aef 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java -@@ -151,6 +_,7 @@ +@@ -150,6 +_,7 @@ } public boolean m_6469_(DamageSource p_108662_, float p_108663_) { @@ -8,15 +8,15 @@ return false; } -@@ -277,6 +_,7 @@ +@@ -276,6 +_,7 @@ public boolean m_108700_(boolean p_108701_) { ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_ ? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS : ServerboundPlayerActionPacket.Action.DROP_ITEM; + if (m_6117_() && m_7655_() == InteractionHand.MAIN_HAND && (p_108701_ || m_21211_().m_41613_() == 1)) m_5810_(); // Forge: fix MC-231097 on the clientside ItemStack itemstack = this.m_150109_().m_182403_(p_108701_); - this.f_108617_.m_104955_(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.f_121853_, Direction.DOWN)); + this.f_108617_.m_295327_(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.f_121853_, Direction.DOWN)); return !itemstack.m_41619_(); -@@ -459,7 +_,14 @@ +@@ -457,7 +_,14 @@ } public void m_5496_(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -32,15 +32,15 @@ } public void m_6330_(SoundEvent p_108655_, SoundSource p_108656_, float p_108657_, float p_108658_) { -@@ -633,6 +_,7 @@ - this.f_108601_ = !this.m_150110_().f_35935_ && !this.m_6069_() && this.m_20175_(Pose.CROUCHING) && (this.m_6144_() || !this.m_5803_() && !this.m_20175_(Pose.STANDING)); +@@ -631,6 +_,7 @@ + this.f_108601_ = !this.m_150110_().f_35935_ && !this.m_6069_() && !this.m_20159_() && this.m_295652_(Pose.CROUCHING) && (this.m_6144_() || !this.m_5803_() && !this.m_295652_(Pose.STANDING)); float f = Mth.m_14036_(0.3F + EnchantmentHelper.m_220302_(this), 0.0F, 1.0F); this.f_108618_.m_214106_(this.m_108635_(), f); + net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.f_108618_); this.f_108619_.m_91301_().m_120586_(this.f_108618_); if (this.m_6117_() && !this.m_20159_()) { this.f_108618_.f_108566_ *= 0.2F; -@@ -661,7 +_,7 @@ +@@ -659,7 +_,7 @@ boolean flag4 = this.m_264082_(); boolean flag5 = this.m_20159_() ? this.m_20202_().m_20096_() : this.m_20096_(); boolean flag6 = !flag1 && !flag2; @@ -49,7 +49,7 @@ if (this.f_108583_ <= 0 && !this.f_108619_.f_91066_.f_92091_.m_90857_()) { this.f_108583_ = 7; } else { -@@ -669,15 +_,15 @@ +@@ -667,15 +_,15 @@ } } @@ -68,13 +68,13 @@ this.m_6858_(false); } } else if (flag8) { -@@ -707,14 +_,15 @@ +@@ -705,14 +_,15 @@ if (this.f_108618_.f_108572_ && !flag9 && !flag && !this.m_150110_().f_35935_ && !this.m_20159_() && !this.m_6147_()) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); - if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack) && this.m_36319_()) { + if (itemstack.canElytraFly(this) && this.m_36319_()) { - this.f_108617_.m_104955_(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)); + this.f_108617_.m_295327_(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)); } } @@ -87,7 +87,7 @@ } if (this.m_204029_(FluidTags.f_13131_)) { -@@ -814,6 +_,7 @@ +@@ -812,6 +_,7 @@ public void m_6083_() { super.m_6083_(); @@ -95,7 +95,7 @@ this.f_108611_ = false; Entity entity = this.m_275832_(); if (entity instanceof Boat boat) { -@@ -1046,6 +_,18 @@ +@@ -1044,6 +_,18 @@ } else { return super.m_7398_(p_108758_); } diff --git a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch index 96edea9c15..f67de65aba 100644 --- a/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/RemotePlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/RemotePlayer.java +++ b/net/minecraft/client/player/RemotePlayer.java -@@ -32,6 +_,7 @@ +@@ -31,6 +_,7 @@ } public boolean m_6469_(DamageSource p_108772_, float p_108773_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index 9842d28ea4..0a07b6837f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -75,7 +75,7 @@ } } -@@ -907,12 +_,12 @@ +@@ -908,12 +_,12 @@ Window window = this.f_109059_.m_91268_(); RenderSystem.clear(256, Minecraft.f_91002_); @@ -90,16 +90,16 @@ RenderSystem.applyModelViewMatrix(); Lighting.m_84931_(); GuiGraphics guigraphics = new GuiGraphics(this.f_109059_, this.f_109064_.m_110104_()); -@@ -948,7 +_,7 @@ +@@ -949,7 +_,7 @@ } - } else if (this.f_109059_.f_91080_ != null) { + } else if (flag && this.f_109059_.f_91080_ != null) { try { - this.f_109059_.f_91080_.m_280264_(guigraphics, i, j, this.f_109059_.m_91297_()); + net.minecraftforge.client.ForgeHooksClient.drawScreen(this.f_109059_.f_91080_, guigraphics, i, j, this.f_109059_.m_91297_()); } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.m_127521_(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.m_127514_("Screen render details"); -@@ -1099,12 +_,19 @@ +@@ -1103,12 +_,19 @@ Matrix4f matrix4f = posestack.m_85850_().m_252922_(); this.m_252879_(matrix4f); camera.m_90575_(this.f_109059_.f_91073_, (Entity)(this.f_109059_.m_91288_() == null ? this.f_109059_.f_91074_ : this.f_109059_.m_91288_()), !this.f_109059_.f_91066_.m_92176_().m_90612_(), this.f_109059_.f_91066_.m_92176_().m_90613_(), p_109090_); @@ -115,7 +115,7 @@ this.f_109059_.f_91060_.m_253210_(p_109092_, camera.m_90583_(), this.m_253088_(Math.max(d0, (double)this.f_109059_.f_91066_.m_231837_().m_231551_().intValue()))); this.f_109059_.f_91060_.m_109599_(p_109092_, p_109090_, p_109091_, flag, camera, this, this.f_109074_, matrix4f); + this.f_109059_.m_91307_().m_6182_("forge_render_last"); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_LEVEL, this.f_109059_.f_91060_, posestack, matrix4f, this.f_109059_.f_91060_.getTicks(), camera, this.f_109059_.f_91060_.getFrustum()); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_LEVEL.dispatch(this.f_109059_.f_91060_, posestack, matrix4f, this.f_109059_.f_91060_.getTicks(), camera, this.f_109059_.f_91060_.getFrustum()); this.f_109059_.m_91307_().m_6182_("hand"); if (this.f_109070_) { RenderSystem.clear(256, Minecraft.f_91002_); diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index 7c4db01269..0486f8de47 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -5,18 +5,18 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map f_109275_ = Util.m_137469_(Maps.newHashMap(), (p_277225_) -> { + private static final Map f_109275_ = Util.m_137469_(Maps.newHashMap(), (p_296246_) -> { RenderType rendertype = RenderType.m_110503_(); - p_277225_.put(Blocks.f_50267_, rendertype); -@@ -310,6 +_,7 @@ - p_277225_.put(Blocks.f_50628_, rendertype3); - p_277225_.put(Blocks.f_152498_, rendertype3); + p_296246_.put(Blocks.f_50267_, rendertype); +@@ -309,6 +_,7 @@ + p_296246_.put(Blocks.f_50628_, rendertype3); + p_296246_.put(Blocks.f_152498_, rendertype3); }); + @Deprecated private static final Map f_109276_ = Util.m_137469_(Maps.newHashMap(), (p_109290_) -> { RenderType rendertype = RenderType.m_110466_(); p_109290_.put(Fluids.f_76192_, rendertype); -@@ -317,6 +_,8 @@ +@@ -316,6 +_,8 @@ }); private static boolean f_109277_; @@ -25,7 +25,7 @@ public static RenderType m_109282_(BlockState p_109283_) { Block block = p_109283_.m_60734_(); if (block instanceof LeavesBlock) { -@@ -327,6 +_,8 @@ +@@ -326,6 +_,8 @@ } } @@ -34,7 +34,7 @@ public static RenderType m_109293_(BlockState p_109294_) { Block block = p_109294_.m_60734_(); if (block instanceof LeavesBlock) { -@@ -341,6 +_,8 @@ +@@ -340,6 +_,8 @@ } } @@ -43,7 +43,7 @@ public static RenderType m_109284_(BlockState p_109285_, boolean p_109286_) { RenderType rendertype = m_109282_(p_109285_); if (rendertype == RenderType.m_110466_()) { -@@ -354,6 +_,8 @@ +@@ -353,6 +_,8 @@ } } @@ -52,7 +52,7 @@ public static RenderType m_109279_(ItemStack p_109280_, boolean p_109281_) { Item item = p_109280_.m_41720_(); if (item instanceof BlockItem) { -@@ -365,8 +_,73 @@ +@@ -364,8 +_,73 @@ } public static RenderType m_109287_(FluidState p_109288_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index 4df2878e02..adfcfa533d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java -@@ -313,12 +_,14 @@ +@@ -310,12 +_,14 @@ if (iteminhandrenderer$handrenderselection.f_172921_) { float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F; float f5 = 1.0F - Mth.m_14179_(p_109315_, this.f_109303_, this.f_109302_); @@ -15,7 +15,7 @@ this.m_109371_(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.f_109301_, f7, p_109316_, p_109317_, p_109319_); } -@@ -369,7 +_,7 @@ +@@ -366,7 +_,7 @@ } else { this.m_109353_(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_); } @@ -24,7 +24,7 @@ boolean flag1 = CrossbowItem.m_40932_(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; int i = flag2 ? 1 : -1; -@@ -411,6 +_,7 @@ +@@ -408,6 +_,7 @@ this.m_269530_(p_109372_, p_109377_, flag2 ? ItemDisplayContext.FIRST_PERSON_RIGHT_HAND : ItemDisplayContext.FIRST_PERSON_LEFT_HAND, !flag2, p_109379_, p_109380_, p_109381_); } else { boolean flag3 = humanoidarm == HumanoidArm.RIGHT; @@ -32,7 +32,7 @@ if (p_109372_.m_6117_() && p_109372_.m_21212_() > 0 && p_109372_.m_7655_() == p_109375_) { int k = flag3 ? 1 : -1; switch (p_109377_.m_41780_()) { -@@ -517,8 +_,16 @@ +@@ -514,8 +_,16 @@ this.f_109304_ = Mth.m_14036_(this.f_109304_ - 0.4F, 0.0F, 1.0F); } else { float f = localplayer.m_36403_(1.0F); diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch index 78ec977519..feb2ddd4a8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -267,6 +_,8 @@ +@@ -245,6 +_,8 @@ } private void m_109703_(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { @@ -9,7 +9,7 @@ float f = this.f_109461_.f_91073_.m_46722_(p_109705_); if (!(f <= 0.0F)) { p_109704_.m_109896_(); -@@ -386,6 +_,8 @@ +@@ -364,6 +_,8 @@ } public void m_109693_(Camera p_109694_) { @@ -18,7 +18,7 @@ float f = this.f_109461_.f_91073_.m_46722_(1.0F) / (Minecraft.m_91405_() ? 1.0F : 2.0F); if (!(f <= 0.0F)) { RandomSource randomsource = RandomSource.m_216335_((long)this.f_109477_ * 312987231L); -@@ -1145,11 +_,13 @@ +@@ -888,11 +_,13 @@ RenderSystem.clear(16640, Minecraft.f_91002_); float f = p_109605_.m_109152_(); boolean flag1 = this.f_109461_.f_91073_.m_104583_().m_5781_(Mth.m_14107_(d0), Mth.m_14107_(d1)) || this.f_109461_.f_91065_.m_93090_().m_93715_(); @@ -28,30 +28,30 @@ this.m_202423_(p_109600_, p_254120_, p_109601_, p_109604_, flag1, () -> { FogRenderer.m_234172_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag1, p_109601_); }); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY.dispatch(this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); profilerfiller.m_6182_("fog"); FogRenderer.m_234172_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f, 32.0F), flag1, p_109601_); profilerfiller.m_6182_("terrain_setup"); -@@ -1158,7 +_,9 @@ +@@ -901,7 +_,9 @@ this.m_194370_(p_109604_); profilerfiller.m_6182_("terrain"); - this.m_172993_(RenderType.m_110451_(), p_109600_, d0, d1, d2, p_254120_); + this.m_293111_(RenderType.m_110451_(), p_109600_, d0, d1, d2, p_254120_); + this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).setBlurMipmap(false, this.f_109461_.f_91066_.m_232119_().m_231551_() > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings - this.m_172993_(RenderType.m_110457_(), p_109600_, d0, d1, d2, p_254120_); + this.m_293111_(RenderType.m_110457_(), p_109600_, d0, d1, d2, p_254120_); + this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).restoreLastBlurMipmap(); - this.m_172993_(RenderType.m_110463_(), p_109600_, d0, d1, d2, p_254120_); + this.m_293111_(RenderType.m_110463_(), p_109600_, d0, d1, d2, p_254120_); if (this.f_109465_.m_104583_().m_108885_()) { Lighting.m_252995_(p_109600_.m_85850_().m_252922_()); -@@ -1190,7 +_,7 @@ +@@ -933,7 +_,7 @@ for(Entity entity : this.f_109465_.m_104735_()) { if (this.f_109463_.m_114397_(entity, frustum, d0, d1, d2) || entity.m_20367_(this.f_109461_.f_91074_)) { BlockPos blockpos = entity.m_20183_(); -- if ((this.f_109465_.m_151562_(blockpos.m_123342_()) || this.m_202430_(blockpos)) && (entity != p_109604_.m_90592_() || p_109604_.m_90594_() || p_109604_.m_90592_() instanceof LivingEntity && ((LivingEntity)p_109604_.m_90592_()).m_5803_()) && (!(entity instanceof LocalPlayer) || p_109604_.m_90592_() == entity)) { -+ if ((this.f_109465_.m_151562_(blockpos.m_123342_()) || this.m_202430_(blockpos)) && (entity != p_109604_.m_90592_() || p_109604_.m_90594_() || p_109604_.m_90592_() instanceof LivingEntity && ((LivingEntity)p_109604_.m_90592_()).m_5803_()) && (!(entity instanceof LocalPlayer) || p_109604_.m_90592_() == entity || (entity == f_109461_.f_91074_ && !f_109461_.f_91074_.m_5833_()))) { //FORGE: render local player entity when it is not the renderViewEntity +- if ((this.f_109465_.m_151562_(blockpos.m_123342_()) || this.m_292727_(blockpos)) && (entity != p_109604_.m_90592_() || p_109604_.m_90594_() || p_109604_.m_90592_() instanceof LivingEntity && ((LivingEntity)p_109604_.m_90592_()).m_5803_()) && (!(entity instanceof LocalPlayer) || p_109604_.m_90592_() == entity)) { ++ if ((this.f_109465_.m_151562_(blockpos.m_123342_()) || this.m_292727_(blockpos)) && (entity != p_109604_.m_90592_() || p_109604_.m_90594_() || p_109604_.m_90592_() instanceof LivingEntity && ((LivingEntity)p_109604_.m_90592_()).m_5803_()) && (!(entity instanceof LocalPlayer) || p_109604_.m_90592_() == entity || (entity == f_109461_.f_91074_ && !f_109461_.f_91074_.m_5833_()))) { //FORGE: render local player entity when it is not the renderViewEntity ++this.f_109439_; if (entity.f_19797_ == 0) { entity.f_19790_ = entity.m_20185_(); -@@ -1206,6 +_,9 @@ +@@ -949,6 +_,9 @@ int i = entity.m_19876_(); outlinebuffersource.m_109929_(FastColor.ARGB32.m_13665_(i), FastColor.ARGB32.m_13667_(i), FastColor.ARGB32.m_13669_(i), 255); } else { @@ -61,22 +61,22 @@ multibuffersource = multibuffersource$buffersource; } -@@ -1220,12 +_,14 @@ +@@ -963,12 +_,14 @@ multibuffersource$buffersource.m_109912_(RenderType.m_110452_(TextureAtlas.f_118259_)); multibuffersource$buffersource.m_109912_(RenderType.m_110458_(TextureAtlas.f_118259_)); multibuffersource$buffersource.m_109912_(RenderType.m_110476_(TextureAtlas.f_118259_)); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_ENTITIES, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_ENTITIES.dispatch(this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); profilerfiller.m_6182_("blockentities"); - for(LevelRenderer.RenderChunkInfo levelrenderer$renderchunkinfo : this.f_194297_) { - List list = levelrenderer$renderchunkinfo.f_109839_.m_112835_().m_112773_(); + for(SectionRenderDispatcher.RenderSection sectionrenderdispatcher$rendersection : this.f_290776_) { + List list = sectionrenderdispatcher$rendersection.m_293175_().m_293674_(); if (!list.isEmpty()) { for(BlockEntity blockentity1 : list) { -+ if(!frustum.m_113029_(blockentity1.getRenderBoundingBox())) continue; ++ if (!frustum.m_113029_(blockentity1.getRenderBoundingBox())) continue; BlockPos blockpos4 = blockentity1.m_58899_(); MultiBufferSource multibuffersource1 = multibuffersource$buffersource; p_109600_.m_85836_(); -@@ -1242,6 +_,9 @@ +@@ -985,6 +_,9 @@ }; } } @@ -86,7 +86,7 @@ this.f_172946_.m_112267_(blockentity1, p_109601_, p_109600_, multibuffersource1); p_109600_.m_85849_(); -@@ -1251,9 +_,13 @@ +@@ -994,9 +_,13 @@ synchronized(this.f_109468_) { for(BlockEntity blockentity : this.f_109468_) { @@ -100,25 +100,25 @@ this.f_172946_.m_112267_(blockentity, p_109601_, p_109600_, multibuffersource$buffersource); p_109600_.m_85849_(); } -@@ -1276,6 +_,7 @@ +@@ -1019,6 +_,7 @@ this.f_109461_.m_91385_().m_83947_(false); } -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_BLOCK_ENTITIES, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_BLOCK_ENTITIES.dispatch(this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); profilerfiller.m_6182_("destroyProgress"); for(Long2ObjectMap.Entry> entry : this.f_109409_.long2ObjectEntrySet()) { -@@ -1291,7 +_,8 @@ +@@ -1034,7 +_,8 @@ p_109600_.m_85837_((double)blockpos2.m_123341_() - d0, (double)blockpos2.m_123342_() - d1, (double)blockpos2.m_123343_() - d2); PoseStack.Pose posestack$pose1 = p_109600_.m_85850_(); VertexConsumer vertexconsumer1 = new SheetedDecalTextureGenerator(this.f_109464_.m_110108_().m_6299_(ModelBakery.f_119229_.get(k)), posestack$pose1.m_252922_(), posestack$pose1.m_252943_(), 1.0F); - this.f_109461_.m_91289_().m_110918_(this.f_109465_.m_8055_(blockpos2), blockpos2, this.f_109465_, p_109600_, vertexconsumer1); -+ net.minecraftforge.client.model.data.ModelData modelData = f_109465_.getModelDataManager().getAt(blockpos2); ++ var modelData = f_109465_.getModelDataManager().getAt(blockpos2); + this.f_109461_.m_91289_().renderBreakingTexture(this.f_109465_.m_8055_(blockpos2), blockpos2, this.f_109465_, p_109600_, vertexconsumer1, modelData == null ? net.minecraftforge.client.model.data.ModelData.EMPTY : modelData); p_109600_.m_85849_(); } } -@@ -1303,10 +_,13 @@ +@@ -1046,10 +_,13 @@ profilerfiller.m_6182_("outline"); BlockPos blockpos1 = ((BlockHitResult)hitresult).m_82425_(); BlockState blockstate = this.f_109465_.m_8055_(blockpos1); @@ -132,51 +132,51 @@ } this.f_109461_.f_91064_.m_113457_(p_109600_, multibuffersource$buffersource, d0, d1, d2); -@@ -1338,7 +_,8 @@ +@@ -1081,7 +_,8 @@ this.f_109415_.m_83945_(this.f_109461_.m_91385_()); RenderStateShard.f_110126_.m_110185_(); profilerfiller.m_6182_("particles"); - this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); + this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES.dispatch(this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); RenderStateShard.f_110126_.m_110188_(); } else { profilerfiller.m_6182_("translucent"); -@@ -1352,7 +_,8 @@ +@@ -1095,7 +_,8 @@ profilerfiller.m_6182_("string"); - this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_254120_); + this.m_293111_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_254120_); profilerfiller.m_6182_("particles"); - this.f_109461_.f_91061_.m_107336_(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_); + this.f_109461_.f_91061_.render(p_109600_, multibuffersource$buffersource, p_109606_, p_109604_, p_109601_, frustum); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES.dispatch(this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); } posestack.m_85836_(); -@@ -1376,6 +_,7 @@ +@@ -1119,6 +_,7 @@ RenderStateShard.f_110127_.m_110185_(); profilerfiller.m_6182_("weather"); this.m_109703_(p_109606_, p_109601_, d0, d1, d2); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER.dispatch(this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); this.m_173012_(p_109604_); RenderStateShard.f_110127_.m_110188_(); this.f_109418_.m_110023_(p_109601_); -@@ -1384,6 +_,7 @@ +@@ -1127,6 +_,7 @@ RenderSystem.depthMask(false); profilerfiller.m_6182_("weather"); this.m_109703_(p_109606_, p_109601_, d0, d1, d2); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); ++ net.minecraftforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER.dispatch(this, p_109600_, p_254120_, this.f_109477_, p_109604_, frustum); this.m_173012_(p_109604_); RenderSystem.depthMask(true); } -@@ -1527,6 +_,7 @@ +@@ -1269,6 +_,7 @@ shaderinstance.m_173362_(); VertexBuffer.m_85931_(); this.f_109461_.m_91307_().m_7238_(); -+ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_172994_, this, p_172995_, p_254039_, this.f_109477_, this.f_109461_.f_91063_.m_109153_(), this.getFrustum()); - p_172994_.m_110188_(); ++ net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(p_298012_, this, p_298121_, p_297481_, this.f_109477_, this.f_109461_.f_91063_.m_109153_(), this.getFrustum()); + p_298012_.m_110188_(); } -@@ -1741,6 +_,8 @@ +@@ -1485,6 +_,8 @@ } public void m_202423_(PoseStack p_202424_, Matrix4f p_254034_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { @@ -185,7 +185,7 @@ p_202429_.run(); if (!p_202428_) { FogType fogtype = p_202427_.m_167685_(); -@@ -1862,6 +_,8 @@ +@@ -1606,6 +_,8 @@ } public void m_253054_(PoseStack p_254145_, Matrix4f p_254537_, float p_254364_, double p_253843_, double p_253663_, double p_253795_) { @@ -194,16 +194,16 @@ float f = this.f_109465_.m_104583_().m_108871_(); if (!Float.isNaN(f)) { RenderSystem.disableCull(); -@@ -2049,7 +_,7 @@ +@@ -1792,7 +_,7 @@ boolean flag = false; if (this.f_109461_.f_91066_.m_232080_().m_231551_() == PrioritizeChunkUpdates.NEARBY) { - BlockPos blockpos1 = chunkrenderdispatcher$renderchunk.m_112839_().m_7918_(8, 8, 8); -- flag = blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_(); -+ flag = !net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && (blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_()); // the target is the else block below, so invert the forge addition to get there early + BlockPos blockpos1 = sectionrenderdispatcher$rendersection.m_295500_().m_7918_(8, 8, 8); +- flag = blockpos1.m_123331_(blockpos) < 768.0D || sectionrenderdispatcher$rendersection.m_295878_(); ++ flag = !net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && (blockpos1.m_123331_(blockpos) < 768.0D || sectionrenderdispatcher$rendersection.m_295878_()); // the target is the else block below, so invert the forge addition to get there early } else if (this.f_109461_.f_91066_.m_232080_().m_231551_() == PrioritizeChunkUpdates.PLAYER_AFFECTED) { - flag = chunkrenderdispatcher$renderchunk.m_112842_(); + flag = sectionrenderdispatcher$rendersection.m_295878_(); } -@@ -2396,7 +_,23 @@ +@@ -2139,7 +_,23 @@ this.f_109469_.m_110859_(p_109502_, p_109503_, p_109504_, p_109505_); } @@ -227,7 +227,7 @@ SoundInstance soundinstance = this.f_109410_.get(p_109516_); if (soundinstance != null) { this.f_109461_.m_91106_().m_120399_(soundinstance); -@@ -2404,7 +_,7 @@ +@@ -2147,7 +_,7 @@ } if (p_109515_ != null) { @@ -236,7 +236,7 @@ if (recorditem != null) { this.f_109461_.f_91065_.m_93055_(recorditem.m_43050_()); } -@@ -2541,7 +_,7 @@ +@@ -2284,7 +_,7 @@ case 1010: Item item = Item.m_41445_(p_234307_); if (item instanceof RecordItem recorditem) { @@ -245,7 +245,7 @@ } break; case 1011: -@@ -2694,7 +_,7 @@ +@@ -2437,7 +_,7 @@ case 2001: BlockState blockstate1 = Block.m_49803_(p_234307_); if (!blockstate1.m_60795_()) { @@ -254,7 +254,7 @@ this.f_109465_.m_245747_(p_234306_, soundtype.m_56775_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F, false); } -@@ -2925,7 +_,7 @@ +@@ -2672,7 +_,7 @@ } else { int i = p_109538_.m_45517_(LightLayer.SKY, p_109540_); int j = p_109538_.m_45517_(LightLayer.BLOCK, p_109540_); diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch index b2ea1f87a5..13f64f8008 100644 --- a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/RenderType.java +++ b/net/minecraft/client/renderer/RenderType.java -@@ -314,7 +_,7 @@ +@@ -322,7 +_,7 @@ } public static RenderType m_110497_(ResourceLocation p_110498_) { @@ -9,7 +9,7 @@ } public static RenderType m_269058_() { -@@ -322,19 +_,19 @@ +@@ -330,19 +_,19 @@ } public static RenderType m_173237_(ResourceLocation p_173238_) { @@ -33,7 +33,7 @@ } public static RenderType m_269508_() { -@@ -342,7 +_,7 @@ +@@ -350,7 +_,7 @@ } public static RenderType m_173240_(ResourceLocation p_173241_) { @@ -42,7 +42,7 @@ } public static RenderType m_110502_() { -@@ -669,4 +_,17 @@ +@@ -677,4 +_,17 @@ return this.f_110696_; } } diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch index 871b786d09..e21a8cc190 100644 --- a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java -@@ -145,11 +_,13 @@ +@@ -146,11 +_,13 @@ } private static Material m_173385_(WoodType p_173386_) { @@ -16,7 +16,7 @@ } public static Material m_173381_(WoodType p_173382_) { -@@ -208,6 +_,23 @@ +@@ -209,6 +_,23 @@ case SINGLE: default: return p_110773_; diff --git a/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch b/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch index 21a950d89b..7607a660d4 100644 --- a/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/SpriteCoordinateExpander.java.patch @@ -16,8 +16,8 @@ } public VertexConsumer m_7421_(float p_110805_, float p_110806_) { -- return this.f_110795_.m_7421_(this.f_110796_.m_118367_((double)(p_110805_ * 16.0F)), this.f_110796_.m_118393_((double)(p_110806_ * 16.0F))); -+ this.f_110795_.m_7421_(this.f_110796_.m_118367_((double)(p_110805_ * 16.0F)), this.f_110796_.m_118393_((double)(p_110806_ * 16.0F))); +- return this.f_110795_.m_7421_(this.f_110796_.m_118367_(p_110805_), this.f_110796_.m_118393_(p_110806_)); ++ this.f_110795_.m_7421_(this.f_110796_.m_118367_(p_110805_), this.f_110796_.m_118393_(p_110806_)); + return this; //Forge: Fix MC-263524 not working with chained methods } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch index 0a7d0e625d..9e58b4f394 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -16,14 +16,3 @@ } public static BlockFaceUV m_111581_(BlockFaceUV p_111582_, Direction p_111583_, Transformation p_111584_, ResourceLocation p_111585_) { -@@ -129,8 +_,8 @@ - p_111615_[i + 1] = Float.floatToRawIntBits(p_254291_.y()); - p_111615_[i + 2] = Float.floatToRawIntBits(p_254291_.z()); - p_111615_[i + 3] = -1; -- p_111615_[i + 4] = Float.floatToRawIntBits(p_111618_.m_118367_((double)p_111619_.m_111392_(p_111616_))); -- p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.m_118393_((double)p_111619_.m_111396_(p_111616_))); -+ p_111615_[i + 4] = Float.floatToRawIntBits(p_111618_.m_118367_((double)p_111619_.m_111392_(p_111616_) * .999 + p_111619_.m_111392_((p_111616_ + 2) % 4) * .001)); -+ p_111615_[i + 4 + 1] = Float.floatToRawIntBits(p_111618_.m_118393_((double)p_111619_.m_111396_(p_111616_) * .999 + p_111619_.m_111396_((p_111616_ + 2) % 4) * .001)); - } - - private void m_252985_(Vector3f p_254412_, @Nullable BlockElementRotation p_254150_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch index a0db1ed525..4beb893aa8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java -@@ -55,6 +_,7 @@ +@@ -53,6 +_,7 @@ builder.put(SkullBlock.Types.CREEPER, new SkullModel(p_173662_.m_171103_(ModelLayers.f_171130_))); builder.put(SkullBlock.Types.DRAGON, new DragonHeadModel(p_173662_.m_171103_(ModelLayers.f_171135_))); builder.put(SkullBlock.Types.PIGLIN, new PiglinHeadModel(p_173662_.m_171103_(ModelLayers.f_260668_))); diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch deleted file mode 100644 index 196d9731e0..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch +++ /dev/null @@ -1,134 +0,0 @@ ---- a/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java -+++ b/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java -@@ -79,12 +_,15 @@ - private Vec3 f_112683_ = Vec3.f_82478_; - - public ChunkRenderDispatcher(ClientLevel p_194405_, LevelRenderer p_194406_, Executor p_194407_, boolean p_194408_, ChunkBufferBuilderPack p_194409_) { -+ this(p_194405_, p_194406_, p_194407_, p_194408_, p_194409_, -1); -+ } -+ public ChunkRenderDispatcher(ClientLevel p_194405_, LevelRenderer p_194406_, Executor p_194407_, boolean p_194408_, ChunkBufferBuilderPack p_194409_, int countRenderBuilders) { - this.f_112681_ = p_194405_; - this.f_112682_ = p_194406_; - int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / (RenderType.m_110506_().stream().mapToInt(RenderType::m_110507_).sum() * 4) - 1); - int j = Runtime.getRuntime().availableProcessors(); - int k = p_194408_ ? j : Math.min(j, 4); -- int l = Math.max(1, Math.min(k, i)); -+ int l = countRenderBuilders < 0 ? Math.max(1, Math.min(k, i)) : countRenderBuilders; - this.f_112678_ = p_194409_; - List list = Lists.newArrayListWithExpectedSize(l); - -@@ -420,7 +_,7 @@ - if (!chunkrenderdispatcher$compiledchunk.f_112749_.contains(p_112810_)) { - return false; - } else { -- this.f_112788_ = new ChunkRenderDispatcher.RenderChunk.ResortTransparencyTask(this.m_112832_(), chunkrenderdispatcher$compiledchunk); -+ this.f_112788_ = new ChunkRenderDispatcher.RenderChunk.ResortTransparencyTask(new net.minecraft.world.level.ChunkPos(m_112839_()), this.m_112832_(), chunkrenderdispatcher$compiledchunk); - p_112811_.m_112709_(this.f_112788_); - return true; - } -@@ -452,7 +_,7 @@ - this.f_202433_.incrementAndGet(); - } - -- this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(this.m_112832_(), renderchunkregion, !flag1 || this.f_202433_.get() > 2); -+ this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(new net.minecraft.world.level.ChunkPos(m_112839_()), this.m_112832_(), renderchunkregion, flag || this.f_112784_.get() != ChunkRenderDispatcher.CompiledChunk.f_112748_); - return this.f_112787_; - } - -@@ -485,10 +_,20 @@ - protected final double f_112847_; - protected final AtomicBoolean f_112848_ = new AtomicBoolean(false); - protected final boolean f_194420_; -+ protected java.util.Map modelData; - - public ChunkCompileTask(double p_194423_, boolean p_194424_) { -+ this(null, p_194423_, p_194424_); -+ } -+ -+ public ChunkCompileTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_194423_, boolean p_194424_) { - this.f_112847_ = p_194423_; - this.f_194420_ = p_194424_; -+ if (pos == null) { -+ this.modelData = java.util.Collections.emptyMap(); -+ } else { -+ this.modelData = net.minecraft.client.Minecraft.m_91087_().f_91073_.getModelDataManager().getAt(pos); -+ } - } - - public abstract CompletableFuture m_5869_(ChunkBufferBuilderPack p_112853_); -@@ -500,6 +_,10 @@ - public int compareTo(ChunkRenderDispatcher.RenderChunk.ChunkCompileTask p_112855_) { - return Doubles.compare(this.f_112847_, p_112855_.f_112847_); - } -+ -+ public net.minecraftforge.client.model.data.ModelData getModelData(net.minecraft.core.BlockPos pos) { -+ return modelData.getOrDefault(pos, net.minecraftforge.client.model.data.ModelData.EMPTY); -+ } - } - - @OnlyIn(Dist.CLIENT) -@@ -507,8 +_,13 @@ - @Nullable - protected RenderChunkRegion f_112858_; - -+ @Deprecated - public RebuildTask(double p_194427_, @Nullable RenderChunkRegion p_194428_, boolean p_194429_) { -- super(p_194427_, p_194429_); -+ this(null, p_194427_, p_194428_, p_194429_); -+ } -+ -+ public RebuildTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_194427_, @Nullable RenderChunkRegion p_194428_, boolean p_194429_) { -+ super(pos, p_194427_, p_194429_); - this.f_112858_ = p_194428_; - } - -@@ -605,7 +_,10 @@ - } - - if (blockstate.m_60799_() != RenderShape.INVISIBLE) { -- RenderType rendertype2 = ItemBlockRenderTypes.m_109282_(blockstate); -+ var model = blockrenderdispatcher.m_110910_(blockstate); -+ var modelData = model.getModelData(renderchunkregion, blockpos2, blockstate, getModelData(blockpos2)); -+ randomsource.m_188584_(blockstate.m_60726_(blockpos2)); -+ for (RenderType rendertype2 : model.getRenderTypes(blockstate, randomsource, modelData)) { - BufferBuilder bufferbuilder2 = p_234471_.m_108839_(rendertype2); - if (set.add(rendertype2)) { - RenderChunk.this.m_112805_(bufferbuilder2); -@@ -613,8 +_,9 @@ - - posestack.m_85836_(); - posestack.m_252880_((float)(blockpos2.m_123341_() & 15), (float)(blockpos2.m_123342_() & 15), (float)(blockpos2.m_123343_() & 15)); -- blockrenderdispatcher.m_234355_(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, randomsource); -+ blockrenderdispatcher.renderBatched(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, randomsource, modelData, rendertype2); - posestack.m_85849_(); -+ } - } - } - -@@ -643,10 +_,10 @@ - private void m_234476_(ChunkRenderDispatcher.RenderChunk.RebuildTask.CompileResults p_234477_, E p_234478_) { - BlockEntityRenderer blockentityrenderer = Minecraft.m_91087_().m_167982_().m_112265_(p_234478_); - if (blockentityrenderer != null) { -- p_234477_.f_234485_.add(p_234478_); - if (blockentityrenderer.m_5932_(p_234478_)) { - p_234477_.f_234484_.add(p_234478_); - } -+ else p_234477_.f_234485_.add(p_234478_); //FORGE: Fix MC-112730 - } - - } -@@ -674,8 +_,13 @@ - class ResortTransparencyTask extends ChunkRenderDispatcher.RenderChunk.ChunkCompileTask { - private final ChunkRenderDispatcher.CompiledChunk f_112886_; - -+ @Deprecated - public ResortTransparencyTask(double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { -- super(p_112889_, true); -+ this(null, p_112889_, p_112890_); -+ } -+ -+ public ResortTransparencyTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { -+ super(pos, p_112889_, true); - this.f_112886_ = p_112890_; - } - diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch new file mode 100644 index 0000000000..bd6d900566 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch @@ -0,0 +1,135 @@ +--- a/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java ++++ b/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java +@@ -78,12 +_,16 @@ + private Vec3 f_290602_ = Vec3.f_82478_; + + public SectionRenderDispatcher(ClientLevel p_299878_, LevelRenderer p_299032_, Executor p_298480_, boolean p_298587_, SectionBufferBuilderPack p_299187_) { ++ this(p_299878_, p_299032_, p_298480_, p_298587_, p_299187_, -1); ++ } ++ ++ public SectionRenderDispatcher(ClientLevel p_299878_, LevelRenderer p_299032_, Executor p_298480_, boolean p_298587_, SectionBufferBuilderPack p_299187_, int countRenderBuilders) { + this.f_291400_ = p_299878_; + this.f_290611_ = p_299032_; + int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / (RenderType.m_110506_().stream().mapToInt(RenderType::m_110507_).sum() * 4) - 1); + int j = Runtime.getRuntime().availableProcessors(); + int k = p_298587_ ? j : Math.min(j, 4); +- int l = Math.max(1, Math.min(k, i)); ++ int l = countRenderBuilders < 0 ? Math.max(1, Math.min(k, i)) : countRenderBuilders; + this.f_290794_ = p_299187_; + List list = Lists.newArrayListWithExpectedSize(l); + +@@ -413,7 +_,7 @@ + if (!sectionrenderdispatcher$compiledsection.f_290391_.contains(p_301074_)) { + return false; + } else { +- this.f_291330_ = new SectionRenderDispatcher.RenderSection.ResortTransparencyTask(this.m_293828_(), sectionrenderdispatcher$compiledsection); ++ this.f_291330_ = new SectionRenderDispatcher.RenderSection.ResortTransparencyTask(new net.minecraft.world.level.ChunkPos(m_295500_()), this.m_293828_(), sectionrenderdispatcher$compiledsection); + p_298196_.m_294204_(this.f_291330_); + return true; + } +@@ -445,7 +_,7 @@ + this.f_291503_.incrementAndGet(); + } + +- this.f_291315_ = new SectionRenderDispatcher.RenderSection.RebuildTask(this.m_293828_(), renderchunkregion, !flag1 || this.f_291503_.get() > 2); ++ this.f_291315_ = new SectionRenderDispatcher.RenderSection.RebuildTask(new net.minecraft.world.level.ChunkPos(m_295500_()), this.m_293828_(), renderchunkregion, !flag1 || this.f_291503_.get() > 2); + return this.f_291315_; + } + +@@ -483,10 +_,20 @@ + protected final double f_290350_; + protected final AtomicBoolean f_291175_ = new AtomicBoolean(false); + protected final boolean f_290632_; ++ protected java.util.Map modelData; + + public CompileTask(double p_300617_, boolean p_299251_) { ++ this(null, p_300617_, p_299251_); ++ } ++ ++ public CompileTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_300617_, boolean p_299251_) { + this.f_290350_ = p_300617_; + this.f_290632_ = p_299251_; ++ if (pos == null) { ++ this.modelData = java.util.Collections.emptyMap(); ++ } else { ++ this.modelData = net.minecraft.client.Minecraft.m_91087_().f_91073_.getModelDataManager().getAt(pos); ++ } + } + + public abstract CompletableFuture m_294443_(SectionBufferBuilderPack p_300298_); +@@ -498,6 +_,10 @@ + public int compareTo(SectionRenderDispatcher.RenderSection.CompileTask p_298947_) { + return Doubles.compare(this.f_290350_, p_298947_.f_290350_); + } ++ ++ public net.minecraftforge.client.model.data.ModelData getModelData(net.minecraft.core.BlockPos pos) { ++ return modelData.getOrDefault(pos, net.minecraftforge.client.model.data.ModelData.EMPTY); ++ } + } + + @OnlyIn(Dist.CLIENT) +@@ -505,8 +_,13 @@ + @Nullable + protected RenderChunkRegion f_290484_; + ++ @Deprecated + public RebuildTask(double p_301300_, @Nullable RenderChunkRegion p_300496_, boolean p_299891_) { +- super(p_301300_, p_299891_); ++ this(null, p_301300_, p_300496_, p_299891_); ++ } ++ ++ public RebuildTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_301300_, @Nullable RenderChunkRegion p_300496_, boolean p_299891_) { ++ super(pos, p_301300_, p_299891_); + this.f_290484_ = p_300496_; + } + +@@ -602,7 +_,10 @@ + } + + if (blockstate.m_60799_() != RenderShape.INVISIBLE) { +- RenderType rendertype2 = ItemBlockRenderTypes.m_109282_(blockstate); ++ var model = blockrenderdispatcher.m_110910_(blockstate); ++ var modelData = model.getModelData(renderchunkregion, blockpos2, blockstate, getModelData(blockpos2)); ++ randomsource.m_188584_(blockstate.m_60726_(blockpos2)); ++ for (RenderType rendertype2 : model.getRenderTypes(blockstate, randomsource, modelData)) { + BufferBuilder bufferbuilder2 = p_300020_.m_294384_(rendertype2); + if (set.add(rendertype2)) { + RenderSection.this.m_293308_(bufferbuilder2); +@@ -610,8 +_,9 @@ + + posestack.m_85836_(); + posestack.m_252880_((float)(blockpos2.m_123341_() & 15), (float)(blockpos2.m_123342_() & 15), (float)(blockpos2.m_123343_() & 15)); +- blockrenderdispatcher.m_234355_(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, randomsource); ++ blockrenderdispatcher.renderBatched(blockstate, blockpos2, renderchunkregion, posestack, bufferbuilder2, true, randomsource, modelData, rendertype2); + posestack.m_85849_(); ++ } + } + } + +@@ -640,10 +_,10 @@ + private void m_293240_(SectionRenderDispatcher.RenderSection.RebuildTask.CompileResults p_297364_, E p_299361_) { + BlockEntityRenderer blockentityrenderer = Minecraft.m_91087_().m_167982_().m_112265_(p_299361_); + if (blockentityrenderer != null) { +- p_297364_.f_290796_.add(p_299361_); + if (blockentityrenderer.m_5932_(p_299361_)) { + p_297364_.f_291894_.add(p_299361_); + } ++ else p_297364_.f_290796_.add(p_299361_); //FORGE: Fix MC-112730 + } + + } +@@ -671,8 +_,13 @@ + class ResortTransparencyTask extends SectionRenderDispatcher.RenderSection.CompileTask { + private final SectionRenderDispatcher.CompiledSection f_291899_; + ++ @Deprecated + public ResortTransparencyTask(double p_300619_, SectionRenderDispatcher.CompiledSection p_297742_) { +- super(p_300619_, true); ++ this(null, p_300619_, p_297742_); ++ } ++ ++ public ResortTransparencyTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_300619_, SectionRenderDispatcher.CompiledSection p_297742_) { ++ super(pos, p_300619_, true); + this.f_291899_ = p_297742_; + } + diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch index 9d1ed7dd7a..b0d9ccd71e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java -@@ -172,12 +_,12 @@ +@@ -173,12 +_,12 @@ private static void m_114441_(PoseStack p_114442_, VertexConsumer p_114443_, Entity p_114444_, float p_114445_) { AABB aabb = p_114444_.m_20191_().m_82386_(-p_114444_.m_20185_(), -p_114444_.m_20186_(), -p_114444_.m_20189_()); LevelRenderer.m_109646_(p_114442_, p_114443_, aabb, 1.0F, 1.0F, 1.0F, 1.0F); @@ -15,11 +15,11 @@ p_114442_.m_85836_(); double d3 = d0 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19790_, enderdragonpart.m_20185_()); double d4 = d1 + Mth.m_14139_((double)p_114445_, enderdragonpart.f_19791_, enderdragonpart.m_20186_()); -@@ -351,9 +_,14 @@ +@@ -360,9 +_,14 @@ return this.f_234577_; } -+ public Map> getSkinMap() { ++ public Map> getSkinMap() { + return java.util.Collections.unmodifiableMap(f_114363_); + } + @@ -27,6 +27,6 @@ EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context(this, this.f_173995_, this.f_234576_, this.f_234577_, p_174004_, this.f_173996_, this.f_114365_); this.f_114362_ = EntityRenderers.m_174049_(entityrendererprovider$context); this.f_114363_ = EntityRenderers.m_174051_(entityrendererprovider$context); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.EntityRenderersEvent.AddLayers(f_114362_, f_114363_, entityrendererprovider$context)); ++ net.minecraftforge.event.ForgeEventFactory.gatherLayers(f_114362_, f_114363_, entityrendererprovider$context); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch index 8729499de1..fe3f2879dd 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java -@@ -49,14 +_,17 @@ +@@ -50,14 +_,17 @@ } public void m_7392_(T p_115308_, float p_115309_, float p_115310_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { @@ -15,21 +15,21 @@ float f = Mth.m_14189_(p_115310_, p_115308_.f_20884_, p_115308_.f_20883_); float f1 = Mth.m_14189_(p_115310_, p_115308_.f_20886_, p_115308_.f_20885_); float f2 = f1 - f; -- if (p_115308_.m_20159_() && p_115308_.m_20202_() instanceof LivingEntity) { +- if (p_115308_.m_20159_()) { + if (shouldSit && p_115308_.m_20202_() instanceof LivingEntity) { - LivingEntity livingentity = (LivingEntity)p_115308_.m_20202_(); - f = Mth.m_14189_(p_115310_, livingentity.f_20884_, livingentity.f_20883_); - f2 = f1 - f; -@@ -98,7 +_,7 @@ + Entity $$14 = p_115308_.m_20202_(); + if ($$14 instanceof LivingEntity) { + LivingEntity livingentity = (LivingEntity)$$14; +@@ -102,7 +_,7 @@ p_115311_.m_252880_(0.0F, -1.501F, 0.0F); float f8 = 0.0F; - float f5 = 0.0F; + float f4 = 0.0F; - if (!p_115308_.m_20159_() && p_115308_.m_6084_()) { + if (!shouldSit && p_115308_.m_6084_()) { f8 = p_115308_.f_267362_.m_267711_(p_115310_); - f5 = p_115308_.f_267362_.m_267590_(p_115310_); + f4 = p_115308_.f_267362_.m_267590_(p_115310_); if (p_115308_.m_6162_()) { -@@ -131,6 +_,7 @@ +@@ -135,6 +_,7 @@ p_115311_.m_85849_(); super.m_7392_(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch index 887023f783..ec4fc0e756 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/layers/ElytraLayer.java +++ b/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -@@ -33,7 +_,7 @@ +@@ -34,7 +_,7 @@ public void m_6494_(PoseStack p_116951_, MultiBufferSource p_116952_, int p_116953_, T p_116954_, float p_116955_, float p_116956_, float p_116957_, float p_116958_, float p_116959_, float p_116960_) { ItemStack itemstack = p_116954_.m_6844_(EquipmentSlot.CHEST); @@ -9,9 +9,9 @@ ResourceLocation resourcelocation; if (p_116954_ instanceof AbstractClientPlayer) { AbstractClientPlayer abstractclientplayer = (AbstractClientPlayer)p_116954_; -@@ -42,10 +_,10 @@ - } else if (abstractclientplayer.m_108555_() && abstractclientplayer.m_108561_() != null && abstractclientplayer.m_36170_(PlayerModelPart.CAPE)) { - resourcelocation = abstractclientplayer.m_108561_(); +@@ -44,10 +_,10 @@ + } else if (playerskin.f_291348_() != null && abstractclientplayer.m_36170_(PlayerModelPart.CAPE)) { + resourcelocation = playerskin.f_291348_(); } else { - resourcelocation = f_116934_; + resourcelocation = getElytraTexture(itemstack, p_116954_); @@ -22,7 +22,7 @@ } p_116951_.m_85836_(); -@@ -56,5 +_,30 @@ +@@ -58,5 +_,30 @@ this.f_116935_.m_7695_(p_116951_, vertexconsumer, p_116953_, OverlayTexture.f_118083_, 1.0F, 1.0F, 1.0F, 1.0F); p_116951_.m_85849_(); } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch index b1bb2366c1..ad385c0409 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch @@ -23,7 +23,7 @@ + this.renderModel(p_117119_, p_117120_, p_117123_, armoritem, model, flag, 1.0F, 1.0F, 1.0F, this.getArmorResource(p_117121_, itemstack, p_117122_, null)); } - ArmorTrim.m_266285_(p_117121_.m_9236_().m_9598_(), itemstack).ifPresent((p_289638_) -> { + ArmorTrim.m_266285_(p_117121_.m_9236_().m_9598_(), itemstack, true).ifPresent((p_289638_) -> { - this.m_289604_(armoritem.m_40401_(), p_117119_, p_117120_, p_117123_, p_289638_, p_117124_, flag); + this.renderTrim(armoritem.m_40401_(), p_117119_, p_117120_, p_117123_, p_289638_, model, flag); }); @@ -50,7 +50,7 @@ + } + private void renderTrim(ArmorMaterial p_289690_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, net.minecraft.client.model.Model p_289663_, boolean p_289651_) { TextureAtlasSprite textureatlassprite = this.f_266073_.m_118316_(p_289651_ ? p_289692_.m_267774_(p_289690_) : p_289692_.m_267606_(p_289690_)); - VertexConsumer vertexconsumer = textureatlassprite.m_118381_(p_289643_.m_6299_(Sheets.m_266442_())); + VertexConsumer vertexconsumer = textureatlassprite.m_118381_(p_289643_.m_6299_(Sheets.m_266442_(p_289692_.m_266429_().m_203334_().f_290976_()))); p_289663_.m_7695_(p_289687_, vertexconsumer, p_289683_, OverlayTexture.f_118083_, 1.0F, 1.0F, 1.0F, 1.0F); } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch index 2fae918bf2..b0657a2248 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/player/PlayerRenderer.java +++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java -@@ -59,7 +_,9 @@ +@@ -60,7 +_,9 @@ public void m_7392_(AbstractClientPlayer p_117788_, float p_117789_, float p_117790_, PoseStack p_117791_, MultiBufferSource p_117792_, int p_117793_) { this.m_117818_(p_117788_); @@ -10,7 +10,7 @@ } public Vec3 m_7860_(AbstractClientPlayer p_117785_, float p_117786_) { -@@ -132,10 +_,13 @@ +@@ -133,10 +_,13 @@ if (useanim == UseAnim.BRUSH) { return HumanoidModel.ArmPose.BRUSH; } @@ -25,7 +25,7 @@ return HumanoidModel.ArmPose.ITEM; } } -@@ -167,10 +_,12 @@ +@@ -168,10 +_,12 @@ } public void m_117770_(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, AbstractClientPlayer p_117774_) { @@ -38,12 +38,12 @@ this.m_117775_(p_117814_, p_117815_, p_117816_, p_117817_, (this.f_115290_).f_102812_, (this.f_115290_).f_103374_); } -@@ -208,7 +_,7 @@ +@@ -211,7 +_,7 @@ } } else if (f > 0.0F) { super.m_7523_(p_117802_, p_117803_, p_117804_, p_117805_, p_117806_); -- float f3 = p_117802_.m_20069_() ? -90.0F - p_117802_.m_146909_() : -90.0F; -+ float f3 = p_117802_.m_20069_() || p_117802_.isInFluidType((fluidType, height) -> p_117802_.canSwimInFluidType(fluidType)) ? -90.0F - p_117802_.m_146909_() : -90.0F; - float f4 = Mth.m_14179_(f, 0.0F, f3); - p_117803_.m_252781_(Axis.f_252529_.m_252977_(f4)); +- float f4 = p_117802_.m_20069_() ? -90.0F - f1 : -90.0F; ++ float f4 = p_117802_.m_20069_() || p_117802_.isInFluidType((fluidType, height) -> p_117802_.canSwimInFluidType(fluidType)) ? -90.0F - p_117802_.m_146909_() : -90.0F; + float f5 = Mth.m_14179_(f, 0.0F, f4); + p_117803_.m_252781_(Axis.f_252529_.m_252977_(f5)); if (p_117802_.m_6067_()) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch index 39510330ad..90b40d728e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/renderer/texture/SpriteContents.java +++ b/net/minecraft/client/renderer/texture/SpriteContents.java -@@ -32,14 +_,29 @@ - public NativeImage[] f_243731_; +@@ -34,8 +_,18 @@ @Nullable final SpriteContents.AnimatedTexture f_244575_; + private final ResourceMetadata f_290652_; + @Nullable + public final net.minecraftforge.client.textures.ForgeTextureMetadata forgeMeta; @@ -11,26 +11,23 @@ + * @deprecated Forge: Use the {@linkplain SpriteContents#SpriteContents(ResourceLocation, FrameSize, NativeImage, AnimationMetadataSection, net.minecraftforge.client.textures.ForgeTextureMetadata) overload with Forge metadata parameter} to properly forward custom loaders. + */ + @Deprecated - public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, AnimationMetadataSection p_250432_) { -+ this(p_249787_, p_251031_, p_252131_, p_250432_, null); + public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, ResourceMetadata p_299427_) { ++ this(p_249787_, p_251031_, p_252131_, p_299427_, null); + } + -+ public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, AnimationMetadataSection p_250432_, @org.jetbrains.annotations.Nullable net.minecraftforge.client.textures.ForgeTextureMetadata forgeMeta) { ++ public SpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, ResourceMetadata p_299427_, @Nullable net.minecraftforge.client.textures.ForgeTextureMetadata forgeMeta) { this.f_243877_ = p_249787_; this.f_244302_ = p_251031_.f_244129_(); this.f_244600_ = p_251031_.f_244503_(); - this.f_244575_ = this.m_247391_(p_251031_, p_252131_.m_84982_(), p_252131_.m_85084_(), p_250432_); +@@ -44,6 +_,7 @@ + this.f_244575_ = this.m_247391_(p_251031_, p_252131_.m_84982_(), p_252131_.m_85084_(), animationmetadatasection); this.f_243904_ = p_252131_; this.f_243731_ = new NativeImage[]{this.f_243904_}; + this.forgeMeta = forgeMeta; -+ } -+ -+ public NativeImage getOriginalImage() { -+ return this.f_243904_; } public void m_246368_(int p_248864_) { -@@ -124,6 +_,9 @@ +@@ -128,6 +_,9 @@ void m_247381_(int p_248895_, int p_250245_, int p_250458_, int p_251337_, NativeImage[] p_248825_) { for(int i = 0; i < this.f_243731_.length; ++i) { @@ -40,7 +37,18 @@ p_248825_[i].m_85003_(i, p_248895_ >> i, p_250245_ >> i, p_250458_ >> i, p_251337_ >> i, this.f_244302_ >> i, this.f_244600_ >> i, this.f_243731_.length > 1, false); } -@@ -241,7 +_,8 @@ +@@ -145,6 +_,10 @@ + return this.f_243877_; + } + ++ public NativeImage getOriginalImage() { ++ return this.f_243904_; ++ } ++ + public IntStream m_245638_() { + return this.f_244575_ != null ? this.f_244575_.m_246130_() : IntStream.of(1); + } +@@ -249,7 +_,8 @@ for(int i = 0; i < this.f_244527_.length; ++i) { int j = SpriteContents.this.f_244302_ >> i; int k = SpriteContents.this.f_244600_ >> i; @@ -50,7 +58,7 @@ } } -@@ -257,6 +_,9 @@ +@@ -265,6 +_,9 @@ for(int k = 0; k < this.f_244527_.length; ++k) { int l = SpriteContents.this.f_244302_ >> k; int i1 = SpriteContents.this.f_244600_ >> k; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch index c6c4aee8ea..f48f245cb6 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/SpriteLoader.java +++ b/net/minecraft/client/renderer/texture/SpriteLoader.java -@@ -68,7 +_,7 @@ +@@ -67,7 +_,7 @@ int j1 = Math.min(j, k); int k1 = Mth.m_14173_(j1); int l1; @@ -9,17 +9,7 @@ f_244357_.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.f_244500_, p_261919_, k1, j1); l1 = k1; } else { -@@ -144,6 +_,9 @@ - - FrameSize framesize = animationmetadatasection.m_245821_(nativeimage.m_84982_(), nativeimage.m_85084_()); - if (Mth.m_264612_(nativeimage.m_84982_(), framesize.f_244129_()) && Mth.m_264612_(nativeimage.m_85084_(), framesize.f_244503_())) { -+ SpriteContents contents = net.minecraftforge.client.ForgeHooksClient.loadSpriteContents(p_251630_, p_250558_, framesize, nativeimage, animationmetadatasection); -+ if (contents != null) -+ return contents; - return new SpriteContents(p_251630_, framesize, nativeimage, animationmetadatasection); - } else { - f_244357_.error("Image {} size {},{} is not multiple of frame size {},{}", p_251630_, nativeimage.m_84982_(), nativeimage.m_85084_(), framesize.f_244129_(), framesize.f_244503_()); -@@ -155,6 +_,11 @@ +@@ -133,6 +_,11 @@ private Map m_276091_(Stitcher p_276117_, int p_276111_, int p_276112_) { Map map = new HashMap<>(); p_276117_.m_118180_((p_251421_, p_250533_, p_251913_) -> { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch index 7cb145c90f..3626c10c08 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/TextureManager.java +++ b/net/minecraft/client/renderer/texture/TextureManager.java -@@ -168,6 +_,7 @@ +@@ -167,6 +_,7 @@ public void m_118513_(ResourceLocation p_118514_) { AbstractTexture abstracttexture = this.f_118468_.remove(p_118514_); if (abstracttexture != null) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch new file mode 100644 index 0000000000..4c5414a4a9 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java ++++ b/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java +@@ -44,6 +_,9 @@ + AnimationMetadataSection animationmetadatasection = resourcemetadata.m_214059_(AnimationMetadataSection.f_119011_).orElse(AnimationMetadataSection.f_119012_); + FrameSize framesize = animationmetadatasection.m_245821_(nativeimage.m_84982_(), nativeimage.m_85084_()); + if (Mth.m_264612_(nativeimage.m_84982_(), framesize.f_244129_()) && Mth.m_264612_(nativeimage.m_85084_(), framesize.f_244503_())) { ++ SpriteContents contents = net.minecraftforge.client.ForgeHooksClient.loadSpriteContents(p_296303_, p_296304_, framesize, nativeimage, resourcemetadata); ++ if (contents != null) ++ return contents; + return new SpriteContents(p_296303_, framesize, nativeimage, resourcemetadata); + } else { + f_260482_.error("Image {} size {},{} is not multiple of frame size {},{}", p_296303_, nativeimage.m_84982_(), nativeimage.m_85084_(), framesize.f_244129_(), framesize.f_244503_()); diff --git a/patches/minecraft/net/minecraft/client/resources/language/LanguageManager.java.patch b/patches/minecraft/net/minecraft/client/resources/language/LanguageManager.java.patch index f611e14e34..93334d3c53 100644 --- a/patches/minecraft/net/minecraft/client/resources/language/LanguageManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/language/LanguageManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/language/LanguageManager.java +++ b/net/minecraft/client/resources/language/LanguageManager.java -@@ -29,7 +_,7 @@ +@@ -28,7 +_,7 @@ private String f_118967_; public LanguageManager(String p_118971_) { @@ -9,7 +9,7 @@ } private static Map m_118981_(Stream p_118982_) { -@@ -66,8 +_,12 @@ +@@ -65,8 +_,12 @@ Language.m_128114_(clientlanguage); } diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch index 3b038a5049..b3de135c81 100644 --- a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch @@ -14,7 +14,7 @@ } public void m_5705_(BooleanSupplier p_120049_) { -@@ -192,6 +_,7 @@ +@@ -196,6 +_,7 @@ } public void m_7570_(boolean p_120053_) { diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch index 9163cdd6eb..e02582f029 100644 --- a/patches/minecraft/net/minecraft/commands/Commands.java.patch +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -193,7 +_,7 @@ +@@ -196,7 +_,7 @@ JfrCommand.m_183645_(this.f_82090_); } @@ -8,8 +8,8 @@ + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled()) { TestCommand.m_127946_(this.f_82090_); SpawnArmorTrimsCommand.m_266283_(this.f_82090_); - } -@@ -218,9 +_,11 @@ + if (p_230943_.f_82145_) { +@@ -224,9 +_,11 @@ if (p_230943_.f_82144_) { PublishCommand.m_138184_(this.f_82090_); } @@ -21,7 +21,7 @@ }); } -@@ -243,7 +_,16 @@ +@@ -249,7 +_,16 @@ try { try { @@ -39,13 +39,13 @@ } catch (CommandRuntimeException commandruntimeexception) { commandsourcestack.m_81352_(commandruntimeexception.m_79226_()); return 0; -@@ -299,7 +_,8 @@ +@@ -305,7 +_,8 @@ Map, CommandNode> map = Maps.newHashMap(); RootCommandNode rootcommandnode = new RootCommandNode<>(); map.put(this.f_82090_.getRoot(), rootcommandnode); - this.m_82112_(this.f_82090_.getRoot(), rootcommandnode, p_82096_.m_20203_(), map); + // FORGE: Use our own command node merging method to handle redirect nodes properly, see issue #7551 + net.minecraftforge.server.command.CommandHelper.mergeCommandNode(this.f_82090_.getRoot(), rootcommandnode, map, p_82096_.m_20203_(), ctx -> 0, suggest -> SuggestionProviders.m_121664_((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); - p_82096_.f_8906_.m_9829_(new ClientboundCommandsPacket(rootcommandnode)); + p_82096_.f_8906_.m_141995_(new ClientboundCommandsPacket(rootcommandnode)); } diff --git a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch index 9a67c6f0db..dad8d9b731 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/MessageArgument.java +++ b/net/minecraft/commands/arguments/MessageArgument.java -@@ -100,7 +_,7 @@ +@@ -97,7 +_,7 @@ } Component m_232196_(CommandSourceStack p_232197_) throws CommandSyntaxException { diff --git a/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch index 468f7de99f..76437a6473 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch @@ -2,17 +2,17 @@ +++ b/net/minecraft/commands/arguments/ResourceLocationArgument.java @@ -39,7 +_,7 @@ - public static Advancement m_106987_(CommandContext p_106988_, String p_106989_) throws CommandSyntaxException { + public static AdvancementHolder m_106987_(CommandContext p_106988_, String p_106989_) throws CommandSyntaxException { ResourceLocation resourcelocation = m_107011_(p_106988_, p_106989_); -- Advancement advancement = p_106988_.getSource().m_81377_().m_129889_().m_136041_(resourcelocation); -+ Advancement advancement = p_106988_.getSource().getAdvancement(resourcelocation); - if (advancement == null) { +- AdvancementHolder advancementholder = p_106988_.getSource().m_81377_().m_129889_().m_294099_(resourcelocation); ++ AdvancementHolder advancementholder = p_106988_.getSource().getAdvancement(resourcelocation); + if (advancementholder == null) { throw f_106978_.create(resourcelocation); } else { @@ -48,7 +_,7 @@ } - public static Recipe m_106994_(CommandContext p_106995_, String p_106996_) throws CommandSyntaxException { + public static RecipeHolder m_106994_(CommandContext p_106995_, String p_106996_) throws CommandSyntaxException { - RecipeManager recipemanager = p_106995_.getSource().m_81377_().m_129894_(); + RecipeManager recipemanager = p_106995_.getSource().getRecipeManager(); ResourceLocation resourcelocation = m_107011_(p_106995_, p_106996_); diff --git a/patches/minecraft/net/minecraft/core/HolderSet.java.patch b/patches/minecraft/net/minecraft/core/HolderSet.java.patch index 9d91acd7c6..db65610894 100644 --- a/patches/minecraft/net/minecraft/core/HolderSet.java.patch +++ b/patches/minecraft/net/minecraft/core/HolderSet.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/HolderSet.java +++ b/net/minecraft/core/HolderSet.java -@@ -14,7 +_,7 @@ - import org.jetbrains.annotations.Nullable; +@@ -15,7 +_,7 @@ + import net.minecraft.util.RandomSource; import org.jetbrains.annotations.VisibleForTesting; -public interface HolderSet extends Iterable> { @@ -9,7 +9,7 @@ Stream> m_203614_(); int m_203632_(); -@@ -133,6 +_,9 @@ +@@ -135,6 +_,9 @@ public void m_205835_(List> p_205836_) { this.f_205830_ = List.copyOf(p_205836_); @@ -19,11 +19,12 @@ } public TagKey m_205839_() { -@@ -161,6 +_,11 @@ +@@ -163,6 +_,12 @@ public boolean m_207277_(HolderOwner p_256542_) { return this.f_254711_.m_254921_(p_256542_); + } ++ + // FORGE: Keep a list of invalidation callbacks so they can be run when tags rebind + private List invalidationCallbacks = new java.util.ArrayList<>(); + public void addInvalidationListener(Runnable runnable) { diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch index f8a549f893..b0734d0243 100644 --- a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -12,7 +12,7 @@ + KNOWN.add(m_123023_().m_135782_()); + } + - public Holder.Reference m_203704_(int p_256563_, ResourceKey p_256594_, T p_256374_, Lifecycle p_256469_) { + public Holder.Reference m_255320_(int p_256563_, ResourceKey p_256594_, T p_256374_, Lifecycle p_256469_) { + markKnown(); this.m_205921_(p_256594_); Validate.notNull(p_256594_); diff --git a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch index c2e9703675..4ca849a102 100644 --- a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -20,7 +20,7 @@ + public static final DefaultedRegistry f_257020_ = forge(Registries.f_256808_, "empty", (p_259453_) -> { return Fluids.f_76191_; }); -- public static final Registry f_256974_ = m_258002_(Registries.f_256929_, (p_259689_) -> { +- public static final Registry f_256974_ = m_293167_(Registries.f_256929_, (p_259689_) -> { + /** + * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#MOB_EFFECTS} instead. + */ @@ -36,7 +36,7 @@ + public static final DefaultedRegistry f_256975_ = forge(Registries.f_256747_, "air", (p_259909_) -> { return Blocks.f_50016_; }); -- public static final Registry f_256876_ = m_258002_(Registries.f_256762_, (p_259104_) -> { +- public static final Registry f_256876_ = m_293167_(Registries.f_256762_, (p_259104_) -> { + /** + * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#ENCHANTMENTS} instead. + */ @@ -60,7 +60,7 @@ + public static final DefaultedRegistry f_257033_ = forge(Registries.f_256913_, "air", (p_260227_) -> { return Items.f_41852_; }); -- public static final DefaultedRegistry f_256980_ = m_257988_(Registries.f_256973_, "empty", (p_259869_) -> { +- public static final DefaultedRegistry f_256980_ = m_257834_(Registries.f_256973_, "empty", (p_259869_) -> { + /** + * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#POTIONS} instead. + */ @@ -76,7 +76,7 @@ + public static final Registry> f_257034_ = forge(Registries.f_256890_, (p_260266_) -> { return ParticleTypes.f_123794_; }); -- public static final Registry> f_257049_ = m_258002_(Registries.f_256922_, (p_259434_) -> { +- public static final Registry> f_257049_ = m_293167_(Registries.f_256922_, (p_259434_) -> { + /** + * @deprecated Forge: Use {@link net.minecraftforge.registries.ForgeRegistries#BLOCK_ENTITY_TYPES} instead. + */ @@ -260,8 +260,8 @@ return TreeDecoratorType.f_70043_; }); public static final Registry> f_256958_ = m_258002_(Registries.f_256720_, (p_259370_) -> { -@@ -289,10 +_,18 @@ - return m_258073_(p_260095_, Lifecycle.stable(), p_259057_); +@@ -293,10 +_,18 @@ + return m_257895_(p_297531_, new MappedRegistry<>(p_297531_, Lifecycle.stable(), true), p_298446_, Lifecycle.stable()); } + private static Registry forge(ResourceKey> key, BuiltInRegistries.RegistryBootstrap def) { @@ -279,7 +279,7 @@ private static DefaultedRegistry m_257834_(ResourceKey> p_259296_, String p_259101_, BuiltInRegistries.RegistryBootstrap p_259485_) { return m_257762_(p_259296_, p_259101_, Lifecycle.stable(), p_259485_); } -@@ -301,10 +_,19 @@ +@@ -305,10 +_,19 @@ return m_257895_(p_259121_, new MappedRegistry<>(p_259121_, p_259977_, false), p_259874_, p_259977_); } @@ -299,7 +299,7 @@ private static DefaultedRegistry m_257762_(ResourceKey> p_260010_, String p_260220_, Lifecycle p_260139_, BuiltInRegistries.RegistryBootstrap p_260185_) { return m_257895_(p_260010_, new DefaultedMappedRegistry<>(p_260220_, p_260010_, p_260139_, true), p_260185_, p_260139_); } -@@ -350,7 +_,7 @@ +@@ -354,7 +_,7 @@ if (p_259410_ instanceof DefaultedRegistry) { ResourceLocation resourcelocation = ((DefaultedRegistry)p_259410_).m_122315_(); diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index bfd6ab0b05..2f9608cc2e 100644 --- a/patches/minecraft/net/minecraft/data/Main.java.patch +++ b/patches/minecraft/net/minecraft/data/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/Main.java +++ b/net/minecraft/data/Main.java -@@ -66,8 +_,15 @@ +@@ -67,8 +_,15 @@ OptionSpec optionspec6 = optionparser.accepts("all", "Include all generators"); OptionSpec optionspec7 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); OptionSpec optionspec8 = optionparser.accepts("input", "Input folder").withRequiredArg(); @@ -17,7 +17,7 @@ Path path = Paths.get(optionspec7.value(optionset)); boolean flag = optionset.has(optionspec6); boolean flag1 = flag || optionset.has(optionspec2); -@@ -75,10 +_,14 @@ +@@ -76,10 +_,14 @@ boolean flag3 = flag || optionset.has(optionspec3); boolean flag4 = flag || optionset.has(optionspec4); boolean flag5 = flag || optionset.has(optionspec5); diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch index 76440e3cbe..eb756e80c3 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,38 +1,30 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -89,7 +_,9 @@ - list.add(DataProvider.m_253162_(p_254020_, p_253413_.m_125966_(), this.f_236355_.m_245731_(p_253413_.m_6445_()))); - JsonObject jsonobject = p_253413_.m_5860_(); - if (jsonobject != null) { -- list.add(DataProvider.m_253162_(p_254020_, jsonobject, this.f_236356_.m_245731_(p_253413_.m_6448_()))); -+ var saveAdvancementFuture = saveAdvancement(p_254020_, p_253413_, jsonobject); -+ if (saveAdvancementFuture != null) -+ list.add(saveAdvancementFuture); +@@ -93,7 +_,9 @@ + AdvancementHolder advancementholder = p_300066_.m_126373_(); + if (advancementholder != null) { + JsonObject jsonobject = advancementholder.f_290952_().m_294498_(); +- list.add(DataProvider.m_253162_(p_254020_, jsonobject, RecipeProvider.this.f_236356_.m_245731_(advancementholder.f_291758_()))); ++ var saveAdvancementFuture = saveAdvancement(p_254020_, jsonobject, advancementholder, p_300066_); ++ if (saveAdvancementFuture != null) ++ list.add(saveAdvancementFuture); + } + } - - } -@@ -99,13 +_,23 @@ +@@ -106,6 +_,16 @@ + return CompletableFuture.allOf(list.toArray((p_253414_) -> { + return new CompletableFuture[p_253414_]; })); - } - ++ } ++ + /** + * Called every time a recipe is saved to also save the advancement JSON if it exists. + * + * @return A completable future that saves the advancement to disk, or null to cancel saving the advancement. + */ -+ @org.jetbrains.annotations.Nullable -+ protected CompletableFuture saveAdvancement(CachedOutput output, FinishedRecipe finishedRecipe, JsonObject advancementJson) { -+ return DataProvider.m_253162_(output, advancementJson, this.f_236356_.m_245731_(finishedRecipe.m_6448_())); -+ } -+ - protected CompletableFuture m_253240_(CachedOutput p_253674_, ResourceLocation p_254102_, Advancement.Builder p_253712_) { - return DataProvider.m_253162_(p_253674_, p_253712_.m_138400_(), this.f_236356_.m_245731_(p_254102_)); ++ @Nullable ++ protected CompletableFuture saveAdvancement(CachedOutput output, JsonObject advancementJson, AdvancementHolder holder, FinishedRecipe finishedRecipe) { ++ return DataProvider.m_253162_(output, advancementJson, this.f_236356_.m_245731_(holder.f_291758_())); } - protected abstract void m_245200_(Consumer p_251297_); - -- protected static void m_247051_(Consumer p_249188_, FeatureFlagSet p_251836_) { -+ protected void m_247051_(Consumer p_249188_, FeatureFlagSet p_251836_) { - BlockFamilies.m_175934_().filter((p_248034_) -> { - return p_248034_.m_245288_(p_251836_); - }).forEach((p_176624_) -> { + protected CompletableFuture m_253240_(CachedOutput p_253674_, AdvancementHolder p_297687_) { diff --git a/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch index 989c965381..c778a97ad0 100644 --- a/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/GameEventTagsProvider.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/data/tags/GameEventTagsProvider.java @@ -13,10 +_,15 @@ @VisibleForTesting - static final GameEvent[] f_236425_ = new GameEvent[]{GameEvent.f_157791_, GameEvent.f_157792_, GameEvent.f_157793_, GameEvent.f_157794_, GameEvent.f_157795_, GameEvent.f_157796_, GameEvent.f_157797_, GameEvent.f_223702_, GameEvent.f_223703_, GameEvent.f_157802_, GameEvent.f_157803_, GameEvent.f_223704_, GameEvent.f_157806_, GameEvent.f_223705_, GameEvent.f_223706_, GameEvent.f_223707_, GameEvent.f_268533_, GameEvent.f_223708_, GameEvent.f_268500_, GameEvent.f_157810_, GameEvent.f_223709_, GameEvent.f_223710_, GameEvent.f_157811_, GameEvent.f_157812_, GameEvent.f_157816_, GameEvent.f_157769_, GameEvent.f_157770_, GameEvent.f_223696_, GameEvent.f_223697_, GameEvent.f_157772_, GameEvent.f_223699_, GameEvent.f_157776_, GameEvent.f_157777_, GameEvent.f_157778_, GameEvent.f_157781_, GameEvent.f_157784_, GameEvent.f_157785_, GameEvent.f_157786_, GameEvent.f_238175_}; + static final GameEvent[] f_236425_ = new GameEvent[]{GameEvent.f_157791_, GameEvent.f_157792_, GameEvent.f_157793_, GameEvent.f_157794_, GameEvent.f_157795_, GameEvent.f_157796_, GameEvent.f_157797_, GameEvent.f_223702_, GameEvent.f_223703_, GameEvent.f_157802_, GameEvent.f_157803_, GameEvent.f_223704_, GameEvent.f_157806_, GameEvent.f_223705_, GameEvent.f_223706_, GameEvent.f_223707_, GameEvent.f_268533_, GameEvent.f_223708_, GameEvent.f_268500_, GameEvent.f_157810_, GameEvent.f_290971_, GameEvent.f_157811_, GameEvent.f_157812_, GameEvent.f_157816_, GameEvent.f_157769_, GameEvent.f_157770_, GameEvent.f_223696_, GameEvent.f_223697_, GameEvent.f_157772_, GameEvent.f_223699_, GameEvent.f_157776_, GameEvent.f_157777_, GameEvent.f_157778_, GameEvent.f_157781_, GameEvent.f_157784_, GameEvent.f_157785_, GameEvent.f_157786_, GameEvent.f_238175_, GameEvent.f_291275_}; + /** @deprecated Forge: Use the {@linkplain #GameEventTagsProvider(PackOutput, CompletableFuture, String, net.minecraftforge.common.data.ExistingFileHelper) mod id variant} */ + @Deprecated diff --git a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch b/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch index 4acfa7c4dd..9a97357bbc 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/StructureUtils.java +++ b/net/minecraft/gametest/framework/StructureUtils.java -@@ -239,7 +_,7 @@ +@@ -218,7 +_,7 @@ if (optional.isPresent()) { return optional.get(); } else { diff --git a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch index dd9745e5c6..42b4c2e708 100644 --- a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java -@@ -142,10 +_,12 @@ +@@ -154,10 +_,12 @@ private static Tag m_128930_(DataInput p_128931_, int p_128932_, NbtAccounter p_128933_) throws IOException { byte b0 = p_128931_.readByte(); @@ -11,6 +11,6 @@ - StringTag.m_197563_(p_128931_); + p_128933_.readUTF(p_128931_.readUTF()); //Forge: Count this string. + p_128933_.m_128926_(4); //Forge: 4 extra bytes for the object allocation. - - try { - return TagTypes.m_129397_(b0).m_7300_(p_128931_, p_128932_, p_128933_); + return m_292742_(p_128931_, p_128932_, p_128933_, b0); + } + } diff --git a/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch index 89d56692db..904c8e3ac3 100644 --- a/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch +++ b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch @@ -9,9 +9,9 @@ public CompressionEncoder(int p_129448_) { this.f_129446_ = p_129448_; -@@ -22,6 +_,12 @@ - friendlybytebuf.m_130130_(0); - friendlybytebuf.writeBytes(p_129453_); +@@ -21,6 +_,12 @@ + VarInt.m_293803_(p_129454_, 0); + p_129454_.writeBytes(p_129453_); } else { + if (!DISABLE_PACKET_DEBUG && i > net.minecraft.network.CompressionDecoder.f_182672_) { + p_129453_.markReaderIndex(); @@ -21,4 +21,4 @@ + } byte[] abyte = new byte[i]; p_129453_.readBytes(abyte); - friendlybytebuf.m_130130_(abyte.length); + VarInt.m_293803_(p_129454_, abyte.length); diff --git a/patches/minecraft/net/minecraft/network/Connection.java.patch b/patches/minecraft/net/minecraft/network/Connection.java.patch index 79b466003d..5436876f17 100644 --- a/patches/minecraft/net/minecraft/network/Connection.java.patch +++ b/patches/minecraft/net/minecraft/network/Connection.java.patch @@ -1,50 +1,48 @@ --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -86,6 +_,7 @@ - private boolean f_129479_; - @Nullable +@@ -102,6 +_,7 @@ private volatile Component f_290021_; + @Nullable + BandwidthDebugMonitor f_291520_; + private java.util.function.Consumer activationHandler; public Connection(PacketFlow p_129482_) { this.f_129466_ = p_129482_; -@@ -95,6 +_,7 @@ +@@ -111,6 +_,7 @@ super.channelActive(p_129525_); this.f_129468_ = p_129525_.channel(); this.f_129469_ = this.f_129468_.remoteAddress(); + if (activationHandler != null) activationHandler.accept(this); - - try { - this.m_129498_(ConnectionProtocol.HANDSHAKING); -@@ -111,8 +_,10 @@ - public void m_129498_(ConnectionProtocol p_129499_) { - this.f_129468_.attr(f_129461_).set(p_129499_); - this.f_129468_.attr(BundlerInfo.f_263730_).set(p_129499_); -+ this.f_129468_.eventLoop().execute(()-> { - this.f_129468_.config().setAutoRead(true); - f_129465_.debug("Enabled auto read"); -+ }); + if (this.f_290021_ != null) { + this.m_129507_(this.f_290021_); + } +@@ -395,7 +_,7 @@ + if (this.f_129469_ == null) { + return "local"; + } else { +- return p_298740_ ? this.f_129469_.toString() : "IP hidden"; ++ return p_298740_ ? net.minecraftforge.network.DualStackUtils.getAddressString(this.f_129469_) : "IP hidden"; + } } - public void channelInactive(ChannelHandlerContext p_129527_) { -@@ -316,6 +_,8 @@ +@@ -435,6 +_,8 @@ } public static ChannelFuture m_290025_(InetSocketAddress p_290034_, boolean p_290035_, final Connection p_290031_) { + net.minecraftforge.network.DualStackUtils.checkIPv6(p_290034_.getAddress()); + p_290031_.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel; Class oclass; - LazyLoadedValue lazyloadedvalue; + EventLoopGroup eventloopgroup; if (Epoll.isAvailable() && p_290035_) { -@@ -347,6 +_,7 @@ +@@ -485,6 +_,7 @@ public static Connection m_129493_(SocketAddress p_129494_) { final Connection connection = new Connection(PacketFlow.CLIENTBOUND); + connection.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel; - (new Bootstrap()).group(f_129464_.m_13971_()).handler(new ChannelInitializer() { + (new Bootstrap()).group(f_129464_.get()).handler(new ChannelInitializer() { protected void initChannel(Channel p_129557_) { - ChannelPipeline channelpipeline = p_129557_.pipeline(); -@@ -437,6 +_,14 @@ + Connection.m_294111_(p_129557_); +@@ -581,6 +_,14 @@ public float m_129543_() { return this.f_129477_; @@ -58,4 +56,4 @@ + return this.f_129466_; } - static class PacketHolder { + public void m_292855_(SampleLogger p_300126_) { diff --git a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch index 466a838bad..45ea3c9081 100644 --- a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch @@ -6,10 +6,10 @@ -public class FriendlyByteBuf extends ByteBuf { +public class FriendlyByteBuf extends ByteBuf implements net.minecraftforge.common.extensions.IForgeFriendlyByteBuf { - private static final int f_178335_ = 5; - private static final int f_178336_ = 10; public static final int f_178337_ = 2097152; -@@ -622,6 +_,15 @@ + private final ByteBuf f_130049_; + public static final short f_178333_ = Short.MAX_VALUE; +@@ -577,6 +_,15 @@ } public FriendlyByteBuf m_130055_(ItemStack p_130056_) { @@ -25,7 +25,7 @@ if (p_130056_.m_41619_()) { this.writeBoolean(false); } else { -@@ -630,8 +_,8 @@ +@@ -585,8 +_,8 @@ this.m_236818_(BuiltInRegistries.f_257033_, item); this.writeByte(p_130056_.m_41613_()); CompoundTag compoundtag = null; @@ -36,7 +36,7 @@ } this.m_130079_(compoundtag); -@@ -647,7 +_,7 @@ +@@ -602,7 +_,7 @@ Item item = this.m_236816_(BuiltInRegistries.f_257033_); int i = this.readByte(); ItemStack itemstack = new ItemStack(item, i); diff --git a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..d598b4f56d --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java ++++ b/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java +@@ -26,7 +_,7 @@ + import net.minecraft.network.protocol.common.custom.WorldGenAttemptDebugPayload; + import net.minecraft.resources.ResourceLocation; + +-public record ClientboundCustomPayloadPacket(CustomPacketPayload f_291001_) implements Packet { ++public record ClientboundCustomPayloadPacket(CustomPacketPayload f_291001_) implements Packet, net.minecraftforge.network.ICustomPacket { + private static final int f_290501_ = 1048576; + private static final Map> f_290559_ = ImmutableMap.>builder().put(BrandPayload.f_291556_, BrandPayload::new).put(BeeDebugPayload.f_290721_, BeeDebugPayload::new).put(BrainDebugPayload.f_290905_, BrainDebugPayload::new).put(GameEventDebugPayload.f_290615_, GameEventDebugPayload::new).put(GameEventListenerDebugPayload.f_290865_, GameEventListenerDebugPayload::new).put(GameTestAddMarkerDebugPayload.f_291461_, GameTestAddMarkerDebugPayload::new).put(GameTestClearMarkersDebugPayload.f_291366_, GameTestClearMarkersDebugPayload::new).put(GoalDebugPayload.f_290680_, GoalDebugPayload::new).put(HiveDebugPayload.f_291748_, HiveDebugPayload::new).put(NeighborUpdatesDebugPayload.f_291649_, NeighborUpdatesDebugPayload::new).put(PathfindingDebugPayload.f_291536_, PathfindingDebugPayload::new).put(PoiAddedDebugPayload.f_290556_, PoiAddedDebugPayload::new).put(PoiRemovedDebugPayload.f_291534_, PoiRemovedDebugPayload::new).put(PoiTicketCountDebugPayload.f_291088_, PoiTicketCountDebugPayload::new).put(RaidsDebugPayload.f_291341_, RaidsDebugPayload::new).put(StructuresDebugPayload.f_291313_, StructuresDebugPayload::new).put(VillageSectionsDebugPayload.f_291109_, VillageSectionsDebugPayload::new).put(WorldGenAttemptDebugPayload.f_291888_, WorldGenAttemptDebugPayload::new).build(); + +@@ -42,8 +_,7 @@ + private static DiscardedPayload m_294768_(ResourceLocation p_299265_, FriendlyByteBuf p_297545_) { + int i = p_297545_.readableBytes(); + if (i >= 0 && i <= 1048576) { +- p_297545_.skipBytes(i); +- return new DiscardedPayload(p_299265_); ++ return new DiscardedPayload(p_299265_, p_297545_); + } else { + throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes"); + } +@@ -57,4 +_,8 @@ + public void m_5797_(ClientCommonPacketListener p_299773_) { + p_299773_.m_293213_(this); + } ++ ++ @Override public @org.jetbrains.annotations.Nullable FriendlyByteBuf getInternalData() { return f_291001_ instanceof DiscardedPayload dc ? dc.data() : null; } ++ @Override public ResourceLocation getName() { return f_291001_.m_292644_(); } ++ @Override public int getIndex() { return 0; } + } diff --git a/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..dd02c51dba --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java ++++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java +@@ -9,7 +_,7 @@ + import net.minecraft.network.protocol.common.custom.DiscardedPayload; + import net.minecraft.resources.ResourceLocation; + +-public record ServerboundCustomPayloadPacket(CustomPacketPayload f_291328_) implements Packet { ++public record ServerboundCustomPayloadPacket(CustomPacketPayload f_291328_) implements Packet, net.minecraftforge.network.ICustomPacket { + private static final int f_290599_ = 32767; + private static final Map> f_291010_ = ImmutableMap.>builder().put(BrandPayload.f_291556_, BrandPayload::new).build(); + +@@ -25,8 +_,7 @@ + private static DiscardedPayload m_295544_(ResourceLocation p_300234_, FriendlyByteBuf p_299925_) { + int i = p_299925_.readableBytes(); + if (i >= 0 && i <= 32767) { +- p_299925_.skipBytes(i); +- return new DiscardedPayload(p_300234_); ++ return new DiscardedPayload(p_300234_, p_299925_); + } else { + throw new IllegalArgumentException("Payload may not be larger than 32767 bytes"); + } +@@ -40,4 +_,8 @@ + public void m_5797_(ServerCommonPacketListener p_297991_) { + p_297991_.m_293234_(this); + } ++ ++ @Override public @org.jetbrains.annotations.Nullable FriendlyByteBuf getInternalData() { return f_291328_ instanceof DiscardedPayload dc ? dc.data() : null; } ++ @Override public ResourceLocation getName() { return f_291328_.m_292644_(); } ++ @Override public int getIndex() { return 0; } + } diff --git a/patches/minecraft/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch new file mode 100644 index 0000000000..400d0c9f7e --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/common/custom/DiscardedPayload.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/network/protocol/common/custom/DiscardedPayload.java ++++ b/net/minecraft/network/protocol/common/custom/DiscardedPayload.java +@@ -3,8 +_,14 @@ + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.resources.ResourceLocation; + +-public record DiscardedPayload(ResourceLocation f_291401_) implements CustomPacketPayload { ++public record DiscardedPayload(ResourceLocation f_291401_, @org.jetbrains.annotations.Nullable FriendlyByteBuf data) implements CustomPacketPayload { ++ public DiscardedPayload(ResourceLocation f_291401_) { ++ this(f_291401_, null); ++ } ++ + public void m_293110_(FriendlyByteBuf p_301050_) { ++ if (data != null) ++ p_301050_.writeBytes(data.slice()); + } + + public ResourceLocation m_292644_() { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch deleted file mode 100644 index f7df25ecac..0000000000 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java -+++ b/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java -@@ -4,7 +_,7 @@ - import net.minecraft.network.protocol.Packet; - import net.minecraft.resources.ResourceLocation; - --public class ClientboundCustomPayloadPacket implements Packet { -+public class ClientboundCustomPayloadPacket implements Packet, net.minecraftforge.network.ICustomPacket { - private static final int f_178834_ = 1048576; - public static final ResourceLocation f_132012_ = new ResourceLocation("brand"); - public static final ResourceLocation f_132013_ = new ResourceLocation("debug/path"); -@@ -26,6 +_,7 @@ - public static final ResourceLocation f_178833_ = new ResourceLocation("debug/game_event_listeners"); - private final ResourceLocation f_132029_; - private final FriendlyByteBuf f_132030_; -+ private final boolean shouldRelease; - - public ClientboundCustomPayloadPacket(ResourceLocation p_132034_, FriendlyByteBuf p_132035_) { - this.f_132029_ = p_132034_; -@@ -33,6 +_,7 @@ - if (p_132035_.writerIndex() > 1048576) { - throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes"); - } -+ this.shouldRelease = false; //We are not the owner of the buffer, don't release it, it might be reused. - } - - public ClientboundCustomPayloadPacket(FriendlyByteBuf p_178836_) { -@@ -43,15 +_,17 @@ - } else { - throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes"); - } -+ this.shouldRelease = true; //We are the owner of the buffer, release it when we are done. - } - - public void m_5779_(FriendlyByteBuf p_132044_) { - p_132044_.m_130085_(this.f_132029_); -- p_132044_.writeBytes(this.f_132030_.copy()); -+ p_132044_.writeBytes(this.f_132030_.slice()); // Use Slice instead of copy, to not update the read index, allowing packet to be sent multiple times. - } - - public void m_5797_(ClientGamePacketListener p_132041_) { - p_132041_.m_7413_(this); -+ if (this.shouldRelease) this.f_132030_.release(); // FORGE: Fix impl buffer leaks (MC-121884), can only be fixed partially, because else you get problems in LAN-Worlds - } - - public ResourceLocation m_132042_() { -@@ -61,4 +_,8 @@ - public FriendlyByteBuf m_132045_() { - return new FriendlyByteBuf(this.f_132030_.copy()); - } -+ -+ @Override public int getIndex() { return Integer.MAX_VALUE; } -+ @Override public ResourceLocation getName() { return m_132042_(); } -+ @Override public FriendlyByteBuf getInternalData() { return m_132045_(); } - } diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch deleted file mode 100644 index cf0c9fd96d..0000000000 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java -+++ b/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java -@@ -5,7 +_,7 @@ - import net.minecraft.network.protocol.Packet; - import net.minecraft.resources.ResourceLocation; - --public class ServerboundCustomPayloadPacket implements Packet { -+public class ServerboundCustomPayloadPacket implements Packet, net.minecraftforge.network.ICustomPacket { - private static final int f_179586_ = 32767; - public static final ResourceLocation f_133979_ = new ResourceLocation("brand"); - private final ResourceLocation f_133980_; -@@ -28,7 +_,7 @@ - - public void m_5779_(FriendlyByteBuf p_133994_) { - p_133994_.m_130085_(this.f_133980_); -- p_133994_.writeBytes((ByteBuf)this.f_133981_); -+ p_133994_.writeBytes((ByteBuf)this.f_133981_.slice()); // Use Slice instead of copy, to not update the read index, allowing packet to be sent multiple times. - } - - public void m_5797_(ServerGamePacketListener p_133992_) { -@@ -43,4 +_,8 @@ - public FriendlyByteBuf m_179590_() { - return this.f_133981_; - } -+ -+ @Override public int getIndex() { return Integer.MAX_VALUE; } -+ @Override public ResourceLocation getName() { return m_179589_(); } -+ @org.jetbrains.annotations.Nullable @Override public FriendlyByteBuf getInternalData() { return m_179590_(); } - } diff --git a/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch index e4f230e60f..2fd8a71fa7 100644 --- a/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -1,39 +1,11 @@ --- a/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java +++ b/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java -@@ -11,6 +_,7 @@ - private final String f_134721_; - private final int f_134722_; - private final ConnectionProtocol f_134723_; -+ private String fmlVersion = net.minecraftforge.network.NetworkConstants.NETVERSION; - - public ClientIntentionPacket(String p_134726_, int p_134727_, ConnectionProtocol p_134728_) { - this.f_134720_ = SharedConstants.m_183709_().m_132495_(); -@@ -21,14 +_,16 @@ - - public ClientIntentionPacket(FriendlyByteBuf p_179801_) { - this.f_134720_ = p_179801_.m_130242_(); -- this.f_134721_ = p_179801_.m_130136_(255); -+ String hostName = p_179801_.m_130136_(255); - this.f_134722_ = p_179801_.readUnsignedShort(); - this.f_134723_ = ConnectionProtocol.m_129583_(p_179801_.m_130242_()); -+ this.fmlVersion = net.minecraftforge.network.NetworkHooks.getFMLVersion(hostName); -+ this.f_134721_ = hostName.split("\0")[0]; - } +@@ -13,7 +_,7 @@ public void m_5779_(FriendlyByteBuf p_134737_) { p_134737_.m_130130_(this.f_134720_); - p_134737_.m_130070_(this.f_134721_); -+ p_134737_.m_130070_(this.f_134721_ + "\0"+ net.minecraftforge.network.NetworkConstants.NETVERSION+"\0"); ++ p_134737_.m_130070_(this.f_134721_ + "\0" + net.minecraftforge.network.NetworkConstants.NETVERSION + "\0"); p_134737_.writeShort(this.f_134722_); - p_134737_.m_130130_(this.f_134723_.m_129582_()); + p_134737_.m_130130_(this.f_134723_.m_293527_()); } -@@ -51,5 +_,9 @@ - - public int m_179803_() { - return this.f_134722_; -+ } -+ -+ public String getFMLVersion() { -+ return this.fmlVersion; - } - } diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch index 9c6a58ce77..ec3b545754 100644 --- a/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch @@ -1,29 +1,30 @@ --- a/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java +++ b/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java -@@ -4,7 +_,7 @@ - import net.minecraft.network.protocol.Packet; +@@ -6,7 +_,7 @@ + import net.minecraft.network.protocol.login.custom.DiscardedQueryPayload; import net.minecraft.resources.ResourceLocation; --public class ClientboundCustomQueryPacket implements Packet { -+public class ClientboundCustomQueryPacket implements Packet, net.minecraftforge.network.ICustomPacket { +-public record ClientboundCustomQueryPacket(int f_134745_, CustomQueryPayload f_291166_) implements Packet { ++public record ClientboundCustomQueryPacket(int f_134745_, CustomQueryPayload f_291166_) implements Packet, net.minecraftforge.network.ICustomPacket { private static final int f_179804_ = 1048576; - private final int f_134745_; - private final ResourceLocation f_134746_; -@@ -30,7 +_,7 @@ - public void m_5779_(FriendlyByteBuf p_134757_) { - p_134757_.m_130130_(this.f_134745_); - p_134757_.m_130085_(this.f_134746_); -- p_134757_.writeBytes(this.f_134747_.copy()); -+ p_134757_.writeBytes(this.f_134747_.slice()); // Use Slice instead of copy, to not update the read index, allowing packet to be sent multiple times. - } + public ClientboundCustomQueryPacket(FriendlyByteBuf p_179810_) { +@@ -20,8 +_,7 @@ + private static DiscardedQueryPayload m_294633_(ResourceLocation p_299981_, FriendlyByteBuf p_297706_) { + int i = p_297706_.readableBytes(); + if (i >= 0 && i <= 1048576) { +- p_297706_.skipBytes(i); +- return new DiscardedQueryPayload(p_299981_); ++ return new DiscardedQueryPayload(p_299981_, p_297706_); + } else { + throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes"); + } +@@ -36,4 +_,8 @@ public void m_5797_(ClientLoginPacketListener p_134754_) { -@@ -48,4 +_,8 @@ - public FriendlyByteBuf m_179812_() { - return this.f_134747_; + p_134754_.m_7254_(this); } + -+ @Override public int getIndex() { return m_134755_(); } -+ @Override public ResourceLocation getName() { return m_179811_(); } -+ @org.jetbrains.annotations.Nullable @Override public FriendlyByteBuf getInternalData() { return m_179812_(); } ++ @Override public int getIndex() { return f_134745_(); } ++ @Override public ResourceLocation getName() { return this.f_291166_.m_293131_(); } ++ @org.jetbrains.annotations.Nullable @Override public FriendlyByteBuf getInternalData() { return ((DiscardedQueryPayload)this.f_291166_).data(); } } diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch new file mode 100644 index 0000000000..39d55ef85c --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java ++++ b/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java +@@ -6,7 +_,7 @@ + import net.minecraft.network.protocol.login.custom.CustomQueryAnswerPayload; + import net.minecraft.network.protocol.login.custom.DiscardedQueryAnswerPayload; + +-public record ServerboundCustomQueryAnswerPacket(int f_290801_, @Nullable CustomQueryAnswerPayload f_290461_) implements Packet { ++public record ServerboundCustomQueryAnswerPacket(int f_290801_, @Nullable CustomQueryAnswerPayload f_290461_) implements Packet, net.minecraftforge.network.ICustomPacket { + private static final int f_290617_ = 1048576; + + public static ServerboundCustomQueryAnswerPacket m_294367_(FriendlyByteBuf p_300962_) { +@@ -21,8 +_,7 @@ + private static CustomQueryAnswerPayload m_294815_(FriendlyByteBuf p_299934_) { + int i = p_299934_.readableBytes(); + if (i >= 0 && i <= 1048576) { +- p_299934_.skipBytes(i); +- return DiscardedQueryAnswerPayload.f_290582_; ++ return new DiscardedQueryAnswerPayload(p_299934_); + } else { + throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes"); + } +@@ -38,4 +_,8 @@ + public void m_5797_(ServerLoginPacketListener p_298492_) { + p_298492_.m_10044_(this); + } ++ ++ @Override public int getIndex() { return f_290801_(); } ++ @Override public net.minecraft.resources.ResourceLocation getName() { return net.minecraftforge.network.LoginWrapper.WRAPPER; } ++ @Nullable @Override public FriendlyByteBuf getInternalData() { return this.f_290461_ == null ? null : ((DiscardedQueryAnswerPayload)this.f_290461_).data(); } + } diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch deleted file mode 100644 index bfef7808ba..0000000000 --- a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java -+++ b/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java -@@ -4,7 +_,8 @@ - import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.protocol.Packet; - --public class ServerboundCustomQueryPacket implements Packet { -+public class ServerboundCustomQueryPacket implements Packet, net.minecraftforge.network.ICustomPacket -+{ - private static final int f_179821_ = 1048576; - private final int f_134825_; - @Nullable -@@ -46,4 +_,8 @@ - public FriendlyByteBuf m_179825_() { - return this.f_134826_; - } -+ -+ @Override public int getIndex() { return m_179824_(); } -+ @Override public net.minecraft.resources.ResourceLocation getName() { return net.minecraftforge.network.LoginWrapper.WRAPPER; } -+ @org.jetbrains.annotations.Nullable @Override public FriendlyByteBuf getInternalData() { return m_179825_(); } - } diff --git a/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryAnswerPayload.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryAnswerPayload.java.patch new file mode 100644 index 0000000000..cdd949edc1 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryAnswerPayload.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/network/protocol/login/custom/DiscardedQueryAnswerPayload.java ++++ b/net/minecraft/network/protocol/login/custom/DiscardedQueryAnswerPayload.java +@@ -2,9 +_,15 @@ + + import net.minecraft.network.FriendlyByteBuf; + +-public record DiscardedQueryAnswerPayload() implements CustomQueryAnswerPayload { ++public record DiscardedQueryAnswerPayload(@javax.annotation.Nullable FriendlyByteBuf data) implements CustomQueryAnswerPayload { + public static final DiscardedQueryAnswerPayload f_290582_ = new DiscardedQueryAnswerPayload(); + ++ public DiscardedQueryAnswerPayload() { ++ this(null); ++ } ++ + public void m_295630_(FriendlyByteBuf p_299186_) { ++ if (this.data != null) ++ p_299186_.writeBytes(this.data.slice()); + } + } diff --git a/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java.patch new file mode 100644 index 0000000000..58fcac5925 --- /dev/null +++ b/patches/minecraft/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java ++++ b/net/minecraft/network/protocol/login/custom/DiscardedQueryPayload.java +@@ -3,8 +_,14 @@ + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.resources.ResourceLocation; + +-public record DiscardedQueryPayload(ResourceLocation f_291669_) implements CustomQueryPayload { ++public record DiscardedQueryPayload(ResourceLocation f_291669_, @org.jetbrains.annotations.Nullable FriendlyByteBuf data) implements CustomQueryPayload { ++ public DiscardedQueryPayload(ResourceLocation f_291669_) { ++ this(f_291669_, null); ++ } ++ + public void m_294761_(FriendlyByteBuf p_299949_) { ++ if (this.data != null) ++ p_299949_.writeBytes(this.data.slice()); + } + + public ResourceLocation m_293131_() { diff --git a/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch b/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch index 6e60254b87..4aa5b7eaa3 100644 --- a/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch +++ b/patches/minecraft/net/minecraft/recipebook/PlaceRecipe.java.patch @@ -1,14 +1,13 @@ --- a/net/minecraft/recipebook/PlaceRecipe.java +++ b/net/minecraft/recipebook/PlaceRecipe.java -@@ -9,9 +_,10 @@ - default void m_135408_(int p_135409_, int p_135410_, int p_135411_, Recipe p_135412_, Iterator p_135413_, int p_135414_) { +@@ -11,9 +_,9 @@ int i = p_135409_; int j = p_135410_; -- if (p_135412_ instanceof ShapedRecipe shapedrecipe) { + Recipe recipe = p_298822_.f_291008_(); +- if (recipe instanceof ShapedRecipe shapedrecipe) { - i = shapedrecipe.m_44220_(); - j = shapedrecipe.m_44221_(); -+ if (p_135412_ instanceof net.minecraftforge.common.crafting.IShapedRecipe) { -+ net.minecraftforge.common.crafting.IShapedRecipe shapedrecipe = (net.minecraftforge.common.crafting.IShapedRecipe)p_135412_; ++ if (recipe instanceof net.minecraftforge.common.crafting.IShapedRecipe shapedrecipe) { + i = shapedrecipe.getRecipeWidth(); + j = shapedrecipe.getRecipeHeight(); } diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index aa6e1e551d..4b0398323a 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -84,6 +_,15 @@ - OptionSpec optionspec13 = optionparser.accepts("jfrProfile"); - OptionSpec optionspec14 = optionparser.accepts("pidFile").withRequiredArg().withValuesConvertedBy(new PathConverter()); - OptionSpec optionspec15 = optionparser.nonOptions(); +@@ -80,6 +_,15 @@ + OptionSpec optionspec12 = optionparser.accepts("jfrProfile"); + OptionSpec optionspec13 = optionparser.accepts("pidFile").withRequiredArg().withValuesConvertedBy(new PathConverter()); + OptionSpec optionspec14 = optionparser.nonOptions(); + optionparser.accepts("allowUpdates").withRequiredArg().ofType(Boolean.class).defaultsTo(Boolean.TRUE); // Forge: allow mod updates to proceed + optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File(".")); //Forge: Consume this argument, we use it in the launcher, and the client side. + final OptionSpec spawnPosOpt; @@ -16,7 +16,7 @@ try { OptionSet optionset = optionparser.parse(p_129699_); -@@ -91,6 +_,13 @@ +@@ -87,6 +_,13 @@ optionparser.printHelpOn(System.err); return; } @@ -28,9 +28,9 @@ + return; + } - Path path = optionset.valueOf(optionspec14); + Path path = optionset.valueOf(optionspec13); if (path != null) { -@@ -106,25 +_,24 @@ +@@ -102,25 +_,24 @@ Bootstrap.m_135889_(); Util.m_137584_(); Path path1 = Paths.get("server.properties"); @@ -49,9 +49,9 @@ - return; - } - - File file1 = new File(optionset.valueOf(optionspec9)); + File file1 = new File(optionset.valueOf(optionspec8)); Services services = Services.m_214344_(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file1); - String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.m_139777_().f_139741_); + String s = Optional.ofNullable(optionset.valueOf(optionspec9)).orElse(dedicatedserversettings.m_139777_().f_139741_); + if (s == null || s.isEmpty() || new File(file1, s).getAbsolutePath().equals(new File(s).getAbsolutePath())) { + f_129670_.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s); + return; @@ -62,7 +62,7 @@ LevelSummary levelsummary = levelstoragesource$levelstorageaccess.m_78308_(); if (levelsummary != null) { if (levelsummary.m_193020_()) { -@@ -170,6 +_,8 @@ +@@ -166,6 +_,8 @@ worlddimensions = dedicatedserverproperties.m_246483_(p_248079_.f_244104_()); } @@ -71,12 +71,12 @@ WorldDimensions.Complete worlddimensions$complete = worlddimensions.m_245300_(registry); Lifecycle lifecycle = worlddimensions$complete.m_245945_().add(p_248079_.f_244104_().m_211816_()); return new WorldLoader.DataLoadOutput<>(new PrimaryLevelData(levelsettings, worldoptions, worlddimensions$complete.f_244634_(), lifecycle), worlddimensions$complete.m_245593_()); -@@ -190,22 +_,33 @@ +@@ -186,21 +_,32 @@ WorldData worlddata = worldstem.f_206895_(); levelstoragesource$levelstorageaccess.m_78287_(registryaccess$frozen, worlddata); -- final DedicatedServer dedicatedserver = MinecraftServer.m_129872_((p_236710_) -> { -- DedicatedServer dedicatedserver1 = new DedicatedServer(p_236710_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.m_14512_(), services, LoggerChunkProgressListener::new); +- final DedicatedServer dedicatedserver = MinecraftServer.m_129872_((p_296433_) -> { +- DedicatedServer dedicatedserver1 = new DedicatedServer(p_296433_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.m_14512_(), services, LoggerChunkProgressListener::new); + final MinecraftServer dedicatedserver = MinecraftServer.m_129872_((p_129697_) -> { + MinecraftServer dedicatedserver1; + if (gametestEnabled) { @@ -87,11 +87,10 @@ + } else { + dedicatedserver1 = new DedicatedServer(p_129697_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.m_14512_(), services, LoggerChunkProgressListener::new); + } - dedicatedserver1.m_236740_(optionset.has(optionspec8) ? new GameProfile((UUID)null, optionset.valueOf(optionspec8)) : null); - dedicatedserver1.m_129801_(optionset.valueOf(optionspec11)); + dedicatedserver1.m_129801_(optionset.valueOf(optionspec10)); dedicatedserver1.m_129975_(optionset.has(optionspec2)); - dedicatedserver1.m_129948_(optionset.valueOf(optionspec12)); - boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec15).contains("nogui"); + dedicatedserver1.m_129948_(optionset.valueOf(optionspec11)); + boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec14).contains("nogui"); - if (flag1 && !GraphicsEnvironment.isHeadless()) { - dedicatedserver1.m_139667_(); + if (dedicatedserver1 instanceof DedicatedServer dedicatedServer && flag1 && !GraphicsEnvironment.isHeadless()) { diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 77ed2104c2..3fe2945cbc 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -247,7 +_,7 @@ +@@ -245,7 +_,7 @@ public static S m_129872_(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -9,7 +9,7 @@ atomicreference.get().m_130011_(); }, "Server thread"); thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> { -@@ -340,6 +_,7 @@ +@@ -338,6 +_,7 @@ this.m_129841_(dimensiondatastorage); this.f_129732_ = new CommandStorage(dimensiondatastorage); WorldBorder worldborder = serverlevel.m_6857_(); @@ -17,7 +17,7 @@ if (!serverleveldata.m_6535_()) { try { m_177896_(serverlevel, serverleveldata, worldoptions.m_245100_(), flag); -@@ -376,6 +_,7 @@ +@@ -374,6 +_,7 @@ ServerLevel serverlevel1 = new ServerLevel(this, this.f_129738_, this.f_129744_, derivedleveldata, resourcekey1, entry.getValue(), p_129816_, flag, j, ImmutableList.of(), false, randomsequences); worldborder.m_61929_(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.m_6857_())); this.f_129762_.put(resourcekey1, serverlevel1); @@ -25,7 +25,7 @@ } } -@@ -387,6 +_,7 @@ +@@ -385,6 +_,7 @@ p_177898_.m_7250_(BlockPos.f_121853_.m_6630_(80), 0.0F); } else { ServerChunkCache serverchunkcache = p_177897_.m_7726_(); @@ -33,7 +33,7 @@ ChunkPos chunkpos = new ChunkPos(serverchunkcache.m_214994_().m_224579_().m_183230_()); int i = serverchunkcache.m_8481_().m_142051_(p_177897_); if (i < p_177897_.m_141937_()) { -@@ -469,6 +_,7 @@ +@@ -467,6 +_,7 @@ ChunkPos chunkpos = new ChunkPos(i); serverlevel1.m_7726_().m_6692_(chunkpos, true); } @@ -41,7 +41,7 @@ } } -@@ -582,6 +_,7 @@ +@@ -577,6 +_,7 @@ for(ServerLevel serverlevel2 : this.m_129785_()) { if (serverlevel2 != null) { try { @@ -49,7 +49,7 @@ serverlevel2.close(); } catch (IOException ioexception1) { f_129750_.error("Exception closing the level", (Throwable)ioexception1); -@@ -630,9 +_,11 @@ +@@ -625,9 +_,11 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -61,7 +61,7 @@ while(this.f_129764_) { long i = Util.m_137550_() - this.f_129726_; -@@ -661,6 +_,8 @@ +@@ -656,6 +_,8 @@ this.f_129717_ = true; JvmProfiler.f_185340_.m_183597_(this.f_129737_); } @@ -70,7 +70,7 @@ } catch (Throwable throwable1) { f_129750_.error("Encountered an unexpected exception", throwable1); CrashReport crashreport = m_206568_(throwable1); -@@ -672,6 +_,7 @@ +@@ -667,6 +_,7 @@ f_129750_.error("We were unable to save this crash report to disk."); } @@ -78,7 +78,7 @@ this.m_7268_(crashreport); } finally { try { -@@ -684,6 +_,7 @@ +@@ -679,6 +_,7 @@ this.f_236721_.f_214336_().m_196559_(); } @@ -86,7 +86,7 @@ this.m_6988_(); } -@@ -798,11 +_,13 @@ +@@ -793,11 +_,13 @@ public void m_5705_(BooleanSupplier p_129871_) { long i = Util.m_137569_(); @@ -100,9 +100,9 @@ } if (this.f_129766_ % 6000 == 0) { -@@ -819,11 +_,22 @@ +@@ -814,6 +_,17 @@ long k = Util.m_137569_(); - this.f_129735_.m_13755_(k - i); + this.m_293783_(k - i); this.f_129754_.m_7238_(); + net.minecraftforge.event.ForgeEventFactory.onPostServerTick(p_129871_, this); + } @@ -117,6 +117,9 @@ + return cachedServerStatus; } + protected void m_293783_(long p_298126_) { +@@ -821,7 +_,7 @@ + private ServerStatus m_271988_() { ServerStatus.Players serverstatus$players = this.m_271961_(); - return new ServerStatus(Component.m_130674_(this.f_129709_), Optional.of(serverstatus$players), Optional.of(ServerStatus.Version.m_272202_()), Optional.ofNullable(this.f_271173_), this.m_214005_()); @@ -124,7 +127,7 @@ } private ServerStatus.Players m_271961_() { -@@ -851,7 +_,8 @@ +@@ -852,7 +_,8 @@ this.m_129890_().m_136128_(); this.f_129754_.m_6182_("levels"); @@ -134,7 +137,7 @@ this.f_129754_.m_6521_(() -> { return serverlevel + " " + serverlevel.m_46472_().m_135782_(); }); -@@ -862,6 +_,7 @@ +@@ -863,6 +_,7 @@ } this.f_129754_.m_6180_("tick"); @@ -142,7 +145,7 @@ try { serverlevel.m_8793_(p_129954_); -@@ -870,16 +_,18 @@ +@@ -871,16 +_,18 @@ serverlevel.m_6026_(crashreport); throw new ReportedException(crashreport); } @@ -162,7 +165,7 @@ GameTestTicker.f_177648_.m_127790_(); } -@@ -961,7 +_,7 @@ +@@ -969,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -171,7 +174,7 @@ } public SystemReport m_177935_(SystemReport p_177936_) { -@@ -1311,6 +_,7 @@ +@@ -1318,6 +_,7 @@ this.m_6846_().m_11315_(); this.f_129734_.m_136120_(this.f_129740_.f_206585_.m_206860_()); this.f_236720_.m_230370_(this.f_129740_.f_206584_); @@ -179,7 +182,7 @@ }, this); if (this.m_18695_()) { this.m_18701_(completablefuture::isDone); -@@ -1320,10 +_,13 @@ +@@ -1327,10 +_,13 @@ } public static WorldDataConfiguration m_246048_(PackRepository p_248681_, DataPackConfig p_248920_, boolean p_249869_, FeatureFlagSet p_251243_) { @@ -195,7 +198,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -1481,6 +_,31 @@ +@@ -1484,6 +_,31 @@ public abstract boolean m_7779_(GameProfile p_129840_); @@ -227,7 +230,7 @@ public void m_142116_(Path p_177911_) throws IOException { } -@@ -1644,6 +_,10 @@ +@@ -1647,6 +_,10 @@ public WorldData m_129910_() { return this.f_129749_; diff --git a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch index 2fa39923cc..f0a1b0998b 100644 --- a/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch +++ b/patches/minecraft/net/minecraft/server/PlayerAdvancements.java.patch @@ -1,33 +1,35 @@ --- a/net/minecraft/server/PlayerAdvancements.java +++ b/net/minecraft/server/PlayerAdvancements.java -@@ -167,6 +_,8 @@ +@@ -171,6 +_,8 @@ } - public boolean m_135988_(Advancement p_135989_, String p_135990_) { + public boolean m_135988_(AdvancementHolder p_298135_, String p_135990_) { + // Forge: don't grant advancements for fake players + if (this.f_135968_ instanceof net.minecraftforge.common.util.FakePlayer) return false; boolean flag = false; - AdvancementProgress advancementprogress = this.m_135996_(p_135989_); + AdvancementProgress advancementprogress = this.m_135996_(p_298135_); boolean flag1 = advancementprogress.m_8193_(); -@@ -174,11 +_,13 @@ - this.m_136008_(p_135989_); - this.f_135967_.add(p_135989_); +@@ -178,6 +_,7 @@ + this.m_136008_(p_298135_); + this.f_135967_.add(p_298135_); flag = true; -+ net.minecraftforge.event.ForgeEventFactory.onAdvancementProgressedEvent(this.f_135968_, p_135989_, advancementprogress, p_135990_, net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent.ProgressType.GRANT); ++ net.minecraftforge.event.ForgeEventFactory.onAdvancementGrant(this.f_135968_, p_298135_, advancementprogress, p_135990_); if (!flag1 && advancementprogress.m_8193_()) { - p_135989_.m_138321_().m_9989_(this.f_135968_); - if (p_135989_.m_138320_() != null && p_135989_.m_138320_().m_14996_() && this.f_135968_.m_9236_().m_46469_().m_46207_(GameRules.f_46153_)) { - this.f_135962_.m_240416_(Component.m_237110_("chat.type.advancement." + p_135989_.m_138320_().m_14992_().m_15548_(), this.f_135968_.m_5446_(), p_135989_.m_138330_()), false); - } -+ net.minecraftforge.event.ForgeEventFactory.onAdvancementEarnedEvent(this.f_135968_, p_135989_); + p_298135_.f_290952_().f_138300_().m_9989_(this.f_135968_); + p_298135_.f_290952_().f_138299_().ifPresent((p_296444_) -> { +@@ -186,6 +_,7 @@ + } + + }); ++ net.minecraftforge.event.ForgeEventFactory.onAdvancementEarned(this.f_135968_, p_298135_); } } -@@ -197,6 +_,7 @@ - this.m_136004_(p_135999_); - this.f_135967_.add(p_135999_); +@@ -204,6 +_,7 @@ + this.m_136004_(p_297905_); + this.f_135967_.add(p_297905_); flag = true; -+ net.minecraftforge.event.ForgeEventFactory.onAdvancementProgressedEvent(this.f_135968_, p_135999_, advancementprogress, p_136000_, net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent.ProgressType.REVOKE); ++ net.minecraftforge.event.ForgeEventFactory.onAdvancementRevoke(this.f_135968_, p_297905_, advancementprogress, p_136000_); } if (flag1 && !advancementprogress.m_8193_()) { diff --git a/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch index edf2ca89f3..fd8fa1299e 100644 --- a/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch +++ b/patches/minecraft/net/minecraft/server/ServerAdvancementManager.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/ServerAdvancementManager.java +++ b/net/minecraft/server/ServerAdvancementManager.java -@@ -26,10 +_,18 @@ - private static final Gson f_136022_ = (new GsonBuilder()).create(); - private AdvancementList f_136023_ = new AdvancementList(); +@@ -29,10 +_,18 @@ + private Map f_136023_ = Map.of(); + private AdvancementTree f_290842_ = new AdvancementTree(); private final LootDataManager f_278379_; + private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context; //Forge: add context @@ -19,16 +19,16 @@ } protected void m_5787_(Map p_136034_, ResourceManager p_136035_, ProfilerFiller p_136036_) { -@@ -37,7 +_,11 @@ - p_136034_.forEach((p_278903_, p_278904_) -> { +@@ -40,7 +_,11 @@ + p_136034_.forEach((p_296449_, p_296450_) -> { try { - JsonObject jsonobject = GsonHelper.m_13918_(p_278904_, "advancement"); -- Advancement.Builder advancement$builder = Advancement.Builder.m_138380_(jsonobject, new DeserializationContext(p_278903_, this.f_278379_)); -+ Advancement.Builder advancement$builder = Advancement.Builder.fromJson(jsonobject, new DeserializationContext(p_278903_, this.f_278379_), this.context); -+ if (advancement$builder == null) { -+ f_136021_.debug("Skipping loading advancement {} as its conditions were not met", p_278903_); + JsonObject jsonobject = GsonHelper.m_13918_(p_296450_, "advancement"); +- Advancement advancement = Advancement.m_294730_(jsonobject, new DeserializationContext(p_296449_, this.f_278379_)); ++ Advancement advancement = Advancement.fromJson(jsonobject, new DeserializationContext(p_296449_, this.f_278379_), this.context); ++ if (advancement == null) { ++ f_136021_.debug("Skipping loading advancement {} as its conditions were not met", p_296449_); + return; + } - map.put(p_278903_, advancement$builder); + builder.put(p_296449_, new AdvancementHolder(p_296449_, advancement)); } catch (Exception exception) { - f_136021_.error("Parsing error loading custom advancement {}: {}", p_278903_, exception.getMessage()); + f_136021_.error("Parsing error loading custom advancement {}: {}", p_296449_, exception.getMessage()); diff --git a/patches/minecraft/net/minecraft/server/advancements/AdvancementVisibilityEvaluator.java.patch b/patches/minecraft/net/minecraft/server/advancements/AdvancementVisibilityEvaluator.java.patch index db82f7700e..5be03f9195 100644 --- a/patches/minecraft/net/minecraft/server/advancements/AdvancementVisibilityEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/server/advancements/AdvancementVisibilityEvaluator.java.patch @@ -1,18 +1,19 @@ --- a/net/minecraft/server/advancements/AdvancementVisibilityEvaluator.java +++ b/net/minecraft/server/advancements/AdvancementVisibilityEvaluator.java -@@ -62,6 +_,15 @@ - m_264402_(advancement, stack, p_265359_, p_265303_); +@@ -64,6 +_,16 @@ + m_264099_(advancementnode, stack, p_265561_, p_265381_); } -+ public static boolean isVisible(Advancement advancement, Predicate test) { ++ public static boolean isVisible(AdvancementNode advancement, Predicate test) { + Stack stack = new ObjectArrayList<>(); + + for(int i = 0; i <= 2; ++i) { + stack.push(AdvancementVisibilityEvaluator.VisibilityRule.NO_CHANGE); + } -+ return m_264402_(advancement.m_264348_(), stack, test, (p_265639_, p_265580_) -> {}); ++ ++ return m_264099_(advancement.m_295389_(), stack, test, (node, currentVis) -> {}); + } + @FunctionalInterface public interface Output { - void m_264135_(Advancement p_265639_, boolean p_265580_); + void m_264135_(AdvancementNode p_298555_, boolean p_265580_); diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index c02078a5f3..127f14c7ea 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -56,7 +56,7 @@ } public void m_5703_(BooleanSupplier p_139661_) { -@@ -492,7 +_,12 @@ +@@ -496,7 +_,12 @@ } public void m_7041_() { diff --git a/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch index 6368a8ef8c..4041345e78 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch @@ -6,5 +6,5 @@ private boolean f_140017_; + LevelChunk currentlyLoading; // Forge: Used to bypass future chain when loading chunks. private CompletableFuture f_142981_ = CompletableFuture.completedFuture((Void)null); + private CompletableFuture f_290310_ = CompletableFuture.completedFuture((Object)null); - public ChunkHolder(ChunkPos p_142986_, int p_142987_, LevelHeightAccessor p_142988_, LevelLightEngine p_142989_, ChunkHolder.LevelChangeListener p_142990_, ChunkHolder.PlayerProvider p_142991_) { diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 908a575135..bb29b447be 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -398,6 +_,7 @@ +@@ -392,6 +_,7 @@ this.f_140140_ = true; } @@ -8,15 +8,15 @@ return p_140179_; } } -@@ -503,6 +_,7 @@ +@@ -497,6 +_,7 @@ if (this.f_140131_.remove(p_140182_, p_140183_) && p_203002_ != null) { if (p_203002_ instanceof LevelChunk) { ((LevelChunk)p_203002_).m_62913_(false); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.level.ChunkEvent.Unload(p_203002_)); ++ net.minecraftforge.event.ForgeEventFactory.onChunkUnload(p_203002_); } this.m_140258_(p_203002_); -@@ -713,8 +_,14 @@ +@@ -707,8 +_,14 @@ levelchunk.m_62952_(); if (this.f_140132_.add(chunkpos.m_45588_())) { levelchunk.m_62913_(true); @@ -24,30 +24,46 @@ + p_140384_.currentlyLoading = levelchunk; // Forge - bypass the future chain when getChunk is called, this prevents deadlocks. levelchunk.m_156369_(); levelchunk.m_187958_(this.f_140133_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.level.ChunkEvent.Load(levelchunk, !(protochunk instanceof ImposterProtoChunk))); ++ net.minecraftforge.event.ForgeEventFactory.onChunkLoad(levelchunk, !(protochunk instanceof ImposterProtoChunk)); + } finally { + p_140384_.currentlyLoading = null; // Forge - Stop bypassing the future chain. + } } return levelchunk; -@@ -819,6 +_,7 @@ +@@ -756,6 +_,7 @@ + for(ServerPlayer serverplayer : this.f_140149_.m_183926_()) { + if (serverplayer.m_292900_().m_293959_(chunkpos)) { + m_296018_(serverplayer, p_299599_); ++ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(serverplayer, p_299599_, this.f_140133_); + } + } + +@@ -823,6 +_,7 @@ this.f_140133_.m_46473_().m_6174_("chunkSave"); CompoundTag compoundtag = ChunkSerializer.m_63454_(this.f_140133_, p_140259_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.level.ChunkDataEvent.Save(p_140259_, p_140259_.getWorldForge() != null ? p_140259_.getWorldForge() : this.f_140133_, compoundtag)); ++ net.minecraftforge.event.ForgeEventFactory.onChunkDataSave(p_140259_, p_140259_.getWorldForge() != null ? p_140259_.getWorldForge() : this.f_140133_, compoundtag); this.m_63502_(chunkpos, compoundtag); this.m_140229_(chunkpos, chunkstatus.m_62494_()); return true; -@@ -889,6 +_,7 @@ - - if (!p_183759_ && p_183758_) { - p_183755_.m_9088_(p_183756_); -+ net.minecraftforge.event.ForgeEventFactory.fireChunkUnWatch(p_183755_, p_183756_, this.f_140133_); - } - +@@ -877,6 +_,7 @@ + LevelChunk levelchunk = this.m_295187_(p_298062_.m_45588_()); + if (levelchunk != null) { + m_296018_(p_297974_, levelchunk); ++ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_297974_, levelchunk, this.f_140133_); } -@@ -1132,7 +_,7 @@ + + } +@@ -1099,6 +_,7 @@ + this.m_294841_(p_301380_, p_296566_); + }, (p_296568_) -> { + m_295122_(p_301380_, p_296568_); ++ net.minecraftforge.event.ForgeEventFactory.fireChunkUnWatch(p_301380_, p_296568_, this.f_140133_); + }); + p_301380_.m_294756_(p_301057_); + } +@@ -1118,7 +_,7 @@ } protected void m_140199_(Entity p_140200_) { @@ -56,11 +72,3 @@ EntityType entitytype = p_140200_.m_6095_(); int i = entitytype.m_20681_() * 16; if (i != 0) { -@@ -1282,6 +_,7 @@ - } - } - -+ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_183761_, p_183763_, this.f_140133_); - } - - protected PoiManager m_140424_() { diff --git a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch index 58a9458b73..797e2d36e3 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -92,10 +_,9 @@ +@@ -95,10 +_,9 @@ if ($$11 instanceof ItemFrame itemframe) { if (this.f_8521_ % 10 == 0) { ItemStack itemstack = itemframe.m_31822_(); @@ -14,7 +14,7 @@ for(ServerPlayer serverplayer : this.f_8509_.m_6907_()) { mapitemsaveddata.m_77918_(serverplayer, itemstack); Packet packet = mapitemsaveddata.m_164796_(integer, serverplayer); -@@ -104,11 +_,12 @@ +@@ -107,11 +_,12 @@ } } } @@ -28,17 +28,17 @@ if (this.f_8521_ % this.f_8511_ == 0 || this.f_8510_.f_19812_ || this.f_8510_.m_20088_().m_135352_()) { if (this.f_8510_.m_20159_()) { -@@ -215,6 +_,7 @@ +@@ -218,6 +_,7 @@ public void m_8534_(ServerPlayer p_8535_) { this.f_8510_.m_6452_(p_8535_); - p_8535_.f_8906_.m_9829_(new ClientboundRemoveEntitiesPacket(this.f_8510_.m_19879_())); + p_8535_.f_8906_.m_141995_(new ClientboundRemoveEntitiesPacket(this.f_8510_.m_19879_())); + net.minecraftforge.event.ForgeEventFactory.onStopEntityTracking(this.f_8510_, p_8535_); } public void m_8541_(ServerPlayer p_8542_) { -@@ -222,6 +_,7 @@ +@@ -225,6 +_,7 @@ this.m_289200_(p_8542_, list::add); - p_8542_.f_8906_.m_9829_(new ClientboundBundlePacket(list)); + p_8542_.f_8906_.m_141995_(new ClientboundBundlePacket(list)); this.f_8510_.m_6457_(p_8542_); + net.minecraftforge.event.ForgeEventFactory.onStartEntityTracking(this.f_8510_, p_8542_); } diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index 47b5810ac1..79fb20fd65 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch @@ -14,15 +14,15 @@ public ServerLevel(MinecraftServer p_214999_, Executor p_215000_, LevelStorageSource.LevelStorageAccess p_215001_, ServerLevelData p_215002_, ResourceKey p_215003_, LevelStem p_215004_, ChunkProgressListener p_215005_, boolean p_215006_, long p_215007_, List p_215008_, boolean p_215009_, @Nullable RandomSequences p_288977_) { super(p_215002_, p_215003_, p_214999_.m_206579_(), p_215004_.f_63975_(), p_214999_::m_129905_, false, p_215006_, p_215007_, p_214999_.m_213994_()); -@@ -240,6 +_,7 @@ - return new RandomSequences(i); - }, "random_sequences"); +@@ -232,6 +_,7 @@ + this.f_286969_ = Objects.requireNonNullElseGet(p_288977_, () -> { + return this.m_8895_().m_164861_(RandomSequences.m_295760_(i), "random_sequences"); }); + this.initCapabilities(); } /** @deprecated */ -@@ -275,8 +_,8 @@ +@@ -267,8 +_,8 @@ int i = this.m_46469_().m_46215_(GameRules.f_151486_); if (this.f_143245_.m_144002_(i) && this.f_143245_.m_144004_(i, this.f_8546_)) { if (this.m_46469_().m_46207_(GameRules.f_46140_)) { @@ -33,7 +33,7 @@ } this.m_8804_(); -@@ -305,7 +_,7 @@ +@@ -297,7 +_,7 @@ this.m_8807_(); this.f_8557_ = false; profilerfiller.m_7238_(); @@ -42,7 +42,7 @@ if (flag) { this.m_8886_(); } -@@ -337,7 +_,9 @@ +@@ -329,7 +_,9 @@ } profilerfiller.m_6180_("tick"); @@ -53,14 +53,14 @@ profilerfiller.m_7238_(); } } -@@ -430,6 +_,7 @@ - BlockPos blockpos1 = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, this.m_46496_(i, 0, j, 15)); - BlockPos blockpos2 = blockpos1.m_7495_(); - Biome biome = this.m_204166_(blockpos1).m_203334_(); -+ if (this.isAreaLoaded(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks - if (biome.m_47477_(this, blockpos2)) { - this.m_46597_(blockpos2, Blocks.f_50126_.m_49966_()); - } +@@ -461,6 +_,7 @@ + BlockPos blockpos = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, p_300602_); + BlockPos blockpos1 = blockpos.m_7495_(); + Biome biome = this.m_204166_(blockpos).m_203334_(); ++ if (this.isAreaLoaded(blockpos1, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks + if (biome.m_47477_(this, blockpos1)) { + this.m_46597_(blockpos1, Blocks.f_50126_.m_49966_()); + } @@ -633,15 +_,19 @@ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); } @@ -108,7 +108,7 @@ + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinLevelEvent(p_8854_, this))) return; Entity entity = this.m_142646_().m_142694_(p_8854_.m_20148_()); if (entity != null) { - f_8566_.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.m_20148_().toString()); + f_8566_.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.m_20148_()); @@ -835,7 +_,8 @@ this.m_143261_((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -180,14 +180,13 @@ this.f_220350_.m_214152_(p_215052_, p_215053_, p_215054_); } -@@ -1380,6 +_,12 @@ +@@ -1380,6 +_,11 @@ }); } + protected void initCapabilities() { + this.gatherCapabilities(); -+ capabilityData = this.m_8895_().m_164861_(e -> net.minecraftforge.common.util.LevelCapabilityData.load(e, getCapabilities()), () -> new net.minecraftforge.common.util.LevelCapabilityData(getCapabilities()), net.minecraftforge.common.util.LevelCapabilityData.ID); -+ capabilityData.setCapabilities(getCapabilities()); ++ capabilityData = net.minecraftforge.common.util.LevelCapabilityData.compute(this.m_8895_(), getCapabilities()); + } + public LevelEntityGetter m_142646_() { diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index 6930720aa3..e7307b909d 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -570,6 +_,7 @@ +@@ -571,6 +_,7 @@ public void m_6667_(DamageSource p_9035_) { this.m_146850_(GameEvent.f_223707_); @@ -8,13 +8,14 @@ boolean flag = this.m_9236_().m_46469_().m_46207_(GameRules.f_46142_); if (flag) { Component component = this.m_21231_().m_19293_(); -@@ -716,11 +_,12 @@ +@@ -717,11 +_,13 @@ } @Nullable - public Entity m_5489_(ServerLevel p_9180_) { + public Entity changeDimension(ServerLevel p_9180_, net.minecraftforge.common.util.ITeleporter teleporter) { -+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_9180_.m_46472_())) return null; ++ if (!net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_9180_.m_46472_())) ++ return null; this.f_8927_ = true; ServerLevel serverlevel = this.m_284548_(); ResourceKey resourcekey = serverlevel.m_46472_(); @@ -23,7 +24,7 @@ this.m_19877_(); this.m_284548_().m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); if (!this.f_8944_) { -@@ -737,13 +_,14 @@ +@@ -738,13 +_,14 @@ PlayerList playerlist = this.f_8924_.m_6846_(); playerlist.m_11289_(this); serverlevel.m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); @@ -41,49 +42,49 @@ this.m_9006_(p_9180_, BlockPos.m_274446_(portalinfo.f_77676_)); } -@@ -755,6 +_,9 @@ +@@ -756,6 +_,9 @@ p_9180_.m_8817_(this); serverlevel.m_46473_().m_7238_(); this.m_9209_(serverlevel); + return this;//forge: this is part of the ITeleporter patch + });//Forge: End vanilla logic + if (e != this) throw new java.lang.IllegalArgumentException(String.format(java.util.Locale.ENGLISH, "Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this)); - this.f_8906_.m_9829_(new ClientboundPlayerAbilitiesPacket(this.m_150110_())); + this.f_8906_.m_141995_(new ClientboundPlayerAbilitiesPacket(this.m_150110_())); playerlist.m_11229_(this, p_9180_); playerlist.m_11292_(this); -@@ -763,10 +_,12 @@ - this.f_8906_.m_9829_(new ClientboundUpdateMobEffectPacket(this.m_19879_(), mobeffectinstance)); +@@ -764,10 +_,12 @@ + this.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(this.m_19879_(), mobeffectinstance)); } + if (teleporter.playTeleportSound(this, serverlevel, p_9180_)) - this.f_8906_.m_9829_(new ClientboundLevelEventPacket(1032, BlockPos.f_121853_, 0, false)); + this.f_8906_.m_141995_(new ClientboundLevelEventPacket(1032, BlockPos.f_121853_, 0, false)); this.f_8920_ = -1; this.f_8917_ = -1.0F; this.f_8918_ = -1; -+ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(this, resourcekey, p_9180_.m_46472_()); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerChangedDimension(this, resourcekey, p_9180_.m_46472_()); } return this; -@@ -830,6 +_,9 @@ +@@ -831,6 +_,9 @@ } public Either m_7720_(BlockPos p_9115_) { -+ java.util.Optional optAt = java.util.Optional.of(p_9115_); -+ Player.BedSleepingProblem ret = net.minecraftforge.event.ForgeEventFactory.onPlayerSleepInBed(this, optAt); ++ var optAt = java.util.Optional.of(p_9115_); ++ var ret = net.minecraftforge.event.ForgeEventFactory.onPlayerSleepInBed(this, optAt); + if (ret != null) return Either.left(ret); Direction direction = this.m_9236_().m_8055_(p_9115_).m_61143_(HorizontalDirectionalBlock.f_54117_); if (!this.m_5803_() && this.m_6084_()) { if (!this.m_9236_().m_6042_().f_63858_()) { -@@ -840,7 +_,7 @@ +@@ -841,7 +_,7 @@ return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } else { this.m_9158_(this.m_9236_().m_46472_(), p_9115_, this.m_146908_(), false, true); - if (this.m_9236_().m_46461_()) { -+ if (!net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, optAt)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, optAt)) { return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { if (!this.m_7500_()) { -@@ -878,6 +_,7 @@ +@@ -879,6 +_,7 @@ } private boolean m_9116_(BlockPos p_9117_, Direction p_9118_) { @@ -91,31 +92,31 @@ return this.m_9222_(p_9117_) || this.m_9222_(p_9117_.m_121945_(p_9118_.m_122424_())); } -@@ -959,6 +_,7 @@ - this.f_8906_.m_9829_(new ClientboundOpenScreenPacket(abstractcontainermenu.f_38840_, abstractcontainermenu.m_6772_(), p_9033_.m_5446_())); +@@ -960,6 +_,7 @@ + this.f_8906_.m_141995_(new ClientboundOpenScreenPacket(abstractcontainermenu.f_38840_, abstractcontainermenu.m_6772_(), p_9033_.m_5446_())); this.m_143399_(abstractcontainermenu); this.f_36096_ = abstractcontainermenu; -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.f_36096_)); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerOpenContainer(this, this.f_36096_); return OptionalInt.of(this.f_8940_); } } -@@ -977,6 +_,7 @@ - this.f_8906_.m_9829_(new ClientboundHorseScreenOpenPacket(this.f_8940_, p_9060_.m_6643_(), p_9059_.m_19879_())); +@@ -978,6 +_,7 @@ + this.f_8906_.m_141995_(new ClientboundHorseScreenOpenPacket(this.f_8940_, p_9060_.m_6643_(), p_9059_.m_19879_())); this.f_36096_ = new HorseInventoryMenu(this.f_8940_, this.m_150109_(), p_9060_, p_9059_); this.m_143399_(this.f_36096_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.f_36096_)); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerOpenContainer(this, this.f_36096_); } public void m_6986_(ItemStack p_9082_, InteractionHand p_9083_) { -@@ -1002,6 +_,7 @@ +@@ -1003,6 +_,7 @@ public void m_9230_() { this.f_36096_.m_6877_(this); this.f_36095_.m_150414_(this.f_36096_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Close(this, this.f_36096_)); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerCloseContainer(this, this.f_36096_); this.f_36096_ = this.f_36095_; } -@@ -1135,6 +_,15 @@ +@@ -1136,6 +_,15 @@ this.m_36362_(p_9016_.m_36331_()); this.m_36364_(p_9016_.m_36332_()); this.m_219749_(p_9016_.m_219759_()); @@ -131,32 +132,24 @@ } protected void m_142540_(MobEffectInstance p_143393_, @Nullable Entity p_143394_) { -@@ -1215,6 +_,8 @@ +@@ -1216,6 +_,7 @@ } public boolean m_143403_(GameType p_143404_) { + p_143404_ = net.minecraftforge.common.ForgeHooks.onChangeGameType(this, this.f_8941_.m_9290_(), p_143404_); -+ if (p_143404_ == null) return false; if (!this.f_8941_.m_143473_(p_143404_)) { return false; } else { -@@ -1282,6 +_,7 @@ - this.f_184127_ = p_9157_.f_195812_(); - this.m_20088_().m_135381_(f_36089_, (byte)p_9157_.f_133867_()); - this.m_20088_().m_135381_(f_36090_, (byte)(p_9157_.f_133868_() == HumanoidArm.LEFT ? 0 : 1)); -+ this.language = p_9157_.f_133863_(); - } - - public boolean m_143432_() { -@@ -1341,6 +_,7 @@ +@@ -1350,6 +_,8 @@ public void m_9213_(@Nullable Entity p_9214_) { Entity entity = this.m_8954_(); this.f_8926_ = (Entity)(p_9214_ == null ? this : p_9214_); -+ while (this.f_8926_ instanceof net.minecraftforge.entity.PartEntity partEntity) this.f_8926_ = partEntity.getParent(); // FORGE: fix MC-46486 ++ while (this.f_8926_ instanceof net.minecraftforge.entity.PartEntity partEntity) ++ this.f_8926_ = partEntity.getParent(); // FORGE: fix MC-46486 if (entity != this.f_8926_) { Level level = this.f_8926_.m_9236_(); if (level instanceof ServerLevel) { -@@ -1380,7 +_,11 @@ +@@ -1389,7 +_,11 @@ @Nullable public Component m_8957_() { @@ -169,16 +162,16 @@ } public void m_6674_(InteractionHand p_9031_) { -@@ -1405,21 +_,23 @@ +@@ -1414,21 +_,23 @@ this.m_8127_(); if (p_9000_ == this.m_9236_()) { this.f_8906_.m_9774_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); - } else { -+ } else if (net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_9000_.m_46472_())) { ++ } else if (!net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_9000_.m_46472_())) { ServerLevel serverlevel = this.m_284548_(); LevelData leveldata = p_9000_.m_6106_(); - this.f_8906_.m_9829_(new ClientboundRespawnPacket(p_9000_.m_220362_(), p_9000_.m_46472_(), BiomeManager.m_47877_(p_9000_.m_7328_()), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), p_9000_.m_46659_(), p_9000_.m_8584_(), (byte)3, this.m_219759_(), this.m_287157_())); - this.f_8906_.m_9829_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); + this.f_8906_.m_141995_(new ClientboundRespawnPacket(this.m_292591_(p_9000_), (byte)3)); + this.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); this.f_8924_.m_6846_().m_11289_(this); serverlevel.m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); - this.m_146912_(); @@ -191,38 +184,39 @@ + this.f_8941_.m_9260_(p_9000_); this.f_8924_.m_6846_().m_11229_(this, p_9000_); this.f_8924_.m_6846_().m_11292_(this); -+ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(this, serverlevel.m_46472_(), p_9000_.m_46472_()); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerChangedDimension(this, serverlevel.m_46472_(), p_9000_.m_46472_()); } } -@@ -1442,6 +_,7 @@ +@@ -1451,6 +_,8 @@ } public void m_9158_(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, p_9160_ == null ? Level.f_46428_ : p_9159_, p_9160_, p_9162_)) return; ++ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, p_9160_ == null ? Level.f_46428_ : p_9159_, p_9160_, p_9162_)) ++ return; if (p_9160_ != null) { boolean flag = p_9160_.equals(this.f_8936_) && p_9159_.equals(this.f_8935_); if (p_9163_ && !flag) { -@@ -1493,6 +_,8 @@ +@@ -1499,6 +_,9 @@ if (itementity == null) { return null; } else { -+ if (captureDrops() != null) captureDrops().add(itementity); ++ if (captureDrops() != null) ++ captureDrops().add(itementity); + else this.m_9236_().m_7967_(itementity); ItemStack itemstack = itementity.m_32055_(); if (p_9087_) { -@@ -1507,6 +_,76 @@ +@@ -1513,6 +_,75 @@ } } -+ private String language = "en_us"; + /** + * Returns the language last reported by the player as their local language. + * Defaults to en_us if the value is unknown. + */ + public String getLanguage() { -+ return this.language; ++ return this.f_290755_; + } + + private Component tabListHeader = Component.m_237119_(); @@ -269,7 +263,7 @@ + this.tabListHeader = java.util.Objects.requireNonNull(header, "header"); + this.tabListFooter = java.util.Objects.requireNonNull(footer, "footer"); + -+ this.f_8906_.m_9829_(new net.minecraft.network.protocol.game.ClientboundTabListPacket(header, footer)); ++ this.f_8906_.m_141995_(new net.minecraft.network.protocol.game.ClientboundTabListPacket(header, footer)); + } + + // We need this as tablistDisplayname may be null even if the event was fired. @@ -289,7 +283,7 @@ public TextFilter m_8967_() { return this.f_8939_; } -@@ -1566,11 +_,14 @@ +@@ -1572,11 +_,14 @@ public boolean m_182294_(boolean p_182295_) { Inventory inventory = this.m_150109_(); diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 1a56c7aaff..a1d17a959d 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -12,7 +12,7 @@ + if (!this.f_9245_.canReach(p_215120_, 1.5)) { // Vanilla check is eye-to-center distance < 6, so padding is 6 - 4.5 = 1.5 this.m_215125_(p_215120_, false, p_215124_, "too far"); } else if (p_215120_.m_123342_() >= p_215123_) { - this.f_9245_.f_8906_.m_9829_(new ClientboundBlockUpdatePacket(p_215120_, this.f_9244_.m_8055_(p_215120_))); + this.f_9245_.f_8906_.m_141995_(new ClientboundBlockUpdatePacket(p_215120_, this.f_9244_.m_8055_(p_215120_))); @@ -152,6 +_,7 @@ float f = 1.0F; BlockState blockstate = this.f_9244_.m_8055_(p_215120_); diff --git a/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch index 841d455e1c..defd7a13f8 100644 --- a/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java +++ b/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java -@@ -16,6 +_,7 @@ +@@ -17,6 +_,7 @@ } public void m_7322_(ClientIntentionPacket p_9697_) { + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9697_, this.f_9689_)) return; - this.f_9689_.m_129498_(p_9697_.m_134735_()); - this.f_9689_.m_129505_(new ServerLoginPacketListenerImpl(this.f_9688_, this.f_9689_)); - } + if (p_9697_.f_134723_() != ClientIntent.LOGIN) { + throw new UnsupportedOperationException("Invalid intention " + p_9697_.f_134723_()); + } else { diff --git a/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch new file mode 100644 index 0000000000..3c71309ff8 --- /dev/null +++ b/patches/minecraft/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +@@ -66,6 +_,7 @@ + } + + public void m_293234_(ServerboundCustomPayloadPacket p_300164_) { ++ net.minecraftforge.network.NetworkHooks.onCustomPayload(p_300164_, this.f_291338_); + } + + public void m_293248_(ServerboundResourcePackPacket p_300656_) { +@@ -147,5 +_,9 @@ + + protected CommonListenerCookie m_295477_(ClientInformation p_297318_) { + return new CommonListenerCookie(this.m_293343_(), this.f_291042_, p_297318_); ++ } ++ ++ public Connection getConnection() { ++ return this.f_291338_; + } + } diff --git a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch index 7338d6507f..1c99db8b9b 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/server/network/ServerConnectionListener.java +++ b/net/minecraft/server/network/ServerConnectionListener.java -@@ -47,11 +_,12 @@ +@@ -49,11 +_,12 @@ public class ServerConnectionListener { private static final Logger f_9701_ = LogUtils.getLogger(); + private static final int READ_TIMEOUT = Integer.parseInt(System.getProperty("forge.readTimeout", "30")); - public static final LazyLoadedValue f_9698_ = new LazyLoadedValue<>(() -> { + public static final Supplier f_9698_ = Suppliers.memoize(() -> { - return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).build()); + return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).build()); }); - public static final LazyLoadedValue f_9699_ = new LazyLoadedValue<>(() -> { + public static final Supplier f_9699_ = Suppliers.memoize(() -> { - return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build()); + return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setThreadFactory(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER).build()); }); final MinecraftServer f_9702_; public volatile boolean f_9700_; -@@ -64,6 +_,8 @@ +@@ -66,6 +_,8 @@ } public void m_9711_(@Nullable InetAddress p_9712_, int p_9713_) throws IOException { @@ -23,13 +23,13 @@ + net.minecraftforge.network.DualStackUtils.checkIPv6(p_9712_); synchronized(this.f_9703_) { Class oclass; - LazyLoadedValue lazyloadedvalue; -@@ -84,7 +_,7 @@ + EventLoopGroup eventloopgroup; +@@ -88,7 +_,7 @@ } catch (ChannelException channelexception) { } -- ChannelPipeline channelpipeline = p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this)); -+ ChannelPipeline channelpipeline = p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(READ_TIMEOUT)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this)); - Connection.m_264299_(channelpipeline, PacketFlow.SERVERBOUND); +- ChannelPipeline channelpipeline = p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this.m_9722_())); ++ ChannelPipeline channelpipeline = p_9729_.pipeline().addLast("timeout", new ReadTimeoutHandler(READ_TIMEOUT)).addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this.m_9722_())); + Connection.m_264299_(channelpipeline, PacketFlow.SERVERBOUND, (BandwidthDebugMonitor)null); int i = ServerConnectionListener.this.f_9702_.m_7032_(); Connection connection = (Connection)(i > 0 ? new RateKickingConnection(i) : new Connection(PacketFlow.SERVERBOUND)); diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 6d2182e02e..21525d5104 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -185,6 +_,12 @@ - public class ServerGamePacketListenerImpl implements ServerPlayerConnection, TickablePacketListener, ServerGamePacketListener { +@@ -179,6 +_,12 @@ + + public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener { static final Logger f_9744_ = LogUtils.getLogger(); - private static final int f_143608_ = 15000; + /** + * Forge: Deprecated in favor of range/reach attributes. + * @see net.minecraftforge.common.ForgeMod#BLOCK_REACH @@ -13,7 +13,7 @@ public static final double f_215198_ = Mth.m_144952_(6.0D); private static final int f_215199_ = -1; private static final int f_244471_ = 4096; -@@ -436,9 +_,11 @@ +@@ -413,9 +_,11 @@ } entity.m_19890_(d3, d4, d5, f, f1); @@ -22,10 +22,10 @@ if (flag && (flag2 || !flag3)) { entity.m_19890_(d0, d1, d2, f, f1); + this.f_9743_.m_19890_(d3, d4, d5, this.f_9743_.m_146908_(), this.f_9743_.m_146909_()); // Forge - Resync player position on vehicle moving - this.f_9742_.m_129512_(new ClientboundMoveVehiclePacket(entity)); + this.m_141995_(new ClientboundMoveVehiclePacket(entity)); return; } -@@ -983,8 +_,10 @@ +@@ -960,8 +_,10 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.f_9743_.m_5833_()) { ItemStack itemstack = this.f_9743_.m_21120_(InteractionHand.OFF_HAND); @@ -38,7 +38,7 @@ this.f_9743_.m_5810_(); } -@@ -1035,7 +_,7 @@ +@@ -1012,7 +_,7 @@ Vec3 vec3 = blockhitresult.m_82450_(); BlockPos blockpos = blockhitresult.m_82425_(); Vec3 vec31 = Vec3.m_82512_(blockpos); @@ -47,7 +47,7 @@ Vec3 vec32 = vec3.m_82546_(vec31); double d0 = 1.0000001D; if (Math.abs(vec32.m_7096_()) < 1.0000001D && Math.abs(vec32.m_7098_()) < 1.0000001D && Math.abs(vec32.m_7094_()) < 1.0000001D) { -@@ -1043,7 +_,7 @@ +@@ -1020,7 +_,7 @@ this.f_9743_.m_9243_(); int i = this.f_9743_.m_9236_().m_151558_(); if (blockpos.m_123342_() < i) { @@ -56,23 +56,19 @@ InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult); if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) { Component component = Component.m_237110_("build.tooHigh", i - 1).m_130940_(ChatFormatting.RED); -@@ -1187,10 +_,13 @@ +@@ -1135,9 +_,10 @@ } CompletableFuture completablefuture = this.m_243132_(playerchatmessage.m_245728_()); -- CompletableFuture completablefuture1 = this.f_9745_.m_236742_().m_236961_(this.f_9743_, playerchatmessage.m_245692_()); -+ CompletableFuture completablefuture1 = net.minecraftforge.common.ForgeHooks.getServerChatSubmittedDecorator().m_236961_(this.f_9743_, playerchatmessage.m_245692_()); - this.f_241681_.m_241849_((p_248212_) -> { - return CompletableFuture.allOf(completablefuture, completablefuture1).thenAcceptAsync((p_248218_) -> { -- PlayerChatMessage playerchatmessage1 = playerchatmessage.m_241956_(completablefuture1.join()).m_243072_(completablefuture.join().f_243010_()); -+ Component decoratedContent = completablefuture1.join(); -+ if (decoratedContent == null) -+ return; // Forge: ServerChatEvent was canceled if this is null. -+ PlayerChatMessage playerchatmessage1 = playerchatmessage.m_241956_(decoratedContent).m_243072_(completablefuture.join().f_243010_()); +- Component component = this.f_291389_.m_236742_().m_236961_(this.f_9743_, playerchatmessage.m_245692_()); ++ Component component = net.minecraftforge.common.ForgeHooks.onServerChatSubmittedEvent(this.f_9743_, playerchatmessage.m_245692_()); + this.f_241681_.m_241849_((p_296593_) -> { + return completablefuture.thenAcceptAsync((p_296589_) -> { ++ if (component == null) return; + PlayerChatMessage playerchatmessage1 = playerchatmessage.m_241956_(component).m_243072_(p_296589_.f_243010_()); this.m_243086_(playerchatmessage1); - }, p_248212_); - }); -@@ -1440,7 +_,7 @@ + }, p_296593_); +@@ -1398,7 +_,7 @@ } AABB aabb = entity.m_20191_(); @@ -81,7 +77,7 @@ p_9866_.m_179617_(new ServerboundInteractPacket.Handler() { private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) { ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_); -@@ -1463,6 +_,8 @@ +@@ -1421,6 +_,8 @@ public void m_142143_(InteractionHand p_143682_, Vec3 p_143683_) { this.m_143678_(p_143682_, (p_143686_, p_143687_, p_143688_) -> { @@ -90,11 +86,3 @@ return p_143687_.m_7111_(p_143686_, p_143683_, p_143688_); }); } -@@ -1659,6 +_,7 @@ - } - - public void m_7423_(ServerboundCustomPayloadPacket p_9860_) { -+ net.minecraftforge.network.NetworkHooks.onCustomPayload(p_9860_, this.f_9742_); - } - - public void m_7477_(ServerboundChangeDifficultyPacket p_9839_) { diff --git a/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch index 987e3c0daf..db53a3a968 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -5,13 +5,13 @@ public void m_7322_(ClientIntentionPacket p_9975_) { + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9975_, this.f_9966_)) return; - switch (p_9975_.m_134735_()) { + switch (p_9975_.f_134723_()) { case LOGIN: - this.f_9966_.m_129498_(ConnectionProtocol.LOGIN); + this.f_9966_.m_294993_(ClientIntent.LOGIN); @@ -42,7 +_,7 @@ ServerStatus serverstatus = this.f_9965_.m_129928_(); if (this.f_9965_.m_6373_() && serverstatus != null) { - this.f_9966_.m_129498_(ConnectionProtocol.STATUS); + this.f_9966_.m_294993_(ClientIntent.STATUS); - this.f_9966_.m_129505_(new ServerStatusPacketListenerImpl(serverstatus, this.f_9966_)); + this.f_9966_.m_129505_(new ServerStatusPacketListenerImpl(serverstatus, this.f_9966_, this.f_9965_.getStatusJson())); } else { diff --git a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 881cf045f4..e4efd7b764 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,84 +1,77 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -60,7 +_,13 @@ +@@ -62,7 +_,10 @@ } public void m_9933_() { -- if (this.f_10019_ == ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT) { -+ if (this.f_10019_ == State.NEGOTIATING) { -+ // We force the state into "NEGOTIATING" which is otherwise unused. Once we're completed we move the negotiation onto "READY_TO_ACCEPT" -+ // Might want to promote player object creation to here as well.. -+ boolean negotiationComplete = net.minecraftforge.network.NetworkHooks.tickNegotiation(this, this.f_10013_, this.f_10024_); -+ if (negotiationComplete) -+ this.f_10019_ = State.READY_TO_ACCEPT; -+ } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT) { - this.m_10055_(); - } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.DELAY_ACCEPT) { - ServerPlayer serverplayer = this.f_10018_.m_6846_().m_11259_(this.f_10021_.getId()); -@@ -138,7 +_,8 @@ - } +- if (this.f_10019_ == ServerLoginPacketListenerImpl.State.VERIFYING) { ++ if (this.f_10019_ == State.NEGOTIATING) { //TODO: Redesign with new protocol switching Mojang added ++ if (net.minecraftforge.network.NetworkHooks.tickNegotiation(this.f_10013_)) ++ this.f_10019_ = State.VERIFYING; ++ } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.VERIFYING) { + this.m_294778_(Objects.requireNonNull(this.f_291112_)); + } + +@@ -101,7 +_,7 @@ public String m_10056_() { -- return this.f_10021_ != null ? this.f_10021_ + " (" + this.f_10013_.m_129523_() + ")" : String.valueOf((Object)this.f_10013_.m_129523_()); -+ final String addressString = net.minecraftforge.network.DualStackUtils.getAddressString(this.f_10013_.m_129523_()); -+ return this.f_10021_ != null ? this.f_10021_ + " (" + addressString + ")" : addressString; + String s = this.f_10013_.m_295656_(this.f_10018_.m_292975_()); +- return this.f_291165_ != null ? this.f_291165_ + " (" + s + ")" : s; ++ return this.f_291112_ != null ? this.f_291112_ + " (" + s + ")" : s; } public void m_5990_(ServerboundHelloPacket p_10047_) { -@@ -147,14 +_,14 @@ +@@ -110,13 +_,13 @@ + this.f_291165_ = p_10047_.f_238040_(); GameProfile gameprofile = this.f_10018_.m_236731_(); - if (gameprofile != null && p_10047_.f_238040_().equalsIgnoreCase(gameprofile.getName())) { - this.f_10021_ = gameprofile; -- this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; + if (gameprofile != null && this.f_291165_.equalsIgnoreCase(gameprofile.getName())) { +- this.m_294008_(gameprofile); + this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; // FORGE: continue NEGOTIATING, we move to READY_TO_ACCEPT after Forge is ready } else { - this.f_10021_ = new GameProfile((UUID)null, p_10047_.f_238040_()); if (this.f_10018_.m_129797_() && !this.f_10013_.m_129531_()) { this.f_10019_ = ServerLoginPacketListenerImpl.State.KEY; this.f_10013_.m_129512_(new ClientboundHelloPacket("", this.f_10018_.m_129790_().getPublic().getEncoded(), this.f_252396_)); } else { -- this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; +- this.m_294008_(m_295545_(this.f_291165_)); + this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; // FORGE: continue NEGOTIATING, we move to READY_TO_ACCEPT after Forge is ready } } -@@ -186,7 +_,7 @@ +@@ -180,7 +_,7 @@ throw new IllegalStateException("Protocol error", cryptexception); } - Thread thread = new Thread("User Authenticator #" + f_10014_.incrementAndGet()) { + Thread thread = new Thread(net.minecraftforge.fml.util.thread.SidedThreadGroups.SERVER, "User Authenticator #" + f_10014_.incrementAndGet()) { public void run() { - GameProfile gameprofile = ServerLoginPacketListenerImpl.this.f_10021_; + String s1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.f_291165_, "Player name not initialized"); -@@ -194,11 +_,11 @@ - ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.f_10018_.m_129925_().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.m_10064_()); - if (ServerLoginPacketListenerImpl.this.f_10021_ != null) { - ServerLoginPacketListenerImpl.f_10015_.info("UUID of player {} is {}", ServerLoginPacketListenerImpl.this.f_10021_.getName(), ServerLoginPacketListenerImpl.this.f_10021_.getId()); -- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; -+ ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; // FORGE: continue NEGOTIATING, we move to READY_TO_ACCEPT after Forge is ready - } else if (ServerLoginPacketListenerImpl.this.f_10018_.m_129792_()) { - ServerLoginPacketListenerImpl.f_10015_.warn("Failed to verify username but will let them in anyway!"); - ServerLoginPacketListenerImpl.this.f_10021_ = gameprofile; -- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; -+ ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; // FORGE: continue NEGOTIATING, we move to READY_TO_ACCEPT after Forge is ready - } else { - ServerLoginPacketListenerImpl.this.m_10053_(Component.m_237115_("multiplayer.disconnect.unverified_username")); - ServerLoginPacketListenerImpl.f_10015_.error("Username '{}' tried to join with an invalid session", (Object)gameprofile.getName()); -@@ -207,7 +_,7 @@ +@@ -200,7 +_,7 @@ + } catch (AuthenticationUnavailableException authenticationunavailableexception) { if (ServerLoginPacketListenerImpl.this.f_10018_.m_129792_()) { ServerLoginPacketListenerImpl.f_10015_.warn("Authentication servers are down but will let them in anyway!"); - ServerLoginPacketListenerImpl.this.f_10021_ = gameprofile; -- ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT; +- ServerLoginPacketListenerImpl.this.m_294008_(ServerLoginPacketListenerImpl.m_295545_(s1)); + ServerLoginPacketListenerImpl.this.f_10019_ = ServerLoginPacketListenerImpl.State.NEGOTIATING; // FORGE: continue NEGOTIATING, we move to READY_TO_ACCEPT after Forge is ready } else { ServerLoginPacketListenerImpl.this.m_10053_(Component.m_237115_("multiplayer.disconnect.authservers_down")); ServerLoginPacketListenerImpl.f_10015_.error("Couldn't verify username because servers are unavailable"); -@@ -227,6 +_,7 @@ +@@ -220,6 +_,7 @@ } - public void m_7223_(ServerboundCustomQueryPacket p_10045_) { -+ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_10045_, this.f_10013_)) - this.m_10053_(Component.m_237115_("multiplayer.disconnect.unexpected_query_response")); + public void m_10044_(ServerboundCustomQueryAnswerPacket p_297965_) { ++ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_297965_, this.f_10013_)) + this.m_10053_(f_291075_); } +@@ -230,6 +_,11 @@ + this.f_10013_.m_129505_(serverconfigurationpacketlistenerimpl); + serverconfigurationpacketlistenerimpl.m_294295_(); + this.f_10019_ = ServerLoginPacketListenerImpl.State.ACCEPTED; ++ } ++ ++ @Nullable ++ public GameProfile getAuthenticatedProfile() { ++ return this.f_291112_; + } + + protected static GameProfile m_295545_(String p_297551_) { diff --git a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch deleted file mode 100644 index 0d2ce817fe..0000000000 --- a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java -+++ b/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java -@@ -7,17 +_,29 @@ - public static final MetadataSectionType f_243696_ = new PackMetadataSectionSerializer(); - private final Component f_10367_; - private final int f_10368_; -+ private final java.util.Map packTypeVersions; - - public PackMetadataSection(Component p_10371_, int p_10372_) { - this.f_10367_ = p_10371_; - this.f_10368_ = p_10372_; -+ this.packTypeVersions = java.util.Map.of(); -+ } -+ public PackMetadataSection(Component p_10371_, int p_10372_, java.util.Map packTypeVersions) { -+ this.f_10367_ = p_10371_; -+ this.f_10368_ = p_10372_; -+ this.packTypeVersions = packTypeVersions; - } - - public Component m_10373_() { - return this.f_10367_; - } - -+ /** @deprecated Forge: Use {@link #getPackFormat(net.minecraft.server.packs.PackType)} instead.*/ -+ @Deprecated - public int m_10374_() { - return this.f_10368_; -+ } -+ public int getPackFormat(net.minecraft.server.packs.PackType packType) { -+ return packTypeVersions.getOrDefault(packType, this.f_10368_); - } - } diff --git a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java.patch b/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java.patch deleted file mode 100644 index 3276770081..0000000000 --- a/patches/minecraft/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java -+++ b/net/minecraft/server/packs/metadata/pack/PackMetadataSectionSerializer.java -@@ -13,7 +_,7 @@ - throw new JsonParseException("Invalid/missing description!"); - } else { - int i = GsonHelper.m_13927_(p_10380_, "pack_format"); -- return new PackMetadataSection(component, i); -+ return new PackMetadataSection(component, i, net.minecraftforge.common.ForgeHooks.readTypedPackFormats(p_10380_)); - } - } - -@@ -21,6 +_,7 @@ - JsonObject jsonobject = new JsonObject(); - jsonobject.add("description", Component.Serializer.m_130716_(p_250206_.m_10373_())); - jsonobject.addProperty("pack_format", p_250206_.m_10374_()); -+ net.minecraftforge.common.ForgeHooks.writeTypedPackFormats(jsonobject, p_250206_); - return jsonobject; - } - diff --git a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch index 612561ee8d..68cbca2c1f 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/repository/Pack.java +++ b/net/minecraft/server/packs/repository/Pack.java -@@ -27,6 +_,7 @@ +@@ -28,6 +_,7 @@ private final Pack.Position f_10406_; private final boolean f_10407_; private final boolean f_10408_; @@ -16,42 +16,35 @@ } @Nullable -@@ -62,7 +_,8 @@ - } else { - FeatureFlagsMetadataSection featureflagsmetadatasection = packresources.m_5550_(FeatureFlagsMetadataSection.f_244642_); - FeatureFlagSet featureflagset = featureflagsmetadatasection != null ? featureflagsmetadatasection.f_244197_() : FeatureFlagSet.m_246902_(); -- return new Pack.Info(packmetadatasection.m_10373_(), packmetadatasection.m_10374_(), featureflagset); -+ // Forge: Allow separate pack formats for server data and client resources and setting isHidden -+ return new Pack.Info(packmetadatasection.m_10373_(), packmetadatasection.getPackFormat(PackType.SERVER_DATA), packmetadatasection.getPackFormat(PackType.CLIENT_RESOURCES), featureflagset, packresources.isHidden()); +@@ -66,7 +_,7 @@ + PackCompatibility packcompatibility = PackCompatibility.m_295204_(inclusiverange, p_299232_); + OverlayMetadataSection overlaymetadatasection = packresources.m_5550_(OverlayMetadataSection.f_290597_); + List list = overlaymetadatasection != null ? overlaymetadatasection.m_293385_(p_299232_) : List.of(); +- return new Pack.Info(packmetadatasection.f_10367_(), packcompatibility, featureflagset, list); ++ return new Pack.Info(packmetadatasection.f_10367_(), packcompatibility, featureflagset, list, packresources.isHidden()); } } catch (Exception exception) { - f_10399_.warn("Failed to read pack metadata", (Throwable)exception); -@@ -116,6 +_,8 @@ + f_10399_.warn("Failed to read pack {} metadata", p_250591_, exception); +@@ -135,6 +_,10 @@ return this.f_10409_; } -+ public boolean isHidden() { return hidden; } ++ public boolean isHidden() { ++ return hidden; ++ } + public boolean equals(Object p_10448_) { if (this == p_10448_) { return true; -@@ -131,9 +_,17 @@ +@@ -150,7 +_,10 @@ return this.f_10401_.hashCode(); } -- public static record Info(Component f_244592_, int f_244194_, FeatureFlagSet f_244041_) { -+ public static record Info(Component f_244592_, int dataFormat, int resourceFormat, FeatureFlagSet f_244041_, boolean hidden) { -+ public Info(Component f_244592_, int f_244194_, FeatureFlagSet f_244041_) { -+ this(f_244592_, f_244194_, f_244194_, f_244041_, false); +- public static record Info(Component f_244592_, PackCompatibility f_290856_, FeatureFlagSet f_244041_, List f_291122_) { ++ public static record Info(Component f_244592_, PackCompatibility f_290856_, FeatureFlagSet f_244041_, List f_291122_, boolean hidden) { ++ public Info(Component f_244592_, PackCompatibility f_290856_, FeatureFlagSet f_244041_, List f_291122_) { ++ this(f_244592_, f_290856_, f_244041_, f_291122_, false); + } -+ -+ public int getFormat(PackType type) { -+ return type == PackType.SERVER_DATA ? this.dataFormat : this.resourceFormat; -+ } -+ - public PackCompatibility m_246438_(PackType p_249204_) { -- return PackCompatibility.m_143882_(this.f_244194_, p_249204_); -+ return PackCompatibility.m_143882_(getFormat(p_249204_), p_249204_); - } } + public static enum Position { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch index c47942149e..a93bf33890 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/ServerPacksSource.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/server/packs/repository/ServerPacksSource.java +++ b/net/minecraft/server/packs/repository/ServerPacksSource.java -@@ -48,7 +_,9 @@ +@@ -50,7 +_,9 @@ } - public static PackRepository m_245786_(Path p_251569_) { -- return new PackRepository(new ServerPacksSource(), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.f_10529_)); -+ final PackRepository packRepository = new PackRepository(new ServerPacksSource(), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.f_10529_)); -+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(PackType.SERVER_DATA, packRepository::addPackFinder)); -+ return packRepository; + public static PackRepository m_245786_(Path p_251569_, DirectoryValidator p_300268_) { +- return new PackRepository(new ServerPacksSource(p_300268_), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.f_10529_, p_300268_)); ++ var ret = new PackRepository(new ServerPacksSource(p_300268_), new FolderRepositorySource(p_251569_, PackType.SERVER_DATA, PackSource.f_10529_, p_300268_)); ++ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.event.AddPackFindersEvent(PackType.SERVER_DATA, ret::addPackFinder)); ++ return ret; } - public static PackRepository m_247728_(LevelStorageSource.LevelStorageAccess p_250213_) { + public static PackRepository m_293411_() { diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 78abcbebf6..88f263d740 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -132,6 +_,7 @@ +@@ -126,6 +_,7 @@ private boolean f_11209_; private static final boolean f_143988_ = false; private int f_11210_; @@ -8,31 +8,23 @@ public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, int p_203845_) { this.f_11195_ = p_203842_; -@@ -167,13 +_,14 @@ - p_11263_.m_284127_(serverlevel1); - String s1 = "local"; - if (p_11262_.m_129523_() != null) { -- s1 = p_11262_.m_129523_().toString(); -+ s1 = net.minecraftforge.network.DualStackUtils.getAddressString(p_11262_.m_129523_()); - } - - f_11188_.info("{}[{}] logged in with entity id {} at ({}, {}, {})", p_11263_.m_7755_().getString(), s1, p_11263_.m_19879_(), p_11263_.m_20185_(), p_11263_.m_20186_(), p_11263_.m_20189_()); +@@ -163,6 +_,7 @@ LevelData leveldata = serverlevel1.m_6106_(); p_11263_.m_143427_(compoundtag); - ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.f_11195_, p_11262_, p_11263_); + ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.f_11195_, p_11262_, p_11263_, p_297215_); + net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(p_11262_, "PLAY_TO_CLIENT"); GameRules gamerules = serverlevel1.m_46469_(); boolean flag = gamerules.m_46207_(GameRules.f_46156_); boolean flag1 = gamerules.m_46207_(GameRules.f_46145_); -@@ -183,6 +_,7 @@ - servergamepacketlistenerimpl.m_9829_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); - servergamepacketlistenerimpl.m_9829_(new ClientboundPlayerAbilitiesPacket(p_11263_.m_150110_())); - servergamepacketlistenerimpl.m_9829_(new ClientboundSetCarriedItemPacket(p_11263_.m_150109_().f_35977_)); +@@ -171,6 +_,7 @@ + servergamepacketlistenerimpl.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); + servergamepacketlistenerimpl.m_141995_(new ClientboundPlayerAbilitiesPacket(p_11263_.m_150110_())); + servergamepacketlistenerimpl.m_141995_(new ClientboundSetCarriedItemPacket(p_11263_.m_150109_().f_35977_)); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, p_11263_)); - servergamepacketlistenerimpl.m_9829_(new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_())); - servergamepacketlistenerimpl.m_9829_(new ClientboundUpdateTagsPacket(TagNetworkSerialization.m_245799_(this.f_243858_))); + servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_())); this.m_11289_(p_11263_); -@@ -255,6 +_,7 @@ + p_11263_.m_8951_().m_12850_(); +@@ -239,6 +_,7 @@ } p_11263_.m_143429_(); @@ -40,7 +32,7 @@ } protected void m_11273_(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -315,6 +_,7 @@ +@@ -299,6 +_,7 @@ compoundtag1 = compoundtag; p_11225_.m_20258_(compoundtag); f_11188_.debug("loading single player"); @@ -48,7 +40,7 @@ } else { compoundtag1 = this.f_11204_.m_78435_(p_11225_); } -@@ -323,6 +_,7 @@ +@@ -307,6 +_,7 @@ } protected void m_6765_(ServerPlayer p_11277_) { @@ -56,7 +48,7 @@ this.f_11204_.m_78433_(p_11277_); ServerStatsCounter serverstatscounter = this.f_11202_.get(p_11277_.m_20148_()); if (serverstatscounter != null) { -@@ -337,6 +_,7 @@ +@@ -321,6 +_,7 @@ } public void m_11286_(ServerPlayer p_11287_) { @@ -64,15 +56,15 @@ ServerLevel serverlevel = p_11287_.m_284548_(); p_11287_.m_36220_(Stats.f_12989_); this.m_6765_(p_11287_); -@@ -478,6 +_,7 @@ +@@ -466,6 +_,7 @@ this.f_11197_.put(serverplayer.m_20148_(), serverplayer); serverplayer.m_143429_(); serverplayer.m_21153_(serverplayer.m_21223_()); + net.minecraftforge.event.ForgeEventFactory.firePlayerRespawnEvent(serverplayer, p_11238_); if (flag2) { - serverplayer.f_8906_.m_9829_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)blockpos.m_123341_(), (double)blockpos.m_123342_(), (double)blockpos.m_123343_(), 1.0F, 1.0F, serverlevel1.m_213780_().m_188505_())); + serverplayer.f_8906_.m_141995_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)blockpos.m_123341_(), (double)blockpos.m_123342_(), (double)blockpos.m_123343_(), 1.0F, 1.0F, serverlevel1.m_213780_().m_188505_())); } -@@ -562,6 +_,7 @@ +@@ -550,6 +_,7 @@ } public void m_5749_(GameProfile p_11254_) { @@ -80,7 +72,7 @@ this.f_11200_.m_11381_(new ServerOpListEntry(p_11254_, this.f_11195_.m_7022_(), this.f_11200_.m_11351_(p_11254_))); ServerPlayer serverplayer = this.m_11259_(p_11254_.getId()); if (serverplayer != null) { -@@ -571,6 +_,7 @@ +@@ -559,6 +_,7 @@ } public void m_5750_(GameProfile p_11281_) { @@ -88,7 +80,7 @@ this.f_11200_.m_11393_(p_11281_); ServerPlayer serverplayer = this.m_11259_(p_11281_.getId()); if (serverplayer != null) { -@@ -785,13 +_,6 @@ +@@ -773,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.f_11195_.m_129843_(LevelResource.f_78175_).toFile(); File file2 = new File(file1, uuid + ".json"); @@ -102,7 +94,7 @@ serverstatscounter = new ServerStatsCounter(this.f_11195_, file2); this.f_11202_.put(uuid, serverstatscounter); -@@ -809,6 +_,8 @@ +@@ -797,6 +_,8 @@ this.f_11203_.put(uuid, playeradvancements); } @@ -111,7 +103,7 @@ playeradvancements.m_135979_(p_11297_); return playeradvancements; } -@@ -838,7 +_,7 @@ +@@ -826,7 +_,7 @@ } public List m_11314_() { @@ -120,7 +112,7 @@ } @Nullable -@@ -855,6 +_,7 @@ +@@ -843,6 +_,7 @@ playeradvancements.m_135981_(this.f_11195_.m_129889_()); } diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index 6ea5c4239a..82e19ead21 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -182,4 +_,8 @@ +@@ -184,4 +_,8 @@ private static TagKey m_203846_(String p_203847_) { return TagKey.m_203882_(Registries.f_256747_, new ResourceLocation(p_203847_)); } diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch index 46e5798b61..63839f15b7 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java @@ -17,7 +_,7 @@ + import net.minecraft.world.entity.ai.attributes.AttributeMap; import net.minecraft.world.entity.ai.attributes.AttributeModifier; - import net.minecraft.world.entity.player.Player; -public class MobEffect { +public class MobEffect implements net.minecraftforge.common.extensions.IForgeMobEffect { - private final Map f_19446_ = Maps.newHashMap(); + private final Map f_19446_ = Maps.newHashMap(); private final MobEffectCategory f_19447_; private final int f_19448_; -@@ -43,6 +_,7 @@ +@@ -31,6 +_,7 @@ protected MobEffect(MobEffectCategory p_19451_, int p_19452_) { this.f_19447_ = p_19451_; this.f_19448_ = p_19452_; @@ -17,7 +17,7 @@ } public Optional m_216881_() { -@@ -194,4 +_,29 @@ +@@ -117,6 +_,31 @@ public boolean m_19486_() { return this.f_19447_ == MobEffectCategory.BENEFICIAL; } @@ -46,4 +46,6 @@ + } + // END FORGE + - } + + /** @deprecated */ + @Deprecated diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch index 39dd6908d3..29a87d6798 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -15,7 +_,7 @@ +@@ -17,7 +_,7 @@ import net.minecraft.world.entity.LivingEntity; import org.slf4j.Logger; @@ -8,8 +8,8 @@ +public class MobEffectInstance implements Comparable, net.minecraftforge.common.extensions.IForgeMobEffectInstance { private static final Logger f_19501_ = LogUtils.getLogger(); public static final int f_267388_ = -1; - private final MobEffect f_19502_; -@@ -75,6 +_,7 @@ + private static final String f_290519_ = "id"; +@@ -85,6 +_,7 @@ this.f_19506_ = p_19549_.f_19506_; this.f_19508_ = p_19549_.f_19508_; this.f_19509_ = p_19549_.f_19509_; @@ -17,7 +17,7 @@ } public boolean m_19558_(MobEffectInstance p_19559_) { -@@ -140,7 +_,7 @@ +@@ -149,7 +_,7 @@ } public MobEffect m_19544_() { @@ -26,34 +26,15 @@ } public int m_19557_() { -@@ -252,6 +_,7 @@ - - public CompoundTag m_19555_(CompoundTag p_19556_) { - p_19556_.m_128405_("Id", MobEffect.m_19459_(this.m_19544_())); -+ net.minecraftforge.common.ForgeHooks.saveMobEffect(p_19556_, "forge:id", this.m_19544_()); - this.m_19567_(p_19556_); - return p_19556_; - } -@@ -267,6 +_,7 @@ +@@ -274,6 +_,7 @@ this.f_19510_.m_19555_(compoundtag); - p_19568_.m_128365_("HiddenEffect", compoundtag); + p_19568_.m_128365_("hidden_effect", compoundtag); } + writeCurativeItems(p_19568_); this.f_216885_.ifPresent((p_216903_) -> { MobEffectInstance.FactorData.f_216907_.encodeStart(NbtOps.f_128958_, p_216903_).resultOrPartial(f_19501_::error).ifPresent((p_216906_) -> { -@@ -277,8 +_,9 @@ - - @Nullable - public static MobEffectInstance m_19560_(CompoundTag p_19561_) { -- int i = p_19561_.m_128451_("Id"); -+ int i = p_19561_.m_128445_("Id") & 0xFF; - MobEffect mobeffect = MobEffect.m_19453_(i); -+ mobeffect = net.minecraftforge.common.ForgeHooks.loadMobEffect(p_19561_, "forge:id", mobeffect); - return mobeffect == null ? null : m_19545_(mobeffect, p_19561_); - } - -@@ -308,12 +_,38 @@ +@@ -315,12 +_,38 @@ optional = Optional.empty(); } @@ -64,7 +45,7 @@ public int compareTo(MobEffectInstance p_19566_) { int i = 32147; - return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compareFalseFirst(this.m_19571_(), p_19566_.m_19571_()).compareFalseFirst(this.m_267577_(), p_19566_.m_267577_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result(); -+ return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result(); ++ return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compareFalseFirst(this.m_19571_(), p_19566_.m_19571_()).compareFalseFirst(this.m_267577_(), p_19566_.m_267577_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result(); + } + + //======================= FORGE START =========================== diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index a9669b1336..f2c8c80e0f 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -120,7 +_,7 @@ - import net.minecraft.world.scores.Team; +@@ -122,7 +_,7 @@ + import org.joml.Vector3f; import org.slf4j.Logger; -public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -9,7 +9,7 @@ private static final Logger f_19849_ = LogUtils.getLogger(); public static final String f_146815_ = "id"; public static final String f_146816_ = "Passengers"; -@@ -141,6 +_,7 @@ +@@ -143,6 +_,7 @@ private static final double f_146812_ = 0.0023333333333333335D; public static final String f_146824_ = "UUID"; private static double f_19846_ = 1.0D; @@ -17,7 +17,7 @@ private final EntityType f_19847_; private int f_19848_ = f_19843_.incrementAndGet(); public boolean f_19850_; -@@ -187,8 +_,10 @@ +@@ -189,8 +_,10 @@ public int f_19797_; private int f_19831_ = -this.m_6101_(); protected boolean f_19798_; @@ -28,7 +28,7 @@ private final Set> f_19801_ = new HashSet<>(); public int f_19802_; protected boolean f_19803_ = true; -@@ -237,6 +_,7 @@ +@@ -239,6 +_,7 @@ private BlockState f_185934_ = null; public Entity(EntityType p_19870_, Level p_19871_) { @@ -36,20 +36,16 @@ this.f_19847_ = p_19870_; this.f_19853_ = p_19871_; this.f_19815_ = p_19870_.m_20680_(); -@@ -254,7 +_,11 @@ - this.f_19804_.m_135372_(f_146800_, 0); +@@ -257,6 +_,8 @@ this.m_8097_(); this.m_6034_(0.0D, 0.0D, 0.0D); -- this.f_19816_ = this.m_6380_(Pose.STANDING, this.f_19815_); -+ var sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, Pose.STANDING, this.f_19815_, this.m_6380_(Pose.STANDING, this.f_19815_)); -+ this.f_19815_ = sizeEvent.getNewSize(); -+ this.f_19816_ = sizeEvent.getNewEyeHeight(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); + this.f_19816_ = this.m_6380_(Pose.STANDING, this.f_19815_); ++ net.minecraftforge.event.ForgeEventFactory.onEntityConstructing(this); + this.gatherCapabilities(); } public boolean m_20039_(BlockPos p_20040_, BlockState p_20041_) { -@@ -344,6 +_,7 @@ +@@ -346,6 +_,7 @@ public void m_142687_(Entity.RemovalReason p_146834_) { this.m_142467_(p_146834_); @@ -57,7 +53,7 @@ } public void m_142036_() { -@@ -461,7 +_,7 @@ +@@ -463,7 +_,7 @@ if (this.m_20077_()) { this.m_20093_(); @@ -66,7 +62,7 @@ } this.m_146871_(); -@@ -672,7 +_,7 @@ +@@ -674,7 +_,7 @@ double d1 = vec3.f_82479_; double d2 = vec3.f_82480_; double d3 = vec3.f_82481_; @@ -75,7 +71,7 @@ BlockPos blockpos1 = this.m_20097_(); BlockState blockstate1 = this.m_9236_().m_8055_(blockpos1); boolean flag1 = this.m_285776_(blockstate1); -@@ -716,16 +_,16 @@ +@@ -718,16 +_,16 @@ this.m_7311_(-this.m_6101_()); } @@ -95,7 +91,7 @@ } } } -@@ -813,7 +_,7 @@ +@@ -815,7 +_,7 @@ return blockpos; } else { BlockState blockstate = this.m_9236_().m_8055_(blockpos); @@ -104,7 +100,7 @@ } } else { int i = Mth.m_14107_(this.f_19825_.f_82479_); -@@ -884,10 +_,11 @@ +@@ -886,10 +_,11 @@ boolean flag1 = p_20273_.f_82480_ != vec3.f_82480_; boolean flag2 = p_20273_.f_82481_ != vec3.f_82481_; boolean flag3 = this.m_20096_() || flag1 && p_20273_.f_82480_ < 0.0D; @@ -120,7 +116,7 @@ Vec3 vec33 = m_198894_(this, new Vec3(p_20273_.f_82479_, 0.0D, p_20273_.f_82481_), aabb.m_82383_(vec32), this.m_9236_(), list).m_82549_(vec32); if (vec33.m_165925_() > vec31.m_165925_()) { vec31 = vec33; -@@ -1033,19 +_,20 @@ +@@ -1039,19 +_,20 @@ return !blockstate.m_204336_(BlockTags.f_144271_) && !blockstate.m_204336_(BlockTags.f_276549_) ? p_278049_ : blockpos; } @@ -147,7 +143,7 @@ this.m_5496_(soundtype.m_56776_(), soundtype.m_56773_() * 0.15F, soundtype.m_56774_()); } -@@ -1176,31 +_,38 @@ +@@ -1186,31 +_,38 @@ public void m_5844_() { if (this.m_6069_()) { @@ -193,7 +189,7 @@ if (!this.f_19798_ && !this.f_19803_) { this.m_5841_(); } -@@ -1217,6 +_,7 @@ +@@ -1227,6 +_,7 @@ private void m_20323_() { this.f_19800_ = this.m_204029_(FluidTags.f_13131_); this.f_19801_.clear(); @@ -201,7 +197,7 @@ double d0 = this.m_20188_() - (double)0.11111111F; Entity entity = this.m_20202_(); if (entity instanceof Boat boat) { -@@ -1229,7 +_,7 @@ +@@ -1239,7 +_,7 @@ FluidState fluidstate = this.m_9236_().m_6425_(blockpos); double d1 = (double)((float)blockpos.m_123342_() + fluidstate.m_76155_(this.m_9236_(), blockpos)); if (d1 > d0) { @@ -210,7 +206,7 @@ } } -@@ -1273,12 +_,13 @@ +@@ -1283,12 +_,13 @@ } public boolean m_5843_() { @@ -225,7 +221,7 @@ if (blockstate.m_60799_() != RenderShape.INVISIBLE) { Vec3 vec3 = this.m_20184_(); BlockPos blockpos1 = this.m_20183_(); -@@ -1292,17 +_,20 @@ +@@ -1302,17 +_,20 @@ d1 = Mth.m_14008_(d1, (double)blockpos.m_123343_(), (double)blockpos.m_123343_() + 1.0D); } @@ -248,7 +244,7 @@ } public void m_19920_(float p_19921_, Vec3 p_19922_) { -@@ -1620,6 +_,8 @@ +@@ -1630,6 +_,8 @@ p_20241_.m_128379_("HasVisualFire", this.f_146813_); } @@ -257,7 +253,7 @@ if (!this.f_19841_.isEmpty()) { ListTag listtag = new ListTag(); -@@ -1630,6 +_,10 @@ +@@ -1640,6 +_,10 @@ p_20241_.m_128365_("Tags", listtag); } @@ -268,7 +264,7 @@ this.m_7380_(p_20241_); if (this.m_20160_()) { ListTag listtag1 = new ListTag(); -@@ -1705,6 +_,9 @@ +@@ -1715,6 +_,9 @@ this.m_146915_(p_20259_.m_128471_("Glowing")); this.m_146917_(p_20259_.m_128451_("TicksFrozen")); this.f_146813_ = p_20259_.m_128471_("HasVisualFire"); @@ -278,7 +274,7 @@ if (p_20259_.m_128425_("Tags", 9)) { this.f_19841_.clear(); ListTag listtag3 = p_20259_.m_128437_("Tags", 8); -@@ -1793,6 +_,8 @@ +@@ -1803,6 +_,8 @@ } else { ItemEntity itementity = new ItemEntity(this.m_9236_(), this.m_20185_(), this.m_20186_() + (double)p_19986_, this.m_20189_(), p_19985_); itementity.m_32060_(); @@ -287,7 +283,7 @@ this.m_9236_().m_7967_(itementity); return itementity; } -@@ -1829,6 +_,7 @@ +@@ -1839,6 +_,7 @@ public void m_6083_() { this.m_20256_(Vec3.f_82478_); @@ -295,7 +291,7 @@ this.m_8119_(); if (this.m_20159_()) { this.m_20202_().m_7332_(this); -@@ -1877,6 +_,7 @@ +@@ -1895,6 +_,7 @@ } } @@ -303,7 +299,7 @@ if (p_19967_ || this.m_7341_(p_19966_) && p_19966_.m_7310_(this)) { if (this.m_20159_()) { this.m_8127_(); -@@ -1915,6 +_,7 @@ +@@ -1929,6 +_,7 @@ public void m_6038_() { if (this.f_19824_ != null) { Entity entity = this.f_19824_; @@ -311,7 +307,7 @@ this.f_19824_ = null; entity.m_20351_(this); } -@@ -1967,6 +_,8 @@ +@@ -1981,6 +_,8 @@ return this.f_19823_.isEmpty(); } @@ -320,7 +316,7 @@ protected boolean m_269011_() { return true; } -@@ -2148,7 +_,7 @@ +@@ -2186,7 +_,7 @@ } public boolean m_20143_() { @@ -329,7 +325,7 @@ } public void m_20282_(boolean p_20283_) { -@@ -2258,7 +_,7 @@ +@@ -2296,7 +_,7 @@ this.m_20254_(8); } @@ -338,7 +334,7 @@ } public void m_6845_(boolean p_20313_) { -@@ -2354,7 +_,7 @@ +@@ -2392,7 +_,7 @@ } protected Component m_5677_() { @@ -347,7 +343,7 @@ } public boolean m_7306_(Entity p_20356_) { -@@ -2410,14 +_,20 @@ +@@ -2448,14 +_,20 @@ @Nullable public Entity m_5489_(ServerLevel p_20118_) { @@ -355,7 +351,7 @@ + } + @Nullable + public Entity changeDimension(ServerLevel p_20118_, net.minecraftforge.common.util.ITeleporter teleporter) { -+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_20118_.m_46472_())) return null; ++ if (!net.minecraftforge.event.ForgeEventFactory.onTravelToDimension(this, p_20118_.m_46472_())) return null; if (this.m_9236_() instanceof ServerLevel && !this.m_213877_()) { this.m_9236_().m_46473_().m_6180_("changeDimension"); this.m_19877_(); @@ -369,7 +365,7 @@ this.m_9236_().m_46473_().m_6182_("reloading"); Entity entity = this.m_6095_().m_20615_(p_20118_); if (entity != null) { -@@ -2425,17 +_,19 @@ +@@ -2463,17 +_,19 @@ entity.m_7678_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_, portalinfo.f_77678_, entity.m_146909_()); entity.m_20256_(portalinfo.f_77677_); p_20118_.m_143334_(entity); @@ -391,7 +387,7 @@ } } else { return null; -@@ -2557,6 +_,7 @@ +@@ -2595,6 +_,7 @@ return this.f_19821_; } @@ -399,30 +395,7 @@ public boolean m_6063_() { return true; } -@@ -2679,8 +_,10 @@ - EntityDimensions entitydimensions = this.f_19815_; - Pose pose = this.m_20089_(); - EntityDimensions entitydimensions1 = this.m_6972_(pose); -+ var sizeEvent = net.minecraftforge.event.ForgeEventFactory.getEntitySizeForge(this, pose, entitydimensions, entitydimensions1, this.m_6380_(pose, entitydimensions1)); -+ entitydimensions1 = sizeEvent.getNewSize(); - this.f_19815_ = entitydimensions1; -- this.f_19816_ = this.m_6380_(pose, entitydimensions1); -+ this.f_19816_ = sizeEvent.getNewEyeHeight(); - this.m_20090_(); - boolean flag = (double)entitydimensions1.f_20377_ <= 4.0D && (double)entitydimensions1.f_20378_ <= 4.0D; - if (!this.m_9236_().f_46443_ && !this.f_19803_ && !this.f_19794_ && flag && (entitydimensions1.f_20377_ > entitydimensions.f_20377_ || entitydimensions1.f_20378_ > entitydimensions.f_20378_) && !(this instanceof Player)) { -@@ -2688,8 +_,9 @@ - double d0 = (double)Math.max(0.0F, entitydimensions1.f_20377_ - entitydimensions.f_20377_) + 1.0E-6D; - double d1 = (double)Math.max(0.0F, entitydimensions1.f_20378_ - entitydimensions.f_20378_) + 1.0E-6D; - VoxelShape voxelshape = Shapes.m_83064_(AABB.m_165882_(vec3, d0, d1, d0)); -+ EntityDimensions finalEntitydimensions = entitydimensions1; - this.m_9236_().m_151418_(this, voxelshape, vec3, (double)entitydimensions1.f_20377_, (double)entitydimensions1.f_20378_, (double)entitydimensions1.f_20377_).ifPresent((p_185956_) -> { -- this.m_146884_(p_185956_.m_82520_(0.0D, (double)(-entitydimensions1.f_20378_) / 2.0D, 0.0D)); -+ this.m_146884_(p_185956_.m_82520_(0.0D, (double)(-finalEntitydimensions.f_20378_) / 2.0D, 0.0D)); - }); - } - -@@ -2980,9 +_,22 @@ +@@ -3010,9 +_,22 @@ this.f_19859_ = this.m_146908_(); } @@ -446,7 +419,7 @@ } else { AABB aabb = this.m_20191_().m_82406_(0.001D); int i = Mth.m_14107_(aabb.f_82288_); -@@ -2997,25 +_,28 @@ +@@ -3027,25 +_,28 @@ Vec3 vec3 = Vec3.f_82478_; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -482,7 +455,7 @@ } } } -@@ -3023,27 +_,28 @@ +@@ -3053,27 +_,28 @@ } } @@ -521,7 +494,7 @@ } } -@@ -3056,7 +_,10 @@ +@@ -3086,7 +_,10 @@ return !this.m_9236_().m_151572_(i, k, j, l); } @@ -532,7 +505,7 @@ return this.f_19799_.getDouble(p_204037_); } -@@ -3192,6 +_,7 @@ +@@ -3222,6 +_,7 @@ this.f_146801_.m_142044_(); } @@ -540,7 +513,7 @@ } -@@ -3264,6 +_,7 @@ +@@ -3294,6 +_,7 @@ return false; } @@ -548,7 +521,7 @@ public float m_274421_() { return this.f_19793_; } -@@ -3319,6 +_,109 @@ +@@ -3349,6 +_,109 @@ public boolean m_142265_(Level p_146843_, BlockPos p_146844_) { return true; } diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index f4dbf3ed7c..613416b95d 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -307,6 +_,11 @@ +@@ -308,6 +_,11 @@ private final EntityDimensions f_20547_; private final FeatureFlagSet f_244139_; @@ -12,7 +12,7 @@ private static EntityType m_20634_(String p_20635_, EntityType.Builder p_20636_) { return Registry.m_122961_(BuiltInRegistries.f_256780_, p_20635_, p_20636_.m_20712_(p_20635_)); } -@@ -320,17 +_,24 @@ +@@ -321,17 +_,24 @@ } public EntityType(EntityType.EntityFactory p_273268_, MobCategory p_272918_, boolean p_273417_, boolean p_273389_, boolean p_273556_, boolean p_272654_, ImmutableSet p_273631_, EntityDimensions p_272946_, int p_272895_, int p_273451_, FeatureFlagSet p_273518_) { @@ -48,7 +48,7 @@ } @Nullable -@@ -600,14 +_,23 @@ +@@ -601,14 +_,23 @@ } public int m_20681_() { @@ -72,7 +72,7 @@ return this != f_20532_ && this != f_20467_ && this != f_20496_ && this != f_20549_ && this != f_20462_ && this != f_147033_ && this != f_20464_ && this != f_20506_ && this != f_20564_ && this != f_20569_; } -@@ -630,6 +_,12 @@ +@@ -635,6 +_,12 @@ return this.f_204038_; } @@ -85,7 +85,7 @@ public static class Builder { private final EntityType.EntityFactory f_20685_; private final MobCategory f_20686_; -@@ -643,6 +_,11 @@ +@@ -648,6 +_,11 @@ private EntityDimensions f_20694_ = EntityDimensions.m_20395_(0.6F, 1.8F); private FeatureFlagSet f_244453_ = FeatureFlags.f_244377_; @@ -97,7 +97,7 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.f_20685_ = p_20696_; this.f_20686_ = p_20697_; -@@ -704,12 +_,36 @@ +@@ -709,12 +_,36 @@ return this; } diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index 71ec27eb89..b27169de71 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -7,11 +7,11 @@ -public abstract class LivingEntity extends Entity implements Attackable { +public abstract class LivingEntity extends Entity implements Attackable, net.minecraftforge.common.extensions.IForgeLivingEntity { private static final Logger f_201943_ = LogUtils.getLogger(); - private static final UUID f_20929_ = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); + private static final String f_290660_ = "active_effects"; private static final UUID f_20959_ = UUID.fromString("87f46a96-686f-4796-b035-22e16ee9e038"); private static final UUID f_147184_ = UUID.fromString("1eaf83ff-7207-4596-b37a-d7a07b3ec4ce"); + private static final UUID SLOW_FALLING_ID = UUID.fromString("A5B6CF2A-2F7C-31EF-9022-7C3E7D5E6ABA"); - private static final AttributeModifier f_20960_ = new AttributeModifier(f_20929_, "Sprinting speed boost", (double)0.3F, AttributeModifier.Operation.MULTIPLY_TOTAL); + private static final AttributeModifier f_20960_ = new AttributeModifier(UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"), "Sprinting speed boost", (double)0.3F, AttributeModifier.Operation.MULTIPLY_TOTAL); + private static final AttributeModifier SLOW_FALLING = new AttributeModifier(SLOW_FALLING_ID, "Slow falling acceleration reduction", -0.07, AttributeModifier.Operation.ADDITION); // Add -0.07 to 0.08 so we get the vanilla default of 0.01 public static final int f_147166_ = 2; public static final int f_147167_ = 4; @@ -30,7 +30,7 @@ } public static AttributeSupplier.Builder m_21183_() { -- return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_); +- return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_).m_22266_(Attributes.f_290864_); + return AttributeSupplier.m_22244_().m_22266_(Attributes.f_22276_).m_22266_(Attributes.f_22278_).m_22266_(Attributes.f_22279_).m_22266_(Attributes.f_22284_).m_22266_(Attributes.f_22285_).m_22266_(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).m_22266_(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.get()).m_22266_(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get()).m_22266_(net.minecraftforge.common.ForgeMod.STEP_HEIGHT_ADDITION.get()); } @@ -104,11 +104,10 @@ this.m_6842_(this.m_21023_(MobEffects.f_19609_)); } -@@ -836,7 +_,7 @@ - d0 *= 0.5D; +@@ -837,6 +_,7 @@ } } -- + + d0 = net.minecraftforge.common.ForgeHooks.getEntityVisibilityMultiplier(this, p_20969_, d0); return d0; } @@ -124,25 +123,25 @@ iterator.remove(); } -@@ -913,6 +_,7 @@ - return false; +@@ -914,6 +_,7 @@ } else { MobEffectInstance mobeffectinstance = this.f_20945_.get(p_147208_.m_19544_()); + boolean flag = false; + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.MobEffectEvent.Added(this, mobeffectinstance, p_147208_, p_147209_)); if (mobeffectinstance == null) { this.f_20945_.put(p_147208_.m_19544_(), p_147208_); this.m_142540_(p_147208_, p_147209_); -@@ -927,6 +_,9 @@ +@@ -929,6 +_,9 @@ } public boolean m_7301_(MobEffectInstance p_21197_) { -+ net.minecraftforge.event.entity.living.MobEffectEvent.Applicable event = new net.minecraftforge.event.entity.living.MobEffectEvent.Applicable(this, p_21197_); ++ var event = new net.minecraftforge.event.entity.living.MobEffectEvent.Applicable(this, p_21197_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() != net.minecraftforge.eventbus.api.Event.Result.DEFAULT) return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW; if (this.m_6336_() == MobType.f_21641_) { MobEffect mobeffect = p_21197_.m_19544_(); if (mobeffect == MobEffects.f_19605_ || mobeffect == MobEffects.f_19614_) { -@@ -959,6 +_,7 @@ +@@ -961,6 +_,7 @@ } public boolean m_21195_(MobEffect p_21196_) { @@ -150,7 +149,7 @@ MobEffectInstance mobeffectinstance = this.m_6234_(p_21196_); if (mobeffectinstance != null) { this.m_7285_(mobeffectinstance); -@@ -1016,6 +_,8 @@ +@@ -1042,6 +_,8 @@ } public void m_5634_(float p_21116_) { @@ -159,7 +158,7 @@ float f = this.m_21223_(); if (f > 0.0F) { this.m_21153_(f + p_21116_); -@@ -1036,6 +_,7 @@ +@@ -1062,6 +_,7 @@ } public boolean m_6469_(DamageSource p_21016_, float p_21017_) { @@ -167,37 +166,32 @@ if (this.m_6673_(p_21016_)) { return false; } else if (this.m_9236_().f_46443_) { -@@ -1054,9 +_,11 @@ +@@ -1080,9 +_,11 @@ boolean flag = false; float f1 = 0.0F; if (p_21017_ > 0.0F && this.m_21275_(p_21016_)) { - this.m_7909_(p_21017_); - f1 = p_21017_; - p_21017_ = 0.0F; -+ net.minecraftforge.event.entity.living.ShieldBlockEvent ev = net.minecraftforge.common.ForgeHooks.onShieldBlock(this, p_21016_, p_21017_); -+ if(!ev.isCanceled()) { ++ var ev = net.minecraftforge.common.ForgeHooks.onShieldBlock(this, p_21016_, p_21017_); ++ if(!ev.isCanceled()) { + if(ev.shieldTakesDamage()) this.m_7909_(p_21017_); + f1 = ev.getBlockedDamage(); + p_21017_ -= ev.getBlockedDamage(); if (!p_21016_.m_269533_(DamageTypeTags.f_268524_)) { Entity entity = p_21016_.m_7640_(); if (entity instanceof LivingEntity) { -@@ -1065,12 +_,13 @@ +@@ -1091,7 +_,8 @@ } } - flag = true; + flag = p_21017_ <= 0; ++ } } if (p_21016_.m_269533_(DamageTypeTags.f_268419_) && this.m_6095_().m_204039_(EntityTypeTags.f_144295_)) { - p_21017_ *= 5.0F; - } -+ } - - this.f_267362_.m_267771_(1.5F); - boolean flag1 = true; -@@ -1108,11 +_,10 @@ +@@ -1134,11 +_,10 @@ Player player1 = (Player)entity1; this.f_20889_ = 100; this.f_20888_ = player1; @@ -212,7 +206,7 @@ if (livingentity2 instanceof Player) { Player player = (Player)livingentity2; this.f_20888_ = player; -@@ -1171,7 +_,7 @@ +@@ -1197,7 +_,7 @@ if (this instanceof ServerPlayer) { CriteriaTriggers.f_10574_.m_35174_((ServerPlayer)this, p_21016_, f, p_21017_, flag); if (f1 > 0.0F && f1 < 3.4028235E37F) { @@ -221,7 +215,7 @@ } } -@@ -1199,7 +_,7 @@ +@@ -1225,7 +_,7 @@ for(InteractionHand interactionhand : InteractionHand.values()) { ItemStack itemstack1 = this.m_21120_(interactionhand); @@ -230,16 +224,16 @@ itemstack = itemstack1.m_41777_(); itemstack1.m_41774_(1); break; -@@ -1209,7 +_,7 @@ +@@ -1235,7 +_,7 @@ if (itemstack != null) { if (this instanceof ServerPlayer) { ServerPlayer serverplayer = (ServerPlayer)this; - serverplayer.m_36246_(Stats.f_12982_.m_12902_(Items.f_42747_)); + serverplayer.m_6278_(Stats.f_12982_.m_12902_(Items.f_42747_), 1); CriteriaTriggers.f_10551_.m_74431_(serverplayer, itemstack); + this.m_146850_(GameEvent.f_223697_); } - -@@ -1278,6 +_,7 @@ +@@ -1305,6 +_,7 @@ } public void m_6667_(DamageSource p_21014_) { @@ -247,7 +241,7 @@ if (!this.m_213877_() && !this.f_20890_) { Entity entity = p_21014_.m_7639_(); LivingEntity livingentity = this.m_21232_(); -@@ -1315,10 +_,10 @@ +@@ -1342,10 +_,10 @@ if (!this.m_9236_().f_46443_) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { @@ -260,7 +254,7 @@ this.m_9236_().m_7731_(blockpos, blockstate, 3); flag = true; } -@@ -1335,12 +_,9 @@ +@@ -1362,12 +_,9 @@ protected void m_6668_(DamageSource p_21192_) { Entity entity = p_21192_.m_7639_(); @@ -276,7 +270,7 @@ boolean flag = this.f_20889_ > 0; if (this.m_6125_() && this.m_9236_().m_46469_().m_46207_(GameRules.f_46135_)) { -@@ -1350,6 +_,10 @@ +@@ -1377,6 +_,10 @@ this.m_5907_(); this.m_21226_(); @@ -287,7 +281,7 @@ } protected void m_5907_() { -@@ -1357,7 +_,8 @@ +@@ -1384,7 +_,8 @@ protected void m_21226_() { if (this.m_9236_() instanceof ServerLevel && !this.m_217046_() && (this.m_6124_() || this.f_20889_ > 0 && this.m_6149_() && this.m_9236_().m_46469_().m_46207_(GameRules.f_46135_))) { @@ -297,7 +291,7 @@ } } -@@ -1386,6 +_,11 @@ +@@ -1413,6 +_,11 @@ } public void m_147240_(double p_147241_, double p_147242_, double p_147243_) { @@ -309,7 +303,7 @@ p_147241_ *= 1.0D - this.m_21133_(Attributes.f_22278_); if (!(p_147241_ <= 0.0D)) { this.f_19812_ = true; -@@ -1455,15 +_,9 @@ +@@ -1484,15 +_,9 @@ } else { BlockPos blockpos = this.m_20183_(); BlockState blockstate = this.m_146900_(); @@ -328,7 +322,7 @@ } } -@@ -1483,6 +_,11 @@ +@@ -1512,6 +_,11 @@ } public boolean m_142535_(float p_147187_, float p_147188_, DamageSource p_147189_) { @@ -340,7 +334,7 @@ boolean flag = super.m_142535_(p_147187_, p_147188_, p_147189_); int i = this.m_5639_(p_147187_, p_147188_); if (i > 0) { -@@ -1510,9 +_,10 @@ +@@ -1539,9 +_,10 @@ int i = Mth.m_14107_(this.m_20185_()); int j = Mth.m_14107_(this.m_20186_() - (double)0.2F); int k = Mth.m_14107_(this.m_20189_()); @@ -353,7 +347,7 @@ this.m_5496_(soundtype.m_56779_(), soundtype.m_56773_() * 0.5F, soundtype.m_56774_() * 0.75F); } -@@ -1559,9 +_,9 @@ +@@ -1588,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { @@ -365,7 +359,7 @@ } } } -@@ -1583,6 +_,8 @@ +@@ -1612,6 +_,8 @@ protected void m_6475_(DamageSource p_21240_, float p_21241_) { if (!this.m_6673_(p_21240_)) { @@ -374,7 +368,7 @@ p_21241_ = this.m_21161_(p_21240_, p_21241_); p_21241_ = this.m_6515_(p_21240_, p_21241_); float f1 = Math.max(p_21241_ - this.m_6103_(), 0.0F); -@@ -1596,6 +_,7 @@ +@@ -1625,6 +_,7 @@ } } @@ -382,7 +376,7 @@ if (f1 != 0.0F) { this.m_21231_().m_289194_(p_21240_, f1); this.m_21153_(this.m_21223_() - f1); -@@ -1651,6 +_,8 @@ +@@ -1684,6 +_,8 @@ } public void m_21011_(InteractionHand p_21012_, boolean p_21013_) { @@ -391,7 +385,7 @@ if (!this.f_20911_ || this.f_20913_ >= this.m_21304_() / 2 || this.f_20913_ < 0) { this.f_20913_ = -1; this.f_20911_ = true; -@@ -1761,8 +_,10 @@ +@@ -1794,8 +_,10 @@ private void m_21312_() { ItemStack itemstack = this.m_6844_(EquipmentSlot.OFFHAND); @@ -404,7 +398,7 @@ } protected void m_6088_() { -@@ -1955,14 +_,17 @@ +@@ -1985,14 +_,17 @@ } this.f_19812_ = true; @@ -424,7 +418,7 @@ } protected float m_6108_() { -@@ -1976,13 +_,18 @@ +@@ -2006,13 +_,19 @@ public void m_7023_(Vec3 p_21280_) { if (this.m_6109_()) { double d0 = 0.08D; @@ -432,9 +426,10 @@ boolean flag = this.m_20184_().f_82480_ <= 0.0D; if (flag && this.m_21023_(MobEffects.f_19591_)) { - d0 = 0.01D; -+ if (!gravity.m_22109_(SLOW_FALLING)) gravity.m_22118_(SLOW_FALLING); ++ if (!gravity.m_22109_(SLOW_FALLING)) ++ gravity.m_22118_(SLOW_FALLING); + } else if (gravity.m_22109_(SLOW_FALLING)) { -+ gravity.m_22130_(SLOW_FALLING); ++ gravity.m_22120_(SLOW_FALLING.m_22209_()); } + d0 = gravity.m_22135_(); @@ -445,7 +440,7 @@ double d9 = this.m_20186_(); float f4 = this.m_20142_() ? 0.9F : this.m_6108_(); float f5 = 0.02F; -@@ -2004,6 +_,7 @@ +@@ -2034,6 +_,7 @@ f4 = 0.96F; } @@ -453,7 +448,7 @@ this.m_19920_(f5, p_21280_); this.m_6478_(MoverType.SELF, this.m_20184_()); Vec3 vec36 = this.m_20184_(); -@@ -2017,6 +_,7 @@ +@@ -2047,6 +_,7 @@ if (this.f_19862_ && this.m_20229_(vec32.f_82479_, vec32.f_82480_ + (double)0.6F - this.m_20186_() + d9, vec32.f_82481_)) { this.m_20334_(vec32.f_82479_, (double)0.3F, vec32.f_82481_); } @@ -461,7 +456,7 @@ } else if (this.m_20077_() && this.m_6129_() && !this.m_203441_(fluidstate)) { double d8 = this.m_20186_(); this.m_19920_(0.02F, p_21280_); -@@ -2079,7 +_,7 @@ +@@ -2109,7 +_,7 @@ } } else { BlockPos blockpos = this.m_20099_(); @@ -470,7 +465,7 @@ float f3 = this.m_20096_() ? f2 * 0.91F : 0.91F; Vec3 vec35 = this.m_21074_(p_21280_, f2); double d2 = vec35.f_82480_; -@@ -2175,7 +_,7 @@ +@@ -2205,7 +_,7 @@ double d0 = Mth.m_14008_(p_21298_.f_82479_, (double)-0.15F, (double)0.15F); double d1 = Mth.m_14008_(p_21298_.f_82481_, (double)-0.15F, (double)0.15F); double d2 = Math.max(p_21298_.f_82480_, (double)-0.15F); @@ -479,7 +474,7 @@ d2 = 0.0D; } -@@ -2207,6 +_,7 @@ +@@ -2237,6 +_,7 @@ } public void m_8119_() { @@ -487,7 +482,7 @@ super.m_8119_(); this.m_21329_(); this.m_21333_(); -@@ -2358,6 +_,7 @@ +@@ -2389,6 +_,7 @@ ItemStack itemstack1 = this.m_6844_(equipmentslot); if (this.m_246525_(itemstack, itemstack1)) { @@ -495,22 +490,23 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2503,6 +_,9 @@ +@@ -2527,6 +_,10 @@ this.m_9236_().m_46473_().m_6180_("jump"); if (this.f_20899_ && this.m_6129_()) { - double d7; -+ net.minecraftforge.fluids.FluidType fluidType = this.getMaxHeightFluidType(); -+ if (!fluidType.isAir()) d7 = this.getFluidTypeHeight(fluidType); + double d3; ++ var fluidType = this.getMaxHeightFluidType(); ++ if (!fluidType.isAir()) ++ d3 = this.getFluidTypeHeight(fluidType); + else if (this.m_20077_()) { - d7 = this.m_204036_(FluidTags.f_13132_); + d3 = this.m_204036_(FluidTags.f_13132_); } else { -@@ -2513,15 +_,17 @@ - double d8 = this.m_20204_(); - if (!flag || this.m_20096_() && !(d7 > d8)) { - if (!this.m_20077_() || this.m_20096_() && !(d7 > d8)) { -+ if (fluidType.isAir() || this.m_20096_() && !(d7 > d8)) { - if ((this.m_20096_() || flag && d7 <= d8) && this.f_20954_ == 0) { +@@ -2537,15 +_,17 @@ + double d4 = this.m_20204_(); + if (!flag || this.m_20096_() && !(d3 > d4)) { + if (!this.m_20077_() || this.m_20096_() && !(d3 > d4)) { ++ if (fluidType.isAir() || this.m_20096_() && !(d3 > d4)) { + if ((this.m_20096_() || flag && d3 <= d4) && this.f_20954_ == 0) { this.m_6135_(); this.f_20954_ = 10; } @@ -525,7 +521,7 @@ } } else { this.f_20954_ = 0; -@@ -2590,6 +_,8 @@ +@@ -2614,6 +_,8 @@ boolean flag = this.m_20291_(7); if (flag && !this.m_20096_() && !this.m_20159_() && !this.m_21023_(MobEffects.f_19620_)) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); @@ -534,7 +530,7 @@ if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) { flag = true; int i = this.f_20937_ + 1; -@@ -2821,8 +_,11 @@ +@@ -2863,8 +_,11 @@ private void m_21329_() { if (this.m_6117_()) { @@ -548,7 +544,7 @@ this.m_142106_(this.f_20935_); } else { this.m_5810_(); -@@ -2832,12 +_,15 @@ +@@ -2874,12 +_,15 @@ } protected void m_142106_(ItemStack p_147201_) { @@ -565,7 +561,7 @@ this.m_8095_(); } -@@ -2845,7 +_,7 @@ +@@ -2887,7 +_,7 @@ private boolean m_21332_() { int i = this.m_21212_(); @@ -574,7 +570,7 @@ boolean flag = foodproperties != null && foodproperties.m_38748_(); flag |= i <= this.f_20935_.m_41779_() - 7; return flag && i % 4 == 0; -@@ -2875,8 +_,10 @@ +@@ -2917,8 +_,10 @@ public void m_6672_(InteractionHand p_21159_) { ItemStack itemstack = this.m_21120_(p_21159_); if (!itemstack.m_41619_() && !this.m_6117_()) { @@ -586,7 +582,7 @@ if (!this.m_9236_().f_46443_) { this.m_21155_(1, true); this.m_21155_(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -2937,6 +_,9 @@ +@@ -2979,6 +_,9 @@ vec31 = vec31.m_82496_(-this.m_146909_() * ((float)Math.PI / 180F)); vec31 = vec31.m_82524_(-this.m_146908_() * ((float)Math.PI / 180F)); vec31 = vec31.m_82520_(this.m_20185_(), this.m_20188_(), this.m_20189_()); @@ -596,7 +592,7 @@ this.m_9236_().m_7106_(new ItemParticleOption(ParticleTypes.f_123752_, p_21061_), vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, vec3.f_82479_, vec3.f_82480_ + 0.05D, vec3.f_82481_); } -@@ -2950,7 +_,8 @@ +@@ -2992,7 +_,8 @@ } else { if (!this.f_20935_.m_41619_() && this.m_6117_()) { this.m_21137_(this.f_20935_, 16); @@ -606,7 +602,7 @@ if (itemstack != this.f_20935_) { this.m_21008_(interactionhand, itemstack); } -@@ -2976,7 +_,11 @@ +@@ -3018,7 +_,11 @@ public void m_21253_() { if (!this.f_20935_.m_41619_()) { @@ -618,7 +614,7 @@ if (this.f_20935_.m_41781_()) { this.m_21329_(); } -@@ -2986,6 +_,7 @@ +@@ -3028,6 +_,7 @@ } public void m_5810_() { @@ -626,7 +622,7 @@ if (!this.m_9236_().f_46443_) { boolean flag = this.m_6117_(); this.m_21155_(1, false); -@@ -3001,7 +_,7 @@ +@@ -3043,7 +_,7 @@ public boolean m_21254_() { if (this.m_6117_() && !this.f_20935_.m_41619_()) { Item item = this.f_20935_.m_41720_(); @@ -635,7 +631,7 @@ return false; } else { return item.m_8105_(this.f_20935_) - this.f_20936_ >= 5; -@@ -3127,8 +_,8 @@ +@@ -3174,8 +_,8 @@ } BlockState blockstate = this.m_9236_().m_8055_(p_21141_); @@ -646,12 +642,12 @@ } this.m_20124_(Pose.SLEEPING); -@@ -3144,16 +_,16 @@ +@@ -3191,16 +_,16 @@ private boolean m_21334_() { - return this.m_21257_().map((p_289310_) -> { -- return this.m_9236_().m_8055_(p_289310_).m_60734_() instanceof BedBlock; -+ return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_289310_); + return this.m_21257_().map((p_296657_) -> { +- return this.m_9236_().m_8055_(p_296657_).m_60734_() instanceof BedBlock; ++ return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_296657_); }).orElse(false); } @@ -666,7 +662,7 @@ Vec3 vec31 = BedBlock.m_260958_(this.m_6095_(), this.m_9236_(), p_261435_, direction, this.m_146908_()).orElseGet(() -> { BlockPos blockpos = p_261435_.m_7494_(); return new Vec3((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.1D, (double)blockpos.m_123343_() + 0.5D); -@@ -3175,7 +_,9 @@ +@@ -3222,7 +_,9 @@ @Nullable public Direction m_21259_() { BlockPos blockpos = this.m_21257_().orElse((BlockPos)null); @@ -677,7 +673,7 @@ } public boolean m_5830_() { -@@ -3191,7 +_,7 @@ +@@ -3238,7 +_,7 @@ } public ItemStack m_6298_(ItemStack p_21272_) { @@ -686,7 +682,7 @@ } public ItemStack m_5584_(Level p_21067_, ItemStack p_21068_) { -@@ -3211,7 +_,7 @@ +@@ -3258,7 +_,7 @@ private void m_21063_(ItemStack p_21064_, Level p_21065_, LivingEntity p_21066_) { Item item = p_21064_.m_41720_(); if (item.m_41472_()) { @@ -695,7 +691,7 @@ if (!p_21065_.f_46443_ && pair.getFirst() != null && p_21065_.f_46441_.m_188501_() < pair.getSecond()) { p_21066_.m_7292_(new MobEffectInstance(pair.getFirst())); } -@@ -3247,6 +_,64 @@ +@@ -3294,6 +_,64 @@ this.m_21166_(p_21191_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND); } @@ -760,7 +756,7 @@ public AABB m_6921_() { if (this.m_6844_(EquipmentSlot.HEAD).m_150930_(Items.f_42683_)) { float f = 0.5F; -@@ -3257,6 +_,8 @@ +@@ -3304,6 +_,8 @@ } public static EquipmentSlot m_147233_(ItemStack p_147234_) { diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index b35b97d533..a5b9911b89 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -115,6 +_,9 @@ +@@ -117,6 +_,9 @@ private CompoundTag f_21359_; private BlockPos f_21360_ = BlockPos.f_121853_; private float f_21341_ = -1.0F; @@ -10,7 +10,7 @@ protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); -@@ -229,7 +_,10 @@ +@@ -231,7 +_,10 @@ } public void m_6710_(@Nullable LivingEntity p_21544_) { @@ -22,7 +22,7 @@ } public boolean m_6549_(EntityType p_21399_) { -@@ -427,6 +_,9 @@ +@@ -429,6 +_,9 @@ p_21484_.m_128379_("NoAI", this.m_21525_()); } @@ -32,7 +32,7 @@ } public void m_7378_(CompoundTag p_21450_) { -@@ -479,6 +_,14 @@ +@@ -481,6 +_,14 @@ } this.m_21557_(p_21450_.m_128471_("NoAI")); @@ -47,7 +47,7 @@ } protected void m_7625_(DamageSource p_21389_, boolean p_21390_) { -@@ -518,9 +_,9 @@ +@@ -520,9 +_,9 @@ public void m_8107_() { super.m_8107_(); this.m_9236_().m_46473_().m_6180_("looting"); @@ -58,7 +58,7 @@ for(ItemEntity itementity : this.m_9236_().m_45976_(ItemEntity.class, this.m_20191_().m_82377_((double)vec3i.m_123341_(), (double)vec3i.m_123342_(), (double)vec3i.m_123343_()))) { if (!itementity.m_213877_() && !itementity.m_32055_().m_41619_() && !itementity.m_32063_() && this.m_7243_(itementity.m_32055_())) { this.m_7581_(itementity); -@@ -692,6 +_,14 @@ +@@ -698,6 +_,14 @@ this.m_146870_(); } else if (!this.m_21532_() && !this.m_8023_()) { Entity entity = this.m_9236_().m_45930_(this, -1.0D); @@ -73,7 +73,7 @@ if (entity != null) { double d0 = entity.m_20280_(this); int i = this.m_6095_().m_20674_().m_21611_(); -@@ -1025,6 +_,16 @@ +@@ -1031,6 +_,16 @@ } @@ -90,7 +90,7 @@ @Nullable public SpawnGroupData m_6518_(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, MobSpawnType p_21436_, @Nullable SpawnGroupData p_21437_, @Nullable CompoundTag p_21438_) { RandomSource randomsource = p_21434_.m_213780_(); -@@ -1035,6 +_,7 @@ +@@ -1041,6 +_,7 @@ this.m_21559_(false); } @@ -98,7 +98,7 @@ return p_21437_; } -@@ -1414,15 +_,25 @@ +@@ -1425,15 +_,25 @@ return false; } @@ -125,7 +125,7 @@ public void m_147272_() { this.m_262441_((p_262562_) -> { return true; -@@ -1449,5 +_,40 @@ +@@ -1460,5 +_,40 @@ public ItemStack m_142340_() { SpawnEggItem spawneggitem = SpawnEggItem.m_43213_(this.m_6095_()); return spawneggitem == null ? null : new ItemStack(spawneggitem); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch index 377c94efcc..b22522ad72 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch @@ -26,9 +26,9 @@ if (this.f_25543_ != null) { return true; @@ -98,6 +_,18 @@ - this.f_25545_ = livingentity.m_20186_(); this.f_25546_ = livingentity.m_20189_(); this.f_25547_ = 4 + this.f_25540_.m_217043_().m_188503_(7); + double d0 = this.f_25540_.m_20280_(livingentity); + if (this.canPenalize) { + this.f_25547_ += failedPathFindingPenalty; + if (this.f_25540_.m_21573_().m_26570_() != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch index a1debffc38..273497e734 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java +++ b/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -@@ -54,7 +_,7 @@ - if (entity instanceof Player) { +@@ -55,7 +_,7 @@ + Player player = (Player)entity; int i = this.f_25884_.m_30624_(); int j = this.f_25884_.m_7555_(); - if (j > 0 && this.f_25884_.m_217043_().m_188503_(j) < i) { + if (j > 0 && this.f_25884_.m_217043_().m_188503_(j) < i && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(f_25884_, (Player)entity)) { - this.f_25884_.m_30637_((Player)entity); + this.f_25884_.m_30637_(player); return; } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch index ef3495118d..3bfcd9ffa8 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -206,6 +_,17 @@ +@@ -202,6 +_,17 @@ public void m_27563_(ServerLevel p_27564_, Animal p_27565_) { AgeableMob ageablemob = this.m_142606_(p_27564_, p_27565_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch index 79de3ff689..96d199f6c7 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -365,8 +_,8 @@ +@@ -366,8 +_,8 @@ if (this.m_21830_(p_28153_)) { if (!(item instanceof DyeItem)) { if (item.m_41472_() && this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) { @@ -10,7 +10,7 @@ return InteractionResult.CONSUME; } -@@ -391,7 +_,7 @@ +@@ -392,7 +_,7 @@ } } else if (this.m_6898_(itemstack)) { this.m_142075_(p_28153_, p_28154_, itemstack); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch index 749f4c39df..7bd88382fe 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -653,13 +_,16 @@ +@@ -655,13 +_,16 @@ } protected void m_6668_(DamageSource p_28536_) { @@ -17,8 +17,8 @@ - super.m_6668_(p_28536_); } - public static boolean m_28471_(Fox p_28472_, LivingEntity p_28473_) { -@@ -809,6 +_,17 @@ + protected Vector3f m_292594_(Entity p_301360_, EntityDimensions p_299584_, float p_299082_) { +@@ -815,6 +_,17 @@ protected void m_8026_() { ServerLevel serverlevel = (ServerLevel)this.f_25114_; Fox fox = (Fox)this.f_25113_.m_142606_(serverlevel, this.f_25115_); @@ -36,7 +36,7 @@ if (fox != null) { ServerPlayer serverplayer = this.f_25113_.m_27592_(); ServerPlayer serverplayer1 = this.f_25115_.m_27592_(); -@@ -880,7 +_,7 @@ +@@ -886,7 +_,7 @@ } protected void m_28686_() { @@ -45,7 +45,7 @@ BlockState blockstate = Fox.this.m_9236_().m_8055_(this.f_25602_); if (blockstate.m_60713_(Blocks.f_50685_)) { this.m_148928_(blockstate); -@@ -935,7 +_,7 @@ +@@ -942,7 +_,7 @@ } public boolean m_8036_() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch index b4ec460db4..f65417518d 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java @@ -41,7 +_,7 @@ + import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; - import org.apache.commons.lang3.tuple.Pair; -public class MushroomCow extends Cow implements Shearable, VariantHolder { +public class MushroomCow extends Cow implements Shearable, net.minecraftforge.common.IForgeShearable { private static final EntityDataAccessor f_28908_ = SynchedEntityData.m_135353_(MushroomCow.class, EntityDataSerializers.f_135030_); private static final int f_148934_ = 1024; - @Nullable -@@ -103,7 +_,7 @@ + private static final String f_291553_ = "stew_effects"; +@@ -102,7 +_,7 @@ this.m_5496_(soundevent, 1.0F, 1.0F); return InteractionResult.m_19078_(this.m_9236_().f_46443_); @@ -18,7 +18,7 @@ this.m_5851_(SoundSource.PLAYERS); this.m_146852_(GameEvent.f_157781_, p_28941_); if (!this.m_9236_().f_46443_) { -@@ -144,7 +_,17 @@ +@@ -141,7 +_,17 @@ } } @@ -36,7 +36,7 @@ this.m_9236_().m_6269_((Player)null, this, SoundEvents.f_12075_, p_28924_, 1.0F, 1.0F); if (!this.m_9236_().m_5776_()) { Cow cow = EntityType.f_20557_.m_20615_(this.m_9236_()); -@@ -166,11 +_,14 @@ +@@ -163,11 +_,14 @@ cow.m_20331_(this.m_20147_()); this.m_9236_().m_7967_(cow); @@ -52,30 +52,14 @@ } -@@ -183,6 +_,7 @@ - p_28944_.m_128359_("Type", this.m_28554_().m_7912_()); - if (this.f_28909_ != null) { - p_28944_.m_128405_("EffectId", MobEffect.m_19459_(this.f_28909_)); -+ net.minecraftforge.common.ForgeHooks.saveMobEffect(p_28944_, "forge:effect_id", this.f_28909_); - p_28944_.m_128405_("EffectDuration", this.f_28910_); - } - -@@ -193,6 +_,7 @@ - this.m_28464_(MushroomCow.MushroomType.m_28976_(p_28936_.m_128461_("Type"))); - if (p_28936_.m_128425_("EffectId", 99)) { - this.f_28909_ = MobEffect.m_19453_(p_28936_.m_128451_("EffectId")); -+ this.f_28909_ = net.minecraftforge.common.ForgeHooks.loadMobEffect(p_28936_, "forge:effect_id", this.f_28909_); - } - - if (p_28936_.m_128425_("EffectDuration", 99)) { -@@ -235,6 +_,11 @@ +@@ -231,6 +_,11 @@ } return mushroomcow$mushroomtype2; + } + + @Override -+ public boolean isShearable(@org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos) { ++ public boolean isShearable(ItemStack item, Level world, BlockPos pos) { + return m_6220_(); } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch index 7562580986..4505694809 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -160,7 +_,7 @@ +@@ -162,7 +_,7 @@ if ((this.f_28984_ == null || this.f_28984_.m_25955_()) && !this.m_29038_() && this.m_6898_(itemstack) && p_29021_.m_20280_(this) < 9.0D) { this.m_142075_(p_29021_, p_29022_, itemstack); if (!this.m_9236_().f_46443_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch index d092695100..0247353a47 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Parrot.java +++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -245,7 +_,7 @@ +@@ -246,7 +_,7 @@ } if (!this.m_9236_().f_46443_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch index 6cd396b00e..31ac80500c 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Pig.java +++ b/net/minecraft/world/entity/animal/Pig.java -@@ -201,7 +_,7 @@ +@@ -203,7 +_,7 @@ } public void m_8038_(ServerLevel p_29473_, LightningBolt p_29474_) { @@ -9,7 +9,7 @@ ZombifiedPiglin zombifiedpiglin = EntityType.f_20531_.m_20615_(p_29473_); if (zombifiedpiglin != null) { zombifiedpiglin.m_8061_(EquipmentSlot.MAINHAND, new ItemStack(Items.f_42430_)); -@@ -214,6 +_,7 @@ +@@ -216,6 +_,7 @@ } zombifiedpiglin.m_21530_(); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch index daa618894f..9556d8865a 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -524,7 +_,7 @@ +@@ -515,7 +_,7 @@ public boolean m_8036_() { if (this.f_25600_ <= 0) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch index 9f22bf0c0d..5b28076242 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/Sheep.java +++ b/net/minecraft/world/entity/animal/Sheep.java -@@ -61,7 +_,7 @@ - import net.minecraft.world.level.gameevent.GameEvent; +@@ -63,7 +_,7 @@ import net.minecraft.world.level.storage.loot.BuiltInLootTables; + import org.joml.Vector3f; -public class Sheep extends Animal implements Shearable { +public class Sheep extends Animal implements Shearable, net.minecraftforge.common.IForgeShearable { private static final int f_149039_ = 40; private static final EntityDataAccessor f_29799_ = SynchedEntityData.m_135353_(Sheep.class, EntityDataSerializers.f_135027_); private static final Map f_29800_ = Util.m_137469_(Maps.newEnumMap(DyeColor.class), (p_29841_) -> { -@@ -233,7 +_,7 @@ +@@ -235,7 +_,7 @@ public InteractionResult m_6071_(Player p_29853_, InteractionHand p_29854_) { ItemStack itemstack = p_29853_.m_21120_(p_29854_); @@ -18,10 +18,10 @@ if (!this.m_9236_().f_46443_ && this.m_6220_()) { this.m_5851_(SoundSource.PLAYERS); this.m_146852_(GameEvent.f_157781_, p_29853_); -@@ -386,5 +_,28 @@ +@@ -392,5 +_,27 @@ - protected float m_6431_(Pose p_29850_, EntityDimensions p_29851_) { - return 0.95F * p_29851_.f_20378_; + protected Vector3f m_292594_(Entity p_297780_, EntityDimensions p_298437_, float p_300315_) { + return new Vector3f(0.0F, p_298437_.f_20378_ - 0.0625F * p_300315_, 0.0F); + } + + @Override @@ -29,9 +29,8 @@ + return m_6220_(); + } + -+ @org.jetbrains.annotations.NotNull + @Override -+ public java.util.List onSheared(@Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos, int fortune) { ++ public java.util.List onSheared(@Nullable Player player, ItemStack item, Level world, BlockPos pos, int fortune) { + world.m_6269_(null, this, SoundEvents.f_12344_, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F); + this.m_146852_(GameEvent.f_157781_, player); + if (!world.f_46443_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch index d5f5f4b7d2..0159985959 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Wolf.java +++ b/net/minecraft/world/entity/animal/Wolf.java -@@ -324,11 +_,12 @@ +@@ -325,11 +_,12 @@ return flag ? InteractionResult.CONSUME : InteractionResult.PASS; } else if (this.m_21824_()) { if (this.m_6898_(itemstack) && this.m_21223_() < this.m_21233_()) { @@ -14,7 +14,7 @@ return InteractionResult.SUCCESS; } else { if (item instanceof DyeItem) { -@@ -364,7 +_,7 @@ +@@ -365,7 +_,7 @@ itemstack.m_41774_(1); } @@ -23,7 +23,7 @@ this.m_21828_(p_30412_); this.f_21344_.m_26573_(); this.m_6710_((LivingEntity)null); -@@ -403,7 +_,7 @@ +@@ -404,7 +_,7 @@ public boolean m_6898_(ItemStack p_30440_) { Item item = p_30440_.m_41720_(); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch index e95c241202..b57124590a 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -307,7 +_,7 @@ +@@ -302,7 +_,7 @@ } protected void m_7355_(BlockPos p_252056_, BlockState p_251457_) { -- if (p_251457_.m_60827_() == SoundType.f_56746_) { -+ if (p_251457_.getSoundType(m_9236_(), p_252056_, this) == SoundType.f_56746_) { +- if (p_251457_.m_204336_(BlockTags.f_290764_)) { ++ if (p_251457_.getSoundType(m_9236_(), p_252056_, this) == net.minecraft.world.level.block.SoundType.f_56746_) { this.m_5496_(SoundEvents.f_244016_, 1.0F, 1.0F); } else { this.m_5496_(SoundEvents.f_244506_, 1.0F, 1.0F); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index bbcf25cee7..c11a55ec3e 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -327,6 +_,7 @@ +@@ -328,6 +_,7 @@ this.f_30520_.m_19164_(this); this.m_7493_(); @@ -8,7 +8,7 @@ } protected void m_7493_() { -@@ -374,9 +_,9 @@ +@@ -375,9 +_,9 @@ protected void m_7355_(BlockPos p_30584_, BlockState p_30585_) { if (!p_30585_.m_278721_()) { BlockState blockstate = this.m_9236_().m_8055_(p_30584_.m_7494_()); @@ -20,7 +20,7 @@ } if (this.m_20160_() && this.f_30523_) { -@@ -786,6 +_,7 @@ +@@ -787,6 +_,7 @@ this.m_20334_(vec3.f_82479_, d1, vec3.f_82481_); this.m_30655_(true); this.f_19812_ = true; @@ -28,7 +28,7 @@ if (p_275435_.f_82481_ > 0.0D) { float f = Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)); float f1 = Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)); -@@ -1120,6 +_,25 @@ +@@ -1109,6 +_,25 @@ this.m_214179_(p_30555_.m_213780_()); return super.m_6518_(p_30555_, p_30556_, p_30557_, p_30558_, p_30559_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index 2a666811cb..991b930bc4 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -277,7 +_,7 @@ +@@ -275,7 +_,7 @@ } if (this.f_19797_ % 10 == 0) { diff --git a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index 9cab680f8e..959ebee1aa 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -102,6 +_,14 @@ +@@ -104,6 +_,14 @@ this.f_19794_ = true; this.f_19811_ = true; this.f_31074_ = new EnderDragonPhaseManager(this); @@ -15,7 +15,7 @@ } public void m_287231_(EndDragonFight p_287736_) { -@@ -157,7 +_,11 @@ +@@ -159,7 +_,11 @@ return adouble; } @@ -27,7 +27,7 @@ this.m_146874_(); if (this.m_9236_().f_46443_) { this.m_21153_(this.m_21223_()); -@@ -438,7 +_,7 @@ +@@ -433,7 +_,7 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); BlockState blockstate = this.m_9236_().m_8055_(blockpos); if (!blockstate.m_60795_() && !blockstate.m_204336_(BlockTags.f_215822_)) { @@ -36,7 +36,7 @@ flag1 = this.m_9236_().m_7471_(blockpos, false) || flag1; } else { flag = true; -@@ -529,7 +_,8 @@ +@@ -524,7 +_,8 @@ if (this.m_9236_() instanceof ServerLevel) { if (this.f_31084_ > 150 && this.f_31084_ % 5 == 0 && flag) { @@ -46,7 +46,7 @@ } if (this.f_31084_ == 1 && !this.m_20067_()) { -@@ -540,7 +_,8 @@ +@@ -535,7 +_,8 @@ this.m_6478_(MoverType.SELF, new Vec3(0.0D, (double)0.1F, 0.0D)); if (this.f_31084_ == 200 && this.m_9236_() instanceof ServerLevel) { if (flag) { @@ -56,7 +56,7 @@ } if (this.f_31073_ != null) { -@@ -863,8 +_,19 @@ +@@ -858,8 +_,19 @@ return false; } diff --git a/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch index 15bcac0432..06b5e501e2 100644 --- a/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -72,7 +_,7 @@ +@@ -71,7 +_,7 @@ public static final EntityDataAccessor f_31550_ = SynchedEntityData.m_135353_(ArmorStand.class, EntityDataSerializers.f_135037_); public static final EntityDataAccessor f_31527_ = SynchedEntityData.m_135353_(ArmorStand.class, EntityDataSerializers.f_135037_); private static final Predicate f_31537_ = (p_31582_) -> { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch index 4aef8d1e09..f819db3306 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -110,7 +_,6 @@ +@@ -111,7 +_,6 @@ } public void m_6710_(@Nullable LivingEntity p_32537_) { @@ -8,7 +8,7 @@ AttributeInstance attributeinstance = this.m_21051_(Attributes.f_22279_); if (p_32537_ == null) { this.f_32477_ = 0; -@@ -125,6 +_,7 @@ +@@ -126,6 +_,7 @@ } } @@ -16,7 +16,7 @@ } protected void m_8097_() { -@@ -199,7 +_,7 @@ +@@ -200,7 +_,7 @@ boolean m_32534_(Player p_32535_) { ItemStack itemstack = p_32535_.m_150109_().f_35975_.get(3); @@ -25,7 +25,7 @@ return false; } else { Vec3 vec3 = p_32535_.m_20252_(1.0F).m_82541_(); -@@ -278,8 +_,10 @@ +@@ -283,8 +_,10 @@ boolean flag = blockstate.m_280555_(); boolean flag1 = blockstate.m_60819_().m_205070_(FluidTags.f_13131_); if (flag && !flag1) { @@ -37,7 +37,7 @@ if (flag2) { this.m_9236_().m_214171_(GameEvent.f_238175_, vec3, GameEvent.Context.m_223717_(this)); if (!this.m_20067_()) { -@@ -419,7 +_,7 @@ +@@ -424,7 +_,7 @@ public boolean m_8036_() { if (this.f_32554_.m_32530_() == null) { return false; @@ -46,7 +46,7 @@ return false; } else { return this.f_32554_.m_217043_().m_188503_(m_186073_(2000)) == 0; -@@ -439,7 +_,7 @@ +@@ -444,7 +_,7 @@ BlockState blockstate2 = this.f_32554_.m_32530_(); if (blockstate2 != null) { blockstate2 = Block.m_49931_(blockstate2, this.f_32554_.m_9236_(), blockpos); @@ -55,7 +55,7 @@ level.m_7731_(blockpos, blockstate2, 3); level.m_220407_(GameEvent.f_157797_, blockpos, GameEvent.Context.m_223719_(this.f_32554_, blockstate2)); this.f_32554_.m_32521_((BlockState)null); -@@ -449,7 +_,7 @@ +@@ -454,7 +_,7 @@ } private boolean m_32558_(Level p_32559_, BlockPos p_32560_, BlockState p_32561_, BlockState p_32562_, BlockState p_32563_, BlockPos p_32564_) { @@ -64,7 +64,7 @@ } } -@@ -551,7 +_,7 @@ +@@ -556,7 +_,7 @@ public boolean m_8036_() { if (this.f_32583_.m_32530_() != null) { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch index 710f303f8a..b5e793a63a 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -275,7 +_,7 @@ +@@ -279,7 +_,7 @@ return false; } else if (Evoker.this.f_19797_ < this.f_33775_) { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch index c9f4e58680..2bc3e01074 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -139,7 +_,7 @@ +@@ -129,7 +_,7 @@ this.m_21051_(Attributes.f_22279_).m_22100_(Mth.m_14139_(0.1D, d1, d0)); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch index c33ad79152..b6a1978cea 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -360,6 +_,12 @@ +@@ -354,6 +_,12 @@ if (blockpos1.m_123342_() > this.m_9236_().m_141937_() && this.m_9236_().m_46859_(blockpos1) && this.m_9236_().m_6857_().m_61937_(blockpos1) && this.m_9236_().m_45756_(this, (new AABB(blockpos1)).m_82406_(1.0E-6D))) { Direction direction = this.m_149810_(blockpos1); if (direction != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch index a83fcdfec2..6816204604 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -140,7 +_,7 @@ +@@ -141,7 +_,7 @@ return false; } else { RandomSource randomsource = this.f_25725_.m_217043_(); @@ -9,7 +9,7 @@ this.f_33555_ = Direction.m_235672_(randomsource); BlockPos blockpos = BlockPos.m_274561_(this.f_25725_.m_20185_(), this.f_25725_.m_20186_() + 0.5D, this.f_25725_.m_20189_()).m_121945_(this.f_33555_); BlockState blockstate = this.f_25725_.m_9236_().m_8055_(blockpos); -@@ -209,7 +_,7 @@ +@@ -210,7 +_,7 @@ BlockState blockstate = level.m_8055_(blockpos1); Block block = blockstate.m_60734_(); if (block instanceof InfestedBlock) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch index ca767902fe..424e8d9413 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -124,6 +_,8 @@ +@@ -130,6 +_,8 @@ if (this.m_20096_() && !this.f_33583_) { int i = this.m_33632_(); @@ -9,7 +9,7 @@ for(int j = 0; j < i * 8; ++j) { float f = this.f_19796_.m_188501_() * ((float)Math.PI * 2F); float f1 = this.f_19796_.m_188501_() * 0.5F + 0.5F; -@@ -319,6 +_,12 @@ +@@ -329,6 +_,12 @@ public EntityDimensions m_6972_(Pose p_33597_) { return super.m_6972_(p_33597_).m_20388_(0.255F * (float)this.m_33632_()); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch index 7301595c76..e4f0cf648f 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Spider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Spider.java +++ b/net/minecraft/world/entity/monster/Spider.java -@@ -119,7 +_,12 @@ +@@ -121,7 +_,12 @@ } public boolean m_7301_(MobEffectInstance p_33809_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch index 0d5cf69d17..84cdfef1e9 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -192,7 +_,7 @@ +@@ -193,7 +_,7 @@ if (!this.m_9236_().f_46443_ && this.m_6084_() && !this.m_21525_()) { if (this.m_34329_()) { --this.f_34266_; @@ -9,7 +9,7 @@ this.m_7595_(); } } else if (this.m_7593_()) { -@@ -254,6 +_,7 @@ +@@ -255,6 +_,7 @@ if (zombie != null) { zombie.m_34339_(zombie.m_9236_().m_6436_(zombie.m_20183_()).m_19057_()); zombie.m_34336_(zombie.m_7586_() && this.m_34330_()); @@ -17,7 +17,7 @@ } } -@@ -274,11 +_,15 @@ +@@ -275,11 +_,15 @@ livingentity = (LivingEntity)p_34288_.m_7639_(); } @@ -35,7 +35,7 @@ for(int l = 0; l < 50; ++l) { int i1 = i + Mth.m_216271_(this.f_19796_, 7, 40) * Mth.m_216271_(this.f_19796_, -1, 1); -@@ -290,6 +_,7 @@ +@@ -291,6 +_,7 @@ if (NaturalSpawner.m_47051_(spawnplacements$type, this.m_9236_(), blockpos, entitytype) && SpawnPlacements.m_217074_(entitytype, serverlevel, MobSpawnType.REINFORCEMENT, blockpos, this.m_9236_().f_46441_)) { zombie.m_6034_((double)i1, (double)j1, (double)k1); if (!this.m_9236_().m_45914_((double)i1, (double)j1, (double)k1, 7.0D) && this.m_9236_().m_45784_(zombie) && this.m_9236_().m_45786_(zombie) && !this.m_9236_().m_46855_(zombie.m_20191_())) { @@ -43,7 +43,7 @@ zombie.m_6710_(livingentity); zombie.m_6518_(serverlevel, this.m_9236_().m_6436_(zombie.m_20183_()), MobSpawnType.REINFORCEMENT, (SpawnGroupData)null, (CompoundTag)null); serverlevel.m_47205_(zombie); -@@ -375,7 +_,7 @@ +@@ -376,7 +_,7 @@ public boolean m_214076_(ServerLevel p_219160_, LivingEntity p_219161_) { boolean flag = super.m_214076_(p_219160_, p_219161_); @@ -52,7 +52,7 @@ if (p_219160_.m_46791_() != Difficulty.HARD && this.f_19796_.m_188499_()) { return flag; } -@@ -387,6 +_,7 @@ +@@ -388,6 +_,7 @@ zombievillager.m_34391_(villager.m_35517_().m_262795_(NbtOps.f_128958_)); zombievillager.m_34411_(villager.m_6616_().m_45388_()); zombievillager.m_34373_(villager.m_7809_()); @@ -60,7 +60,7 @@ if (!this.m_20067_()) { p_219160_.m_5898_((Player)null, 1026, this.m_20183_(), 0); } -@@ -464,7 +_,7 @@ +@@ -465,7 +_,7 @@ } public static boolean m_219162_(RandomSource p_219163_) { @@ -69,7 +69,7 @@ } protected void m_34339_(float p_34340_) { -@@ -484,7 +_,7 @@ +@@ -485,7 +_,7 @@ } protected void m_7572_() { @@ -77,4 +77,4 @@ + this.m_21051_(Attributes.f_22287_).m_22100_(this.f_19796_.m_188500_() * net.minecraftforge.common.ForgeConfig.SERVER.zombieBaseSummonChance.get()); } - public double m_6049_() { + protected Vector3f m_292594_(Entity p_300549_, EntityDimensions p_298020_, float p_298000_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch index 4dcedc9e3c..e10760746a 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -126,7 +_,7 @@ +@@ -129,7 +_,7 @@ if (!this.m_9236_().f_46443_ && this.m_6084_() && this.m_34408_()) { int i = this.m_34410_(); this.f_34365_ -= i; @@ -9,7 +9,7 @@ this.m_34398_((ServerLevel)this.m_9236_()); } } -@@ -228,7 +_,7 @@ +@@ -231,7 +_,7 @@ if (!this.m_20067_()) { p_34399_.m_5898_((Player)null, 1027, this.m_20183_(), 0); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index c5ab012bb2..a5a4635e04 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -126,7 +_,7 @@ +@@ -128,7 +_,7 @@ HoglinAi.m_34577_(this); if (this.m_34554_()) { ++this.f_34484_; @@ -9,7 +9,7 @@ this.m_219179_(SoundEvents.f_11959_); this.m_34531_((ServerLevel)this.m_9236_()); } -@@ -219,6 +_,7 @@ +@@ -221,6 +_,7 @@ Zoglin zoglin = this.m_21406_(EntityType.f_20500_, true); if (zoglin != null) { zoglin.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index 37347773e3..5308ab734d 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -87,9 +_,10 @@ +@@ -93,9 +_,10 @@ ++this.f_34649_; } else { this.f_34649_ = 0; @@ -12,7 +12,7 @@ this.m_7580_(); this.m_8063_((ServerLevel)this.m_9236_()); } -@@ -104,6 +_,7 @@ +@@ -110,6 +_,7 @@ ZombifiedPiglin zombifiedpiglin = this.m_21406_(EntityType.f_20531_, true); if (zombifiedpiglin != null) { zombifiedpiglin.m_7292_(new MobEffectInstance(MobEffects.f_19604_, 200, 0)); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 90fbc82ec3..f48848deb8 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -293,7 +_,7 @@ +@@ -289,7 +_,7 @@ } else if (this.m_34773_()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { @@ -9,7 +9,7 @@ } } -@@ -335,7 +_,7 @@ +@@ -331,7 +_,7 @@ } protected void m_34785_(ItemStack p_34786_) { @@ -18,7 +18,7 @@ this.m_8061_(EquipmentSlot.OFFHAND, p_34786_); this.m_21508_(EquipmentSlot.OFFHAND); } else { -@@ -345,7 +_,7 @@ +@@ -341,7 +_,7 @@ } public boolean m_7243_(ItemStack p_34777_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch index 150b54e0a1..b10499746e 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch @@ -3,9 +3,9 @@ @@ -10,7 +_,7 @@ return BehaviorBuilder.m_258034_((p_259197_) -> { return p_259197_.group(p_259197_.m_258080_(MemoryModuleType.f_26336_)).apply(p_259197_, (p_259512_) -> { - return (p_289481_, p_289482_, p_289483_) -> { -- if (!p_289482_.m_21206_().m_41619_() && !p_289482_.m_21206_().m_150930_(Items.f_42740_)) { -+ if (!p_289482_.m_21206_().m_41619_() && !p_289482_.m_21206_().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { - PiglinAi.m_34867_(p_289482_, true); + return (p_296847_, p_296848_, p_296849_) -> { +- if (!p_296848_.m_21206_().m_41619_() && !p_296848_.m_21206_().m_150930_(Items.f_42740_)) { ++ if (!p_296848_.m_21206_().m_41619_() && !p_296848_.m_21206_().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { + PiglinAi.m_34867_(p_296848_, true); return true; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch index 0f7a16feaf..ecb3a470ec 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -255,7 +_,7 @@ +@@ -256,7 +_,7 @@ public InteractionResult m_6071_(Player p_35472_, InteractionHand p_35473_) { ItemStack itemstack = p_35472_.m_21120_(p_35473_); @@ -9,7 +9,7 @@ if (this.m_6162_()) { this.m_35518_(); return InteractionResult.m_19078_(this.m_9236_().f_46443_); -@@ -669,7 +_,8 @@ +@@ -670,7 +_,8 @@ } protected Component m_5677_() { @@ -19,7 +19,7 @@ } public void m_7822_(byte p_35391_) { -@@ -722,7 +_,7 @@ +@@ -723,7 +_,7 @@ } public void m_8038_(ServerLevel p_35409_, LightningBolt p_35410_) { @@ -28,7 +28,7 @@ f_201976_.info("Villager {} was struck by lightning {}.", this, p_35410_); Witch witch = EntityType.f_20495_.m_20615_(p_35409_); if (witch != null) { -@@ -735,6 +_,7 @@ +@@ -736,6 +_,7 @@ } witch.m_21530_(); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch index 8111ee9fcb..c0edb7a6bb 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -115,7 +_,8 @@ +@@ -114,7 +_,8 @@ import net.minecraft.world.scores.Team; import org.slf4j.Logger; @@ -9,8 +9,8 @@ + public static final String PERSISTED_NBT_TAG = "PlayerPersisted"; private static final Logger f_219722_ = LogUtils.getLogger(); public static final int f_150082_ = 16; - public static final int f_150083_ = 20; -@@ -168,6 +_,9 @@ + public static final HumanoidArm f_291841_ = HumanoidArm.RIGHT; +@@ -169,6 +_,9 @@ @Nullable public FishingHook f_36083_; protected float f_263750_; @@ -20,7 +20,7 @@ public Player(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_) { super(EntityType.f_20532_, p_250508_); -@@ -193,7 +_,7 @@ +@@ -194,7 +_,7 @@ } public static AttributeSupplier.Builder m_36340_() { @@ -29,7 +29,7 @@ } protected void m_8097_() { -@@ -207,6 +_,7 @@ +@@ -208,6 +_,7 @@ } public void m_8119_() { @@ -37,16 +37,16 @@ this.f_19794_ = this.m_5833_(); if (this.m_5833_()) { this.m_6853_(false); -@@ -222,7 +_,7 @@ +@@ -223,7 +_,7 @@ this.f_36110_ = 100; } - if (!this.m_9236_().f_46443_ && this.m_9236_().m_46461_()) { -+ if (!this.m_9236_().f_46443_ && !net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, m_21257_())) { ++ if (!this.m_9236_().f_46443_ && !net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, m_21257_())) { this.m_6145_(false, true); } } else if (this.f_36110_ > 0) { -@@ -277,6 +_,7 @@ +@@ -278,6 +_,7 @@ this.m_36372_(); this.f_36087_.m_41518_(); this.m_7594_(); @@ -54,7 +54,7 @@ } public boolean m_36341_() { -@@ -352,6 +_,10 @@ +@@ -353,6 +_,10 @@ } protected void m_7594_() { @@ -62,10 +62,10 @@ + this.m_20124_(forcedPose); + return; + } - if (this.m_20175_(Pose.SWIMMING)) { + if (this.m_295652_(Pose.SWIMMING)) { Pose pose; if (this.m_21255_()) { -@@ -573,6 +_,7 @@ +@@ -577,6 +_,7 @@ } public void m_6667_(DamageSource p_36152_) { @@ -73,7 +73,7 @@ super.m_6667_(p_36152_); this.m_20090_(); if (!this.m_5833_()) { -@@ -622,7 +_,7 @@ +@@ -626,7 +_,7 @@ @Nullable public ItemEntity m_36176_(ItemStack p_36177_, boolean p_36178_) { @@ -82,7 +82,7 @@ } @Nullable -@@ -660,7 +_,12 @@ +@@ -664,7 +_,12 @@ } } @@ -95,7 +95,7 @@ float f = this.f_36093_.m_36020_(p_36282_); if (f > 1.0F) { int i = EnchantmentHelper.m_44926_(this); -@@ -702,11 +_,12 @@ +@@ -706,11 +_,12 @@ f /= 5.0F; } @@ -109,7 +109,7 @@ } public void m_7378_(CompoundTag p_36215_) { -@@ -792,6 +_,7 @@ +@@ -796,6 +_,7 @@ } public boolean m_6469_(DamageSource p_36154_, float p_36155_) { @@ -117,7 +117,7 @@ if (this.m_6673_(p_36154_)) { return false; } else if (this.f_36077_.f_35934_ && !p_36154_.m_269533_(DamageTypeTags.f_268738_)) { -@@ -826,7 +_,7 @@ +@@ -830,7 +_,7 @@ protected void m_6728_(LivingEntity p_36295_) { super.m_6728_(p_36295_); @@ -126,7 +126,7 @@ this.m_36384_(true); } -@@ -855,7 +_,7 @@ +@@ -859,7 +_,7 @@ } protected void m_7909_(float p_36383_) { @@ -135,7 +135,7 @@ if (!this.m_9236_().f_46443_) { this.m_36246_(Stats.f_12982_.m_12902_(this.f_20935_.m_41720_())); } -@@ -865,6 +_,8 @@ +@@ -869,6 +_,8 @@ InteractionHand interactionhand = this.m_7655_(); this.f_20935_.m_41622_(i, this, (p_219739_) -> { p_219739_.m_21190_(interactionhand); @@ -144,7 +144,7 @@ }); if (this.f_20935_.m_41619_()) { if (interactionhand == InteractionHand.MAIN_HAND) { -@@ -883,10 +_,13 @@ +@@ -887,10 +_,13 @@ protected void m_6475_(DamageSource p_36312_, float p_36313_) { if (!this.m_6673_(p_36312_)) { @@ -158,7 +158,7 @@ float f = p_36313_ - f1; if (f > 0.0F && f < 3.4028235E37F) { this.m_36222_(Stats.f_12933_, Math.round(f * 10.0F)); -@@ -949,6 +_,8 @@ +@@ -953,6 +_,8 @@ return InteractionResult.PASS; } else { @@ -167,7 +167,7 @@ ItemStack itemstack = this.m_21120_(p_36159_); ItemStack itemstack1 = itemstack.m_41777_(); InteractionResult interactionresult = p_36158_.m_6096_(this, p_36159_); -@@ -957,6 +_,9 @@ +@@ -961,6 +_,9 @@ itemstack.m_41764_(itemstack1.m_41613_()); } @@ -177,7 +177,7 @@ return interactionresult; } else { if (!itemstack.m_41619_() && p_36158_ instanceof LivingEntity) { -@@ -968,6 +_,7 @@ +@@ -972,6 +_,7 @@ if (interactionresult1.m_19077_()) { this.m_9236_().m_214171_(GameEvent.f_223708_, p_36158_.m_20182_(), GameEvent.Context.m_223717_(this)); if (itemstack.m_41619_() && !this.f_36077_.f_35937_) { @@ -185,7 +185,7 @@ this.m_21008_(p_36159_, ItemStack.f_41583_); } -@@ -997,6 +_,7 @@ +@@ -1001,6 +_,7 @@ return !this.f_36077_.f_35935_; } @@ -193,7 +193,7 @@ protected Vec3 m_5763_(Vec3 p_36201_, MoverType p_36202_) { if (!this.f_36077_.f_35935_ && p_36201_.f_82480_ <= 0.0D && (p_36202_ == MoverType.SELF || p_36202_ == MoverType.PLAYER) && this.m_36343_() && this.m_36386_()) { double d0 = p_36201_.f_82479_; -@@ -1047,11 +_,13 @@ +@@ -1051,11 +_,13 @@ return p_36201_; } @@ -207,7 +207,7 @@ if (p_36347_.m_6097_()) { if (!p_36347_.m_7313_(this)) { float f = (float)this.m_21133_(Attributes.f_22281_); -@@ -1065,11 +_,10 @@ +@@ -1069,11 +_,10 @@ float f2 = this.m_36403_(0.5F); f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -220,7 +220,7 @@ i += EnchantmentHelper.m_44894_(this); if (this.m_20142_() && flag) { this.m_9236_().m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12314_, this.m_5720_(), 1.0F, 1.0F); -@@ -1079,8 +_,10 @@ +@@ -1083,8 +_,10 @@ boolean flag2 = flag && this.f_19789_ > 0.0F && !this.m_20096_() && !this.m_6147_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19610_) && !this.m_20159_() && p_36347_ instanceof LivingEntity; flag2 = flag2 && !this.m_20142_(); @@ -232,7 +232,7 @@ } f += f1; -@@ -1088,9 +_,7 @@ +@@ -1092,9 +_,7 @@ double d0 = (double)(this.f_19787_ - this.f_19867_); if (flag && !flag2 && !flag1 && this.m_20096_() && d0 < (double)this.m_6113_()) { ItemStack itemstack = this.m_21120_(InteractionHand.MAIN_HAND); @@ -243,7 +243,7 @@ } float f4 = 0.0F; -@@ -1121,8 +_,9 @@ +@@ -1125,8 +_,9 @@ if (flag3) { float f3 = 1.0F + EnchantmentHelper.m_44821_(this) * f; @@ -255,7 +255,7 @@ livingentity.m_147240_((double)0.4F, (double)Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)), (double)(-Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)))); livingentity.m_6469_(this.m_269291_().m_269075_(this), f3); } -@@ -1163,13 +_,15 @@ +@@ -1167,13 +_,15 @@ EnchantmentHelper.m_44896_(this, p_36347_); ItemStack itemstack1 = this.m_21205_(); Entity entity = p_36347_; @@ -273,7 +273,7 @@ this.m_21008_(InteractionHand.MAIN_HAND, ItemStack.f_41583_); } } -@@ -1195,6 +_,7 @@ +@@ -1199,6 +_,7 @@ } } } @@ -281,7 +281,7 @@ } } -@@ -1211,7 +_,7 @@ +@@ -1215,7 +_,7 @@ } if (this.f_19796_.m_188501_() < f) { @@ -290,7 +290,7 @@ this.m_5810_(); this.m_9236_().m_7605_(this, (byte)30); } -@@ -1275,6 +_,7 @@ +@@ -1279,6 +_,7 @@ } public void m_6145_(boolean p_36226_, boolean p_36227_) { @@ -298,7 +298,7 @@ super.m_5796_(); if (this.m_9236_() instanceof ServerLevel && p_36227_) { ((ServerLevel)this.m_9236_()).m_8878_(); -@@ -1300,7 +_,7 @@ +@@ -1304,7 +_,7 @@ } else if (block instanceof BedBlock && BedBlock.m_49488_(p_36131_)) { return BedBlock.m_260958_(EntityType.f_20532_, p_36131_, p_36132_, blockstate.m_61143_(BedBlock.f_54117_), p_36133_); } else if (!p_36134_) { @@ -307,7 +307,7 @@ } else { boolean flag = block.m_48673_(blockstate); BlockState blockstate1 = p_36131_.m_8055_(p_36132_.m_7494_()); -@@ -1481,6 +_,7 @@ +@@ -1485,6 +_,7 @@ public boolean m_142535_(float p_150093_, float p_150094_, DamageSource p_150095_) { if (this.f_36077_.f_35936_) { @@ -315,7 +315,7 @@ return false; } else { if (p_150093_ >= 2.0F) { -@@ -1494,7 +_,7 @@ +@@ -1498,7 +_,7 @@ public boolean m_36319_() { if (!this.m_20096_() && !this.m_21255_() && !this.m_20069_() && !this.m_21023_(MobEffects.f_19620_)) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); @@ -324,7 +324,7 @@ this.m_36320_(); return true; } -@@ -1522,13 +_,13 @@ +@@ -1526,13 +_,13 @@ protected void m_7355_(BlockPos p_282121_, BlockState p_282194_) { if (this.m_20069_()) { this.m_280447_(); @@ -340,7 +340,7 @@ } else { super.m_7355_(blockpos, blockstate); } -@@ -1556,6 +_,10 @@ +@@ -1560,6 +_,10 @@ } public void m_6756_(int p_36291_) { @@ -351,7 +351,7 @@ this.m_36401_(p_36291_); this.f_36080_ += (float)p_36291_ / (float)this.m_36323_(); this.f_36079_ = Mth.m_14045_(this.f_36079_ + p_36291_, 0, Integer.MAX_VALUE); -@@ -1584,7 +_,7 @@ +@@ -1588,7 +_,7 @@ } public void m_7408_(ItemStack p_36172_, int p_36173_) { @@ -360,7 +360,7 @@ if (this.f_36078_ < 0) { this.f_36078_ = 0; this.f_36080_ = 0.0F; -@@ -1595,6 +_,10 @@ +@@ -1599,6 +_,10 @@ } public void m_6749_(int p_36276_) { @@ -371,7 +371,7 @@ this.f_36078_ += p_36276_; if (this.f_36078_ < 0) { this.f_36078_ = 0; -@@ -1790,7 +_,11 @@ +@@ -1794,7 +_,11 @@ } public Component m_5446_() { diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch index 37882eca8a..f5e8b24b4a 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -817,7 +_,7 @@ +@@ -816,7 +_,7 @@ } } @@ -9,7 +9,7 @@ VINDICATOR(EntityType.f_20493_, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityType.f_20568_, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityType.f_20513_, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -831,6 +_,20 @@ +@@ -830,6 +_,20 @@ private RaiderType(EntityType p_37821_, int[] p_37822_) { this.f_37814_ = p_37821_; this.f_37815_ = p_37822_; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index ece0a0d49b..b97151c74f 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -1,31 +1,24 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -45,7 +_,7 @@ - import net.minecraft.world.phys.AABB; +@@ -46,7 +_,7 @@ import net.minecraft.world.phys.Vec3; + import org.joml.Vector3f; -public abstract class AbstractMinecart extends Entity { +public abstract class AbstractMinecart extends Entity implements net.minecraftforge.common.extensions.IForgeAbstractMinecart { private static final EntityDataAccessor f_38079_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38080_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38081_ = SynchedEntityData.m_135353_(AbstractMinecart.class, EntityDataSerializers.f_135029_); -@@ -76,6 +_,7 @@ +@@ -84,6 +_,8 @@ p_38135_.put(RailShape.NORTH_WEST, Pair.of(vec3i2, vec3i)); p_38135_.put(RailShape.NORTH_EAST, Pair.of(vec3i2, vec3i1)); }); + private static net.minecraftforge.common.IMinecartCollisionHandler COLLISIONS = null; - private int f_38070_; - private double f_38071_; - private double f_38072_; -@@ -85,6 +_,7 @@ - private double f_38076_; - private double f_38077_; - private double f_38078_; + private boolean canBePushed = true; protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { super(p_38087_, p_38088_); -@@ -99,6 +_,14 @@ +@@ -98,6 +_,14 @@ this.f_19856_ = p_38094_; } @@ -40,7 +33,7 @@ public static AbstractMinecart m_38119_(Level p_38120_, double p_38121_, double p_38122_, double p_38123_, AbstractMinecart.Type p_38124_) { if (p_38124_ == AbstractMinecart.Type.CHEST) { return new MinecartChest(p_38120_, p_38121_, p_38122_, p_38123_); -@@ -133,7 +_,7 @@ +@@ -132,7 +_,7 @@ } public boolean m_6094_() { @@ -49,7 +42,7 @@ } protected Vec3 m_7643_(Direction.Axis p_38132_, BlockUtil.FoundRectangle p_38133_) { -@@ -303,9 +_,9 @@ +@@ -295,9 +_,9 @@ BlockPos blockpos = new BlockPos(k, i, j); BlockState blockstate = this.m_9236_().m_8055_(blockpos); this.f_287786_ = BaseRailBlock.m_49416_(blockstate); @@ -57,11 +50,11 @@ + if (canUseRail() && this.f_287786_) { this.m_6401_(blockpos, blockstate); - if (blockstate.m_60713_(Blocks.f_50285_)) { -+ if (blockstate.m_60734_() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.m_60734_()).isActivatorRail()) { ++ if (blockstate.m_60734_() instanceof PoweredRailBlock power && power.isActivatorRail()) { this.m_6025_(k, i, j, blockstate.m_61143_(PoweredRailBlock.f_55215_)); } } else { -@@ -330,8 +_,11 @@ +@@ -322,8 +_,11 @@ } this.m_19915_(this.m_146908_(), this.m_146909_()); @@ -73,9 +66,9 @@ + if (canBeRidden() && this.m_20184_().m_165925_() > 0.01D) { + List list = this.m_9236_().m_6249_(this, box, EntitySelector.m_20421_(this)); if (!list.isEmpty()) { - for(int l = 0; l < list.size(); ++l) { - Entity entity1 = list.get(l); -@@ -343,7 +_,7 @@ + for(Entity entity1 : list) { + if (!(entity1 instanceof Player) && !(entity1 instanceof IronGolem) && !(entity1 instanceof AbstractMinecart) && !this.m_20160_() && !entity1.m_20159_()) { +@@ -334,7 +_,7 @@ } } } else { @@ -84,7 +77,7 @@ if (!this.m_20363_(entity) && entity.m_6094_() && entity instanceof AbstractMinecart) { entity.m_7334_(this); } -@@ -368,16 +_,23 @@ +@@ -359,16 +_,23 @@ } protected void m_38163_() { @@ -110,7 +103,7 @@ } } -@@ -391,18 +_,19 @@ +@@ -382,18 +_,19 @@ d1 = (double)p_38156_.m_123342_(); boolean flag = false; boolean flag1 = false; @@ -133,7 +126,7 @@ switch (railshape) { case ASCENDING_EAST: this.m_20256_(vec31.m_82520_(-d3, 0.0D, 0.0D)); -@@ -448,7 +_,7 @@ +@@ -439,7 +_,7 @@ } } @@ -142,7 +135,7 @@ double d22 = this.m_20184_().m_165924_(); if (d22 < 0.03D) { this.m_20256_(Vec3.f_82478_); -@@ -477,10 +_,7 @@ +@@ -468,10 +_,7 @@ d0 = d23 + d4 * d14; d2 = d10 + d5 * d14; this.m_6034_(d0, d1, d2); @@ -154,7 +147,7 @@ if (vec3i.m_123342_() != 0 && Mth.m_14107_(this.m_20185_()) - p_38156_.m_123341_() == vec3i.m_123341_() && Mth.m_14107_(this.m_20189_()) - p_38156_.m_123343_() == vec3i.m_123343_()) { this.m_6034_(this.m_20185_(), this.m_20186_() + (double)vec3i.m_123342_(), this.m_20189_()); } else if (vec3i1.m_123342_() != 0 && Mth.m_14107_(this.m_20185_()) - p_38156_.m_123341_() == vec3i1.m_123341_() && Mth.m_14107_(this.m_20189_()) - p_38156_.m_123343_() == vec3i1.m_123343_()) { -@@ -508,7 +_,10 @@ +@@ -499,7 +_,10 @@ this.m_20334_(d26 * (double)(j - p_38156_.m_123341_()), vec35.f_82480_, d26 * (double)(i - p_38156_.m_123343_())); } @@ -166,7 +159,7 @@ Vec3 vec36 = this.m_20184_(); double d27 = vec36.m_165924_(); if (d27 > 0.01D) { -@@ -572,7 +_,7 @@ +@@ -563,7 +_,7 @@ BlockState blockstate = this.m_9236_().m_8055_(new BlockPos(i, j, k)); if (BaseRailBlock.m_49416_(blockstate)) { @@ -175,7 +168,7 @@ p_38098_ = (double)j; if (railshape.m_61745_()) { p_38098_ = (double)(j + 1); -@@ -611,7 +_,7 @@ +@@ -602,7 +_,7 @@ BlockState blockstate = this.m_9236_().m_8055_(new BlockPos(i, j, k)); if (BaseRailBlock.m_49416_(blockstate)) { @@ -184,7 +177,7 @@ Pair pair = m_38125_(railshape); Vec3i vec3i = pair.getFirst(); Vec3i vec3i1 = pair.getSecond(); -@@ -673,6 +_,10 @@ +@@ -664,6 +_,10 @@ } public void m_7334_(Entity p_38165_) { @@ -195,7 +188,7 @@ if (!this.m_9236_().f_46443_) { if (!p_38165_.f_19794_ && !this.f_19794_) { if (!this.m_20363_(p_38165_)) { -@@ -706,11 +_,11 @@ +@@ -697,11 +_,11 @@ Vec3 vec32 = this.m_20184_(); Vec3 vec33 = p_38165_.m_20184_(); @@ -209,7 +202,7 @@ p_38165_.m_20256_(vec33.m_82542_(0.2D, 1.0D, 0.2D)); p_38165_.m_5997_(vec32.f_82479_ + d0, 0.0D, vec32.f_82481_ + d1); this.m_20256_(vec32.m_82542_(0.95D, 1.0D, 0.95D)); -@@ -809,6 +_,42 @@ +@@ -818,6 +_,42 @@ public void m_38138_(boolean p_38139_) { this.m_20088_().m_135381_(f_38084_, p_38139_); } diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch index 79bf0d6dcd..aca7193fe9 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/Boat.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/vehicle/Boat.java +++ b/net/minecraft/world/entity/vehicle/Boat.java -@@ -50,7 +_,7 @@ - import net.minecraft.world.phys.shapes.Shapes; +@@ -52,7 +_,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; + import org.joml.Vector3f; -public class Boat extends Entity implements VariantHolder { +public class Boat extends Entity implements net.minecraftforge.common.extensions.IForgeBoat { private static final EntityDataAccessor f_38282_ = SynchedEntityData.m_135353_(Boat.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38283_ = SynchedEntityData.m_135353_(Boat.class, EntityDataSerializers.f_135028_); private static final EntityDataAccessor f_38284_ = SynchedEntityData.m_135353_(Boat.class, EntityDataSerializers.f_135029_); -@@ -455,7 +_,7 @@ +@@ -483,7 +_,7 @@ for(int i2 = i1; i2 < j1; ++i2) { blockpos$mutableblockpos.m_122178_(l1, k1, i2); FluidState fluidstate = this.m_9236_().m_6425_(blockpos$mutableblockpos); @@ -18,7 +18,7 @@ f = Math.max(f, fluidstate.m_76155_(this.m_9236_(), blockpos$mutableblockpos)); } -@@ -496,7 +_,7 @@ +@@ -524,7 +_,7 @@ blockpos$mutableblockpos.m_122178_(l1, k2, i2); BlockState blockstate = this.m_9236_().m_8055_(blockpos$mutableblockpos); if (!(blockstate.m_60734_() instanceof WaterlilyBlock) && Shapes.m_83157_(blockstate.m_60812_(this.m_9236_(), blockpos$mutableblockpos).m_83216_((double)l1, (double)k2, (double)i2), voxelshape, BooleanOp.f_82689_)) { @@ -27,7 +27,7 @@ ++k1; } } -@@ -525,7 +_,7 @@ +@@ -553,7 +_,7 @@ for(int i2 = i1; i2 < j1; ++i2) { blockpos$mutableblockpos.m_122178_(k1, l1, i2); FluidState fluidstate = this.m_9236_().m_6425_(blockpos$mutableblockpos); @@ -36,7 +36,7 @@ float f = (float)l1 + fluidstate.m_76155_(this.m_9236_(), blockpos$mutableblockpos); this.f_38277_ = Math.max((double)f, this.f_38277_); flag |= aabb.f_82289_ < (double)f; -@@ -555,7 +_,7 @@ +@@ -583,7 +_,7 @@ for(int i2 = i1; i2 < j1; ++i2) { blockpos$mutableblockpos.m_122178_(k1, l1, i2); FluidState fluidstate = this.m_9236_().m_6425_(blockpos$mutableblockpos); @@ -45,7 +45,7 @@ if (!fluidstate.m_76170_()) { return Boat.Status.UNDER_FLOWING_WATER; } -@@ -773,7 +_,7 @@ +@@ -783,7 +_,7 @@ } this.m_183634_(); @@ -54,7 +54,7 @@ this.f_19789_ -= (float)p_38307_; } -@@ -829,7 +_,7 @@ +@@ -839,7 +_,7 @@ } protected boolean m_7310_(Entity p_38390_) { @@ -63,7 +63,7 @@ } protected int m_213801_() { -@@ -858,6 +_,16 @@ +@@ -872,6 +_,16 @@ public boolean m_5842_() { return this.f_38279_ == Boat.Status.UNDER_WATER || this.f_38279_ == Boat.Status.UNDER_FLOWING_WATER; diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch index f2fd063093..e6114aa50f 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java +++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -147,7 +_,7 @@ +@@ -149,7 +_,7 @@ } protected boolean m_38988_(ItemStack p_38989_) { @@ -8,4 +8,4 @@ + return net.minecraftforge.common.ForgeHooks.getBurnTime(p_38989_, this.f_38957_) > 0; } - public int m_38995_() { + public float m_38995_() { diff --git a/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch index 1ae6b8680c..043f18bf69 100644 --- a/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java -@@ -91,10 +_,8 @@ +@@ -93,10 +_,8 @@ } slot.m_40234_(itemstack1, itemstack); diff --git a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 8bae4964f9..2bf3726132 100644 --- a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/inventory/EnchantmentMenu.java +++ b/net/minecraft/world/inventory/EnchantmentMenu.java -@@ -55,7 +_,7 @@ +@@ -54,7 +_,7 @@ }); this.m_38897_(new Slot(this.f_39449_, 1, 35, 47) { public boolean m_5857_(ItemStack p_39517_) { - return p_39517_.m_150930_(Items.f_42534_); + return p_39517_.m_204117_(net.minecraftforge.common.Tags.Items.ENCHANTING_FUELS); } - }); -@@ -86,23 +_,24 @@ + public Pair m_7543_() { +@@ -89,23 +_,24 @@ ItemStack itemstack = p_39461_.m_8020_(0); if (!itemstack.m_41619_() && itemstack.m_41792_()) { this.f_39450_.m_39292_((p_39485_, p_39486_) -> { @@ -37,7 +37,7 @@ } for(int l = 0; l < 3; ++l) { -@@ -235,7 +_,7 @@ +@@ -237,7 +_,7 @@ if (!this.m_38903_(itemstack1, 2, 38, true)) { return ItemStack.f_41583_; } diff --git a/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch index aaee4a35e1..618cad11cf 100644 --- a/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/RecipeBookMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/RecipeBookMenu.java +++ b/net/minecraft/world/inventory/RecipeBookMenu.java -@@ -29,6 +_,10 @@ +@@ -30,6 +_,10 @@ public abstract int m_6653_(); diff --git a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch index 5f226c8879..4c9fe07e52 100644 --- a/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/Slot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/Slot.java +++ b/net/minecraft/world/inventory/Slot.java -@@ -78,7 +_,7 @@ +@@ -82,7 +_,7 @@ @Nullable public Pair m_7543_() { @@ -9,7 +9,7 @@ } public ItemStack m_6201_(int p_40227_) { -@@ -91,6 +_,38 @@ +@@ -95,6 +_,38 @@ public boolean m_6659_() { return true; diff --git a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch index 91d1db6bc7..9de9503ef2 100644 --- a/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BoneMealItem.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/BoneMealItem.java +++ b/net/minecraft/world/item/BoneMealItem.java -@@ -33,7 +_,7 @@ +@@ -35,7 +_,7 @@ Level level = p_40637_.m_43725_(); BlockPos blockpos = p_40637_.m_8083_(); BlockPos blockpos1 = blockpos.m_121945_(p_40637_.m_43719_()); - if (m_40627_(p_40637_.m_43722_(), level, blockpos)) { + if (applyBonemeal(p_40637_.m_43722_(), level, blockpos, p_40637_.m_43723_())) { if (!level.f_46443_) { + p_40637_.m_43723_().m_146850_(GameEvent.f_223697_); level.m_46796_(1505, blockpos, 0); - } -@@ -54,8 +_,17 @@ +@@ -58,8 +_,17 @@ } } @@ -24,6 +24,6 @@ BlockState blockstate = p_40629_.m_8055_(p_40630_); + int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, p_40629_, p_40630_, blockstate, p_40628_); + if (hook != 0) return hook > 0; - if (blockstate.m_60734_() instanceof BonemealableBlock) { - BonemealableBlock bonemealableblock = (BonemealableBlock)blockstate.m_60734_(); - if (bonemealableblock.m_7370_(p_40629_, p_40630_, blockstate, p_40629_.f_46443_)) { + Block block = blockstate.m_60734_(); + if (block instanceof BonemealableBlock bonemealableblock) { + if (bonemealableblock.m_7370_(p_40629_, p_40630_, blockstate)) { diff --git a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch index f1aec6cf6c..c62e8c731a 100644 --- a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -29,16 +29,16 @@ if (blockhitresult.m_6662_() == HitResult.Type.MISS) { return InteractionResultHolder.m_19098_(itemstack); } else if (blockhitresult.m_6662_() != HitResult.Type.BLOCK) { -@@ -55,7 +_,7 @@ - ItemStack itemstack1 = bucketpickup.m_142598_(p_40703_, blockpos, blockstate1); - if (!itemstack1.m_41619_()) { +@@ -56,7 +_,7 @@ + ItemStack itemstack2 = bucketpickup.m_142598_(p_40704_, p_40703_, blockpos, blockstate1); + if (!itemstack2.m_41619_()) { p_40704_.m_36246_(Stats.f_12982_.m_12902_(this)); - bucketpickup.m_142298_().ifPresent((p_150709_) -> { + bucketpickup.getPickupSound(blockstate1).ifPresent((p_150709_) -> { p_40704_.m_5496_(p_150709_, 1.0F, 1.0F); }); p_40703_.m_142346_(p_40704_, GameEvent.f_157816_, blockpos); -@@ -71,8 +_,8 @@ +@@ -72,8 +_,8 @@ return InteractionResultHolder.m_19100_(itemstack); } else { BlockState blockstate = p_40703_.m_8055_(blockpos); @@ -49,7 +49,7 @@ this.m_142131_(p_40704_, p_40703_, itemstack, blockpos2); if (p_40704_ instanceof ServerPlayer) { CriteriaTriggers.f_10591_.m_285767_((ServerPlayer)p_40704_, blockpos2, itemstack); -@@ -97,7 +_,12 @@ +@@ -98,7 +_,12 @@ public void m_142131_(@Nullable Player p_150711_, Level p_150712_, ItemStack p_150713_, BlockPos p_150714_) { } @@ -59,13 +59,13 @@ + } + + public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container) { - if (!(this.f_40687_ instanceof FlowingFluid)) { - return false; - } else { -@@ -105,8 +_,12 @@ - Block block = blockstate.m_60734_(); - boolean flag = blockstate.m_60722_(this.f_40687_); - boolean flag1 = blockstate.m_60795_() || flag || block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).m_6044_(p_150717_, p_150718_, blockstate, this.f_40687_); + Fluid $$6 = this.f_40687_; + if ($$6 instanceof FlowingFluid flowingfluid) { + BlockState blockstate; +@@ -127,8 +_,12 @@ + } + + boolean flag1 = flag2; + java.util.Optional containedFluidStack = java.util.Optional.ofNullable(container).flatMap(net.minecraftforge.fluids.FluidUtil::getFluidContained); if (!flag1) { - return p_150719_ != null && this.m_142073_(p_150716_, p_150717_, p_150719_.m_82425_().m_121945_(p_150719_.m_82434_()), (BlockHitResult)null); @@ -74,18 +74,18 @@ + this.f_40687_.getFluidType().onVaporize(p_150716_, p_150717_, p_150718_, containedFluidStack.get()); + return true; } else if (p_150717_.m_6042_().f_63857_() && this.f_40687_.m_205067_(FluidTags.f_13131_)) { - int i = p_150718_.m_123341_(); - int j = p_150718_.m_123342_(); -@@ -118,7 +_,7 @@ - } + int l = p_150718_.m_123341_(); + int i = p_150718_.m_123342_(); +@@ -141,7 +_,7 @@ return true; -- } else if (block instanceof LiquidBlockContainer && this.f_40687_ == Fluids.f_76193_) { -+ } else if (block instanceof LiquidBlockContainer && ((LiquidBlockContainer)block).m_6044_(p_150717_,p_150718_,blockstate,f_40687_)) { - ((LiquidBlockContainer)block).m_7361_(p_150717_, p_150718_, blockstate, ((FlowingFluid)this.f_40687_).m_76068_(false)); - this.m_7718_(p_150716_, p_150717_, p_150718_); - return true; -@@ -138,8 +_,25 @@ + } else { +- if ($$7 instanceof LiquidBlockContainer) { ++ if ($$7 instanceof LiquidBlockContainer liquid && liquid.m_6044_(p_150716_, p_150717_, p_150718_, blockstate, f_40687_)) { + LiquidBlockContainer liquidblockcontainer1 = (LiquidBlockContainer)$$7; + if (this.f_40687_ == Fluids.f_76193_) { + liquidblockcontainer1.m_7361_(p_150717_, p_150718_, blockstate, flowingfluid.m_76068_(false)); +@@ -166,8 +_,24 @@ } protected void m_7718_(@Nullable Player p_40696_, LevelAccessor p_40697_, BlockPos p_40698_) { @@ -107,8 +107,7 @@ + private final java.util.function.Supplier fluidSupplier; + public Fluid getFluid() { return fluidSupplier.get(); } + -+ protected boolean canBlockContainFluid(Level worldIn, BlockPos posIn, BlockState blockstate) -+ { -+ return blockstate.m_60734_() instanceof LiquidBlockContainer && ((LiquidBlockContainer)blockstate.m_60734_()).m_6044_(worldIn, posIn, blockstate, this.f_40687_); ++ protected boolean canBlockContainFluid(Level worldIn, BlockPos posIn, BlockState blockstate) { ++ return blockstate.m_60734_() instanceof LiquidBlockContainer liquid && liquid.m_6044_(null, worldIn, posIn, blockstate, this.f_40687_); } } diff --git a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch index 4944ba0b39..065332d720 100644 --- a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch +++ b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch @@ -1,20 +1,19 @@ --- a/net/minecraft/world/item/CreativeModeTab.java +++ b/net/minecraft/world/item/CreativeModeTab.java -@@ -31,16 +_,40 @@ +@@ -31,16 +_,38 @@ private Consumer> f_256965_; private final Supplier f_256912_; private final CreativeModeTab.DisplayItemsGenerator f_256824_; + private net.minecraft.resources.ResourceLocation backgroundLocation; + private final boolean hasSearchBar; + private final int searchBarWidth; -+ private final net.minecraft.resources.ResourceLocation tabsImage; + private final int labelColor; + private final int slotColor; + public final List tabsBefore; + public final List tabsAfter; - CreativeModeTab(CreativeModeTab.Row p_260217_, int p_259557_, CreativeModeTab.Type p_260176_, Component p_260100_, Supplier p_259543_, CreativeModeTab.DisplayItemsGenerator p_259085_) { -+ CreativeModeTab(CreativeModeTab.Row p_260217_, int p_259557_, CreativeModeTab.Type p_260176_, Component p_260100_, Supplier p_259543_, CreativeModeTab.DisplayItemsGenerator p_259085_, net.minecraft.resources.ResourceLocation backgroundLocation, boolean hasSearchBar, int searchBarWidth, net.minecraft.resources.ResourceLocation tabsImage, int labelColor, int slotColor, List tabsBefore, List tabsAfter) { ++ CreativeModeTab(CreativeModeTab.Row p_260217_, int p_259557_, CreativeModeTab.Type p_260176_, Component p_260100_, Supplier p_259543_, CreativeModeTab.DisplayItemsGenerator p_259085_, net.minecraft.resources.ResourceLocation backgroundLocation, boolean hasSearchBar, int searchBarWidth, int labelColor, int slotColor, List tabsBefore, List tabsAfter) { this.f_256931_ = p_260217_; this.f_256967_ = p_259557_; this.f_40764_ = p_260100_; @@ -26,7 +25,6 @@ + this.backgroundLocation = backgroundLocation; + this.hasSearchBar = hasSearchBar; + this.searchBarWidth = searchBarWidth; -+ this.tabsImage = tabsImage; + this.labelColor = labelColor; + this.slotColor = slotColor; + this.tabsBefore = List.copyOf(tabsBefore); @@ -34,7 +32,7 @@ + } + + protected CreativeModeTab(CreativeModeTab.Builder builder) { -+ this(builder.f_256796_, builder.f_256977_, builder.f_256847_, builder.f_256856_, builder.f_256981_, builder.f_256953_, builder.backgroundLocation, builder.hasSearchBar, builder.searchBarWidth, builder.tabsImage, builder.labelColor, builder.slotColor, builder.tabsBefore, builder.tabsAfter); ++ this(builder.f_256796_, builder.f_256977_, builder.f_256847_, builder.f_256856_, builder.f_256981_, builder.f_256953_, builder.backgroundLocation, builder.hasSearchBar, builder.searchBarWidth, builder.labelColor, builder.slotColor, builder.tabsBefore, builder.tabsAfter); + } + + public static CreativeModeTab.Builder builder() { @@ -64,7 +62,7 @@ this.f_243839_ = creativemodetab$itemdisplaybuilder.f_244363_; this.f_243841_ = creativemodetab$itemdisplaybuilder.f_244585_; this.m_257466_(); -@@ -127,9 +_,34 @@ +@@ -127,6 +_,26 @@ } @@ -80,10 +78,6 @@ + return searchBarWidth; + } + -+ public net.minecraft.resources.ResourceLocation getTabsImage() { -+ return tabsImage; -+ } -+ + public int getLabelColor() { + return labelColor; + } @@ -95,19 +89,14 @@ public static class Builder { private static final CreativeModeTab.DisplayItemsGenerator f_256756_ = (p_270422_, p_259433_) -> { }; -+ private static final net.minecraft.resources.ResourceLocation CREATIVE_INVENTORY_TABS_IMAGE = new net.minecraft.resources.ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); - private final CreativeModeTab.Row f_256796_; - private final int f_256977_; - private Component f_256856_ = Component.m_237119_(); -@@ -142,6 +_,16 @@ +@@ -142,6 +_,15 @@ private boolean f_256854_ = false; private CreativeModeTab.Type f_256847_ = CreativeModeTab.Type.CATEGORY; private String f_257036_ = "items.png"; -+ @org.jetbrains.annotations.Nullable ++ @Nullable + private net.minecraft.resources.ResourceLocation backgroundLocation; + private boolean hasSearchBar = false; + private int searchBarWidth = 89; -+ private net.minecraft.resources.ResourceLocation tabsImage = CREATIVE_INVENTORY_TABS_IMAGE; + private int labelColor = 4210752; + private int slotColor = -2130706433; + private java.util.function.Function tabFactory = CreativeModeTab::new; @@ -116,7 +105,7 @@ public Builder(CreativeModeTab.Row p_259171_, int p_259661_) { this.f_256796_ = p_259171_; -@@ -180,11 +_,95 @@ +@@ -180,11 +_,87 @@ protected CreativeModeTab.Builder m_257623_(CreativeModeTab.Type p_259283_) { this.f_256847_ = p_259283_; @@ -159,14 +148,6 @@ + } + + /** -+ * Sets the image of the tab to a custom resource location, instead of an item's texture. -+ */ -+ public CreativeModeTab.Builder withTabsImage(net.minecraft.resources.ResourceLocation tabsImage) { -+ this.tabsImage = tabsImage; -+ return this; -+ } -+ -+ /** + * Sets the color of the tab label. + */ + public CreativeModeTab.Builder withLabelColor(int labelColor) { diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index cd8605e719..4d0b1ec396 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -75,12 +_,16 @@ +@@ -76,12 +_,16 @@ import net.minecraft.world.level.block.state.pattern.BlockInWorld; import org.slf4j.Logger; @@ -18,7 +18,7 @@ private static final Logger f_41585_ = LogUtils.getLogger(); public static final ItemStack f_41583_ = new ItemStack((Void)null); public static final DecimalFormat f_41584_ = Util.m_137469_(new DecimalFormat("#.##"), (p_41704_) -> { -@@ -136,28 +_,40 @@ +@@ -137,28 +_,40 @@ this(p_220155_.m_203334_(), p_220156_); } @@ -64,7 +64,7 @@ this.m_41721_(this.m_41773_()); } -@@ -173,7 +_,7 @@ +@@ -174,7 +_,7 @@ } public boolean m_41619_() { @@ -73,7 +73,7 @@ } public boolean m_246617_(FeatureFlagSet p_250869_) { -@@ -198,7 +_,7 @@ +@@ -199,7 +_,7 @@ } public Item m_41720_() { @@ -82,7 +82,7 @@ } public Holder m_220173_() { -@@ -226,6 +_,15 @@ +@@ -231,6 +_,15 @@ } public InteractionResult m_41661_(UseOnContext p_41662_) { @@ -98,7 +98,7 @@ Player player = p_41662_.m_43723_(); BlockPos blockpos = p_41662_.m_8083_(); BlockInWorld blockinworld = new BlockInWorld(p_41662_.m_43725_(), blockpos, false); -@@ -233,7 +_,7 @@ +@@ -238,7 +_,7 @@ return InteractionResult.PASS; } else { Item item = this.m_41720_(); @@ -107,7 +107,7 @@ if (player != null && interactionresult.m_146666_()) { player.m_36246_(Stats.f_12982_.m_12902_(item)); } -@@ -262,11 +_,15 @@ +@@ -267,11 +_,15 @@ p_41740_.m_128365_("tag", this.f_41590_.m_6426_()); } @@ -124,7 +124,7 @@ } public boolean m_41753_() { -@@ -274,7 +_,7 @@ +@@ -279,7 +_,7 @@ } public boolean m_41763_() { @@ -133,7 +133,7 @@ CompoundTag compoundtag = this.m_41783_(); return compoundtag == null || !compoundtag.m_128471_("Unbreakable"); } else { -@@ -283,19 +_,19 @@ +@@ -288,19 +_,19 @@ } public boolean m_41768_() { @@ -157,7 +157,7 @@ } public boolean m_220157_(int p_220158_, RandomSource p_220159_, @Nullable ServerPlayer p_220160_) { -@@ -331,6 +_,7 @@ +@@ -336,6 +_,7 @@ public void m_41622_(int p_41623_, T p_41624_, Consumer p_41625_) { if (!p_41624_.m_9236_().f_46443_ && (!(p_41624_ instanceof Player) || !((Player)p_41624_).m_150110_().f_35937_)) { if (this.m_41763_()) { @@ -165,7 +165,7 @@ if (this.m_220157_(p_41623_, p_41624_.m_217043_(), p_41624_ instanceof ServerPlayer ? (ServerPlayer)p_41624_ : null)) { p_41625_.accept(p_41624_); Item item = this.m_41720_(); -@@ -383,7 +_,7 @@ +@@ -388,7 +_,7 @@ } public boolean m_41735_(BlockState p_41736_) { @@ -174,7 +174,7 @@ } public InteractionResult m_41647_(Player p_41648_, LivingEntity p_41649_, InteractionHand p_41650_) { -@@ -394,7 +_,7 @@ +@@ -399,7 +_,7 @@ if (this.m_41619_()) { return f_41583_; } else { @@ -183,7 +183,7 @@ itemstack.m_41754_(this.m_41612_()); if (this.f_41590_ != null) { itemstack.f_41590_ = this.f_41590_.m_6426_(); -@@ -430,7 +_,7 @@ +@@ -435,7 +_,7 @@ if (!p_150943_.m_150930_(p_150944_.m_41720_())) { return false; } else { @@ -192,7 +192,7 @@ } } -@@ -522,7 +_,7 @@ +@@ -527,7 +_,7 @@ public void m_41751_(@Nullable CompoundTag p_41752_) { this.f_41590_ = p_41752_; @@ -201,7 +201,7 @@ this.m_41721_(this.m_41773_()); } -@@ -583,7 +_,7 @@ +@@ -588,7 +_,7 @@ public List m_41651_(@Nullable Player p_41652_, TooltipFlag p_41653_) { List list = Lists.newArrayList(); @@ -210,7 +210,7 @@ if (this.m_41788_()) { mutablecomponent.m_130940_(ChatFormatting.ITALIC); } -@@ -730,6 +_,7 @@ +@@ -735,6 +_,7 @@ list.add(f_243862_); } @@ -218,7 +218,7 @@ return list; } -@@ -738,7 +_,7 @@ +@@ -743,7 +_,7 @@ } private int m_41618_() { @@ -227,7 +227,7 @@ } public void m_41654_(ItemStack.TooltipPart p_41655_) { -@@ -853,9 +_,10 @@ +@@ -863,9 +_,10 @@ } } } else { @@ -239,7 +239,7 @@ return multimap; } -@@ -883,7 +_,7 @@ +@@ -893,7 +_,7 @@ MutableComponent mutablecomponent1 = ComponentUtils.m_130748_(mutablecomponent); if (!this.m_41619_()) { @@ -248,7 +248,7 @@ return p_220170_.m_131144_(new HoverEvent(HoverEvent.Action.f_130832_, new HoverEvent.ItemStackInfo(this))); }); } -@@ -935,12 +_,31 @@ +@@ -945,12 +_,31 @@ this.m_41720_().m_5929_(p_41732_, p_41733_, this, p_41734_); } diff --git a/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch b/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch deleted file mode 100644 index fb04d49fbc..0000000000 --- a/patches/minecraft/net/minecraft/world/item/SuspiciousStewItem.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/item/SuspiciousStewItem.java -+++ b/net/minecraft/world/item/SuspiciousStewItem.java -@@ -29,6 +_,7 @@ - ListTag listtag = compoundtag.m_128437_("Effects", 9); - CompoundTag compoundtag1 = new CompoundTag(); - compoundtag1.m_128405_("EffectId", MobEffect.m_19459_(p_43260_)); -+ net.minecraftforge.common.ForgeHooks.saveMobEffect(compoundtag1, "forge:effect_id", p_43260_); - compoundtag1.m_128405_("EffectDuration", p_43261_); - listtag.add(compoundtag1); - compoundtag.m_128365_("Effects", listtag); -@@ -49,6 +_,7 @@ - } - - MobEffect mobeffect = MobEffect.m_19453_(compoundtag1.m_128451_("EffectId")); -+ mobeffect = net.minecraftforge.common.ForgeHooks.loadMobEffect(compoundtag1, "forge:effect_id", mobeffect); - if (mobeffect != null) { - p_259500_.accept(new MobEffectInstance(mobeffect, j)); - } diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch index 6c7f064845..b133bd8357 100644 --- a/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch +++ b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/alchemy/Potion.java +++ b/net/minecraft/world/item/alchemy/Potion.java -@@ -7,7 +_,7 @@ +@@ -8,7 +_,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffectInstance; diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch index 4eabfa660d..a46bb9635d 100644 --- a/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch +++ b/patches/minecraft/net/minecraft/world/item/alchemy/PotionBrewing.java.patch @@ -1,36 +1,36 @@ --- a/net/minecraft/world/item/alchemy/PotionBrewing.java +++ b/net/minecraft/world/item/alchemy/PotionBrewing.java -@@ -57,7 +_,7 @@ - int i = 0; +@@ -51,7 +_,7 @@ - for(int j = f_43494_.size(); i < j; ++i) { -- if ((f_43494_.get(i)).f_43534_ == p_43512_) { -+ if ((f_43494_.get(i)).f_43534_.get() == p_43512_) { + public static boolean m_43511_(Potion p_43512_) { + for(PotionBrewing.Mix mix : f_43494_) { +- if (mix.f_43534_ == p_43512_) { ++ if (mix.f_43534_.get() == p_43512_) { return true; } } -@@ -79,7 +_,7 @@ +@@ -71,7 +_,7 @@ + Item item = p_43520_.m_41720_(); - for(int j = f_43495_.size(); i < j; ++i) { - PotionBrewing.Mix mix = f_43495_.get(i); + for(PotionBrewing.Mix mix : f_43495_) { - if (mix.f_43532_ == item && mix.f_43533_.test(p_43521_)) { + if (mix.f_43532_.get() == item && mix.f_43533_.test(p_43521_)) { return true; } } -@@ -93,7 +_,7 @@ +@@ -83,7 +_,7 @@ + Potion potion = PotionUtils.m_43579_(p_43525_); - for(int j = f_43494_.size(); i < j; ++i) { - PotionBrewing.Mix mix = f_43494_.get(i); + for(PotionBrewing.Mix mix : f_43494_) { - if (mix.f_43532_ == potion && mix.f_43533_.test(p_43526_)) { + if (mix.f_43532_.get() == potion && mix.f_43533_.test(p_43526_)) { return true; } } -@@ -109,8 +_,8 @@ +@@ -97,14 +_,14 @@ + Item item = p_43531_.m_41720_(); - for(int j = f_43495_.size(); i < j; ++i) { - PotionBrewing.Mix mix = f_43495_.get(i); + for(PotionBrewing.Mix mix : f_43495_) { - if (mix.f_43532_ == item && mix.f_43533_.test(p_43530_)) { - return PotionUtils.m_43549_(new ItemStack(mix.f_43534_), potion); + if (mix.f_43532_.get() == item && mix.f_43533_.test(p_43530_)) { @@ -38,10 +38,7 @@ } } -@@ -118,8 +_,8 @@ - - for(int k = f_43494_.size(); i < k; ++i) { - PotionBrewing.Mix mix1 = f_43494_.get(i); + for(PotionBrewing.Mix mix1 : f_43494_) { - if (mix1.f_43532_ == potion && mix1.f_43533_.test(p_43530_)) { - return PotionUtils.m_43549_(new ItemStack(item), mix1.f_43534_); + if (mix1.f_43532_.get() == potion && mix1.f_43533_.test(p_43530_)) { @@ -49,7 +46,7 @@ } } } -@@ -196,7 +_,7 @@ +@@ -181,7 +_,7 @@ } else if (!(p_43505_ instanceof PotionItem)) { throw new IllegalArgumentException("Expected a potion, got: " + BuiltInRegistries.f_257033_.m_7981_(p_43505_)); } else { @@ -58,7 +55,7 @@ } } -@@ -209,18 +_,18 @@ +@@ -194,18 +_,18 @@ } private static void m_43513_(Potion p_43514_, Item p_43515_, Potion p_43516_) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch index 06f8621a46..a30ba73be3 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java +++ b/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java -@@ -80,8 +_,8 @@ +@@ -79,8 +_,8 @@ for(int i = 0; i < nonnulllist.size(); ++i) { ItemStack itemstack = p_43791_.m_8020_(i); if (!itemstack.m_41619_()) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch index ececeab5ad..e1022b05a9 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/BookCloningRecipe.java +++ b/net/minecraft/world/item/crafting/BookCloningRecipe.java -@@ -80,8 +_,8 @@ +@@ -79,8 +_,8 @@ for(int i = 0; i < nonnulllist.size(); ++i) { ItemStack itemstack = p_43820_.m_8020_(i); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/FireworkStarRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/FireworkStarRecipe.java.patch index 4ac3372c11..e69d61fac3 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/FireworkStarRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/FireworkStarRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/FireworkStarRecipe.java +++ b/net/minecraft/world/item/crafting/FireworkStarRecipe.java -@@ -107,7 +_,7 @@ +@@ -106,7 +_,7 @@ } compoundtag.m_128408_("Colors", list); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch index 9b5c7138b8..7aeb437cb5 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Ingredient.java +++ b/net/minecraft/world/item/crafting/Ingredient.java -@@ -30,12 +_,19 @@ +@@ -30,6 +_,12 @@ import net.minecraft.world.level.ItemLike; public class Ingredient implements Predicate { @@ -13,14 +13,15 @@ public static final Ingredient f_43901_ = new Ingredient(Stream.empty()); private final Ingredient.Value[] f_43902_; @Nullable - private ItemStack[] f_43903_; - @Nullable +@@ -38,6 +_,7 @@ private IntList f_43904_; + public static final Codec f_291570_ = m_294319_(true); + public static final Codec f_290991_ = m_294319_(false); + private int invalidationCounter; protected Ingredient(Stream p_43907_) { this.f_43902_ = p_43907_.toArray((p_43933_) -> { -@@ -72,7 +_,8 @@ +@@ -78,7 +_,8 @@ } public IntList m_43931_() { @@ -30,19 +31,21 @@ ItemStack[] aitemstack = this.m_43908_(); this.f_43904_ = new IntArrayList(aitemstack.length); -@@ -87,6 +_,10 @@ +@@ -93,6 +_,12 @@ } public final void m_43923_(FriendlyByteBuf p_43924_) { ++ /* + if (!this.isVanilla()) { + net.minecraftforge.common.crafting.CraftingHelper.write(p_43924_, this); + return; + } ++ */ p_43924_.m_236828_(Arrays.asList(this.m_43908_()), FriendlyByteBuf::m_130055_); } -@@ -108,6 +_,38 @@ - return this.f_43902_.length == 0; +@@ -113,6 +_,40 @@ + } } + public final boolean checkInvalidation() { @@ -72,35 +75,28 @@ + return isVanilla; + } + ++ /* + public net.minecraftforge.common.crafting.IIngredientSerializer getSerializer() { + if (!isVanilla()) throw new IllegalStateException("Modders must implement Ingredient.getSerializer in their custom Ingredients: " + this); + return net.minecraftforge.common.crafting.VanillaIngredientSerializer.INSTANCE; + } ++ */ + public static Ingredient m_43938_(Stream p_43939_) { Ingredient ingredient = new Ingredient(p_43939_); return ingredient.m_43947_() ? f_43901_ : ingredient; -@@ -136,7 +_,9 @@ +@@ -141,7 +_,9 @@ } public static Ingredient m_43940_(FriendlyByteBuf p_43941_) { - return m_43938_(p_43941_.m_236845_(FriendlyByteBuf::m_130267_).stream().map(Ingredient.ItemValue::new)); + var size = p_43941_.m_130242_(); -+ if (size == -1) return net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_43941_.m_130281_(), p_43941_); ++ //if (size == -1) return net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_43941_.readResourceLocation(), p_43941_); + return m_43938_(Stream.generate(() -> new Ingredient.ItemValue(p_43941_.m_130267_())).limit(size)); } - public static Ingredient m_43917_(@Nullable JsonElement p_43918_) { -@@ -145,6 +_,8 @@ - - public static Ingredient m_288218_(@Nullable JsonElement p_289022_, boolean p_288974_) { - if (p_289022_ != null && !p_289022_.isJsonNull()) { -+ Ingredient ret = net.minecraftforge.common.crafting.CraftingHelper.getIngredient(p_289022_, p_288974_); -+ if (ret != null) return ret; - if (p_289022_.isJsonObject()) { - return m_43938_(Stream.of(m_43919_(p_289022_.getAsJsonObject()))); - } else if (p_289022_.isJsonArray()) { -@@ -179,6 +_,12 @@ + private static Codec m_294319_(boolean p_298496_) { +@@ -185,6 +_,12 @@ } } @@ -110,10 +106,10 @@ + return m_43938_(parts.stream().flatMap(i -> Arrays.stream(i.f_43902_))); + } + - public static class ItemValue implements Ingredient.Value { - private final ItemStack f_43951_; - -@@ -211,6 +_,9 @@ + public static record TagValue(TagKey f_43959_) implements Ingredient.Value { + static final Codec f_291685_ = RecordCodecBuilder.create((p_300241_) -> { + return p_300241_.group(TagKey.m_203877_(Registries.f_256913_).fieldOf("tag").forGetter((p_301340_) -> { +@@ -207,6 +_,9 @@ list.add(new ItemStack(holder)); } @@ -122,4 +118,4 @@ + } return list; } - + } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch index 442efbd6f8..dc2015da10 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/Recipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Recipe.java +++ b/net/minecraft/world/item/crafting/Recipe.java -@@ -22,9 +_,9 @@ +@@ -21,9 +_,9 @@ NonNullList nonnulllist = NonNullList.m_122780_(p_44004_.m_6643_(), ItemStack.f_41583_); for(int i = 0; i < nonnulllist.size(); ++i) { @@ -13,7 +13,7 @@ } } -@@ -60,7 +_,7 @@ +@@ -57,7 +_,7 @@ default boolean m_142505_() { NonNullList nonnulllist = this.m_7527_(); return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch((p_151268_) -> { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch index a913f23d81..8ff2582a51 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeManager.java +++ b/net/minecraft/world/item/crafting/RecipeManager.java -@@ -37,9 +_,17 @@ - private Map, Map>> f_44007_ = ImmutableMap.of(); - private Map> f_199900_ = ImmutableMap.of(); +@@ -40,9 +_,17 @@ + private Map, Map>> f_44007_ = ImmutableMap.of(); + private Map> f_199900_ = ImmutableMap.of(); private boolean f_44008_; + private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context; //Forge: add context @@ -18,42 +18,22 @@ } protected void m_5787_(Map p_44037_, ResourceManager p_44038_, ProfilerFiller p_44039_) { -@@ -49,9 +_,18 @@ +@@ -52,9 +_,18 @@ for(Map.Entry entry : p_44037_.entrySet()) { ResourceLocation resourcelocation = entry.getKey(); + if (resourcelocation.m_135815_().startsWith("_")) continue; //Forge: filter anything beginning with "_" as it's used for metadata. try { -- Recipe recipe = m_44045_(resourcelocation, GsonHelper.m_13918_(entry.getValue(), "top element")); + if (entry.getValue().isJsonObject() && !net.minecraftforge.common.crafting.CraftingHelper.processConditions(entry.getValue().getAsJsonObject(), "conditions", this.context)) { + f_44006_.debug("Skipping loading recipe {} as it's conditions were not met", resourcelocation); + continue; + } -+ Recipe recipe = fromJson(resourcelocation, GsonHelper.m_13918_(entry.getValue(), "top element"), this.context); -+ if (recipe == null) { + RecipeHolder recipeholder = m_44045_(resourcelocation, GsonHelper.m_13918_(entry.getValue(), "top element")); ++ if (recipeholder == null) { + f_44006_.info("Skipping loading recipe {} as it's serializer returned null", resourcelocation); + continue; + } - map.computeIfAbsent(recipe.m_6671_(), (p_44075_) -> { + map.computeIfAbsent(recipeholder.f_291008_().m_6671_(), (p_44075_) -> { return ImmutableMap.builder(); - }).put(resourcelocation, recipe); -@@ -141,11 +_,17 @@ - }); - } - -+ /** @deprecated Forge: use {@linkplain #fromJson(ResourceLocation, JsonObject, net.minecraftforge.common.crafting.conditions.ICondition.IContext) overload with context}. */ -+ @Deprecated - public static Recipe m_44045_(ResourceLocation p_44046_, JsonObject p_44047_) { -+ return fromJson(p_44046_, p_44047_, net.minecraftforge.common.crafting.conditions.ICondition.IContext.EMPTY); -+ } -+ -+ public static Recipe fromJson(ResourceLocation p_44046_, JsonObject p_44047_, net.minecraftforge.common.crafting.conditions.ICondition.IContext context) { - String s = GsonHelper.m_13906_(p_44047_, "type"); - return BuiltInRegistries.f_256769_.m_6612_(new ResourceLocation(s)).orElseThrow(() -> { - return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'"); -- }).m_6729_(p_44046_, p_44047_); -+ }).fromJson(p_44046_, p_44047_, context); - } - - public void m_44024_(Iterable> p_44025_) { + }).put(resourcelocation, recipeholder); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch index 31b3244f62..0fafe1fda6 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeSerializer.java.patch @@ -1,22 +1,10 @@ --- a/net/minecraft/world/item/crafting/RecipeSerializer.java +++ b/net/minecraft/world/item/crafting/RecipeSerializer.java -@@ -6,7 +_,7 @@ - import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.resources.ResourceLocation; +@@ -32,6 +_,7 @@ --public interface RecipeSerializer> { -+public interface RecipeSerializer> extends net.minecraftforge.common.extensions.IForgeRecipeSerializer { - RecipeSerializer f_44076_ = m_44098_("crafting_shaped", new ShapedRecipe.Serializer()); - RecipeSerializer f_44077_ = m_44098_("crafting_shapeless", new ShapelessRecipe.Serializer()); - RecipeSerializer f_44078_ = m_44098_("crafting_special_armordye", new SimpleCraftingRecipeSerializer<>(ArmorDyeRecipe::new)); -@@ -31,8 +_,10 @@ - RecipeSerializer f_265968_ = m_44098_("smithing_trim", new SmithingTrimRecipe.Serializer()); - RecipeSerializer f_271437_ = m_44098_("crafting_decorated_pot", new SimpleCraftingRecipeSerializer<>(DecoratedPotRecipe::new)); - -+ // Forge: use fromJson with IContext if you need the context - T m_6729_(ResourceLocation p_44103_, JsonObject p_44104_); + Codec m_292673_(); + @org.jetbrains.annotations.Nullable - T m_8005_(ResourceLocation p_44105_, FriendlyByteBuf p_44106_); + T m_8005_(FriendlyByteBuf p_44106_); void m_6178_(FriendlyByteBuf p_44101_, T p_44102_); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch index 18ac94ae6b..932886a22f 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RepairItemRecipe.java +++ b/net/minecraft/world/item/crafting/RepairItemRecipe.java -@@ -28,7 +_,7 @@ +@@ -27,7 +_,7 @@ list.add(itemstack); if (list.size() > 1) { ItemStack itemstack1 = list.get(0); @@ -9,7 +9,7 @@ return false; } } -@@ -47,7 +_,7 @@ +@@ -46,7 +_,7 @@ list.add(itemstack); if (list.size() > 1) { ItemStack itemstack1 = list.get(0); @@ -18,7 +18,7 @@ return ItemStack.f_41583_; } } -@@ -57,12 +_,12 @@ +@@ -56,12 +_,12 @@ if (list.size() == 2) { ItemStack itemstack3 = list.get(0); ItemStack itemstack4 = list.get(1); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch index 2c9b353d0d..5b0e1bf1d0 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -22,7 +_,20 @@ - import net.minecraft.world.item.Items; +@@ -17,7 +_,20 @@ import net.minecraft.world.level.Level; + import org.apache.commons.lang3.NotImplementedException; -public class ShapedRecipe implements CraftingRecipe { +public class ShapedRecipe implements CraftingRecipe, net.minecraftforge.common.crafting.IShapedRecipe { @@ -22,7 +22,7 @@ final int f_44146_; final int f_44147_; final NonNullList f_44148_; -@@ -126,10 +_,20 @@ +@@ -115,10 +_,20 @@ return this.f_44146_; } @@ -40,10 +40,10 @@ + return m_44221_(); + } + - static NonNullList m_44202_(String[] p_44203_, Map p_44204_, int p_44205_, int p_44206_) { - NonNullList nonnulllist = NonNullList.m_122780_(p_44205_ * p_44206_, Ingredient.f_43901_); - Set set = Sets.newHashSet(p_44204_.keySet()); -@@ -196,7 +_,7 @@ + @VisibleForTesting + static String[] m_44186_(List p_299210_) { + int i = Integer.MAX_VALUE; +@@ -160,7 +_,7 @@ return nonnulllist.isEmpty() || nonnulllist.stream().filter((p_151277_) -> { return !p_151277_.m_43947_(); }).anyMatch((p_151273_) -> { @@ -52,50 +52,27 @@ }); } -@@ -218,15 +_,15 @@ - - static String[] m_44196_(JsonArray p_44197_) { - String[] astring = new String[p_44197_.size()]; -- if (astring.length > 3) { -- throw new JsonSyntaxException("Invalid pattern: too many rows, 3 is maximum"); -+ if (astring.length > MAX_HEIGHT) { -+ throw new JsonSyntaxException("Invalid pattern: too many rows, " + MAX_HEIGHT + " is maximum"); - } else if (astring.length == 0) { - throw new JsonSyntaxException("Invalid pattern: empty pattern not allowed"); - } else { - for(int i = 0; i < astring.length; ++i) { - String s = GsonHelper.m_13805_(p_44197_.get(i), "pattern[" + i + "]"); -- if (s.length() > 3) { -- throw new JsonSyntaxException("Invalid pattern: too many columns, 3 is maximum"); -+ if (s.length() > MAX_WIDTH) { -+ throw new JsonSyntaxException("Invalid pattern: too many columns, " + MAX_WIDTH + " is maximum"); - } - - if (i > 0 && astring[0].length() != s.length()) { -@@ -260,17 +_,7 @@ - } - - public static ItemStack m_151274_(JsonObject p_151275_) { -- Item item = m_151278_(p_151275_); -- if (p_151275_.has("data")) { -- throw new JsonParseException("Disallowed data tag found"); -- } else { -- int i = GsonHelper.m_13824_(p_151275_, "count", 1); -- if (i < 1) { -- throw new JsonSyntaxException("Invalid output count: " + i); -- } else { -- return new ItemStack(item, i); -- } -- } -+ return net.minecraftforge.common.crafting.CraftingHelper.getItemStack(p_151275_, true, true); - } - - public static Item m_151278_(JsonObject p_151279_) { -@@ -286,6 +_,7 @@ - } +@@ -182,9 +_,9 @@ public static class Serializer implements RecipeSerializer { -+ private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shaped"); - public ShapedRecipe m_6729_(ResourceLocation p_44236_, JsonObject p_44237_) { - String s = GsonHelper.m_13851_(p_44237_, "group", ""); - CraftingBookCategory craftingbookcategory = CraftingBookCategory.f_244644_.m_262792_(GsonHelper.m_13851_(p_44237_, "category", (String)null), CraftingBookCategory.MISC); + static final Codec> f_291059_ = Codec.STRING.listOf().flatXmap((p_297814_) -> { +- if (p_297814_.size() > 3) { ++ if (p_297814_.size() > MAX_HEIGHT) { + return DataResult.error(() -> { +- return "Invalid pattern: too many rows, 3 is maximum"; ++ return "Invalid pattern: too many rows, " + MAX_HEIGHT + " is maximum"; + }); + } else if (p_297814_.isEmpty()) { + return DataResult.error(() -> { +@@ -194,9 +_,9 @@ + int i = p_297814_.get(0).length(); + + for(String s : p_297814_) { +- if (s.length() > 3) { ++ if (s.length() > MAX_WIDTH) { + return DataResult.error(() -> { +- return "Invalid pattern: too many columns, 3 is maximum"; ++ return "Invalid pattern: too many columns, " + MAX_WIDTH + " is maximum"; + }); + } + diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index 8b6e94c6ca..699a270015 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,22 +1,21 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -20,6 +_,7 @@ +@@ -18,12 +_,14 @@ final CraftingBookCategory f_244076_; final ItemStack f_44243_; final NonNullList f_44244_; + private final boolean isSimple; - public ShapelessRecipe(ResourceLocation p_251840_, String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, NonNullList p_250689_) { - this.f_44241_ = p_251840_; -@@ -27,6 +_,7 @@ + public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, NonNullList p_250689_) { + this.f_44242_ = p_249640_; this.f_244076_ = p_249390_; this.f_44243_ = p_252071_; this.f_44244_ = p_250689_; + this.isSimple = p_250689_.stream().allMatch(Ingredient::isSimple); } - public ResourceLocation m_6423_() { -@@ -55,17 +_,20 @@ + public RecipeSerializer m_7707_() { +@@ -48,17 +_,20 @@ public boolean m_5818_(CraftingContainer p_44262_, Level p_44263_) { StackedContents stackedcontents = new StackedContents(); @@ -38,30 +37,12 @@ } public ItemStack m_5874_(CraftingContainer p_44260_, RegistryAccess p_266797_) { -@@ -77,14 +_,15 @@ - } - - public static class Serializer implements RecipeSerializer { -+ private static final ResourceLocation NAME = new ResourceLocation("minecraft", "crafting_shapeless"); - public ShapelessRecipe m_6729_(ResourceLocation p_44290_, JsonObject p_44291_) { - String s = GsonHelper.m_13851_(p_44291_, "group", ""); - CraftingBookCategory craftingbookcategory = CraftingBookCategory.f_244644_.m_262792_(GsonHelper.m_13851_(p_44291_, "category", (String)null), CraftingBookCategory.MISC); - NonNullList nonnulllist = m_44275_(GsonHelper.m_13933_(p_44291_, "ingredients")); - if (nonnulllist.isEmpty()) { - throw new JsonParseException("No ingredients for shapeless recipe"); -- } else if (nonnulllist.size() > 9) { -- throw new JsonParseException("Too many ingredients for shapeless recipe"); -+ } else if (nonnulllist.size() > ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT) { -+ throw new JsonParseException("Too many ingredients for shapeless recipe. The maximum is " + (ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT)); - } else { - ItemStack itemstack = ShapedRecipe.m_151274_(GsonHelper.m_13930_(p_44291_, "result")); - return new ShapelessRecipe(p_44290_, s, craftingbookcategory, itemstack, nonnulllist); -@@ -96,7 +_,7 @@ - - for(int i = 0; i < p_44276_.size(); ++i) { - Ingredient ingredient = Ingredient.m_288218_(p_44276_.get(i), false); -- if (!ingredient.m_43947_()) { -+ if (true || !ingredient.m_43947_()) { // FORGE: Skip checking if an ingredient is empty during shapeless recipe deserialization to prevent complex ingredients from caching tags too early. Can not be done using a config value due to sync issues. - nonnulllist.add(ingredient); +@@ -88,7 +_,7 @@ + return "No ingredients for shapeless recipe"; + }); + } else { +- return aingredient.length > 9 ? DataResult.error(() -> { ++ return aingredient.length > ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT ? DataResult.error(() -> { + return "Too many ingredients for shapeless recipe"; + }) : DataResult.success(NonNullList.m_122783_(Ingredient.f_43901_, aingredient)); } - } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch index c4d797c654..57a0b47c00 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/ShulkerBoxColoring.java +++ b/net/minecraft/world/item/crafting/ShulkerBoxColoring.java -@@ -26,7 +_,7 @@ +@@ -25,7 +_,7 @@ if (Block.m_49814_(itemstack.m_41720_()) instanceof ShulkerBoxBlock) { ++i; } else { @@ -9,7 +9,7 @@ return false; } -@@ -44,7 +_,7 @@ +@@ -43,7 +_,7 @@ public ItemStack m_5874_(CraftingContainer p_44322_, RegistryAccess p_266985_) { ItemStack itemstack = ItemStack.f_41583_; @@ -18,7 +18,7 @@ for(int i = 0; i < p_44322_.m_6643_(); ++i) { ItemStack itemstack1 = p_44322_.m_8020_(i); -@@ -52,13 +_,14 @@ +@@ -51,13 +_,14 @@ Item item = itemstack1.m_41720_(); if (Block.m_49814_(item) instanceof ShulkerBoxBlock) { itemstack = itemstack1; diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch deleted file mode 100644 index d5d6a23fdd..0000000000 --- a/patches/minecraft/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SimpleCookingSerializer.java -+++ b/net/minecraft/world/item/crafting/SimpleCookingSerializer.java -@@ -22,11 +_,17 @@ - CookingBookCategory cookingbookcategory = CookingBookCategory.f_244271_.m_262792_(GsonHelper.m_13851_(p_44348_, "category", (String)null), CookingBookCategory.MISC); - JsonElement jsonelement = (JsonElement)(GsonHelper.m_13885_(p_44348_, "ingredient") ? GsonHelper.m_13933_(p_44348_, "ingredient") : GsonHelper.m_13930_(p_44348_, "ingredient")); - Ingredient ingredient = Ingredient.m_288218_(jsonelement, false); -+ //Forge: Check if primitive string to keep vanilla or a object which can contain a count field. -+ if (!p_44348_.has("result")) throw new com.google.gson.JsonSyntaxException("Missing result, expected to find a string or object"); -+ ItemStack itemstack; -+ if (p_44348_.get("result").isJsonObject()) itemstack = ShapedRecipe.m_151274_(GsonHelper.m_13930_(p_44348_, "result")); -+ else { - String s1 = GsonHelper.m_13906_(p_44348_, "result"); - ResourceLocation resourcelocation = new ResourceLocation(s1); -- ItemStack itemstack = new ItemStack(BuiltInRegistries.f_257033_.m_6612_(resourcelocation).orElseThrow(() -> { -+ itemstack = new ItemStack(BuiltInRegistries.f_257033_.m_6612_(resourcelocation).orElseThrow(() -> { - return new IllegalStateException("Item: " + s1 + " does not exist"); - })); -+ } - float f = GsonHelper.m_13820_(p_44348_, "experience", 0.0F); - int i = GsonHelper.m_13824_(p_44348_, "cookingtime", this.f_44327_); - return this.f_44328_.m_44352_(p_44347_, s, cookingbookcategory, ingredient, itemstack, f, i); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch index 767aff5a9a..b366b956ef 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -65,7 +_,7 @@ +@@ -58,7 +_,7 @@ } public boolean m_142505_() { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch index 4af798fd99..81c067fb30 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -94,7 +_,7 @@ +@@ -87,7 +_,7 @@ } public boolean m_142505_() { diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch index f88e1775f2..c53522a47d 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/Enchantment.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/enchantment/Enchantment.java +++ b/net/minecraft/world/item/enchantment/Enchantment.java -@@ -16,7 +_,7 @@ +@@ -17,7 +_,7 @@ import net.minecraft.world.entity.MobType; import net.minecraft.world.item.ItemStack; @@ -9,7 +9,7 @@ private final EquipmentSlot[] f_44671_; private final Enchantment.Rarity f_44674_; public final EnchantmentCategory f_44672_; -@@ -71,6 +_,7 @@ +@@ -73,6 +_,7 @@ return 0; } @@ -17,7 +17,7 @@ public float m_7335_(int p_44682_, MobType p_44683_) { return 0.0F; } -@@ -111,7 +_,7 @@ +@@ -113,7 +_,7 @@ } public boolean m_6081_(ItemStack p_44689_) { @@ -26,7 +26,7 @@ } public void m_7677_(LivingEntity p_44686_, Entity p_44687_, int p_44688_) { -@@ -133,6 +_,24 @@ +@@ -135,6 +_,24 @@ } public boolean m_6592_() { diff --git a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch index 4abf438b36..a110692050 100644 --- a/patches/minecraft/net/minecraft/world/level/Explosion.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Explosion.java.patch @@ -23,8 +23,8 @@ + net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.f_46012_, this, list, f2); Vec3 vec3 = new Vec3(this.f_46013_, this.f_46014_, this.f_46015_); - for(int k2 = 0; k2 < list.size(); ++k2) { -@@ -245,7 +_,7 @@ + for(Entity entity : list) { +@@ -244,7 +_,7 @@ if (!blockstate.m_60795_()) { BlockPos blockpos1 = blockpos.m_7949_(); this.f_46012_.m_46473_().m_6180_("explosion_blocks"); @@ -33,7 +33,7 @@ Level $$9 = this.f_46012_; if ($$9 instanceof ServerLevel) { ServerLevel serverlevel = (ServerLevel)$$9; -@@ -262,8 +_,7 @@ +@@ -261,8 +_,7 @@ } } @@ -43,7 +43,7 @@ this.f_46012_.m_46473_().m_7238_(); } } -@@ -354,6 +_,15 @@ +@@ -353,6 +_,15 @@ public List m_46081_() { return this.f_46020_; diff --git a/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch b/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch index 24cafcb467..2c8de97857 100644 --- a/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/ForcedChunksSavedData.java +++ b/net/minecraft/world/level/ForcedChunksSavedData.java -@@ -19,15 +_,31 @@ +@@ -24,15 +_,31 @@ } public static ForcedChunksSavedData m_151483_(CompoundTag p_151484_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch index 5cb0f09e9d..3714271a42 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Blocks.java +++ b/net/minecraft/world/level/block/Blocks.java -@@ -163,7 +_,7 @@ +@@ -164,7 +_,7 @@ public static final Block f_50027_ = m_50795_("green_bed", m_50764_(DyeColor.GREEN)); public static final Block f_50028_ = m_50795_("red_bed", m_50764_(DyeColor.RED)); public static final Block f_50029_ = m_50795_("black_bed", m_50764_(DyeColor.BLACK)); @@ -9,7 +9,7 @@ public static final Block f_50031_ = m_50795_("detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.m_284310_().m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_))); public static final Block f_50032_ = m_50795_("sticky_piston", m_50798_(true)); public static final Block f_50033_ = m_50795_("cobweb", new WebBlock(BlockBehaviour.Properties.m_284310_().m_284180_(MapColor.f_283930_).m_280606_().m_60910_().m_60999_().m_60978_(4.0F).m_278166_(PushReaction.DESTROY))); -@@ -1253,17 +_,5 @@ +@@ -1258,17 +_,5 @@ public static void m_50758_() { Block.f_49791_.forEach(BlockBehaviour.BlockStateBase::m_60611_); diff --git a/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch index 0ba83dd22d..8bbc561f2f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/BucketPickup.java +++ b/net/minecraft/world/level/block/BucketPickup.java -@@ -7,8 +_,9 @@ +@@ -9,8 +_,9 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; -public interface BucketPickup { +public interface BucketPickup extends net.minecraftforge.common.extensions.IForgeBucketPickup { - ItemStack m_142598_(LevelAccessor p_152719_, BlockPos p_152720_, BlockState p_152721_); + ItemStack m_142598_(@Nullable Player p_298551_, LevelAccessor p_152719_, BlockPos p_152720_, BlockState p_152721_); + @Deprecated//Forge: Use state sensitive variant instead Optional m_142298_(); diff --git a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch index db9cbaef0b..45d6f01f4b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -203,7 +_,7 @@ +@@ -204,7 +_,7 @@ return true; } diff --git a/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch index cc775c663b..e9fae0cf7b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChorusFlowerBlock.java +++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java -@@ -43,7 +_,7 @@ +@@ -50,7 +_,7 @@ BlockPos blockpos = p_220982_.m_7494_(); if (p_220981_.m_46859_(blockpos) && blockpos.m_123342_() < p_220981_.m_151558_()) { int i = p_220980_.m_61143_(f_51647_); @@ -9,7 +9,7 @@ boolean flag = false; boolean flag1 = false; BlockState blockstate = p_220981_.m_8055_(p_220982_.m_7495_()); -@@ -99,7 +_,7 @@ +@@ -106,7 +_,7 @@ } else { this.m_51658_(p_220981_, p_220982_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch index e90897be30..8dfed883bf 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -165,4 +_,16 @@ +@@ -170,4 +_,16 @@ protected void m_7926_(StateDefinition.Builder p_51887_) { p_51887_.m_61104_(f_54117_, f_51854_, f_52496_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch index c343e6db29..db88b9a62e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch @@ -28,7 +28,7 @@ f1 = 3.0F; } } -@@ -136,7 +_,7 @@ +@@ -140,7 +_,7 @@ } public void m_7892_(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch index 4ddac891d5..2de9e2cc9d 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java -@@ -154,6 +_,8 @@ +@@ -159,6 +_,8 @@ protected void m_52580_(Level p_52581_, BlockPos p_52582_, BlockState p_52583_) { Direction direction = p_52583_.m_61143_(f_54117_); BlockPos blockpos = p_52582_.m_121945_(direction.m_122424_()); diff --git a/patches/minecraft/net/minecraft/world/level/block/FlowerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FlowerBlock.java.patch deleted file mode 100644 index adbf2207cc..0000000000 --- a/patches/minecraft/net/minecraft/world/level/block/FlowerBlock.java.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- a/net/minecraft/world/level/block/FlowerBlock.java -+++ b/net/minecraft/world/level/block/FlowerBlock.java -@@ -15,6 +_,17 @@ - private final MobEffect f_53508_; - private final int f_53509_; - -+ private final java.util.function.Supplier suspiciousStewEffectSupplier; -+ -+ public FlowerBlock(java.util.function.Supplier effectSupplier, int p_53513_, BlockBehaviour.Properties p_53514_) { -+ super(p_53514_); -+ this.f_53508_ = null; -+ this.suspiciousStewEffectSupplier = effectSupplier; -+ this.f_53509_ = p_53513_; -+ } -+ -+ /** @deprecated FORGE: Use supplier version instead */ -+ @Deprecated - public FlowerBlock(MobEffect p_53512_, int p_53513_, BlockBehaviour.Properties p_53514_) { - super(p_53514_); - this.f_53508_ = p_53512_; -@@ -23,6 +_,7 @@ - } else { - this.f_53509_ = p_53513_ * 20; - } -+ this.suspiciousStewEffectSupplier = net.minecraftforge.registries.ForgeRegistries.MOB_EFFECTS.getDelegateOrThrow(p_53512_); - - } - -@@ -32,10 +_,12 @@ - } - - public MobEffect m_53521_() { -+ if (true) return this.suspiciousStewEffectSupplier.get(); - return this.f_53508_; - } - - public int m_53522_() { -+ if (this.f_53508_ == null && !this.suspiciousStewEffectSupplier.get().m_8093_()) return this.f_53509_ * 20; - return this.f_53509_; - } - } diff --git a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch index 6b70fcb189..704d828790 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -30,11 +_,13 @@ +@@ -32,11 +_,13 @@ public class LiquidBlock extends Block implements BucketPickup { public static final IntegerProperty f_54688_ = BlockStateProperties.f_61422_; @@ -15,7 +15,7 @@ public LiquidBlock(FlowingFluid p_54694_, BlockBehaviour.Properties p_54695_) { super(p_54695_); this.f_54689_ = p_54694_; -@@ -47,6 +_,19 @@ +@@ -49,6 +_,19 @@ this.f_54691_.add(p_54694_.m_75953_(8, true)); this.m_49959_(this.f_49792_.m_61090_().m_61124_(f_54688_, Integer.valueOf(0))); @@ -35,7 +35,7 @@ } public VoxelShape m_5939_(BlockState p_54760_, BlockGetter p_54761_, BlockPos p_54762_, CollisionContext p_54763_) { -@@ -71,6 +_,7 @@ +@@ -73,6 +_,7 @@ public FluidState m_5888_(BlockState p_54765_) { int i = p_54765_.m_61143_(f_54688_); @@ -43,7 +43,7 @@ return this.f_54691_.get(Math.min(i, 8)); } -@@ -91,7 +_,7 @@ +@@ -93,7 +_,7 @@ } public void m_6807_(BlockState p_54754_, Level p_54755_, BlockPos p_54756_, BlockState p_54757_, boolean p_54758_) { @@ -52,7 +52,7 @@ p_54755_.m_186469_(p_54756_, p_54754_.m_60819_().m_76152_(), this.f_54689_.m_6718_(p_54755_)); } -@@ -106,12 +_,13 @@ +@@ -108,12 +_,13 @@ } public void m_6861_(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, BlockPos p_54713_, boolean p_54714_) { @@ -67,7 +67,7 @@ private boolean m_54696_(Level p_54697_, BlockPos p_54698_, BlockState p_54699_) { if (this.f_54689_.m_205067_(FluidTags.f_13132_)) { boolean flag = p_54697_.m_8055_(p_54698_.m_7495_()).m_60713_(Blocks.f_50136_); -@@ -150,6 +_,25 @@ +@@ -152,6 +_,25 @@ return new ItemStack(this.f_54689_.m_6859_()); } else { return ItemStack.f_41583_; diff --git a/patches/minecraft/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PitcherCropBlock.java.patch deleted file mode 100644 index 19c3854bf2..0000000000 --- a/patches/minecraft/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/world/level/block/PitcherCropBlock.java -+++ b/net/minecraft/world/level/block/PitcherCropBlock.java -@@ -69,7 +_,11 @@ - if (!m_278754_(p_277671_)) { - return super.m_7898_(p_277671_, p_277477_, p_278085_); - } else { -- return this.m_6266_(p_277477_.m_8055_(p_278085_.m_7495_()), p_277477_, p_278085_.m_7495_()) && m_290004_(p_277477_, p_278085_) && (p_277671_.m_61143_(f_276478_) < 3 || m_290001_(p_277477_.m_8055_(p_278085_.m_7494_()))); -+ BlockPos below = p_278085_.m_7495_(); -+ boolean isSoil = this.m_6266_(p_277477_.m_8055_(below), p_277477_, below); -+ if (p_277671_.m_60734_() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. -+ isSoil = p_277477_.m_8055_(below).canSustainPlant(p_277477_, below, Direction.UP, this); -+ return isSoil && m_290004_(p_277477_, p_278085_) && (p_277671_.m_61143_(f_276478_) < 3 || m_290001_(p_277477_.m_8055_(p_278085_.m_7494_()))); - } - } - diff --git a/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch index aaf1f4fc01..a86d27bd63 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -107,7 +_,7 @@ +@@ -108,7 +_,7 @@ if (p_154256_.m_6095_().m_204039_(EntityTypeTags.f_144291_)) { return true; } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch index 08eb44fb2c..9cd3ffade5 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SeagrassBlock.java +++ b/net/minecraft/world/level/block/SeagrassBlock.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch index ae40e9a8ec..0ed166c6b6 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SoundType.java +++ b/net/minecraft/world/level/block/SoundType.java -@@ -115,6 +_,7 @@ +@@ -117,6 +_,7 @@ private final SoundEvent f_56737_; private final SoundEvent f_56738_; diff --git a/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch index f6c138efcd..e08d88897f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpongeBlock.java +++ b/net/minecraft/world/level/block/SpongeBlock.java -@@ -38,6 +_,7 @@ +@@ -41,6 +_,7 @@ } private boolean m_56807_(Level p_56808_, BlockPos p_56809_) { @@ -8,12 +8,12 @@ return BlockPos.m_276833_(p_56809_, 6, 65, (p_277519_, p_277492_) -> { for(Direction direction : f_276425_) { p_277492_.accept(p_277519_.m_121945_(direction)); -@@ -49,7 +_,7 @@ +@@ -52,7 +_,7 @@ } else { - BlockState blockstate = p_56808_.m_8055_(p_279054_); - FluidState fluidstate = p_56808_.m_6425_(p_279054_); + BlockState blockstate = p_56808_.m_8055_(p_296944_); + FluidState fluidstate = p_56808_.m_6425_(p_296944_); - if (!fluidstate.m_205070_(FluidTags.f_13131_)) { -+ if (!spongeState.canBeHydrated(p_56808_, p_56809_, fluidstate, p_279054_)) { ++ if (!spongeState.canBeHydrated(p_56808_, p_56809_, fluidstate, p_296944_)) { return false; } else { Block block = blockstate.m_60734_(); diff --git a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch index 499d47da19..14edf51e5f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -158,7 +_,7 @@ +@@ -160,7 +_,7 @@ if (!(p_57769_ instanceof LivingEntity)) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index ae2f00630d..099073b4a8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -8,14 +8,15 @@ protected NonNullList f_58310_ = NonNullList.m_122780_(3, ItemStack.f_41583_); int f_58316_; int f_58317_; -@@ -107,8 +_,10 @@ +@@ -107,8 +_,11 @@ protected AbstractFurnaceBlockEntity(BlockEntityType p_154991_, BlockPos p_154992_, BlockState p_154993_, RecipeType p_154994_) { super(p_154991_, p_154992_, p_154993_); this.f_222691_ = RecipeManager.m_220267_((RecipeType)p_154994_); + this.recipeType = p_154994_; } -+ /**@deprecated Forge: get burn times by calling ForgeHooks#getBurnTime(ItemStack)*/ @Deprecated ++ /**@deprecated Forge: get burn times by calling ForgeHooks#getBurnTime(ItemStack)*/ ++ @Deprecated public static Map m_58423_() { Map map = Maps.newLinkedHashMap(); m_58374_(map, Items.f_42448_, 20000); @@ -49,8 +50,8 @@ } int i = p_155017_.m_6893_(); -- if (!p_155017_.m_58425_() && m_155005_(p_155014_.m_9598_(), recipe, p_155017_.f_58310_, i)) { -+ if (!p_155017_.m_58425_() && p_155017_.m_155005_(p_155014_.m_9598_(), recipe, p_155017_.f_58310_, i)) { +- if (!p_155017_.m_58425_() && m_155005_(p_155014_.m_9598_(), recipeholder, p_155017_.f_58310_, i)) { ++ if (!p_155017_.m_58425_() && p_155017_.m_155005_(p_155014_.m_9598_(), recipeholder, p_155017_.f_58310_, i)) { p_155017_.f_58316_ = p_155017_.m_7743_(itemstack); p_155017_.f_58317_ = p_155017_.f_58316_; if (p_155017_.m_58425_()) { @@ -70,26 +71,26 @@ } } -- if (p_155017_.m_58425_() && m_155005_(p_155014_.m_9598_(), recipe, p_155017_.f_58310_, i)) { -+ if (p_155017_.m_58425_() && p_155017_.m_155005_(p_155014_.m_9598_(), recipe, p_155017_.f_58310_, i)) { +- if (p_155017_.m_58425_() && m_155005_(p_155014_.m_9598_(), recipeholder, p_155017_.f_58310_, i)) { ++ if (p_155017_.m_58425_() && p_155017_.m_155005_(p_155014_.m_9598_(), recipeholder, p_155017_.f_58310_, i)) { ++p_155017_.f_58318_; if (p_155017_.f_58318_ == p_155017_.f_58319_) { p_155017_.f_58318_ = 0; p_155017_.f_58319_ = m_222692_(p_155014_, p_155017_); -- if (m_266209_(p_155014_.m_9598_(), recipe, p_155017_.f_58310_, i)) { -+ if (p_155017_.m_266209_(p_155014_.m_9598_(), recipe, p_155017_.f_58310_, i)) { - p_155017_.m_6029_(recipe); +- if (m_266209_(p_155014_.m_9598_(), recipeholder, p_155017_.f_58310_, i)) { ++ if (p_155017_.m_266209_(p_155014_.m_9598_(), recipeholder, p_155017_.f_58310_, i)) { + p_155017_.m_40156_(recipeholder); } @@ -295,9 +_,9 @@ } -- private static boolean m_155005_(RegistryAccess p_266924_, @Nullable Recipe p_155006_, NonNullList p_155007_, int p_155008_) { -+ private boolean m_155005_(RegistryAccess p_266924_, @Nullable Recipe p_155006_, NonNullList p_155007_, int p_155008_) { - if (!p_155007_.get(0).m_41619_() && p_155006_ != null) { -- ItemStack itemstack = p_155006_.m_8043_(p_266924_); -+ ItemStack itemstack = ((Recipe) p_155006_).m_5874_(this, p_266924_); +- private static boolean m_155005_(RegistryAccess p_266924_, @Nullable RecipeHolder p_299207_, NonNullList p_155007_, int p_155008_) { ++ private boolean m_155005_(RegistryAccess p_266924_, @Nullable RecipeHolder p_299207_, NonNullList p_155007_, int p_155008_) { + if (!p_155007_.get(0).m_41619_() && p_299207_ != null) { +- ItemStack itemstack = p_299207_.f_291008_().m_8043_(p_266924_); ++ ItemStack itemstack = ((RecipeHolder>)p_299207_).f_291008_().m_5874_(this, p_266924_); if (itemstack.m_41619_()) { return false; } else { @@ -110,13 +111,13 @@ } } -- private static boolean m_266209_(RegistryAccess p_266740_, @Nullable Recipe p_266780_, NonNullList p_267073_, int p_267157_) { -- if (p_266780_ != null && m_155005_(p_266740_, p_266780_, p_267073_, p_267157_)) { -+ private boolean m_266209_(RegistryAccess p_266740_, @Nullable Recipe p_266780_, NonNullList p_267073_, int p_267157_) { -+ if (p_266780_ != null && this.m_155005_(p_266740_, p_266780_, p_267073_, p_267157_)) { +- private static boolean m_266209_(RegistryAccess p_266740_, @Nullable RecipeHolder p_299450_, NonNullList p_267073_, int p_267157_) { +- if (p_299450_ != null && m_155005_(p_266740_, p_299450_, p_267073_, p_267157_)) { ++ private boolean m_266209_(RegistryAccess p_266740_, @Nullable RecipeHolder p_299450_, NonNullList p_267073_, int p_267157_) { ++ if (p_299450_ != null && this.m_155005_(p_266740_, p_299450_, p_267073_, p_267157_)) { ItemStack itemstack = p_267073_.get(0); -- ItemStack itemstack1 = p_266780_.m_8043_(p_266740_); -+ ItemStack itemstack1 = ((Recipe) p_266780_).m_5874_(this, p_266740_); +- ItemStack itemstack1 = p_299450_.f_291008_().m_8043_(p_266740_); ++ ItemStack itemstack1 = ((RecipeHolder>)p_299450_).f_291008_().m_5874_(this, p_266740_); ItemStack itemstack2 = p_267073_.get(2); if (itemstack2.m_41619_()) { p_267073_.set(2, itemstack1.m_41777_()); @@ -135,7 +136,7 @@ } } -@@ -353,7 +_,7 @@ +@@ -355,7 +_,7 @@ } public static boolean m_58399_(ItemStack p_58400_) { @@ -144,7 +145,7 @@ } public int[] m_7071_(Direction p_58363_) { -@@ -429,7 +_,7 @@ +@@ -431,7 +_,7 @@ return true; } else { ItemStack itemstack = this.f_58310_.get(1); @@ -153,7 +154,7 @@ } } -@@ -494,5 +_,34 @@ +@@ -496,5 +_,34 @@ p_58342_.m_36491_(itemstack); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 3e4092a91c..99c215787b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -124,8 +_,8 @@ +@@ -133,8 +_,8 @@ for(int i1 = 0; i1 < 10 && blockpos.m_123342_() <= l; ++i1) { BlockState blockstate = p_155108_.m_8055_(blockpos); Block block = blockstate.m_60734_(); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch index 1ffb8b57f2..aa155126b0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -@@ -121,4 +_,28 @@ +@@ -125,4 +_,28 @@ public int m_262444_() { return this.f_262317_; } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index bdda845473..627b3c89c3 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -28,7 +28,7 @@ Container container = m_155596_(p_155553_, p_155554_); if (container != null) { Direction direction = Direction.DOWN; -@@ -411,5 +_,14 @@ +@@ -414,5 +_,14 @@ protected AbstractContainerMenu m_6555_(int p_59312_, Inventory p_59313_) { return new HopperMenu(p_59312_, p_59313_, this); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index f277ad3adf..432f7bcbbf 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -211,7 +_,7 @@ +@@ -217,7 +_,7 @@ } public boolean m_7155_(int p_59663_, ItemStack p_59664_, @Nullable Direction p_59665_) { @@ -9,7 +9,7 @@ } public boolean m_7157_(int p_59682_, ItemStack p_59683_, Direction p_59684_) { -@@ -233,6 +_,11 @@ +@@ -239,6 +_,11 @@ public boolean m_59702_() { return this.f_59647_ == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index 01e8263198..f266c45e84 100644 --- a/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -24,7 +24,7 @@ return true; } -@@ -354,6 +_,10 @@ +@@ -353,6 +_,10 @@ public BlockState m_6843_(BlockState p_60215_, Rotation p_60216_) { return p_60215_.m_61124_(f_52588_, p_60216_.m_55954_(p_60215_.m_61143_(f_52588_))); diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index fc2dd6155c..0816100077 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -108,8 +108,8 @@ return this.f_278134_; } -@@ -972,8 +_,9 @@ - boolean f_243850_ = true; +@@ -976,8 +_,9 @@ + boolean f_290592_ = true; NoteBlockInstrument f_279538_ = NoteBlockInstrument.HARP; boolean f_279630_; + private java.util.function.Supplier lootTableSupplier; @@ -119,7 +119,7 @@ }; BlockBehaviour.StatePredicate f_60898_ = (p_284888_, p_284889_, p_284890_) -> { return p_284888_.m_60838_(p_284889_, p_284890_); -@@ -1111,9 +_,15 @@ +@@ -1115,9 +_,15 @@ return this; } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch index 34c289341a..4f05476a9b 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -24,6 +_,7 @@ +@@ -25,6 +_,7 @@ import net.minecraft.util.ZeroBitStorage; public class PalettedContainer implements PaletteResize, PalettedContainerRO { diff --git a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index 5b898ca4cf..1adce74cec 100644 --- a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -513,7 +_,14 @@ +@@ -517,7 +_,14 @@ endcrystal.m_31052_((BlockPos)null); } } diff --git a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch index bb5cfeaabf..5fe9b847de 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -159,7 +_,7 @@ +@@ -160,7 +_,7 @@ BlockState blockstate = p_256464_.m_8055_(blockpos); FluidState fluidstate = blockstate.m_60819_(); if (fluidstate.m_76152_().m_6212_(this) && this.m_76061_(direction, p_256464_, p_76037_, p_76038_, blockpos, blockstate)) { @@ -9,7 +9,7 @@ ++j; } -@@ -167,7 +_,7 @@ +@@ -168,7 +_,7 @@ } } @@ -18,7 +18,7 @@ BlockState blockstate1 = p_256464_.m_8055_(p_76037_.m_7495_()); FluidState fluidstate1 = blockstate1.m_60819_(); if (blockstate1.m_280296_() || this.m_76096_(fluidstate1)) { -@@ -231,6 +_,15 @@ +@@ -232,6 +_,15 @@ return this.m_5613_().m_76145_().m_61124_(f_75947_, Boolean.valueOf(p_76069_)); } diff --git a/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch b/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch deleted file mode 100644 index e1862ead65..0000000000 --- a/patches/minecraft/net/minecraft/world/level/saveddata/maps/MapDecoration.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/level/saveddata/maps/MapDecoration.java -+++ b/net/minecraft/world/level/saveddata/maps/MapDecoration.java -@@ -69,6 +_,15 @@ - return 31 * i + Objects.hashCode(this.f_77795_); - } - -+ /** -+ * Renders this decoration, useful for custom sprite sheets. -+ * @param index The index of this icon in the MapData's list. Used by vanilla to offset the Z-coordinate to prevent Z-fighting -+ * @return false to run vanilla logic for this decoration, true to skip it -+ */ -+ public boolean render(int index) { -+ return false; -+ } -+ - public static enum Type { - PLAYER(false, true), - FRAME(true, true), diff --git a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index 9d3ede6cf6..9f563feab9 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -49,9 +_,13 @@ +@@ -48,9 +_,13 @@ @Nullable - public T m_164858_(Function p_164859_, String p_164860_) { + public T m_164858_(SavedData.Factory p_297465_, String p_164860_) { SavedData saveddata = this.f_78144_.get(p_164860_); + if (saveddata == net.minecraftforge.common.util.DummySavedData.DUMMY) return null; if (saveddata == null && !this.f_78144_.containsKey(p_164860_)) { - saveddata = this.m_164868_(p_164859_, p_164860_); + saveddata = this.m_164868_(p_297465_.f_291599_(), p_297465_.f_291120_(), p_164860_); this.f_78144_.put(p_164860_, saveddata); + } else if (saveddata == null) { + this.f_78144_.put(p_164860_, net.minecraftforge.common.util.DummySavedData.DUMMY); diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch index ea51b30606..94a4e0c320 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -439,6 +_,19 @@ +@@ -450,6 +_,19 @@ return LevelStorageSource.this.m_230817_(this.f_230867_, LevelStorageSource.m_245503_(p_248747_, p_251873_, p_249187_, p_249736_)); } @@ -20,7 +20,7 @@ @Nullable public WorldDataConfiguration m_247706_() { this.m_78313_(); -@@ -455,6 +_,8 @@ +@@ -466,6 +_,8 @@ CompoundTag compoundtag1 = new CompoundTag(); compoundtag1.m_128365_("Data", compoundtag); @@ -29,7 +29,7 @@ try { File file2 = File.createTempFile("level", ".dat", file1); NbtIo.m_128944_(compoundtag1, file2); -@@ -469,6 +_,10 @@ +@@ -480,6 +_,10 @@ public Optional m_182514_() { return !this.f_78270_.m_13639_() ? Optional.empty() : Optional.of(this.f_230867_.m_230860_()); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch index ca69dc3bc9..8c99ebd9ed 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootContext.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/LootContext.java +++ b/net/minecraft/world/level/storage/loot/LootContext.java -@@ -88,15 +_,43 @@ +@@ -86,15 +_,45 @@ return new LootContext.VisitedEntry<>(LootDataType.f_278496_, p_279163_); } @@ -16,6 +16,7 @@ + this.queriedLootTableId = queriedLootTableId; + } + ++ /* + public void setQueriedLootTableId(ResourceLocation queriedLootTableId) { + if (this.queriedLootTableId == null && queriedLootTableId != null) this.queriedLootTableId = queriedLootTableId; + } @@ -23,6 +24,7 @@ + public ResourceLocation getQueriedLootTableId() { + return this.queriedLootTableId == null ? net.minecraftforge.common.loot.LootTableIdCondition.UNKNOWN_LOOT_TABLE : this.queriedLootTableId; + } ++ */ + // =============================== FORGE END =============================== + public static class Builder { @@ -44,7 +46,7 @@ public LootContext.Builder m_78965_(long p_78966_) { if (p_78966_ != 0L) { this.f_78958_ = RandomSource.m_216335_(p_78966_); -@@ -105,6 +_,11 @@ +@@ -103,6 +_,11 @@ return this; } @@ -56,16 +58,16 @@ public ServerLevel m_78962_() { return this.f_78956_.m_287182_(); } -@@ -121,7 +_,7 @@ - randomsource = serverlevel.m_213780_(); - } - +@@ -113,7 +_,7 @@ + RandomSource randomsource = Optional.ofNullable(this.f_78958_).or(() -> { + return p_299315_.map(serverlevel::m_287143_); + }).orElseGet(serverlevel::m_213780_); - return new LootContext(this.f_78956_, randomsource, minecraftserver.m_278653_()); + return new LootContext(this.f_78956_, randomsource, minecraftserver.m_278653_(), queriedLootTableId); } } -@@ -141,6 +_,11 @@ +@@ -134,6 +_,11 @@ public LootContextParam m_79003_() { return this.f_78995_; diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataManager.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataManager.java.patch deleted file mode 100644 index b079d0dfda..0000000000 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataManager.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/LootDataManager.java -+++ b/net/minecraft/world/level/storage/loot/LootDataManager.java -@@ -53,7 +_,7 @@ - Map map1 = new HashMap<>(); - SimpleJsonResourceReloadListener.m_278771_(p_279441_, p_279205_.m_278624_(), p_279205_.m_278857_(), map1); - map1.forEach((p_279416_, p_279151_) -> { -- p_279205_.m_278763_(p_279416_, p_279151_).ifPresent((p_279295_) -> { -+ p_279205_.deserialize(p_279416_, p_279151_, p_279441_).ifPresent((p_279295_) -> { - map.put(p_279416_, p_279295_); - }); - }); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataType.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataType.java.patch deleted file mode 100644 index 7a1e4e6ae9..0000000000 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootDataType.java.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/LootDataType.java -+++ b/net/minecraft/world/level/storage/loot/LootDataType.java -@@ -16,13 +_,13 @@ - private static final Logger f_278425_ = LogUtils.getLogger(); - public static final LootDataType f_278407_ = new LootDataType<>(Deserializers.m_78798_().create(), m_278813_(LootItemCondition.class, LootDataManager::m_278755_), "predicates", m_278693_()); - public static final LootDataType f_278496_ = new LootDataType<>(Deserializers.m_78799_().create(), m_278813_(LootItemFunction.class, LootDataManager::m_278704_), "item_modifiers", m_278693_()); -- public static final LootDataType f_278413_ = new LootDataType<>(Deserializers.m_78800_().create(), m_278629_(LootTable.class), "loot_tables", m_278846_()); -+ public static final LootDataType f_278413_ = new LootDataType<>(Deserializers.m_78800_().create(), net.minecraftforge.common.ForgeHooks::getLootTableDeserializer, "loot_tables", m_278846_()); - private final Gson f_278508_; -- private final BiFunction> f_278485_; -+ private final org.apache.commons.lang3.function.TriFunction> f_278485_; - private final String f_278462_; - private final LootDataType.Validator f_278443_; - -- private LootDataType(Gson p_279334_, BiFunction>> p_279478_, String p_279433_, LootDataType.Validator p_279363_) { -+ private LootDataType(Gson p_279334_, BiFunction>> p_279478_, String p_279433_, LootDataType.Validator p_279363_) { - this.f_278508_ = p_279334_; - this.f_278462_ = p_279433_; - this.f_278443_ = p_279363_; -@@ -41,17 +_,17 @@ - this.f_278443_.m_278714_(p_279366_, p_279106_, p_279124_); - } - -- public Optional m_278763_(ResourceLocation p_279253_, JsonElement p_279330_) { -- return this.f_278485_.apply(p_279253_, p_279330_); -+ public Optional deserialize(ResourceLocation p_279253_, JsonElement p_279330_, net.minecraft.server.packs.resources.ResourceManager resourceManager) { -+ return this.f_278485_.apply(p_279253_, p_279330_, resourceManager); - } - - public static Stream> m_278779_() { - return Stream.of(f_278407_, f_278496_, f_278413_); - } - -- private static BiFunction>> m_278629_(Class p_279251_) { -+ private static BiFunction>> m_278629_(Class p_279251_) { - return (p_279398_, p_279358_) -> { -- return (p_279297_, p_279222_) -> { -+ return (p_279297_, p_279222_, resourceManager) -> { - try { - return Optional.of(p_279398_.fromJson(p_279222_, p_279251_)); - } catch (Exception exception) { -@@ -62,10 +_,10 @@ - }; - } - -- private static BiFunction>> m_278813_(Class p_279337_, Function p_279252_) { -+ private static BiFunction>> m_278813_(Class p_279337_, Function p_279252_) { - Class oclass = (Class)p_279337_.arrayType(); - return (p_279462_, p_279351_) -> { -- return (p_279495_, p_279409_) -> { -+ return (p_279495_, p_279409_, resourceManager) -> { - try { - if (p_279409_.isJsonArray()) { - T[] at = (T[])((Object[])p_279462_.fromJson(p_279409_, oclass)); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch deleted file mode 100644 index c2850cab4b..0000000000 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch +++ /dev/null @@ -1,77 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/LootPool.java -+++ b/net/minecraft/world/level/storage/loot/LootPool.java -@@ -39,7 +_,8 @@ - NumberProvider f_79028_; - NumberProvider f_79029_; - -- LootPool(LootPoolEntryContainer[] p_165128_, LootItemCondition[] p_165129_, LootItemFunction[] p_165130_, NumberProvider p_165131_, NumberProvider p_165132_) { -+ LootPool(LootPoolEntryContainer[] p_165128_, LootItemCondition[] p_165129_, LootItemFunction[] p_165130_, NumberProvider p_165131_, NumberProvider p_165132_, @org.jetbrains.annotations.Nullable String name) { -+ this.name = name; - this.f_79023_ = p_165128_; - this.f_79024_ = p_165129_; - this.f_79025_ = LootItemConditions.m_81834_(p_165129_); -@@ -112,6 +_,23 @@ - this.f_79028_.m_6169_(p_79052_.m_79365_(".rolls")); - this.f_79029_.m_6169_(p_79052_.m_79365_(".bonusRolls")); - } -+ //======================== FORGE START ============================================= -+ private boolean isFrozen = false; -+ public void freeze() { this.isFrozen = true; } -+ public boolean isFrozen(){ return this.isFrozen; } -+ private void checkFrozen() { -+ if (this.isFrozen()) -+ throw new RuntimeException("Attempted to modify LootPool after being frozen!"); -+ } -+ @org.jetbrains.annotations.Nullable -+ private final String name; -+ @org.jetbrains.annotations.Nullable -+ public String getName() { return this.name; } -+ public NumberProvider getRolls() { return this.f_79028_; } -+ public NumberProvider getBonusRolls() { return this.f_79029_; } -+ public void setRolls (NumberProvider v){ checkFrozen(); this.f_79028_ = v; } -+ public void setBonusRolls(NumberProvider v){ checkFrozen(); this.f_79029_ = v; } -+ //======================== FORGE END =============================================== - - public static LootPool.Builder m_79043_() { - return new LootPool.Builder(); -@@ -123,6 +_,7 @@ - private final List f_79069_ = Lists.newArrayList(); - private NumberProvider f_79070_ = ConstantValue.m_165692_(1.0F); - private NumberProvider f_79071_ = ConstantValue.m_165692_(0.0F); -+ private String name; - - public LootPool.Builder m_165133_(NumberProvider p_165134_) { - this.f_79070_ = p_165134_; -@@ -153,11 +_,16 @@ - return this; - } - -+ public LootPool.Builder name(String name) { -+ this.name = name; -+ return this; -+ } -+ - public LootPool m_79082_() { - if (this.f_79070_ == null) { - throw new IllegalArgumentException("Rolls not set"); - } else { -- return new LootPool(this.f_79067_.toArray(new LootPoolEntryContainer[0]), this.f_79068_.toArray(new LootItemCondition[0]), this.f_79069_.toArray(new LootItemFunction[0]), this.f_79070_, this.f_79071_); -+ return new LootPool(this.f_79067_.toArray(new LootPoolEntryContainer[0]), this.f_79068_.toArray(new LootItemCondition[0]), this.f_79069_.toArray(new LootItemFunction[0]), this.f_79070_, this.f_79071_, name); - } - } - } -@@ -170,11 +_,13 @@ - LootItemFunction[] alootitemfunction = GsonHelper.m_13845_(jsonobject, "functions", new LootItemFunction[0], p_79092_, LootItemFunction[].class); - NumberProvider numberprovider = GsonHelper.m_13836_(jsonobject, "rolls", p_79092_, NumberProvider.class); - NumberProvider numberprovider1 = GsonHelper.m_13845_(jsonobject, "bonus_rolls", ConstantValue.m_165692_(0.0F), p_79092_, NumberProvider.class); -- return new LootPool(alootpoolentrycontainer, alootitemcondition, alootitemfunction, numberprovider, numberprovider1); -+ return new LootPool(alootpoolentrycontainer, alootitemcondition, alootitemfunction, numberprovider, numberprovider1, net.minecraftforge.common.ForgeHooks.readPoolName(jsonobject)); - } - - public JsonElement serialize(LootPool p_79094_, Type p_79095_, JsonSerializationContext p_79096_) { - JsonObject jsonobject = new JsonObject(); -+ if (p_79094_.name != null && !p_79094_.name.startsWith("custom#")) -+ jsonobject.add("name", p_79096_.serialize(p_79094_.name)); - jsonobject.add("rolls", p_79096_.serialize(p_79094_.f_79028_)); - jsonobject.add("bonus_rolls", p_79096_.serialize(p_79094_.f_79029_)); - jsonobject.add("entries", p_79096_.serialize(p_79094_.f_79023_)); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch index c560173844..f55e1c3e48 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -1,23 +1,15 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java -@@ -39,14 +_,14 @@ - final LootContextParamSet f_79108_; - @Nullable - final ResourceLocation f_286958_; -- final LootPool[] f_79109_; -+ private final List f_79109_; - final LootItemFunction[] f_79110_; - private final BiFunction f_79111_; - - LootTable(LootContextParamSet p_287716_, @Nullable ResourceLocation p_287737_, LootPool[] p_287700_, LootItemFunction[] p_287663_) { +@@ -50,7 +_,7 @@ + LootTable(LootContextParamSet p_287716_, Optional p_298628_, List p_298771_, List p_301234_) { this.f_79108_ = p_287716_; - this.f_286958_ = p_287737_; -- this.f_79109_ = p_287700_; -+ this.f_79109_ = Lists.newArrayList(p_287700_); - this.f_79110_ = p_287663_; - this.f_79111_ = LootItemFunctions.m_80770_(p_287663_); + this.f_286958_ = p_298628_; +- this.f_79109_ = p_298771_; ++ this.f_79109_ = Lists.newArrayList(p_298771_); + this.f_79110_ = p_301234_; + this.f_79111_ = LootItemFunctions.m_80770_(p_301234_); } -@@ -70,10 +_,12 @@ +@@ -74,10 +_,12 @@ }; } @@ -30,7 +22,7 @@ public void m_79131_(LootContext p_79132_, Consumer p_79133_) { LootContext.VisitedEntry visitedentry = LootContext.m_278811_(this); if (p_79132_.m_278759_(visitedentry)) { -@@ -91,15 +_,15 @@ +@@ -95,15 +_,15 @@ } public void m_287276_(LootParams p_287748_, long p_287729_, Consumer p_287583_) { @@ -49,84 +41,37 @@ } public ObjectArrayList m_287214_(LootParams p_287574_, long p_287773_) { -@@ -112,7 +_,8 @@ +@@ -116,7 +_,8 @@ private ObjectArrayList m_230922_(LootContext p_230923_) { ObjectArrayList objectarraylist = new ObjectArrayList<>(); - this.m_79148_(p_230923_, objectarraylist::add); + this.m_79131_(p_230923_, m_246283_(p_230923_.m_78952_(), objectarraylist::add)); -+ objectarraylist = net.minecraftforge.common.ForgeHooks.modifyLoot(this.getLootTableId(), objectarraylist, p_230923_); ++ //objectarraylist = net.minecraftforge.common.ForgeHooks.modifyLoot(this.getLootTableId(), objectarraylist, p_230923_); //TODO: GLM return objectarraylist; } -@@ -121,8 +_,8 @@ - } +@@ -207,6 +_,23 @@ - public void m_79136_(ValidationContext p_79137_) { -- for(int i = 0; i < this.f_79109_.length; ++i) { -- this.f_79109_[i].m_79051_(p_79137_.m_79365_(".pools[" + i + "]")); -+ for(int i = 0; i < this.f_79109_.size(); ++i) { -+ this.f_79109_.get(i).m_79051_(p_79137_.m_79365_(".pools[" + i + "]")); - } - - for(int j = 0; j < this.f_79110_.length; ++j) { -@@ -205,6 +_,50 @@ + public static LootTable.Builder m_79147_() { return new LootTable.Builder(); - } - -+ //======================== FORGE START ============================================= -+ private boolean isFrozen = false; -+ public void freeze() { -+ this.isFrozen = true; -+ this.f_79109_.forEach(LootPool::freeze); -+ } -+ public boolean isFrozen(){ return this.isFrozen; } -+ private void checkFrozen() { -+ if (this.isFrozen()) -+ throw new RuntimeException("Attempted to modify LootTable after being finalized!"); + } + + private ResourceLocation lootTableId; + public void setLootTableId(final ResourceLocation id) { -+ if (this.lootTableId != null) throw new IllegalStateException("Attempted to rename loot table from '" + this.lootTableId + "' to '" + id + "': this is not supported"); ++ if (this.lootTableId != null) ++ throw new IllegalStateException("Attempted to rename loot table from '" + this.lootTableId + "' to '" + id + "': this is not supported"); + this.lootTableId = java.util.Objects.requireNonNull(id); + } -+ public ResourceLocation getLootTableId() { return this.lootTableId; } + -+ @org.jetbrains.annotations.Nullable -+ public LootPool getPool(String name) { -+ return f_79109_.stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null); -+ } -+ -+ @org.jetbrains.annotations.Nullable -+ public LootPool removePool(String name) { -+ checkFrozen(); -+ for (LootPool pool : this.f_79109_) { -+ if (name.equals(pool.getName())) { -+ this.f_79109_.remove(pool); -+ return pool; -+ } -+ } -+ return null; ++ public ResourceLocation getLootTableId() { ++ return this.lootTableId; + } + + public void addPool(LootPool pool) { -+ checkFrozen(); -+ if (f_79109_.stream().anyMatch(e -> e == pool || e.getName() != null && e.getName().equals(pool.getName()))) -+ throw new RuntimeException("Attempted to add a duplicate pool to loot table: " + pool.getName()); ++ if (f_79109_.stream().anyMatch(e -> e == pool)) ++ throw new RuntimeException("Attempted to add a duplicate pool to loot table: " + pool); + this.f_79109_.add(pool); -+ } -+ //======================== FORGE END =============================================== -+ + } + public static class Builder implements FunctionUserBuilder { - private final List f_79156_ = Lists.newArrayList(); - private final List f_79157_ = Lists.newArrayList(); -@@ -278,7 +_,7 @@ - jsonobject.addProperty("random_sequence", p_79177_.f_286958_.toString()); - } - -- if (p_79177_.f_79109_.length > 0) { -+ if (!p_79177_.f_79109_.isEmpty()) { - jsonobject.add("pools", p_79179_.serialize(p_79177_.f_79109_)); - } - diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch index 2ad7438b0c..6ed948beb0 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java -@@ -43,7 +_,7 @@ +@@ -51,7 +_,7 @@ public ItemStack m_7372_(ItemStack p_80789_, LootContext p_80790_) { Entity entity = p_80790_.m_78953_(LootContextParams.f_81458_); if (entity instanceof LivingEntity) { diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch index 9a9dc0b566..9b537ce0dc 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java -@@ -31,7 +_,7 @@ +@@ -36,7 +_,7 @@ if (optional.isPresent()) { - ItemStack itemstack = optional.get().m_8043_(p_81269_.m_78952_().m_9598_()); + ItemStack itemstack = optional.get().f_291008_().m_8043_(p_81269_.m_78952_().m_9598_()); if (!itemstack.m_41619_()) { - return itemstack.m_255036_(p_81268_.m_41613_()); + return itemstack.m_255036_(p_81268_.m_41613_() * itemstack.m_41613_()); // Forge: Support smelting returning multiple diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch index 325d5fbe68..82b28f1ca9 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java -@@ -12,6 +_,7 @@ +@@ -21,6 +_,7 @@ }); public static final LootContextParamSet f_81411_ = m_81428_("chest", (p_81452_) -> { p_81452_.m_81406_(LootContextParams.f_81460_).m_81408_(LootContextParams.f_81455_); @@ -8,7 +8,7 @@ }); public static final LootContextParamSet f_81412_ = m_81428_("command", (p_81450_) -> { p_81450_.m_81406_(LootContextParams.f_81460_).m_81408_(LootContextParams.f_81455_); -@@ -21,6 +_,7 @@ +@@ -30,6 +_,7 @@ }); public static final LootContextParamSet f_81414_ = m_81428_("fishing", (p_81446_) -> { p_81446_.m_81406_(LootContextParams.f_81460_).m_81406_(LootContextParams.f_81463_).m_81408_(LootContextParams.f_81455_); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch index 01040b2531..9bbfc71e77 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java +++ b/net/minecraft/world/level/storage/loot/predicates/LootItemRandomChanceWithLootingCondition.java -@@ -31,12 +_,7 @@ +@@ -25,12 +_,7 @@ } public boolean test(LootContext p_81967_) { diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch index be17438bd4..730ed9d48b 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java +++ b/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java -@@ -46,7 +_,7 @@ +@@ -57,7 +_,7 @@ } public String m_142016_() { diff --git a/settings.gradle b/settings.gradle index 9061595066..8993137459 100644 --- a/settings.gradle +++ b/settings.gradle @@ -31,10 +31,8 @@ include 'fmlearlydisplay' include ':mcp' include ':clean' -include ':fmlonly' include ':forge' project(":mcp").projectDir = file("projects/mcp") project(":clean").projectDir = file("projects/clean") -project(":fmlonly").projectDir = file("projects/fmlonly") project(":forge").projectDir = file("projects/forge") diff --git a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java index 4a67cb8565..52fa692cc3 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandSourceStack.java @@ -5,8 +5,7 @@ package net.minecraftforge.client; -import net.minecraft.Util; -import net.minecraft.advancements.Advancement; +import net.minecraft.advancements.AdvancementHolder; import net.minecraft.client.Minecraft; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; @@ -32,30 +31,26 @@ import java.util.stream.Stream; /** * overrides for {@link CommandSourceStack} so that the methods will run successfully client side */ -public class ClientCommandSourceStack extends CommandSourceStack -{ - - public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotation, int permission, String plainTextName, Component displayName, - Entity executing) - { +public class ClientCommandSourceStack extends CommandSourceStack { + public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotation, int permission, String plainTextName, Component displayName, Entity executing) { super(source, position, rotation, null, permission, plainTextName, displayName, null, executing); } /** * Sends a success message without attempting to get the server side list of admins */ + @SuppressWarnings("resource") @Override - public void sendSuccess(Supplier message, boolean sendToAdmins) - { + public void sendSuccess(Supplier message, boolean sendToAdmins) { Minecraft.getInstance().player.sendSystemMessage(message.get()); } /** * {@return the list of teams from the client side} */ + @SuppressWarnings("resource") @Override - public Collection getAllTeams() - { + public Collection getAllTeams() { return Minecraft.getInstance().level.getScoreboard().getTeamNames(); } @@ -63,8 +58,7 @@ public class ClientCommandSourceStack extends CommandSourceStack * {@return the list of online player names from the client side} */ @Override - public Collection getOnlinePlayerNames() - { + public Collection getOnlinePlayerNames() { return Minecraft.getInstance().getConnection().getOnlinePlayers().stream().map((player) -> player.getProfile().getName()).collect(Collectors.toList()); } @@ -72,8 +66,7 @@ public class ClientCommandSourceStack extends CommandSourceStack * {@return a {@link Stream} of recipe ids that are available on the client} */ @Override - public Stream getRecipeNames() - { + public Stream getRecipeNames() { return Minecraft.getInstance().getConnection().getRecipeManager().getRecipeIds(); } @@ -81,8 +74,7 @@ public class ClientCommandSourceStack extends CommandSourceStack * {@return a set of {@link ResourceKey} for levels from the client side} */ @Override - public Set> levels() - { + public Set> levels() { return Minecraft.getInstance().getConnection().levels(); } @@ -90,17 +82,16 @@ public class ClientCommandSourceStack extends CommandSourceStack * {@return the {@link RegistryAccess} from the client side} */ @Override - public RegistryAccess registryAccess() - { + public RegistryAccess registryAccess() { return Minecraft.getInstance().getConnection().registryAccess(); } /** * {@return the scoreboard from the client side} */ + @SuppressWarnings("resource") @Override - public Scoreboard getScoreboard() - { + public Scoreboard getScoreboard() { return Minecraft.getInstance().level.getScoreboard(); } @@ -108,26 +99,24 @@ public class ClientCommandSourceStack extends CommandSourceStack * {@return the advancement from the id from the client side where the advancement needs to be visible to the player} */ @Override - public Advancement getAdvancement(ResourceLocation id) - { - return Minecraft.getInstance().getConnection().getAdvancements().getAdvancements().get(id); + public AdvancementHolder getAdvancement(ResourceLocation id) { + return Minecraft.getInstance().getConnection().getAdvancements().get(id); } /** * {@return the {@link RecipeManager} from the client side} */ @Override - public RecipeManager getRecipeManager() - { + public RecipeManager getRecipeManager() { return Minecraft.getInstance().getConnection().getRecipeManager(); } /** * {@return the level from the client side} */ + @SuppressWarnings("resource") @Override - public Level getUnsidedLevel() - { + public Level getUnsidedLevel() { return Minecraft.getInstance().level; } @@ -136,8 +125,7 @@ public class ClientCommandSourceStack extends CommandSourceStack * because the server isn't available on the client */ @Override - public MinecraftServer getServer() - { + public MinecraftServer getServer() { throw new UnsupportedOperationException("Attempted to get server in client command"); } @@ -146,9 +134,7 @@ public class ClientCommandSourceStack extends CommandSourceStack * because the server side level isn't available on the client side */ @Override - public ServerLevel getLevel() - { + public ServerLevel getLevel() { throw new UnsupportedOperationException("Attempted to get server level in client command"); } - } diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 235e1b55d1..7768c68244 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -85,6 +85,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ReloadableResourceManager; import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceMetadata; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; @@ -280,20 +281,10 @@ public class ForgeHooksClient } } - public static void dispatchRenderStage(RenderLevelStageEvent.Stage stage, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) - { - var mc = Minecraft.getInstance(); - var profiler = mc.getProfiler(); - profiler.push(stage.toString()); - MinecraftForge.EVENT_BUS.post(new RenderLevelStageEvent(stage, levelRenderer, poseStack, projectionMatrix, renderTick, mc.getPartialTick(), camera, frustum)); - profiler.pop(); - } - - public static void dispatchRenderStage(RenderType renderType, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) - { + public static void dispatchRenderStage(RenderType renderType, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) { RenderLevelStageEvent.Stage stage = RenderLevelStageEvent.Stage.fromRenderType(renderType); if (stage != null) - dispatchRenderStage(stage, levelRenderer, poseStack, projectionMatrix, renderTick, camera, frustum); + stage.dispatch(levelRenderer, poseStack, projectionMatrix, renderTick, camera, frustum); } public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, float partialTick, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) @@ -619,62 +610,6 @@ public class ForgeHooksClient MinecraftForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput)); } - public static boolean onScreenMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button) - { - Event event = new ScreenEvent.MouseButtonPressed.Pre(guiScreen, mouseX, mouseY, button); - return MinecraftForge.EVENT_BUS.post(event); - } - - public static boolean onScreenMouseClickedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) - { - Event event = new ScreenEvent.MouseButtonPressed.Post(guiScreen, mouseX, mouseY, button, handled); - MinecraftForge.EVENT_BUS.post(event); - return event.getResult() == Event.Result.DEFAULT ? handled : event.getResult() == Event.Result.ALLOW; - } - - public static boolean onScreenMouseReleasedPre(Screen guiScreen, double mouseX, double mouseY, int button) - { - Event event = new ScreenEvent.MouseButtonReleased.Pre(guiScreen, mouseX, mouseY, button); - return MinecraftForge.EVENT_BUS.post(event); - } - - public static boolean onScreenMouseReleasedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) - { - Event event = new ScreenEvent.MouseButtonReleased.Post(guiScreen, mouseX, mouseY, button, handled); - MinecraftForge.EVENT_BUS.post(event); - return event.getResult() == Event.Result.DEFAULT ? handled : event.getResult() == Event.Result.ALLOW; - } - - public static boolean onScreenMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) - { - Event event = new ScreenEvent.MouseDragged.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY); - return MinecraftForge.EVENT_BUS.post(event); - } - - public static void onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) - { - Event event = new ScreenEvent.MouseDragged.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY); - MinecraftForge.EVENT_BUS.post(event); - } - - public static boolean onScreenMouseScrollPre(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) - { - Window mainWindow = guiScreen.getMinecraft().getWindow(); - double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth(); - double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight(); - Event event = new ScreenEvent.MouseScrolled.Pre(guiScreen, mouseX, mouseY, scrollDelta); - return MinecraftForge.EVENT_BUS.post(event); - } - - public static void onScreenMouseScrollPost(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) - { - Window mainWindow = guiScreen.getMinecraft().getWindow(); - double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth(); - double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight(); - Event event = new ScreenEvent.MouseScrolled.Post(guiScreen, mouseX, mouseY, scrollDelta); - MinecraftForge.EVENT_BUS.post(event); - } - public static boolean onScreenKeyPressedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers) { Event event = new ScreenEvent.KeyPressed.Pre(guiScreen, keyCode, scanCode, modifiers); @@ -717,22 +652,6 @@ public class ForgeHooksClient MinecraftForge.EVENT_BUS.post(event); } - public static boolean onMouseButtonPre(int button, int action, int mods) - { - return MinecraftForge.EVENT_BUS.post(new InputEvent.MouseButton.Pre(button, action, mods)); - } - - public static void onMouseButtonPost(int button, int action, int mods) - { - MinecraftForge.EVENT_BUS.post(new InputEvent.MouseButton.Post(button, action, mods)); - } - - public static boolean onMouseScroll(MouseHandler mouseHelper, double scrollDelta) - { - Event event = new InputEvent.MouseScrollingEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos()); - return MinecraftForge.EVENT_BUS.post(event); - } - public static void onKeyInput(int key, int scanCode, int action, int modifiers) { MinecraftForge.EVENT_BUS.post(new InputEvent.Key(key, scanCode, action, modifiers)); @@ -770,21 +689,11 @@ public class ForgeHooksClient } @Nullable - public static SpriteContents loadSpriteContents( - ResourceLocation name, - Resource resource, - FrameSize frameSize, - NativeImage image, - AnimationMetadataSection animationMeta - ) - { - try - { + public static SpriteContents loadSpriteContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, ResourceMetadata animationMeta) { + try { ForgeTextureMetadata forgeMeta = ForgeTextureMetadata.forResource(resource); return forgeMeta.getLoader() == null ? null : forgeMeta.getLoader().loadContents(name, resource, frameSize, image, animationMeta, forgeMeta); - } - catch (IOException e) - { + } catch (IOException e) { LOGGER.error("Unable to get Forge metadata for {}, falling back to vanilla loading", name); e.printStackTrace(); return null; diff --git a/src/main/java/net/minecraftforge/client/RecipeBookManager.java b/src/main/java/net/minecraftforge/client/RecipeBookManager.java index 3eeb7fefcc..a8919f8ac8 100644 --- a/src/main/java/net/minecraftforge/client/RecipeBookManager.java +++ b/src/main/java/net/minecraftforge/client/RecipeBookManager.java @@ -10,6 +10,7 @@ import com.google.common.collect.ImmutableMap; import net.minecraft.client.RecipeBookCategories; import net.minecraft.world.inventory.RecipeBookType; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent; import net.minecraftforge.fml.ModLoader; @@ -39,10 +40,10 @@ public final class RecipeBookManager * Finds the category the specified recipe should display in, or null if none. */ @Nullable - public static > RecipeBookCategories findCategories(RecipeType type, T recipe) + public static > RecipeBookCategories findCategories(RecipeType type, RecipeHolder recipe) { var lookup = RECIPE_CATEGORY_LOOKUPS.get(type); - return lookup != null ? lookup.apply(recipe) : null; + return lookup != null ? lookup.apply(recipe.value()) : null; } @ApiStatus.Internal diff --git a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java index 1d05344889..7f4f90a424 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityRenderersEvent.java @@ -20,6 +20,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.player.PlayerRenderer; +import net.minecraft.client.resources.PlayerSkin; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -141,11 +142,11 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent public static class AddLayers extends EntityRenderersEvent { private final Map, EntityRenderer> renderers; - private final Map> skinMap; + private final Map> skinMap; private final EntityRendererProvider.Context context; @ApiStatus.Internal - public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, EntityRendererProvider.Context context) + public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, EntityRendererProvider.Context context) { this.renderers = renderers; this.skinMap = playerRenderers; @@ -159,7 +160,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent * {@linkplain ModelLayers#PLAYER regular player model} and {@code slim} for the * {@linkplain ModelLayers#PLAYER_SLIM slim player model}. */ - public Set getSkins() + public Set getSkins() { return skinMap.keySet(); } @@ -174,7 +175,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent */ @Nullable @SuppressWarnings("unchecked") - public >> R getSkin(String skinName) + public >> R getSkin(PlayerSkin.Model skinName) { return (R) skinMap.get(skinName); } diff --git a/src/main/java/net/minecraftforge/client/event/InputEvent.java b/src/main/java/net/minecraftforge/client/event/InputEvent.java index f07c7fa468..6f4db92f73 100644 --- a/src/main/java/net/minecraftforge/client/event/InputEvent.java +++ b/src/main/java/net/minecraftforge/client/event/InputEvent.java @@ -24,12 +24,9 @@ import org.lwjgl.glfw.GLFW; * @see Key * @see InteractionKeyMappingTriggered */ -public abstract class InputEvent extends Event -{ +public abstract class InputEvent extends Event { @ApiStatus.Internal - protected InputEvent() - { - } + protected InputEvent() {} /** * Fired when a mouse button is pressed/released. Sub-events get fired {@link Pre before} and {@link Post after} this happens. @@ -41,15 +38,13 @@ public abstract class InputEvent extends Event * @see Pre * @see Post */ - public static abstract class MouseButton extends InputEvent - { + public static abstract class MouseButton extends InputEvent { private final int button; private final int action; private final int modifiers; @ApiStatus.Internal - protected MouseButton(int button, int action, int modifiers) - { + protected MouseButton(int button, int action, int modifiers) { this.button = button; this.action = action; this.modifiers = modifiers; @@ -61,8 +56,7 @@ public abstract class InputEvent extends Event * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getButton() - { + public int getButton() { return this.button; } @@ -72,8 +66,7 @@ public abstract class InputEvent extends Event * @see InputConstants#PRESS * @see InputConstants#RELEASE */ - public int getAction() - { + public int getAction() { return this.action; } @@ -88,8 +81,7 @@ public abstract class InputEvent extends Event * @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit * @see the online GLFW documentation */ - public int getModifiers() - { + public int getModifiers() { return this.modifiers; } @@ -105,11 +97,9 @@ public abstract class InputEvent extends Event * @see the online GLFW documentation */ @Cancelable - public static class Pre extends MouseButton - { + public static class Pre extends MouseButton { @ApiStatus.Internal - public Pre(int button, int action, int modifiers) - { + public Pre(int button, int action, int modifiers) { super(button, action, modifiers); } } @@ -124,11 +114,9 @@ public abstract class InputEvent extends Event * * @see the online GLFW documentation */ - public static class Post extends MouseButton - { + public static class Post extends MouseButton { @ApiStatus.Internal - public Post(int button, int action, int modifiers) - { + public Post(int button, int action, int modifiers) { super(button, action, modifiers); } } @@ -147,9 +135,9 @@ public abstract class InputEvent extends Event * @see the online GLFW documentation */ @Cancelable - public static class MouseScrollingEvent extends InputEvent - { - private final double scrollDelta; + public static class MouseScrollingEvent extends InputEvent { + private final double deltaX; + private final double deltaY; private final double mouseX; private final double mouseY; private final boolean leftDown; @@ -157,9 +145,9 @@ public abstract class InputEvent extends Event private final boolean rightDown; @ApiStatus.Internal - public MouseScrollingEvent(double scrollDelta, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY) - { - this.scrollDelta = scrollDelta; + public MouseScrollingEvent(double deltaX, double deltaY, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY) { + this.deltaX = deltaX; + this.deltaY = deltaY; this.leftDown = leftDown; this.middleDown = middleDown; this.rightDown = rightDown; @@ -168,50 +156,51 @@ public abstract class InputEvent extends Event } /** - * {@return the amount of change / delta of the mouse scroll} + * {@return the amount of change / delta of the mouse scroll in the vertical direction} */ - public double getScrollDelta() - { - return this.scrollDelta; + public double getDeltaX() { + return this.deltaX; + } + + /** + * {@return the amount of change / delta of the mouse scroll in the horizontal direction} + */ + public double getDeltaY() { + return this.deltaY; } /** * {@return {@code true} if the left mouse button is pressed} */ - public boolean isLeftDown() - { + public boolean isLeftDown() { return this.leftDown; } /** * {@return {@code true} if the right mouse button is pressed} */ - public boolean isRightDown() - { + public boolean isRightDown() { return this.rightDown; } /** * {@return {@code true} if the middle mouse button is pressed} */ - public boolean isMiddleDown() - { + public boolean isMiddleDown() { return this.middleDown; } /** * {@return the X position of the mouse cursor} */ - public double getMouseX() - { + public double getMouseX() { return this.mouseX; } /** * {@return the Y position of the mouse cursor} */ - public double getMouseY() - { + public double getMouseY() { return this.mouseY; } } @@ -224,16 +213,14 @@ public abstract class InputEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Key extends InputEvent - { + public static class Key extends InputEvent { private final int key; private final int scanCode; private final int action; private final int modifiers; @ApiStatus.Internal - public Key(int key, int scanCode, int action, int modifiers) - { + public Key(int key, int scanCode, int action, int modifiers) { this.key = key; this.scanCode = scanCode; this.action = action; @@ -247,8 +234,7 @@ public abstract class InputEvent extends Event * @see GLFW key constants starting with {@code GLFW_KEY_} * @see the online GLFW documentation */ - public int getKey() - { + public int getKey() { return this.key; } @@ -261,8 +247,7 @@ public abstract class InputEvent extends Event * * @see InputConstants#getKey(int, int) */ - public int getScanCode() - { + public int getScanCode() { return this.scanCode; } @@ -273,8 +258,7 @@ public abstract class InputEvent extends Event * @see InputConstants#RELEASE * @see InputConstants#REPEAT */ - public int getAction() - { + public int getAction() { return this.action; } @@ -289,8 +273,7 @@ public abstract class InputEvent extends Event * @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit * @see the online GLFW documentation */ - public int getModifiers() - { + public int getModifiers() { return this.modifiers; } } @@ -313,16 +296,14 @@ public abstract class InputEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class InteractionKeyMappingTriggered extends InputEvent - { + public static class InteractionKeyMappingTriggered extends InputEvent { private final int button; private final KeyMapping keyMapping; private final InteractionHand hand; private boolean handSwing = true; @ApiStatus.Internal - public InteractionKeyMappingTriggered(int button, KeyMapping keyMapping, InteractionHand hand) - { + public InteractionKeyMappingTriggered(int button, KeyMapping keyMapping, InteractionHand hand) { this.button = button; this.keyMapping = keyMapping; this.hand = hand; @@ -333,16 +314,14 @@ public abstract class InputEvent extends Event * * @param value whether to swing the hand */ - public void setSwingHand(boolean value) - { + public void setSwingHand(boolean value) { handSwing = value; } /** * {@return whether to swing the hand; always takes effect, regardless of cancellation} */ - public boolean shouldSwingHand() - { + public boolean shouldSwingHand() { return handSwing; } @@ -353,40 +332,35 @@ public abstract class InputEvent extends Event * of both event's cancellation. * Will always be {@link InteractionHand#MAIN_HAND} if this is an attack or pick block input. */ - public InteractionHand getHand() - { + public InteractionHand getHand() { return hand; } /** * {@return {@code true} if the mouse button is the left mouse button} */ - public boolean isAttack() - { + public boolean isAttack() { return button == 0; } /** * {@return {@code true} if the mouse button is the right mouse button} */ - public boolean isUseItem() - { + public boolean isUseItem() { return button == 1; } /** * {@return {@code true} if the mouse button is the middle mouse button} */ - public boolean isPickBlock() - { + public boolean isPickBlock() { return button == 2; } /** * {@return the key mapping which triggered this event} */ - public KeyMapping getKeyMapping() - { + public KeyMapping getKeyMapping() { return keyMapping; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java index b29b461eb6..647ae7353d 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java @@ -13,6 +13,7 @@ import javax.annotation.Nullable; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Camera; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; @@ -26,6 +27,8 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +import org.jetbrains.annotations.ApiStatus; import org.joml.Matrix4f; /** @@ -37,8 +40,7 @@ import org.joml.Matrix4f; *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ -public class RenderLevelStageEvent extends Event -{ +public class RenderLevelStageEvent extends Event { private final Stage stage; private final LevelRenderer levelRenderer; private final PoseStack poseStack; @@ -48,8 +50,7 @@ public class RenderLevelStageEvent extends Event private final Camera camera; private final Frustum frustum; - public RenderLevelStageEvent(Stage stage, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, float partialTick, Camera camera, Frustum frustum) - { + public RenderLevelStageEvent(Stage stage, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, float partialTick, Camera camera, Frustum frustum) { this.stage = stage; this.levelRenderer = levelRenderer; this.poseStack = poseStack; @@ -64,64 +65,56 @@ public class RenderLevelStageEvent extends Event * {@return the current {@linkplain Stage stage} that is being rendered. Check this before doing rendering to ensure * that rendering happens at the appropriate time.} */ - public Stage getStage() - { + public Stage getStage() { return stage; } /** * {@return the level renderer} */ - public LevelRenderer getLevelRenderer() - { + public LevelRenderer getLevelRenderer() { return levelRenderer; } /** * {@return the pose stack used for rendering} */ - public PoseStack getPoseStack() - { + public PoseStack getPoseStack() { return poseStack; } /** * {@return the projection matrix} */ - public Matrix4f getProjectionMatrix() - { + public Matrix4f getProjectionMatrix() { return projectionMatrix; } /** * {@return the current "ticks" value in the {@linkplain LevelRenderer level renderer}} */ - public int getRenderTick() - { + public int getRenderTick() { return renderTick; } /** * {@return the current partialTick value used for rendering} */ - public float getPartialTick() - { + public float getPartialTick() { return partialTick; } /** * {@return the camera} */ - public Camera getCamera() - { + public Camera getCamera() { return camera; } /** * {@return the frustum} */ - public Frustum getFrustum() - { + public Frustum getFrustum() { return frustum; } @@ -134,8 +127,7 @@ public class RenderLevelStageEvent extends Event *

This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class RegisterStageEvent extends Event implements IModBusEvent - { + public static class RegisterStageEvent extends Event implements IModBusEvent { /** * @param name The name of your Stage. * @param renderType @@ -144,8 +136,7 @@ public class RenderLevelStageEvent extends Event * * @throws IllegalArgumentException if the RenderType passed is already mapped to a Stage. */ - public Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException - { + public Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException { return Stage.register(name, renderType); } } @@ -154,8 +145,7 @@ public class RenderLevelStageEvent extends Event * A time during level rendering for you to render custom things into the world. * @see RegisterStageEvent */ - public static class Stage - { + public static class Stage { private static final Map RENDER_TYPE_STAGES = new HashMap<>(); /** @@ -215,27 +205,23 @@ public class RenderLevelStageEvent extends Event private final String name; - private Stage(String name) - { + private Stage(String name) { this.name = name; } - private static Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException - { + private static Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException { Stage stage = new Stage(name.toString()); if (renderType != null && RENDER_TYPE_STAGES.putIfAbsent(renderType, stage) != null) throw new IllegalArgumentException("Attempted to replace an existing RenderLevelStageEvent.Stage for a RenderType: Stage = " + stage + ", RenderType = " + renderType); return stage; } - private static Stage register(String name, @Nullable RenderType renderType) throws IllegalArgumentException - { + private static Stage register(String name, @Nullable RenderType renderType) throws IllegalArgumentException { return register(new ResourceLocation(name), renderType); } @Override - public String toString() - { + public String toString() { return this.name; } @@ -243,9 +229,18 @@ public class RenderLevelStageEvent extends Event * {@return the {@linkplain Stage stage} bound to the {@linkplain RenderType render type}, or null if no value is present} */ @Nullable - public static Stage fromRenderType(RenderType renderType) - { + public static Stage fromRenderType(RenderType renderType) { return RENDER_TYPE_STAGES.get(renderType); } + + /** Internal just to make our patch smaller, it just fires the event. If you have good reason for this to be external, ask. */ + @ApiStatus.Internal + public void dispatch(LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) { + var mc = Minecraft.getInstance(); + var profiler = mc.getProfiler(); + profiler.push(this.toString()); + MinecraftForge.EVENT_BUS.post(new RenderLevelStageEvent(this, levelRenderer, poseStack, projectionMatrix, renderTick, mc.getPartialTick(), camera, frustum)); + profiler.pop(); + } } } diff --git a/src/main/java/net/minecraftforge/client/event/ScreenEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java index c70892662f..3f0e5c4bc0 100644 --- a/src/main/java/net/minecraftforge/client/event/ScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java @@ -39,21 +39,18 @@ import java.util.function.Consumer; * @see KeyInput */ @OnlyIn(Dist.CLIENT) -public abstract class ScreenEvent extends Event -{ +public abstract class ScreenEvent extends Event { private final Screen screen; @ApiStatus.Internal - protected ScreenEvent(Screen screen) - { + protected ScreenEvent(Screen screen) { this.screen = Objects.requireNonNull(screen); } /** * {@return the screen that caused this event} */ - public Screen getScreen() - { + public Screen getScreen() { return screen; } @@ -68,16 +65,14 @@ public abstract class ScreenEvent extends Event * @see Init.Pre * @see Init.Post */ - public static abstract class Init extends ScreenEvent - { + public static abstract class Init extends ScreenEvent { private final Consumer add; private final Consumer remove; private final List listenerList; @ApiStatus.Internal - protected Init(Screen screen, List listenerList, Consumer add, Consumer remove) - { + protected Init(Screen screen, List listenerList, Consumer add, Consumer remove) { super(screen); this.listenerList = Collections.unmodifiableList(listenerList); this.add = add; @@ -87,8 +82,7 @@ public abstract class ScreenEvent extends Event /** * {@return unmodifiable view of list of event listeners on the screen} */ - public List getListenersList() - { + public List getListenersList() { return listenerList; } @@ -97,8 +91,7 @@ public abstract class ScreenEvent extends Event * * @param listener the listener to add */ - public void addListener(GuiEventListener listener) - { + public void addListener(GuiEventListener listener) { add.accept(listener); } @@ -107,8 +100,7 @@ public abstract class ScreenEvent extends Event * * @param listener the listener to remove */ - public void removeListener(GuiEventListener listener) - { + public void removeListener(GuiEventListener listener) { remove.accept(listener); } @@ -123,11 +115,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends Init - { + public static class Pre extends Init { @ApiStatus.Internal - public Pre(Screen screen, List list, Consumer add, Consumer remove) - { + public Pre(Screen screen, List list, Consumer add, Consumer remove) { super(screen, list, add, remove); } } @@ -140,11 +130,9 @@ public abstract class ScreenEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Post extends Init - { + public static class Post extends Init { @ApiStatus.Internal - public Post(Screen screen, List list, Consumer add, Consumer remove) - { + public Post(Screen screen, List list, Consumer add, Consumer remove) { super(screen, list, add, remove); } } @@ -157,16 +145,14 @@ public abstract class ScreenEvent extends Event * @see Render.Pre * @see Render.Post */ - public static abstract class Render extends ScreenEvent - { + public static abstract class Render extends ScreenEvent { private final GuiGraphics guiGraphics; private final int mouseX; private final int mouseY; private final float partialTick; @ApiStatus.Internal - protected Render(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) - { + protected Render(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { super(screen); this.guiGraphics = guiGraphics; this.mouseX = mouseX; @@ -177,32 +163,28 @@ public abstract class ScreenEvent extends Event /** * {@return the gui graphics used for rendering} */ - public GuiGraphics getGuiGraphics() - { + public GuiGraphics getGuiGraphics() { return guiGraphics; } /** * {@return the X coordinate of the mouse pointer} */ - public int getMouseX() - { + public int getMouseX() { return mouseX; } /** * {@return the Y coordinate of the mouse pointer} */ - public int getMouseY() - { + public int getMouseY() { return mouseY; } /** * {@return the partial tick} */ - public float getPartialTick() - { + public float getPartialTick() { return partialTick; } @@ -216,11 +198,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends Render - { + public static class Pre extends Render { @ApiStatus.Internal - public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) - { + public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { super(screen, guiGraphics, mouseX, mouseY, partialTick); } } @@ -233,11 +213,9 @@ public abstract class ScreenEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Post extends Render - { + public static class Post extends Render { @ApiStatus.Internal - public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) - { + public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { super(screen, guiGraphics, mouseX, mouseY, partialTick); } } @@ -252,13 +230,11 @@ public abstract class ScreenEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class BackgroundRendered extends ScreenEvent - { + public static class BackgroundRendered extends ScreenEvent { private final GuiGraphics guiGraphics; @ApiStatus.Internal - public BackgroundRendered(Screen screen, GuiGraphics guiGraphics) - { + public BackgroundRendered(Screen screen, GuiGraphics guiGraphics) { super(screen); this.guiGraphics = guiGraphics; } @@ -266,8 +242,7 @@ public abstract class ScreenEvent extends Event /** * {@return the gui graphics used for rendering} */ - public GuiGraphics getGuiGraphics() - { + public GuiGraphics getGuiGraphics() { return guiGraphics; } } @@ -284,15 +259,13 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class RenderInventoryMobEffects extends ScreenEvent - { + public static class RenderInventoryMobEffects extends ScreenEvent { private final int availableSpace; private boolean compact; private int horizontalOffset; @ApiStatus.Internal - public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact, int horizontalOffset) - { + public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact, int horizontalOffset) { super(screen); this.availableSpace = availableSpace; this.compact = compact; @@ -302,48 +275,42 @@ public abstract class ScreenEvent extends Event /** * The available space to the right of the inventory. */ - public int getAvailableSpace() - { + public int getAvailableSpace() { return availableSpace; } /** * Whether the effects should be rendered in compact mode (only icons, no text), or the default full size. */ - public boolean isCompact() - { + public boolean isCompact() { return compact; } /** * The distance from the left side of the screen that the effect stack is rendered. Positive values shift this more to the right. */ - public int getHorizontalOffset() - { + public int getHorizontalOffset() { return horizontalOffset; } /** * Replaces the horizontal offset of the effect stack */ - public void setHorizontalOffset(int offset) - { + public void setHorizontalOffset(int offset) { horizontalOffset = offset; } /** * Adds to the horizontal offset of the effect stack. Negative values are acceptable. */ - public void addHorizontalOffset(int offset) - { + public void addHorizontalOffset(int offset) { horizontalOffset += offset; } /** * Sets whether the effects should be rendered in compact mode (only icons, no text), or the default full size. */ - public void setCompact(boolean compact) - { + public void setCompact(boolean compact) { this.compact = compact; } } @@ -357,14 +324,12 @@ public abstract class ScreenEvent extends Event * @see MouseDragged * @see MouseScrolled */ - private static abstract class MouseInput extends ScreenEvent - { + private static abstract class MouseInput extends ScreenEvent { private final double mouseX; private final double mouseY; @ApiStatus.Internal - protected MouseInput(Screen screen, double mouseX, double mouseY) - { + protected MouseInput(Screen screen, double mouseX, double mouseY) { super(screen); this.mouseX = mouseX; this.mouseY = mouseY; @@ -373,16 +338,14 @@ public abstract class ScreenEvent extends Event /** * {@return the X position of the mouse cursor, relative to the screen} */ - public double getMouseX() - { + public double getMouseX() { return mouseX; } /** * {@return the Y position of the mouse cursor, relative to the screen} */ - public double getMouseY() - { + public double getMouseY() { return mouseY; } } @@ -394,13 +357,11 @@ public abstract class ScreenEvent extends Event * @see MouseButtonPressed.Pre * @see MouseButtonPressed.Post */ - public static abstract class MouseButtonPressed extends MouseInput - { + public static abstract class MouseButtonPressed extends MouseInput { private final int button; @ApiStatus.Internal - public MouseButtonPressed(Screen screen, double mouseX, double mouseY, int button) - { + public MouseButtonPressed(Screen screen, double mouseX, double mouseY, int button) { super(screen, mouseX, mouseY); this.button = button; } @@ -411,8 +372,7 @@ public abstract class ScreenEvent extends Event * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getButton() - { + public int getButton() { return button; } @@ -427,11 +387,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends MouseButtonPressed - { + public static class Pre extends MouseButtonPressed { @ApiStatus.Internal - public Pre(Screen screen, double mouseX, double mouseY, int button) - { + public Pre(Screen screen, double mouseX, double mouseY, int button) { super(screen, mouseX, mouseY, button); } } @@ -452,13 +410,11 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @HasResult - public static class Post extends MouseButtonPressed - { + public static class Post extends MouseButtonPressed { private final boolean handled; @ApiStatus.Internal - public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) - { + public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) { super(screen, mouseX, mouseY, button); this.handled = handled; } @@ -466,8 +422,7 @@ public abstract class ScreenEvent extends Event /** * {@return {@code true} if the mouse click was already handled by its screen} */ - public boolean wasHandled() - { + public boolean wasHandled() { return handled; } } @@ -480,13 +435,11 @@ public abstract class ScreenEvent extends Event * @see MouseButtonReleased.Pre * @see MouseButtonReleased.Post */ - public static abstract class MouseButtonReleased extends MouseInput - { + public static abstract class MouseButtonReleased extends MouseInput { private final int button; @ApiStatus.Internal - public MouseButtonReleased(Screen screen, double mouseX, double mouseY, int button) - { + public MouseButtonReleased(Screen screen, double mouseX, double mouseY, int button) { super(screen, mouseX, mouseY); this.button = button; } @@ -497,8 +450,7 @@ public abstract class ScreenEvent extends Event * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getButton() - { + public int getButton() { return button; } @@ -513,11 +465,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends MouseButtonReleased - { + public static class Pre extends MouseButtonReleased { @ApiStatus.Internal - public Pre(Screen screen, double mouseX, double mouseY, int button) - { + public Pre(Screen screen, double mouseX, double mouseY, int button) { super(screen, mouseX, mouseY, button); } } @@ -538,13 +488,11 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @HasResult - public static class Post extends MouseButtonReleased - { + public static class Post extends MouseButtonReleased { private final boolean handled; @ApiStatus.Internal - public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) - { + public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) { super(screen, mouseX, mouseY, button); this.handled = handled; } @@ -552,8 +500,7 @@ public abstract class ScreenEvent extends Event /** * @return {@code true} if the mouse release was already handled by its screen */ - public boolean wasHandled() - { + public boolean wasHandled() { return handled; } } @@ -566,15 +513,13 @@ public abstract class ScreenEvent extends Event * @see MouseDragged.Pre * @see MouseDragged.Post */ - public static abstract class MouseDragged extends MouseInput - { + public static abstract class MouseDragged extends MouseInput { private final int mouseButton; private final double dragX; private final double dragY; @ApiStatus.Internal - public MouseDragged(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) - { + public MouseDragged(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { super(screen, mouseX, mouseY); this.mouseButton = mouseButton; this.dragX = dragX; @@ -587,24 +532,21 @@ public abstract class ScreenEvent extends Event * @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_' * @see the online GLFW documentation */ - public int getMouseButton() - { + public int getMouseButton() { return mouseButton; } /** * {@return amount of mouse drag along the X axis} */ - public double getDragX() - { + public double getDragX() { return dragX; } /** * {@return amount of mouse drag along the Y axis} */ - public double getDragY() - { + public double getDragY() { return dragY; } @@ -619,11 +561,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends MouseDragged - { + public static class Pre extends MouseDragged { @ApiStatus.Internal - public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) - { + public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { super(screen, mouseX, mouseY, mouseButton, dragX, dragY); } } @@ -638,11 +578,9 @@ public abstract class ScreenEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Post extends MouseDragged - { + public static class Post extends MouseDragged { @ApiStatus.Internal - public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) - { + public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { super(screen, mouseX, mouseY, mouseButton, dragX, dragY); } } @@ -655,23 +593,29 @@ public abstract class ScreenEvent extends Event * @see MouseScrolled.Pre * @see MouseScrolled.Post */ - public static abstract class MouseScrolled extends MouseInput - { - private final double scrollDelta; + public static abstract class MouseScrolled extends MouseInput { + private final double deltaX; + private final double deltaY; @ApiStatus.Internal - public MouseScrolled(Screen screen, double mouseX, double mouseY, double scrollDelta) - { + public MouseScrolled(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) { super(screen, mouseX, mouseY); - this.scrollDelta = scrollDelta; + this.deltaX = deltaX; + this.deltaY = deltaY; } /** - * {@return the amount of change / delta of the mouse scroll} + * {@return the amount of change / delta of the mouse scroll in the vertical direction} */ - public double getScrollDelta() - { - return scrollDelta; + public double getDeltaX() { + return deltaX; + } + + /** + * {@return the amount of change / delta of the mouse scroll in the horizontal direction} + */ + public double getDeltaY() { + return deltaY; } /** @@ -685,12 +629,10 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends MouseScrolled - { + public static class Pre extends MouseScrolled { @ApiStatus.Internal - public Pre(Screen screen, double mouseX, double mouseY, double scrollDelta) - { - super(screen, mouseX, mouseY, scrollDelta); + public Pre(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) { + super(screen, mouseX, mouseY, deltaX, deltaY); } } @@ -704,12 +646,10 @@ public abstract class ScreenEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Post extends MouseScrolled - { + public static class Post extends MouseScrolled { @ApiStatus.Internal - public Post(Screen screen, double mouseX, double mouseY, double scrollDelta) - { - super(screen, mouseX, mouseY, scrollDelta); + public Post(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) { + super(screen, mouseX, mouseY, deltaX, deltaY); } } } @@ -723,15 +663,13 @@ public abstract class ScreenEvent extends Event * @see InputConstants * @see the online GLFW documentation */ - private static abstract class KeyInput extends ScreenEvent - { + private static abstract class KeyInput extends ScreenEvent { private final int keyCode; private final int scanCode; private final int modifiers; @ApiStatus.Internal - protected KeyInput(Screen screen, int keyCode, int scanCode, int modifiers) - { + protected KeyInput(Screen screen, int keyCode, int scanCode, int modifiers) { super(screen); this.keyCode = keyCode; this.scanCode = scanCode; @@ -745,8 +683,7 @@ public abstract class ScreenEvent extends Event * @see GLFW key constants starting with {@code GLFW_KEY_} * @see the online GLFW documentation */ - public int getKeyCode() - { + public int getKeyCode() { return keyCode; } @@ -759,8 +696,7 @@ public abstract class ScreenEvent extends Event * * @see InputConstants#getKey(int, int) */ - public int getScanCode() - { + public int getScanCode() { return scanCode; } @@ -775,8 +711,7 @@ public abstract class ScreenEvent extends Event * @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit * @see the online GLFW documentation */ - public int getModifiers() - { + public int getModifiers() { return modifiers; } } @@ -788,11 +723,9 @@ public abstract class ScreenEvent extends Event * @see KeyPressed.Pre * @see KeyPressed.Post */ - public static abstract class KeyPressed extends KeyInput - { + public static abstract class KeyPressed extends KeyInput { @ApiStatus.Internal - public KeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) - { + public KeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) { super(screen, keyCode, scanCode, modifiers); } @@ -807,11 +740,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends KeyPressed - { + public static class Pre extends KeyPressed { @ApiStatus.Internal - public Pre(Screen screen, int keyCode, int scanCode, int modifiers) - { + public Pre(Screen screen, int keyCode, int scanCode, int modifiers) { super(screen, keyCode, scanCode, modifiers); } } @@ -827,11 +758,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Post extends KeyPressed - { + public static class Post extends KeyPressed { @ApiStatus.Internal - public Post(Screen screen, int keyCode, int scanCode, int modifiers) - { + public Post(Screen screen, int keyCode, int scanCode, int modifiers) { super(screen, keyCode, scanCode, modifiers); } } @@ -844,11 +773,9 @@ public abstract class ScreenEvent extends Event * @see KeyReleased.Pre * @see KeyReleased.Post */ - public static abstract class KeyReleased extends KeyInput - { + public static abstract class KeyReleased extends KeyInput { @ApiStatus.Internal - public KeyReleased(Screen screen, int keyCode, int scanCode, int modifiers) - { + public KeyReleased(Screen screen, int keyCode, int scanCode, int modifiers) { super(screen, keyCode, scanCode, modifiers); } @@ -863,11 +790,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends KeyReleased - { + public static class Pre extends KeyReleased { @ApiStatus.Internal - public Pre(Screen screen, int keyCode, int scanCode, int modifiers) - { + public Pre(Screen screen, int keyCode, int scanCode, int modifiers) { super(screen, keyCode, scanCode, modifiers); } } @@ -883,11 +808,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Post extends KeyReleased - { + public static class Post extends KeyReleased { @ApiStatus.Internal - public Post(Screen screen, int keyCode, int scanCode, int modifiers) - { + public Post(Screen screen, int keyCode, int scanCode, int modifiers) { super(screen, keyCode, scanCode, modifiers); } } @@ -901,14 +824,12 @@ public abstract class ScreenEvent extends Event * @see CharacterTyped.Post * @see the online GLFW documentation */ - public static class CharacterTyped extends ScreenEvent - { + public static class CharacterTyped extends ScreenEvent { private final char codePoint; private final int modifiers; @ApiStatus.Internal - public CharacterTyped(Screen screen, char codePoint, int modifiers) - { + public CharacterTyped(Screen screen, char codePoint, int modifiers) { super(screen); this.codePoint = codePoint; this.modifiers = modifiers; @@ -917,8 +838,7 @@ public abstract class ScreenEvent extends Event /** * {@return the character code point} */ - public char getCodePoint() - { + public char getCodePoint() { return codePoint; } @@ -933,8 +853,7 @@ public abstract class ScreenEvent extends Event * @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit * @see the online GLFW documentation */ - public int getModifiers() - { + public int getModifiers() { return modifiers; } @@ -949,11 +868,9 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Pre extends CharacterTyped - { + public static class Pre extends CharacterTyped { @ApiStatus.Internal - public Pre(Screen screen, char codePoint, int modifiers) - { + public Pre(Screen screen, char codePoint, int modifiers) { super(screen, codePoint, modifiers); } } @@ -968,11 +885,9 @@ public abstract class ScreenEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Post extends CharacterTyped - { + public static class Post extends CharacterTyped { @ApiStatus.Internal - public Post(Screen screen, char codePoint, int modifiers) - { + public Post(Screen screen, char codePoint, int modifiers) { super(screen, codePoint, modifiers); } } @@ -991,15 +906,13 @@ public abstract class ScreenEvent extends Event * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ @Cancelable - public static class Opening extends ScreenEvent - { + public static class Opening extends ScreenEvent { @Nullable private final Screen currentScreen; private Screen newScreen; @ApiStatus.Internal - public Opening(@Nullable Screen currentScreen, Screen screen) - { + public Opening(@Nullable Screen currentScreen, Screen screen) { super(screen); this.currentScreen = currentScreen; this.newScreen = screen; @@ -1011,8 +924,7 @@ public abstract class ScreenEvent extends Event * May be null if no screen was open. */ @Nullable - public Screen getCurrentScreen() - { + public Screen getCurrentScreen() { return currentScreen; } @@ -1020,16 +932,14 @@ public abstract class ScreenEvent extends Event * @return The screen that will be opened if the event is not cancelled. May be null. */ @Nullable - public Screen getNewScreen() - { + public Screen getNewScreen() { return newScreen; } /** * Sets the new screen to be opened if the event is not cancelled. May be null. */ - public void setNewScreen(Screen newScreen) - { + public void setNewScreen(Screen newScreen) { this.newScreen = newScreen; } } @@ -1043,11 +953,9 @@ public abstract class ScreenEvent extends Event *

This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Closing extends ScreenEvent - { + public static class Closing extends ScreenEvent { @ApiStatus.Internal - public Closing(Screen screen) - { + public Closing(Screen screen) { super(screen); } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java b/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java index 2bf0fc135c..8831e62027 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeGuiGraphics.java @@ -136,63 +136,4 @@ public interface IForgeGuiGraphics self().blit(texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight); } - - /** - * Version of {@link GuiGraphics#blitNineSliced(ResourceLocation, int, int, int, int, int, int, int, int, int)} that supports specifying the texture's size. - */ - default void blitNineSlicedSized(ResourceLocation texture, int x, int y, int width, int height, int sliceSize, int uWidth, int vHeight, int uOffset, int vOffset, - int textureWidth, int textureHeight) - { - blitNineSlicedSized(texture, x, y, width, height, sliceSize, sliceSize, uWidth, vHeight, uOffset, vOffset, textureWidth, textureHeight); - } - - /** - * Version of {@link GuiGraphics#blitNineSliced(ResourceLocation, int, int, int, int, int, int, int, int, int, int)} that supports specifying the texture's size. - */ - default void blitNineSlicedSized(ResourceLocation texture, int x, int y, int width, int height, int sliceWidth, int sliceHeight, int uWidth, int vHeight, - int uOffset, int vOffset, int textureWidth, int textureHeight) - { - blitNineSlicedSized(texture, x, y, width, height, sliceWidth, sliceHeight, sliceWidth, sliceHeight, uWidth, vHeight, uOffset, vOffset, textureWidth, textureHeight); - } - - /** - * Version of {@link GuiGraphics#blitNineSliced(ResourceLocation, int, int, int, int, int, int, int, int, int, int, int, int)} that supports specifying the texture's size. - */ - default void blitNineSlicedSized(ResourceLocation texture, int x, int y, int width, int height, int cornerWidth, int cornerHeight, int edgeWidth, int edgeHeight, - int uWidth, int vHeight, int uOffset, int vOffset, int textureWidth, int textureHeight) - { - cornerWidth = Math.min(cornerWidth, width / 2); - edgeWidth = Math.min(edgeWidth, width / 2); - cornerHeight = Math.min(cornerHeight, height / 2); - edgeHeight = Math.min(edgeHeight, height / 2); - GuiGraphics self = self(); - if (width == uWidth && height == vHeight) - { - self.blit(texture, x, y, uOffset, vOffset, width, height, textureWidth, textureHeight); - } - else if (height == vHeight) - { - self.blit(texture, x, y, uOffset, vOffset, cornerWidth, height, textureWidth, textureHeight); - self.blitRepeating(texture, x + cornerWidth, y, width - edgeWidth - cornerWidth, height, uOffset + cornerWidth, vOffset, uWidth - edgeWidth - cornerWidth, vHeight, textureWidth, textureHeight); - self.blit(texture, x + width - edgeWidth, y, uOffset + uWidth - edgeWidth, vOffset, edgeWidth, height, textureWidth, textureHeight); - } - else if (width == uWidth) - { - self.blit(texture, x, y, uOffset, vOffset, width, cornerHeight, textureWidth, textureHeight); - self.blitRepeating(texture, x, y + cornerHeight, width, height - edgeHeight - cornerHeight, uOffset, vOffset + cornerHeight, uWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight); - self.blit(texture, x, y + height - edgeHeight, uOffset, vOffset + vHeight - edgeHeight, width, edgeHeight, textureWidth, textureHeight); - } - else - { - self.blit(texture, x, y, uOffset, vOffset, cornerWidth, cornerHeight, textureWidth, textureHeight); - self.blitRepeating(texture, x + cornerWidth, y, width - edgeWidth - cornerWidth, cornerHeight, uOffset + cornerWidth, vOffset, uWidth - edgeWidth - cornerWidth, cornerHeight, textureWidth, textureHeight); - self.blit(texture, x + width - edgeWidth, y, uOffset + uWidth - edgeWidth, vOffset, edgeWidth, cornerHeight, textureWidth, textureHeight); - self.blit(texture, x, y + height - edgeHeight, uOffset, vOffset + vHeight - edgeHeight, cornerWidth, edgeHeight, textureWidth, textureHeight); - self.blitRepeating(texture, x + cornerWidth, y + height - edgeHeight, width - edgeWidth - cornerWidth, edgeHeight, uOffset + cornerWidth, vOffset + vHeight - edgeHeight, uWidth - edgeWidth - cornerWidth, edgeHeight, textureWidth, textureHeight); - self.blit(texture, x + width - edgeWidth, y + height - edgeHeight, uOffset + uWidth - edgeWidth, vOffset + vHeight - edgeHeight, edgeWidth, edgeHeight, textureWidth, textureHeight); - self.blitRepeating(texture, x, y + cornerHeight, cornerWidth, height - edgeHeight - cornerHeight, uOffset, vOffset + cornerHeight, cornerWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight); - self.blitRepeating(texture, x + cornerWidth, y + cornerHeight, width - edgeWidth - cornerWidth, height - edgeHeight - cornerHeight, uOffset + cornerWidth, vOffset + cornerHeight, uWidth - edgeWidth - cornerWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight); - self.blitRepeating(texture, x + width - edgeWidth, y + cornerHeight, cornerWidth, height - edgeHeight - cornerHeight, uOffset + uWidth - edgeWidth, vOffset + cornerHeight, edgeWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight); - } - } } diff --git a/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java b/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java index faedbf56f3..48dd2520ca 100644 --- a/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java +++ b/src/main/java/net/minecraftforge/client/extensions/common/IClientBlockExtensions.java @@ -74,7 +74,7 @@ public interface IClientBlockExtensions */ default boolean addDestroyEffects(BlockState state, Level Level, BlockPos pos, ParticleEngine manager) { - return !state.shouldSpawnParticlesOnBreak(); + return !state.shouldSpawnTerrainParticles(); } /** @@ -117,8 +117,8 @@ public interface IClientBlockExtensions } /** - * Returns true if the breaking particles created from the {@link BlockState} passed should be tinted with biome colors. - * + * Returns true if the breaking particles created from the {@link BlockState} passed should be tinted with biome colors. + * * @param state The state of this block * @param level The level the particles are spawning in * @param pos The position of the block diff --git a/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java index 6865391375..25d1400908 100644 --- a/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java @@ -80,7 +80,7 @@ public class LoadingErrorScreen extends ErrorScreen { @Override public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { - this.renderBackground(guiGraphics); + this.renderBackground(guiGraphics, mouseX, mouseY, partialTick); this.entryList.render(guiGraphics, mouseX, mouseY, partialTick); drawMultiLineCenteredString(guiGraphics, font, this.modLoadErrors.isEmpty() ? warningHeader : errorHeader, this.width / 2, 10); this.renderables.forEach(button -> button.render(guiGraphics, mouseX, mouseY, partialTick)); diff --git a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java index 9886f6bd94..bacbef2d57 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java @@ -311,7 +311,6 @@ public class ModListScreen extends Screen @Override public void tick() { - search.tick(); modList.setSelected(selected); if (!search.getValue().equals(lastFilterText)) diff --git a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java index deb4bfac47..f07aabd80e 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java @@ -104,7 +104,7 @@ public class ModMismatchDisconnectedScreen extends Screen @Override public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { - this.renderBackground(guiGraphics); + this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks); int textYOffset = modMismatchData.containsMismatches() ? 18 : 0; guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset - 9 * 2, 0xAAAAAA); this.message.renderCentered(guiGraphics, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset); diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java index e21b196d54..16239f3aef 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/ForgeGui.java @@ -17,6 +17,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.resources.language.I18n; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.util.StringUtil; import net.minecraft.world.effect.MobEffects; @@ -30,6 +31,7 @@ import net.minecraft.world.food.FoodData; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.scores.DisplaySlot; import net.minecraft.world.scores.Objective; import net.minecraftforge.client.event.CustomizeGuiOverlayEvent; import net.minecraftforge.client.event.RenderGuiEvent; @@ -46,8 +48,7 @@ import java.util.List; /** * Forge wrapper around {@link Gui} to be able to render {@link IGuiOverlay HUD overlays}. */ -public class ForgeGui extends Gui -{ +public class ForgeGui extends Gui { private static final Logger LOGGER = LogManager.getLogger(); private static final int WHITE = 0xFFFFFF; @@ -64,45 +65,33 @@ public class ForgeGui extends Gui private final ForgeDebugScreenOverlay debugOverlay; - public ForgeGui(Minecraft mc) - { + public ForgeGui(Minecraft mc) { super(mc, mc.getItemRenderer()); debugOverlay = new ForgeDebugScreenOverlay(mc); } - public Minecraft getMinecraft() - { + public Minecraft getMinecraft() { return minecraft; } - public void setupOverlayRenderState(boolean blend, boolean depthTest) - { - if (blend) - { + public void setupOverlayRenderState(boolean blend, boolean depthTest) { + if (blend) { RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - } - else - { + } else RenderSystem.disableBlend(); - } if (depthTest) - { RenderSystem.enableDepthTest(); - } else - { RenderSystem.disableDepthTest(); - } RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShader(GameRenderer::getPositionTexShader); } @Override - public void render(GuiGraphics guiGraphics, float partialTick) - { + public void render(GuiGraphics guiGraphics, float partialTick) { this.screenWidth = this.minecraft.getWindow().getGuiScaledWidth(); this.screenHeight = this.minecraft.getWindow().getGuiScaledHeight(); @@ -110,23 +99,19 @@ public class ForgeGui extends Gui leftHeight = 39; if (MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Pre(minecraft.getWindow(), guiGraphics, partialTick))) - { return; - } font = minecraft.font; this.random.setSeed(tickCount * 312871L); GuiOverlayManager.getOverlays().forEach(entry -> { - try - { + try { IGuiOverlay overlay = entry.overlay(); if (pre(entry, guiGraphics)) return; overlay.render(this, guiGraphics, partialTick, screenWidth, screenHeight); post(entry, guiGraphics); - } catch (Exception e) - { + } catch (Exception e) { LOGGER.error("Error rendering overlay '{}'", entry.id(), e); } }); @@ -136,69 +121,50 @@ public class ForgeGui extends Gui MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Post(minecraft.getWindow(), guiGraphics, partialTick)); } - public boolean shouldDrawSurvivalElements() - { + public boolean shouldDrawSurvivalElements() { return minecraft.gameMode.canHurtPlayer() && minecraft.getCameraEntity() instanceof Player; } - protected void renderSubtitles(GuiGraphics guiGraphics) - { + protected void renderSubtitles(GuiGraphics guiGraphics) { this.subtitleOverlay.render(guiGraphics); } - protected void renderBossHealth(GuiGraphics guiGraphics) - { + protected void renderBossHealth(GuiGraphics guiGraphics) { RenderSystem.defaultBlendFunc(); minecraft.getProfiler().push("bossHealth"); this.bossOverlay.render(guiGraphics); minecraft.getProfiler().pop(); } - void renderSpyglassOverlay(GuiGraphics guiGraphics) - { + void renderSpyglassOverlay(GuiGraphics guiGraphics) { float deltaFrame = this.minecraft.getDeltaFrameTime(); this.scopeScale = Mth.lerp(0.5F * deltaFrame, this.scopeScale, 1.125F); - if (this.minecraft.options.getCameraType().isFirstPerson()) - { + if (this.minecraft.options.getCameraType().isFirstPerson()) { if (this.minecraft.player.isScoping()) - { this.renderSpyglassOverlay(guiGraphics, this.scopeScale); - } else - { this.scopeScale = 0.5F; - } } } - void renderHelmet(float partialTick, GuiGraphics guiGraphics) - { + void renderHelmet(float partialTick, GuiGraphics guiGraphics) { ItemStack itemstack = this.minecraft.player.getInventory().getArmor(3); - if (this.minecraft.options.getCameraType().isFirstPerson() && !itemstack.isEmpty()) - { + if (this.minecraft.options.getCameraType().isFirstPerson() && !itemstack.isEmpty()) { Item item = itemstack.getItem(); if (item == Blocks.CARVED_PUMPKIN.asItem()) - { renderTextureOverlay(guiGraphics, PUMPKIN_BLUR_LOCATION, 1.0F); - } else - { IClientItemExtensions.of(item).renderHelmetOverlay(itemstack, minecraft.player, this.screenWidth, this.screenHeight, partialTick); - } } } - void renderFrostbite(GuiGraphics guiGraphics) - { + void renderFrostbite(GuiGraphics guiGraphics) { if (this.minecraft.player.getTicksFrozen() > 0) - { this.renderTextureOverlay(guiGraphics, POWDER_SNOW_OUTLINE_LOCATION, this.minecraft.player.getPercentFrozen()); - } } - protected void renderArmor(GuiGraphics guiGraphics, int width, int height) - { + protected void renderArmor(GuiGraphics guiGraphics, int width, int height) { minecraft.getProfiler().push("armor"); RenderSystem.enableBlend(); @@ -206,20 +172,13 @@ public class ForgeGui extends Gui int top = height - leftHeight; int level = minecraft.player.getArmorValue(); - for (int i = 1; level > 0 && i < 20; i += 2) - { + for (int i = 1; level > 0 && i < 20; i += 2) { if (i < level) - { - guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 34, 9, 9, 9); - } + guiGraphics.blitSprite(ARMOR_FULL_SPRITE, left, top, 9, 9); else if (i == level) - { - guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 25, 9, 9, 9); - } + guiGraphics.blitSprite(ARMOR_HALF_SPRITE, left, top, 9, 9); else if (i > level) - { - guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 16, 9, 9, 9); - } + guiGraphics.blitSprite(ARMOR_EMPTY_SPRITE, left, top, 9, 9); left += 8; } leftHeight += 10; @@ -229,16 +188,12 @@ public class ForgeGui extends Gui } @Override - protected void renderPortalOverlay(GuiGraphics guiGraphics, float alpha) - { + protected void renderPortalOverlay(GuiGraphics guiGraphics, float alpha) { if (alpha > 0.0F) - { super.renderPortalOverlay(guiGraphics, alpha); - } } - protected void renderAir(int width, int height, GuiGraphics guiGraphics) - { + protected void renderAir(int width, int height, GuiGraphics guiGraphics) { minecraft.getProfiler().push("air"); Player player = (Player) this.minecraft.getCameraEntity(); RenderSystem.enableBlend(); @@ -246,14 +201,15 @@ public class ForgeGui extends Gui int top = height - rightHeight; int air = player.getAirSupply(); - if (player.isEyeInFluidType(ForgeMod.WATER_TYPE.get()) || air < 300) - { + if (player.isEyeInFluidType(ForgeMod.WATER_TYPE.get()) || air < 300) { int full = Mth.ceil((double) (air - 2) * 10.0D / 300.0D); int partial = Mth.ceil((double) air * 10.0D / 300.0D) - full; - for (int i = 0; i < full + partial; ++i) - { - guiGraphics.blit(GUI_ICONS_LOCATION, left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9); + for (int i = 0; i < full + partial; ++i) { + if (i < full) + guiGraphics.blitSprite(AIR_SPRITE, left - i * 8 - 9, top, 9, 9); + else + guiGraphics.blitSprite(AIR_BURSTING_SPRITE, left - i * 8 - 9, top, 9, 9); } rightHeight += 10; } @@ -262,8 +218,7 @@ public class ForgeGui extends Gui minecraft.getProfiler().pop(); } - public void renderHealth(int width, int height, GuiGraphics guiGraphics) - { + public void renderHealth(int width, int height, GuiGraphics guiGraphics) { minecraft.getProfiler().push("health"); RenderSystem.enableBlend(); @@ -271,19 +226,15 @@ public class ForgeGui extends Gui int health = Mth.ceil(player.getHealth()); boolean highlight = healthBlinkTime > (long) tickCount && (healthBlinkTime - (long) tickCount) / 3L % 2L == 1L; - if (health < this.lastHealth && player.invulnerableTime > 0) - { + if (health < this.lastHealth && player.invulnerableTime > 0) { this.lastHealthTime = Util.getMillis(); this.healthBlinkTime = (long) (this.tickCount + 20); - } - else if (health > this.lastHealth && player.invulnerableTime > 0) - { + } else if (health > this.lastHealth && player.invulnerableTime > 0) { this.lastHealthTime = Util.getMillis(); this.healthBlinkTime = (long) (this.tickCount + 10); } - if (Util.getMillis() - this.lastHealthTime > 1000L) - { + if (Util.getMillis() - this.lastHealthTime > 1000L) { this.lastHealth = health; this.displayHealth = health; this.lastHealthTime = Util.getMillis(); @@ -308,9 +259,7 @@ public class ForgeGui extends Gui int regen = -1; if (player.hasEffect(MobEffects.REGENERATION)) - { regen = this.tickCount % Mth.ceil(healthMax + 5.0F); - } this.renderHearts(guiGraphics, player, left, top, rowHeight, regen, healthMax, health, healthLast, absorb, highlight); @@ -318,8 +267,7 @@ public class ForgeGui extends Gui minecraft.getProfiler().pop(); } - public void renderFood(int width, int height, GuiGraphics guiGraphics) - { + public void renderFood(int width, int height, GuiGraphics guiGraphics) { minecraft.getProfiler().push("food"); Player player = (Player) this.minecraft.getCameraEntity(); @@ -327,54 +275,47 @@ public class ForgeGui extends Gui int left = width / 2 + 91; int top = height - rightHeight; rightHeight += 10; - boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic FoodData stats = minecraft.player.getFoodData(); int level = stats.getFoodLevel(); - for (int i = 0; i < 10; ++i) - { + ResourceLocation empty = FOOD_EMPTY_SPRITE; + ResourceLocation half = FOOD_HALF_SPRITE; + ResourceLocation full = FOOD_FULL_SPRITE; + + if (player.hasEffect(MobEffects.HUNGER)) { + empty = FOOD_EMPTY_HUNGER_SPRITE; + half = FOOD_HALF_HUNGER_SPRITE; + full = FOOD_FULL_HUNGER_SPRITE; + } + + for (int i = 0; i < 10; ++i) { int idx = i * 2 + 1; int x = left - i * 8 - 9; int y = top; - int icon = 16; - byte background = 0; - - if (minecraft.player.hasEffect(MobEffects.HUNGER)) - { - icon += 36; - background = 13; - } - if (unused) background = 1; //Probably should be a += 1 but vanilla never uses this if (player.getFoodData().getSaturationLevel() <= 0.0F && tickCount % (level * 3 + 1) == 0) - { y = top + (random.nextInt(3) - 1); - } - guiGraphics.blit(GUI_ICONS_LOCATION, x, y, 16 + background * 9, 27, 9, 9); + guiGraphics.blitSprite(empty, x, y, 9, 9); if (idx < level) - guiGraphics.blit(GUI_ICONS_LOCATION, x, y, icon + 36, 27, 9, 9); + guiGraphics.blitSprite(half, x, y, 9, 9); else if (idx == level) - guiGraphics.blit(GUI_ICONS_LOCATION, x, y, icon + 45, 27, 9, 9); + guiGraphics.blitSprite(full, x, y, 9, 9); } RenderSystem.disableBlend(); minecraft.getProfiler().pop(); } - protected void renderSleepFade(int width, int height, GuiGraphics guiGraphics) - { - if (minecraft.player.getSleepTimer() > 0) - { + protected void renderSleepFade(int width, int height, GuiGraphics guiGraphics) { + if (minecraft.player.getSleepTimer() > 0) { minecraft.getProfiler().push("sleep"); int sleepTime = minecraft.player.getSleepTimer(); float opacity = (float) sleepTime / 100.0F; if (opacity > 1.0F) - { opacity = 1.0F - (float) (sleepTime - 100) / 10.0F; - } int color = (int) (220.0F * opacity) << 24 | 1052704; guiGraphics.fill(RenderType.guiOverlay(), 0, 0, width, height, color); @@ -382,22 +323,19 @@ public class ForgeGui extends Gui } } - protected void renderExperience(int x, GuiGraphics guiGraphics) - { + protected void renderExperience(int x, GuiGraphics guiGraphics) { guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); if (minecraft.gameMode.hasExperience()) - { super.renderExperienceBar(guiGraphics, x); - } + RenderSystem.enableBlend(); guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F); } @Override - public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, GuiGraphics guiGraphics, int x) - { + public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, GuiGraphics guiGraphics, int x) { guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); @@ -408,29 +346,22 @@ public class ForgeGui extends Gui guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F); } - protected void renderHUDText(int width, int height, GuiGraphics guiGraphics) - { + protected void renderHUDText(int width, int height, GuiGraphics guiGraphics) { minecraft.getProfiler().push("forgeHudText"); RenderSystem.defaultBlendFunc(); var listL = new ArrayList(); var listR = new ArrayList(); - if (minecraft.isDemo()) - { + if (minecraft.isDemo()) { long time = minecraft.level.getGameTime(); if (time >= 120500L) - { listR.add(I18n.get("demo.demoExpired")); - } else - { listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int) (120500L - time)))); - } } - if (this.minecraft.options.renderDebug) - { + if (debugOverlay.showDebugScreen()) { debugOverlay.update(); listL.addAll(debugOverlay.getLeft()); listR.addAll(debugOverlay.getRight()); @@ -440,10 +371,8 @@ public class ForgeGui extends Gui MinecraftForge.EVENT_BUS.post(event); int top = 2; - for (String msg : listL) - { - if (msg != null && !msg.isEmpty()) - { + for (String msg : listL) { + if (msg != null && !msg.isEmpty()) { guiGraphics.fill(1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752); guiGraphics.drawString(font, msg, 2, top, 14737632, false); } @@ -451,10 +380,8 @@ public class ForgeGui extends Gui } top = 2; - for (String msg : listR) - { - if (msg != null && !msg.isEmpty()) - { + for (String msg : listR) { + if (msg != null && !msg.isEmpty()) { int w = font.width(msg); int left = width - 2 - w; guiGraphics.fill(left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752); @@ -466,32 +393,25 @@ public class ForgeGui extends Gui minecraft.getProfiler().pop(); } - protected void renderFPSGraph(GuiGraphics guiGraphics) - { - if (this.minecraft.options.renderDebug && this.minecraft.options.renderFpsChart) - { + protected void renderFPSGraph(GuiGraphics guiGraphics) { + if (debugOverlay.showDebugScreen()) this.debugOverlay.render(guiGraphics); - } } @Override - public void clearCache() - { + public void clearCache() { super.clearCache(); this.debugOverlay.clearChunkCache(); } - protected void renderRecordOverlay(int width, int height, float partialTick, GuiGraphics guiGraphics) - { - if (overlayMessageTime > 0) - { + protected void renderRecordOverlay(int width, int height, float partialTick, GuiGraphics guiGraphics) { + if (overlayMessageTime > 0) { minecraft.getProfiler().push("overlayMessage"); float hue = (float) overlayMessageTime - partialTick; int opacity = (int) (hue * 255.0F / 20.0F); if (opacity > 255) opacity = 255; - if (opacity > 8) - { + if (opacity > 8) { //Include a shift based on the bar height plus the difference between the height that renderSelectedItemName // renders at (59) and the height that the overlay/status bar renders at (68) by default int yShift = Math.max(leftHeight, rightHeight) + (68 - 59); @@ -512,16 +432,13 @@ public class ForgeGui extends Gui } } - protected void renderTitle(int width, int height, float partialTick, GuiGraphics guiGraphics) - { - if (title != null && titleTime > 0) - { + protected void renderTitle(int width, int height, float partialTick, GuiGraphics guiGraphics) { + if (title != null && titleTime > 0) { minecraft.getProfiler().push("titleAndSubtitle"); float age = (float) this.titleTime - partialTick; int opacity = 255; - if (titleTime > titleFadeOutTime + titleStayTime) - { + if (titleTime > titleFadeOutTime + titleStayTime) { float f3 = (float) (titleFadeInTime + titleStayTime + titleFadeOutTime) - age; opacity = (int) (f3 * 255.0F / (float) titleFadeInTime); } @@ -529,8 +446,7 @@ public class ForgeGui extends Gui opacity = Mth.clamp(opacity, 0, 255); - if (opacity > 8) - { + if (opacity > 8) { guiGraphics.pose().pushPose(); guiGraphics.pose().translate(width / 2D, height / 2D, 0.0D); RenderSystem.enableBlend(); @@ -540,8 +456,7 @@ public class ForgeGui extends Gui int l = opacity << 24 & -16777216; guiGraphics.drawString(this.font, this.title.getVisualOrderText(), -this.getFont().width(this.title) / 2, -10, 16777215 | l, true); guiGraphics.pose().popPose(); - if (this.subtitle != null) - { + if (this.subtitle != null) { guiGraphics.pose().pushPose(); guiGraphics.pose().scale(2.0F, 2.0F, 2.0F); guiGraphics.drawString(this.font, this.subtitle.getVisualOrderText(), -this.getFont().width(this.subtitle) / 2, 5, 16777215 | l, true); @@ -555,8 +470,7 @@ public class ForgeGui extends Gui } } - protected void renderChat(int width, int height, GuiGraphics guiGraphics) - { + protected void renderChat(int width, int height, GuiGraphics guiGraphics) { minecraft.getProfiler().push("chat"); Window window = minecraft.getWindow(); @@ -574,30 +488,22 @@ public class ForgeGui extends Gui minecraft.getProfiler().pop(); } - protected void renderPlayerList(int width, int height, GuiGraphics guiGraphics) - { - Objective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(0); + protected void renderPlayerList(int width, int height, GuiGraphics guiGraphics) { + Objective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(DisplaySlot.LIST); ClientPacketListener handler = minecraft.player.connection; - if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null)) - { + if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null)) { this.tabList.setVisible(true); this.tabList.render(guiGraphics, width, this.minecraft.level.getScoreboard(), scoreobjective); - - } - else - { + } else this.tabList.setVisible(false); - } } - protected void renderHealthMount(int width, int height, GuiGraphics guiGraphics) - { + protected void renderHealthMount(int width, int height, GuiGraphics guiGraphics) { Player player = (Player) minecraft.getCameraEntity(); Entity tmp = player.getVehicle(); if (!(tmp instanceof LivingEntity)) return; - boolean unused = false; int left_align = width / 2 + 91; minecraft.getProfiler().popPush("mountHealth"); @@ -609,27 +515,21 @@ public class ForgeGui extends Gui if (hearts > 30) hearts = 30; - final int MARGIN = 52; - final int BACKGROUND = MARGIN + (unused ? 1 : 0); - final int HALF = MARGIN + 45; - final int FULL = MARGIN + 36; - for (int heart = 0; hearts > 0; heart += 20) - { + for (int heart = 0; hearts > 0; heart += 20) { int top = height - rightHeight; int rowCount = Math.min(hearts, 10); hearts -= rowCount; - for (int i = 0; i < rowCount; ++i) - { + for (int i = 0; i < rowCount; ++i) { int x = left_align - i * 8 - 9; - guiGraphics.blit(GUI_ICONS_LOCATION, x, top, BACKGROUND, 9, 9, 9); + guiGraphics.blitSprite(HEART_VEHICLE_CONTAINER_SPRITE, x, top, 9, 9); if (i * 2 + 1 + heart < health) - guiGraphics.blit(GUI_ICONS_LOCATION, x, top, FULL, 9, 9, 9); + guiGraphics.blitSprite(HEART_VEHICLE_FULL_SPRITE, x, top, 9, 9); else if (i * 2 + 1 + heart == health) - guiGraphics.blit(GUI_ICONS_LOCATION, x, top, HALF, 9, 9, 9); + guiGraphics.blitSprite(HEART_VEHICLE_HALF_SPRITE, x, top, 9, 9); } rightHeight += 10; @@ -638,36 +538,30 @@ public class ForgeGui extends Gui } //Helper macros - private boolean pre(NamedGuiOverlay overlay, GuiGraphics guiGraphics) - { + private boolean pre(NamedGuiOverlay overlay, GuiGraphics guiGraphics) { return MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Pre(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), overlay)); } - private void post(NamedGuiOverlay overlay, GuiGraphics guiGraphics) - { + private void post(NamedGuiOverlay overlay, GuiGraphics guiGraphics) { MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Post(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), overlay)); } - private static class ForgeDebugScreenOverlay extends DebugScreenOverlay - { + private static class ForgeDebugScreenOverlay extends DebugScreenOverlay { private final Minecraft mc; - private ForgeDebugScreenOverlay(Minecraft mc) - { + private ForgeDebugScreenOverlay(Minecraft mc) { super(mc); this.mc = mc; } - public void update() - { + public void update() { Entity entity = this.mc.getCameraEntity(); this.block = entity.pick(rayTraceDistance, 0.0F, false); this.liquid = entity.pick(rayTraceDistance, 0.0F, true); } @Override - protected void drawGameInformation(GuiGraphics guiGraphics) - { + protected void drawGameInformation(GuiGraphics guiGraphics) { // Replicate the depth test state "leak" caused by the text that is rendered here in vanilla // being flushed when the graphs start drawing (PR #9539) RenderSystem.disableDepthTest(); @@ -676,18 +570,16 @@ public class ForgeGui extends Gui @Override protected void drawSystemInformation(GuiGraphics guiGraphics) {} - private List getLeft() - { + private List getLeft() { List ret = this.getGameInformation(); ret.add(""); boolean flag = this.mc.getSingleplayerServer() != null; - ret.add("Debug: Pie [shift]: " + (this.mc.options.renderDebugCharts ? "visible" : "hidden") + (flag ? " FPS + TPS" : " FPS") + " [alt]: " + (this.mc.options.renderFpsChart ? "visible" : "hidden")); + ret.add("Debug: Pie [shift]: " + (this.renderProfilerChart ? "visible" : "hidden") + (flag ? " FPS + TPS" : " FPS") + " [alt]: " + (this.renderFpsCharts ? "visible" : "hidden")); ret.add("For help: press F3 + Q"); return ret; } - private List getRight() - { + private List getRight() { return this.getSystemInformation(); } } diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java index 0455d3ad5b..b670921bf7 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java @@ -13,6 +13,7 @@ import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.PlayerRideableJumping; import net.minecraft.world.level.GameType; +import net.minecraft.world.scores.DisplaySlot; import net.minecraft.world.scores.Objective; import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.Scoreboard; @@ -22,27 +23,29 @@ import org.lwjgl.opengl.GL11; /** * All the vanilla {@linkplain IGuiOverlay HUD overlays} in the order that they render. */ -public enum VanillaGuiOverlay -{ +public enum VanillaGuiOverlay { VIGNETTE("vignette", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (Minecraft.useFancyGraphics()) - { + if (Minecraft.useFancyGraphics()) { gui.setupOverlayRenderState(true, false); gui.renderVignette(guiGraphics, gui.getMinecraft().getCameraEntity()); } }), + SPYGLASS("spyglass", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { gui.setupOverlayRenderState(true, false); gui.renderSpyglassOverlay(guiGraphics); }), + HELMET("helmet", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { gui.setupOverlayRenderState(true, false); gui.renderHelmet(partialTick, guiGraphics); }), + FROSTBITE("frostbite", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { gui.setupOverlayRenderState(true, false); gui.renderFrostbite(guiGraphics); }), + PORTAL("portal", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { float f1 = Mth.lerp(partialTick, gui.getMinecraft().player.oSpinningEffectIntensity, gui.getMinecraft().player.spinningEffectIntensity); if (f1 > 0.0F && !gui.getMinecraft().player.hasEffect(MobEffects.CONFUSION)) { @@ -50,23 +53,19 @@ public enum VanillaGuiOverlay gui.renderPortalOverlay(guiGraphics, f1); } }), + HOTBAR("hotbar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui) - { + if (!gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); if (gui.getMinecraft().gameMode.getPlayerMode() == GameType.SPECTATOR) - { gui.getSpectatorGui().renderHotbar(guiGraphics); - } else - { gui.renderHotbar(partialTick, guiGraphics); - } } }), + CROSSHAIR("crosshair", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui) - { + if (!gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); guiGraphics.pose().pushPose(); @@ -75,9 +74,9 @@ public enum VanillaGuiOverlay guiGraphics.pose().popPose(); } }), + BOSS_EVENT_PROGRESS("boss_event_progress", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui) - { + if (!gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); guiGraphics.pose().pushPose(); @@ -86,127 +85,125 @@ public enum VanillaGuiOverlay guiGraphics.pose().popPose(); } }), + PLAYER_HEALTH("player_health", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) - { + if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) { gui.setupOverlayRenderState(true, false); gui.renderHealth(screenWidth, screenHeight, guiGraphics); } }), + ARMOR_LEVEL("armor_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) - { + if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) { gui.setupOverlayRenderState(true, false); gui.renderArmor(guiGraphics, screenWidth, screenHeight); } }), + FOOD_LEVEL("food_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { Entity vehicle = gui.getMinecraft().player.getVehicle(); boolean isMounted = vehicle != null && vehicle.showVehicleHealth(); - if (!isMounted && !gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) - { + if (!isMounted && !gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) { gui.setupOverlayRenderState(true, false); gui.renderFood(screenWidth, screenHeight, guiGraphics); } }), + AIR_LEVEL("air_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) - { + if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) { gui.setupOverlayRenderState(true, false); gui.renderAir(screenWidth, screenHeight, guiGraphics); } }), + MOUNT_HEALTH("mount_health", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) - { + if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) { gui.setupOverlayRenderState(true, false); gui.renderHealthMount(screenWidth, screenHeight, guiGraphics); } }), + JUMP_BAR("jump_bar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { PlayerRideableJumping playerRideableJumping = gui.getMinecraft().player.jumpableVehicle(); - if (playerRideableJumping != null && !gui.getMinecraft().options.hideGui) - { + if (playerRideableJumping != null && !gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); gui.renderJumpMeter(playerRideableJumping, guiGraphics, screenWidth / 2 - 91); } }), + EXPERIENCE_BAR("experience_bar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (gui.getMinecraft().player.jumpableVehicle() == null && !gui.getMinecraft().options.hideGui) - { + if (gui.getMinecraft().player.jumpableVehicle() == null && !gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); gui.renderExperience(screenWidth / 2 - 91, guiGraphics); } }), + ITEM_NAME("item_name", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { - if (!gui.getMinecraft().options.hideGui) - { + if (!gui.getMinecraft().options.hideGui) { gui.setupOverlayRenderState(true, false); if (gui.getMinecraft().gameMode.getPlayerMode() != GameType.SPECTATOR) - { gui.renderSelectedItemName(guiGraphics, Math.max(gui.leftHeight, gui.rightHeight)); - } else if (gui.getMinecraft().player.isSpectator()) - { gui.getSpectatorGui().renderTooltip(guiGraphics); - } } }), + SLEEP_FADE("sleep_fade", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { gui.renderSleepFade(screenWidth, screenHeight, guiGraphics); }), + POTION_ICONS("potion_icons", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { gui.renderEffects(guiGraphics); }), + DEBUG_TEXT("debug_text", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { gui.renderHUDText(screenWidth, screenHeight, guiGraphics); }), + FPS_GRAPH("fps_graph", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { gui.renderFPSGraph(guiGraphics); }), + RECORD_OVERLAY("record_overlay", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { if (!gui.getMinecraft().options.hideGui) - { gui.renderRecordOverlay(screenWidth, screenHeight, partialTick, guiGraphics); - } }), + TITLE_TEXT("title_text", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { if (!gui.getMinecraft().options.hideGui) - { gui.renderTitle(screenWidth, screenHeight, partialTick, guiGraphics); - } }), + SUBTITLES("subtitles", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { if (!gui.getMinecraft().options.hideGui) - { gui.renderSubtitles(guiGraphics); - } }), - SCOREBOARD("scoreboard", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { + SCOREBOARD("scoreboard", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { Scoreboard scoreboard = gui.getMinecraft().level.getScoreboard(); Objective objective = null; PlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(gui.getMinecraft().player.getScoreboardName()); - if (scoreplayerteam != null) - { - int slot = scoreplayerteam.getColor().getId(); - if (slot >= 0) objective = scoreboard.getDisplayObjective(3 + slot); + if (scoreplayerteam != null) { + var slot = DisplaySlot.teamColorToSlot(scoreplayerteam.getColor()); + if (slot != null) + objective = scoreboard.getDisplayObjective(slot); } - Objective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1); - if (scoreobjective1 != null) - { - gui.displayScoreboardSidebar(guiGraphics, scoreobjective1); - } - }), - CHAT_PANEL("chat_panel", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { + if (objective == null) + objective = scoreboard.getDisplayObjective(DisplaySlot.SIDEBAR); + + if (objective != null) + gui.displayScoreboardSidebar(guiGraphics, objective); + }), + + CHAT_PANEL("chat_panel", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); gui.renderChat(screenWidth, screenHeight, guiGraphics); }), - PLAYER_LIST("player_list", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { + PLAYER_LIST("player_list", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); @@ -217,20 +214,17 @@ public enum VanillaGuiOverlay final IGuiOverlay overlay; NamedGuiOverlay type; - VanillaGuiOverlay(String id, IGuiOverlay overlay) - { + VanillaGuiOverlay(String id, IGuiOverlay overlay) { this.id = new ResourceLocation("minecraft", id); this.overlay = overlay; } @NotNull - public ResourceLocation id() - { + public ResourceLocation id() { return id; } - public NamedGuiOverlay type() - { + public NamedGuiOverlay type() { return type; } } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java index 8d0b7f3960..5e2f9ca05c 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java @@ -47,7 +47,7 @@ public class ExtendedButton extends Button { Minecraft mc = Minecraft.getInstance(); int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1); - guiGraphics.blitWithBorder(WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2); + guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); final FormattedText buttonText = mc.font.ellipsize(this.getMessage(), this.width - 6); // Remove 6 pixels so that the text is always contained within the button's borders guiGraphics.drawCenteredString(mc.font, Language.getInstance().getVisualOrder(buttonText), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor()); diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java index 7f359b4485..ba1c598b76 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ForgeSlider.java @@ -17,8 +17,7 @@ import java.text.DecimalFormat; /** * Slider widget implementation which allows inputting values in a certain range with optional step size. */ -public class ForgeSlider extends AbstractSliderButton -{ +public class ForgeSlider extends AbstractSliderButton { protected Component prefix; protected Component suffix; @@ -46,8 +45,7 @@ public class ForgeSlider extends AbstractSliderButton * @param precision Only used when {@code stepSize} is 0. Limited to a maximum of 4 (inclusive). * @param drawString Should text be displayed on the widget */ - public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) - { + public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) { super(x, y, width, height, Component.empty(), 0D); this.prefix = prefix; this.suffix = suffix; @@ -57,8 +55,7 @@ public class ForgeSlider extends AbstractSliderButton this.value = this.snapToNearest((currentValue - minValue) / (maxValue - minValue)); this.drawString = drawString; - if (stepSize == 0D) - { + if (stepSize == 0D) { precision = Math.min(precision, 4); StringBuilder builder = new StringBuilder("0"); @@ -70,13 +67,9 @@ public class ForgeSlider extends AbstractSliderButton builder.append('0'); this.format = new DecimalFormat(builder.toString()); - } - else if (Mth.equal(this.stepSize, Math.floor(this.stepSize))) - { + } else if (Mth.equal(this.stepSize, Math.floor(this.stepSize))) { this.format = new DecimalFormat("0"); - } - else - { + } else { this.format = new DecimalFormat(Double.toString(this.stepSize).replaceAll("\\d", "0")); } @@ -86,68 +79,58 @@ public class ForgeSlider extends AbstractSliderButton /** * Overload with {@code stepSize} set to 1, useful for sliders with whole number values. */ - public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) - { + public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) { this(x, y, width, height, prefix, suffix, minValue, maxValue, currentValue, 1D, 0, drawString); } /** * @return Current slider value as a double */ - public double getValue() - { + public double getValue() { return this.value * (maxValue - minValue) + minValue; } /** * @return Current slider value as an long */ - public long getValueLong() - { + public long getValueLong() { return Math.round(this.getValue()); } /** * @return Current slider value as an int */ - public int getValueInt() - { + public int getValueInt() { return (int) this.getValueLong(); } /** * @param value The new slider value */ - public void setValue(double value) - { + public void setValue(double value) { this.value = this.snapToNearest((value - this.minValue) / (this.maxValue - this.minValue)); this.updateMessage(); } - public String getValueString() - { + public String getValueString() { return this.format.format(this.getValue()); } @Override - public void onClick(double mouseX, double mouseY) - { + public void onClick(double mouseX, double mouseY) { this.setValueFromMouse(mouseX); } @Override - protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) - { + protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) { super.onDrag(mouseX, mouseY, dragX, dragY); this.setValueFromMouse(mouseX); } @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) - { + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { boolean flag = keyCode == GLFW.GLFW_KEY_LEFT; - if (flag || keyCode == GLFW.GLFW_KEY_RIGHT) - { + if (flag || keyCode == GLFW.GLFW_KEY_RIGHT) { if (this.minValue > this.maxValue) flag = !flag; float f = flag ? -1F : 1F; @@ -160,16 +143,14 @@ public class ForgeSlider extends AbstractSliderButton return false; } - private void setValueFromMouse(double mouseX) - { + private void setValueFromMouse(double mouseX) { this.setSliderValue((mouseX - (this.getX() + 4)) / (this.width - 8)); } /** * @param value Percentage of slider range */ - private void setSliderValue(double value) - { + private void setSliderValue(double value) { double oldValue = this.value; this.value = this.snapToNearest(value); if (!Mth.equal(oldValue, this.value)) @@ -182,8 +163,7 @@ public class ForgeSlider extends AbstractSliderButton * Snaps the value, so that the displayed value is the nearest multiple of {@code stepSize}. * If {@code stepSize} is 0, no snapping occurs. */ - private double snapToNearest(double value) - { + private double snapToNearest(double value) { if(stepSize <= 0D) return Mth.clamp(value, 0D, 1D); @@ -192,40 +172,29 @@ public class ForgeSlider extends AbstractSliderButton value = (stepSize * Math.round(value / stepSize)); if (this.minValue > this.maxValue) - { value = Mth.clamp(value, this.maxValue, this.minValue); - } else - { value = Mth.clamp(value, this.minValue, this.maxValue); - } return Mth.map(value, this.minValue, this.maxValue, 0D, 1D); } @Override - protected void updateMessage() - { + protected void updateMessage() { if (this.drawString) - { this.setMessage(Component.literal("").append(prefix).append(this.getValueString()).append(suffix)); - } else - { this.setMessage(Component.empty()); - } } @Override protected void applyValue() {} @Override - public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) - { + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { final Minecraft mc = Minecraft.getInstance(); - guiGraphics.blitWithBorder(SLIDER_LOCATION, this.getX(), this.getY(), 0, getTextureY(), this.width, this.height, 200, 20, 2, 3, 2, 2); - - guiGraphics.blitWithBorder(SLIDER_LOCATION, this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 0, getHandleTextureY(), 8, this.height, 200, 20 , 2, 3, 2, 2); + guiGraphics.blitSprite(this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight()); + guiGraphics.blitSprite(this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight()); renderScrollingString(guiGraphics, mc.font, 2, getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24); } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java index 806f4b6ab9..044d61bbe8 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java @@ -54,9 +54,9 @@ public class ModListWidget extends ObjectSelectionList } @Override - protected void renderBackground(GuiGraphics guiGraphics) - { - this.parent.renderBackground(guiGraphics); + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { + this.parent.renderBackground(guiGraphics, mouseX, mouseY, partialTicks); + super.render(guiGraphics, mouseX, mouseY, partialTicks); } public class ModEntry extends ObjectSelectionList.Entry { diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java index 5e4afe43dd..b047fdd29f 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java @@ -25,8 +25,7 @@ import java.util.List; /** * Abstract scroll panel class. */ -public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry -{ +public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry { private final Minecraft client; protected final int width; protected final int height; @@ -54,8 +53,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen * @param top the offset from the top (y coord) * @param left the offset from the left (x coord) */ - public ScrollPanel(Minecraft client, int width, int height, int top, int left) - { + public ScrollPanel(Minecraft client, int width, int height, int top, int left) { this(client, width, height, top, left, 4); } @@ -67,8 +65,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen * @param left the offset from the left (x coord) * @param border the size of the border */ - public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border) - { + public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border) { this(client, width, height, top, left, border, 6); } @@ -81,8 +78,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen * @param border the size of the border * @param barWidth the width of the scroll bar */ - public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth) - { + public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth) { this(client, width, height, top, left, border, barWidth, 0xC0101010, 0xD0101010); } @@ -96,8 +92,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen * @param barWidth the width of the scroll bar * @param bgColor the color for the background */ - public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColor) - { + public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColor) { this(client, width, height, top, left, border, barWidth, bgColor, bgColor); } @@ -112,8 +107,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen * @param bgColorFrom the start color for the background gradient * @param bgColorTo the end color for the background gradient */ - public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo) - { + public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo) { this(client, width, height, top, left, border, barWidth, bgColorFrom, bgColorTo, 0xFF000000, 0xFF808080, 0xFFC0C0C0); } @@ -133,8 +127,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen * @param barColor the color for the scroll bar handle * @param barBorderColor the border color for the scroll bar handle */ - public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo, int barBgColor, int barColor, int barBorderColor) - { + public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo, int barBgColor, int barColor, int barBorderColor) { this.client = client; this.width = width; this.height = height; @@ -157,16 +150,12 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen /** * Draws the background of the scroll panel. This runs AFTER Scissors are enabled. */ - protected void drawBackground(GuiGraphics guiGraphics, Tesselator tess, float partialTick) - { + protected void drawBackground(GuiGraphics guiGraphics, Tesselator tess, float partialTick) { BufferBuilder worldr = tess.getBuilder(); - if (this.client.level != null) - { + if (this.client.level != null) { this.drawGradientRect(guiGraphics, this.left, this.top, this.right, this.bottom, bgColorFrom, bgColorTo); - } - else // Draw dark dirt background - { + } else { // Draw dark dirt background RenderSystem.setShader(GameRenderer::getPositionTexColorShader); RenderSystem.setShaderTexture(0, Screen.BACKGROUND_LOCATION); final float texScale = 32.0F; @@ -185,38 +174,31 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen */ protected abstract void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY); - protected boolean clickPanel(double mouseX, double mouseY, int button) { return false; } + protected boolean clickPanel(double mouseX, double mouseY, int button) { + return false; + } - private int getMaxScroll() - { + private int getMaxScroll() { return this.getContentHeight() - (this.height - this.border); } - private void applyScrollLimits() - { + private void applyScrollLimits() { int max = getMaxScroll(); if (max < 0) - { max /= 2; - } if (this.scrollDistance < 0.0F) - { this.scrollDistance = 0.0F; - } if (this.scrollDistance > max) - { this.scrollDistance = max; - } } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double scroll) - { - if (scroll != 0) - { + public boolean mouseScrolled(double mouseX, double mouseY, double deltaX, double deltaY) { + double scroll = deltaX == 0 ? deltaY : deltaX; + if (scroll != 0) { this.scrollDistance += -scroll * getScrollAmount(); applyScrollLimits(); return true; @@ -224,49 +206,42 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen return false; } - protected int getScrollAmount() - { + protected int getScrollAmount() { return 20; } @Override - public boolean isMouseOver(double mouseX, double mouseY) - { + public boolean isMouseOver(double mouseX, double mouseY) { return mouseX >= this.left && mouseX <= this.left + this.width && mouseY >= this.top && mouseY <= this.bottom; } @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) - { + public boolean mouseClicked(double mouseX, double mouseY, int button) { if (super.mouseClicked(mouseX, mouseY, button)) return true; this.scrolling = button == 0 && mouseX >= barLeft && mouseX < barLeft + barWidth; if (this.scrolling) - { return true; - } + int mouseListY = ((int)mouseY) - this.top - this.getContentHeight() + (int)this.scrollDistance - border; if (mouseX >= left && mouseX <= right && mouseListY < 0) - { return this.clickPanel(mouseX - left, mouseY - this.top + (int)this.scrollDistance - border, button); - } return false; } @Override - public boolean mouseReleased(double mouseX, double mouseY, int button) - { + public boolean mouseReleased(double mouseX, double mouseY, int button) { if (super.mouseReleased(mouseX, mouseY, button)) return true; + boolean ret = this.scrolling; this.scrolling = false; return ret; } - private int getBarHeight() - { + private int getBarHeight() { int barHeight = (height * height) / this.getContentHeight(); if (barHeight < 32) barHeight = 32; @@ -278,10 +253,8 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen } @Override - public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) - { - if (this.scrolling) - { + public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { + if (this.scrolling) { int maxScroll = height - getBarHeight(); double moved = deltaY / maxScroll; this.scrollDistance += getMaxScroll() * moved; @@ -292,8 +265,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen } @Override - public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) - { + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { Tesselator tess = Tesselator.getInstance(); BufferBuilder worldr = tess.getBuilder(); @@ -309,15 +281,12 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen RenderSystem.disableDepthTest(); int extraHeight = (this.getContentHeight() + border) - height; - if (extraHeight > 0) - { + if (extraHeight > 0) { int barHeight = getBarHeight(); int barTop = (int)this.scrollDistance * (height - barHeight) / extraHeight + this.top; if (barTop < this.top) - { barTop = this.top; - } int barBgAlpha = this.barBgColor >> 24 & 0xff; int barBgRed = this.barBgColor >> 16 & 0xff; @@ -361,14 +330,12 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen RenderSystem.disableScissor(); } - protected void drawGradientRect(GuiGraphics guiGraphics, int left, int top, int right, int bottom, int color1, int color2) - { + protected void drawGradientRect(GuiGraphics guiGraphics, int left, int top, int right, int bottom, int color1, int color2) { guiGraphics.fillGradient(left, top, right, bottom, color1, color2); } @Override - public List children() - { + public List children() { return Collections.emptyList(); } } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java b/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java index 079af7dbf7..4999ec1698 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java @@ -33,8 +33,7 @@ public class UnicodeGlyphButton extends ExtendedButton { Minecraft mc = Minecraft.getInstance(); this.isHovered = mouseX >= this.getX() && mouseY >= this.getY() && mouseX < this.getX() + this.width && mouseY < this.getY() + this.height; - int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1); - guiGraphics.blitWithBorder(WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2); + guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); Component buttonText = this.createNarrationMessage(); int glyphWidth = (int) (mc.font.width(glyph) * glyphScale); diff --git a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java index 43a9471f8c..a9b81cbe5a 100644 --- a/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java @@ -11,11 +11,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.concurrent.*; import java.util.function.Consumer; import net.minecraft.network.chat.Component; import net.minecraft.server.packs.repository.RepositorySource; +import net.minecraft.server.packs.repository.Pack.Info; import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.repository.PackSource; import net.minecraft.server.packs.resources.ReloadableResourceManager; @@ -37,6 +39,7 @@ import org.apache.logging.log4j.Logger; import net.minecraft.SharedConstants; import net.minecraft.client.Minecraft; import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.metadata.pack.PackMetadataSection; import net.minecraftforge.api.distmarker.Dist; @@ -163,9 +166,23 @@ public class ClientModLoader var hiddenPacks = new ArrayList(); for (Entry e : modResourcePacks.entrySet()) { + + var supplier = new Pack.ResourcesSupplier() { + @Override + public PackResources openPrimary(String path) { + return e.getValue(); + } + + @Override + public PackResources openFull(String path, Info info) { + return e.getValue(); // TODO: composite + } + + }; + IModInfo mod = e.getKey().getModInfos().get(0); final String name = "mod:" + mod.getModId(); - final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, id -> e.getValue(), PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT); + final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, supplier, PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT); if (modPack == null) { // Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey())); @@ -178,11 +195,30 @@ public class ClientModLoader hiddenPacks.add(e.getValue()); } } + var delegating = new DelegatingPackResources("mod_resources", false, + new PackMetadataSection( + Component.translatable("fml.resources.modresources", hiddenPacks.size()), + SharedConstants.getCurrentVersion().getPackVersion(PackType.CLIENT_RESOURCES), + Optional.empty() + ), + hiddenPacks + ); + + var supplier = new Pack.ResourcesSupplier() { + @Override + public PackResources openPrimary(String path) { + return delegating; + } + + @Override + public PackResources openFull(String path, Info info) { + return delegating; // TODO: composite + } + + }; // Create a resource pack merging all mod resources that should be hidden - final Pack modResourcesPack = Pack.readMetaAndCreate("mod_resources", Component.literal("Mod Resources"), true, - id -> new DelegatingPackResources(id, false, new PackMetadataSection(Component.translatable("fml.resources.modresources", hiddenPacks.size()), - SharedConstants.getCurrentVersion().getPackVersion(PackType.CLIENT_RESOURCES)), hiddenPacks), + final Pack modResourcesPack = Pack.readMetaAndCreate("mod_resources", Component.literal("Mod Resources"), true, supplier, PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT); packAcceptor.accept(modResourcesPack); } diff --git a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java index 13ce84d41b..dbcae06f7b 100644 --- a/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java +++ b/src/main/java/net/minecraftforge/client/textures/ITextureAtlasSpriteLoader.java @@ -8,10 +8,10 @@ package net.minecraftforge.client.textures; import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection; import net.minecraft.client.resources.metadata.animation.FrameSize; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceMetadata; import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent; import org.jetbrains.annotations.NotNull; @@ -29,10 +29,8 @@ import org.jetbrains.annotations.NotNull; * * @see RegisterTextureAtlasSpriteLoadersEvent */ -public interface ITextureAtlasSpriteLoader -{ - SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, - AnimationMetadataSection animationMeta, ForgeTextureMetadata forgeMeta); +public interface ITextureAtlasSpriteLoader { + SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, ResourceMetadata animationMeta, ForgeTextureMetadata forgeMeta); /** * Creates a {@link TextureAtlasSprite} from the given {@link SpriteContents}. diff --git a/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java b/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java index cc73a5947e..649cf9d687 100644 --- a/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java +++ b/src/main/java/net/minecraftforge/client/textures/UnitTextureAtlasSprite.java @@ -7,36 +7,31 @@ package net.minecraftforge.client.textures; import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.client.renderer.texture.SpriteContents; -import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection; import net.minecraft.client.resources.metadata.animation.FrameSize; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceMetadata; /** * A helper sprite with UVs spanning the entire texture. *

* Useful for baking quads that won't be used with an atlas. */ -public class UnitTextureAtlasSprite extends TextureAtlasSprite -{ +public class UnitTextureAtlasSprite extends TextureAtlasSprite { public static final ResourceLocation LOCATION = new ResourceLocation("forge", "unit"); public static final UnitTextureAtlasSprite INSTANCE = new UnitTextureAtlasSprite(); - private UnitTextureAtlasSprite() - { - super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false), AnimationMetadataSection.EMPTY, null), 1, 1, 0, 0); + private UnitTextureAtlasSprite() { + super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false), ResourceMetadata.EMPTY, null), 1, 1, 0, 0); } @Override - public float getU(double u) - { - return (float) u / 16; + public float getU(float u) { + return u / 16; } @Override - public float getV(double v) - { - return (float) v / 16; + public float getV(float v) { + return v / 16; } } diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index b1efb192d8..7976993c76 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -105,6 +105,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.FilteredText; import net.minecraft.world.inventory.AnvilMenu; import net.minecraft.world.Container; import net.minecraft.world.item.context.UseOnContext; @@ -127,9 +128,6 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeSpecialEffects; import net.minecraft.world.level.biome.BiomeGenerationSettings; import net.minecraft.world.level.biome.MobSpawnSettings; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifierManager; -import net.minecraftforge.common.loot.LootTableIdCondition; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.BrainBuilder; import net.minecraftforge.common.util.Lazy; @@ -400,29 +398,13 @@ public class ForgeHooks return !MinecraftForge.EVENT_BUS.post(new VanillaGameEvent(level, vanillaEvent, pos, context)); } - private static String getRawText(Component message) - { - return message.getContents() instanceof LiteralContents literalContents ? literalContents.text() : ""; - } - @Nullable - public static Component onServerChatSubmittedEvent(ServerPlayer player, String plain, Component decorated) - { - ServerChatEvent event = new ServerChatEvent(player, plain, decorated); + public static Component onServerChatSubmittedEvent(ServerPlayer player, Component message) { + var plain = message.getContents() instanceof LiteralContents literalContents ? literalContents.text() : ""; + ServerChatEvent event = new ServerChatEvent(player, plain, message); return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); } - @NotNull - public static ChatDecorator getServerChatSubmittedDecorator() - { - return (sender, message) -> CompletableFuture.supplyAsync(() -> { - if (sender == null) - return message; // Vanilla should never get here with the patches we use, but let's be safe with dumb mods - - return onServerChatSubmittedEvent(sender, getRawText(message), message); - }); - } - static final Pattern URL_PATTERN = Pattern.compile( // schema ipv4 OR namespace port path ends // |-----------------| |-------------------------| |-------------------------| |---------| |--| |---------------| @@ -738,13 +720,6 @@ public class ForgeHooks return stack.isEmpty() || !stack.getItem().onLeftClickEntity(stack, player, target); } - public static boolean onTravelToDimension(Entity entity, ResourceKey dimension) - { - EntityTravelToDimensionEvent event = new EntityTravelToDimensionEvent(entity, dimension); - MinecraftForge.EVENT_BUS.post(event); - return !event.isCanceled(); - } - public static InteractionResult onInteractEntityAt(Player player, Entity entity, HitResult ray, InteractionHand hand) { Vec3 vec3d = ray.getLocation().subtract(entity.position()); @@ -812,21 +787,18 @@ public class ForgeHooks MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.LeftClickEmpty(player)); } - /** - * @return null if game type should not be changed, desired new GameType otherwise - */ - @Nullable - public static GameType onChangeGameType(Player player, GameType currentGameType, GameType newGameType) - { - if (currentGameType != newGameType) - { - PlayerEvent.PlayerChangeGameModeEvent evt = new PlayerEvent.PlayerChangeGameModeEvent(player, currentGameType, newGameType); - MinecraftForge.EVENT_BUS.post(evt); - return evt.isCanceled() ? null : evt.getNewGameMode(); - } - return newGameType; + public static GameType onChangeGameType(Player player, GameType currentGameType, GameType newGameType) { + if (currentGameType == newGameType) + return currentGameType; + + var evt = new PlayerEvent.PlayerChangeGameModeEvent(player, currentGameType, newGameType); + if (MinecraftForge.EVENT_BUS.post(evt)) + return currentGameType; + + return evt.getNewGameMode(); } + /* TODO: GLM private static final ThreadLocal> lootContext = new ThreadLocal<>(); private static LootTableContext getLootTableContext() { @@ -918,6 +890,7 @@ public class ForgeHooks return ctx.poolCount == 1 ? "main" : "pool" + (ctx.poolCount - 1); } + */ /** * Returns a vanilla fluid type for the given fluid. @@ -1147,6 +1120,7 @@ public class ForgeHooks FurnaceBlockEntity.getFuel().entrySet().forEach(e -> VANILLA_BURNS.put(ForgeRegistries.ITEMS.getDelegateOrThrow(e.getKey()), e.getValue())); } + // TODO: GLM /** * All loot table drops should be passed to this function so that mod added effects * (e.g. smelting enchantments) can be processed. @@ -1159,7 +1133,7 @@ public class ForgeHooks * * @implNote This method will use the {@linkplain LootTableIdCondition#UNKNOWN_LOOT_TABLE * unknown loot table marker} when redirecting. - */ + * / @Deprecated public static List modifyLoot(List list, LootContext context) { return modifyLoot(LootTableIdCondition.UNKNOWN_LOOT_TABLE, ObjectArrayList.wrap((ItemStack[]) list.toArray()), context); @@ -1178,7 +1152,7 @@ public class ForgeHooks * * @apiNote The given context will be modified by this method to also store the ID of the * loot table being queried. - */ + * / public static ObjectArrayList modifyLoot(ResourceLocation lootTableId, ObjectArrayList generatedLoot, LootContext context) { context.setQueriedLootTableId(lootTableId); // In case the ID was set via copy constructor, this will be ignored: intended LootModifierManager man = ForgeInternalHandler.getLootModifierManager(); @@ -1187,6 +1161,7 @@ public class ForgeHooks } return generatedLoot; } + */ public static List getModPacks() { @@ -1417,33 +1392,6 @@ public class ForgeHooks throw new IllegalArgumentException("Unknown lifecycle."); } - public static void saveMobEffect(CompoundTag nbt, String key, MobEffect effect) - { - var registryName = ForgeRegistries.MOB_EFFECTS.getKey(effect); - if (registryName != null) - { - nbt.putString(key, registryName.toString()); - } - } - - @Nullable - public static MobEffect loadMobEffect(CompoundTag nbt, String key, @Nullable MobEffect fallback) - { - var registryName = nbt.getString(key); - if (Strings.isNullOrEmpty(registryName)) - { - return fallback; - } - try - { - return ForgeRegistries.MOB_EFFECTS.getValue(new ResourceLocation(registryName)); - } - catch (ResourceLocationException e) - { - return fallback; - } - } - public static boolean shouldSuppressEnderManAnger(EnderMan enderMan, Player player, ItemStack mask) { return mask.isEnderMask(player, enderMan) || MinecraftForge.EVENT_BUS.post(new EnderManAngerEvent(enderMan, player)); @@ -1474,40 +1422,6 @@ public class ForgeHooks return biomeLocation != null && !biomeLocation.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE); } - public static Map readTypedPackFormats(JsonObject json) - { - ImmutableMap.Builder map = ImmutableMap.builder(); - - for (PackType packType : PackType.values()) - { - String key = makePackFormatKey(packType); - if (json.has(key)) - { - map.put(packType, GsonHelper.getAsInt(json, key)); - } - } - - return map.buildOrThrow(); - } - - public static void writeTypedPackFormats(JsonObject json, PackMetadataSection section) - { - int packFormat = section.getPackFormat(); - for (PackType packType : PackType.values()) - { - int format = section.getPackFormat(packType); - if (format != packFormat) - { - json.addProperty(makePackFormatKey(packType), format); - } - } - } - - private static String makePackFormatKey(PackType packType) - { - return "forge:" + packType.name().toLowerCase(Locale.ROOT) + "_pack_format"; - } - /** *

* This method is used to prefix the path, where elements of the associated registry are stored, with their namespace, if it is not minecraft @@ -1569,7 +1483,7 @@ public class ForgeHooks */ public static void onLivingBreathe(LivingEntity entity, int consumeAirAmount, int refillAirAmount) { - // Check things that vanilla considers to be air - these will cause the air supply to be increased. + // Check things that vanilla considers to be air - these will cause the air supply to be increased. boolean isAir = entity.getEyeInFluidType().isAir() || entity.level().getBlockState(BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ())).is(Blocks.BUBBLE_COLUMN); // The following effects cause the entity to not drown, but do not cause the air supply to be increased. boolean canBreathe = !entity.canDrownInFluidType(entity.getEyeInFluidType()) || MobEffectUtil.hasWaterBreathing(entity) || (entity instanceof Player && ((Player) entity).getAbilities().invulnerable); diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index d03b5e7ad9..1618b4b5c3 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -12,7 +12,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.server.TickTask; import net.minecraft.server.level.ServerLevel; -import net.minecraftforge.common.loot.LootModifierManager; import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.event.AddReloadListenerEvent; import net.minecraftforge.event.RegisterCommandsEvent; @@ -114,6 +113,7 @@ public class ForgeInternalHandler ConfigCommand.register(event.getDispatcher()); } + /* private static LootModifierManager INSTANCE; @SubscribeEvent @@ -129,6 +129,7 @@ public class ForgeInternalHandler throw new IllegalStateException("Can not retrieve LootModifierManager until resources have loaded once."); return INSTANCE; } + */ @SubscribeEvent public void resourceReloadListeners(AddReloadListenerEvent event) diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index a0ce44dcfc..1129d504cb 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -43,9 +43,6 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; -import net.minecraftforge.common.crafting.PartialNBTIngredient; -import net.minecraftforge.common.crafting.DifferenceIngredient; -import net.minecraftforge.common.crafting.IntersectionIngredient; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ForgeBiomeTagsProvider; import net.minecraftforge.common.data.ForgeFluidTagsProvider; @@ -53,8 +50,6 @@ import net.minecraftforge.common.data.ForgeSpriteSourceProvider; import net.minecraftforge.common.data.VanillaSoundDefinitionsProvider; import net.minecraftforge.common.extensions.IForgeEntity; import net.minecraftforge.common.extensions.IForgePlayer; -import net.minecraftforge.common.loot.CanToolPerformAction; -import net.minecraftforge.common.loot.LootTableIdCondition; import net.minecraftforge.common.world.BiomeModifier; import net.minecraftforge.common.world.ForgeBiomeModifiers.AddFeaturesBiomeModifier; import net.minecraftforge.common.world.ForgeBiomeModifiers.AddSpawnsBiomeModifier; @@ -80,7 +75,6 @@ import net.minecraftforge.network.NetworkConstants; import net.minecraftforge.event.server.ServerStoppingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.network.filters.VanillaPacketSplitter; import net.minecraftforge.server.command.EnumArgument; import net.minecraftforge.server.command.ModIdArgument; import net.minecraftforge.server.permission.events.PermissionGatherEvent; @@ -94,11 +88,7 @@ import org.apache.logging.log4j.Logger; import net.minecraft.data.DataGenerator; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.crafting.CompoundIngredient; -import net.minecraftforge.common.crafting.ConditionalRecipe; import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.common.crafting.StrictNBTIngredient; -import net.minecraftforge.common.crafting.VanillaIngredientSerializer; import net.minecraftforge.common.crafting.conditions.AndCondition; import net.minecraftforge.common.crafting.conditions.FalseCondition; import net.minecraftforge.common.crafting.conditions.ItemExistsCondition; @@ -110,7 +100,6 @@ import net.minecraftforge.common.crafting.conditions.TrueCondition; import net.minecraftforge.common.data.ForgeBlockTagsProvider; import net.minecraftforge.common.data.ForgeEntityTypeTagsProvider; import net.minecraftforge.common.data.ForgeItemTagsProvider; -import net.minecraftforge.common.data.ForgeLootTableProvider; import net.minecraftforge.common.data.ForgeRecipeProvider; import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.Marker; @@ -476,7 +465,7 @@ public class ForgeMod public void preInit(FMLCommonSetupEvent evt) { VersionChecker.startVersionCheck(); - VanillaPacketSplitter.register(); + //VanillaPacketSplitter.register(); } public void loadComplete(FMLLoadCompleteEvent event) @@ -501,11 +490,11 @@ public class ForgeMod ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); gen.addProvider(true, new PackMetadataGenerator(packOutput) - .add(PackMetadataSection.TYPE, new PackMetadataSection( - Component.translatable("pack.forge.description"), - DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES), - Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion)) - )) + .add(PackMetadataSection.TYPE, new PackMetadataSection( + Component.translatable("pack.forge.description"), + DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES), + Optional.empty() //Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion)) + )) ); ForgeBlockTagsProvider blockTags = new ForgeBlockTagsProvider(packOutput, lookupProvider, existingFileHelper); gen.addProvider(event.includeServer(), blockTags); @@ -513,7 +502,7 @@ public class ForgeMod gen.addProvider(event.includeServer(), new ForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new ForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new ForgeRecipeProvider(packOutput)); - gen.addProvider(event.includeServer(), new ForgeLootTableProvider(packOutput)); + //gen.addProvider(event.includeServer(), new ForgeLootTableProvider(packOutput)); gen.addProvider(event.includeServer(), new ForgeBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeClient(), new ForgeSpriteSourceProvider(packOutput, existingFileHelper)); @@ -621,14 +610,16 @@ public class ForgeMod CraftingHelper.register(TrueCondition.Serializer.INSTANCE); CraftingHelper.register(TagEmptyCondition.Serializer.INSTANCE); + /* CraftingHelper.register(new ResourceLocation("forge", "compound"), CompoundIngredient.Serializer.INSTANCE); CraftingHelper.register(new ResourceLocation("forge", "nbt"), StrictNBTIngredient.Serializer.INSTANCE); CraftingHelper.register(new ResourceLocation("forge", "partial_nbt"), PartialNBTIngredient.Serializer.INSTANCE); CraftingHelper.register(new ResourceLocation("forge", "difference"), DifferenceIngredient.Serializer.INSTANCE); CraftingHelper.register(new ResourceLocation("forge", "intersection"), IntersectionIngredient.Serializer.INSTANCE); CraftingHelper.register(new ResourceLocation("minecraft", "item"), VanillaIngredientSerializer.INSTANCE); + */ - event.register(ForgeRegistries.Keys.RECIPE_SERIALIZERS, new ResourceLocation("forge", "conditional"), ConditionalRecipe.Serializer::new); + //event.register(ForgeRegistries.Keys.RECIPE_SERIALIZERS, new ResourceLocation("forge", "conditional"), ConditionalRecipe.Serializer::new); } } @@ -637,8 +628,8 @@ public class ForgeMod if (!event.getRegistryKey().equals(Registries.LOOT_CONDITION_TYPE)) return; - event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:loot_table_id"), () -> LootTableIdCondition.LOOT_TABLE_ID); - event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:can_tool_perform_action"), () -> CanToolPerformAction.LOOT_CONDITION_TYPE); + //event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:loot_table_id"), () -> LootTableIdCondition.LOOT_TABLE_ID); + //event.register(Registries.LOOT_CONDITION_TYPE, new ResourceLocation("forge:can_tool_perform_action"), () -> CanToolPerformAction.LOOT_CONDITION_TYPE); } public static final PermissionNode USE_SELECTORS_PERMISSION = new PermissionNode<>("forge", "use_entity_selectors", diff --git a/src/main/java/net/minecraftforge/common/TierSortingRegistry.java b/src/main/java/net/minecraftforge/common/TierSortingRegistry.java index 6709971086..75679eaa7b 100644 --- a/src/main/java/net/minecraftforge/common/TierSortingRegistry.java +++ b/src/main/java/net/minecraftforge/common/TierSortingRegistry.java @@ -351,7 +351,7 @@ public class TierSortingRegistry private static void syncToPlayer(ServerPlayer serverPlayer) { - if (SYNC_CHANNEL.isRemotePresent(serverPlayer.connection.connection) && !serverPlayer.connection.connection.isMemoryConnection()) + if (SYNC_CHANNEL.isRemotePresent(serverPlayer.connection.getConnection()) && !serverPlayer.connection.getConnection().isMemoryConnection()) { SYNC_CHANNEL.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new SyncPacket(sortedTiers.stream().map(TierSortingRegistry::getName).toList())); } diff --git a/src/main/java/net/minecraftforge/common/crafting/AbstractIngredient.java b/src/main/java/net/minecraftforge/common/crafting/AbstractIngredient.java index 735ff9948b..865713fa47 100644 --- a/src/main/java/net/minecraftforge/common/crafting/AbstractIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/AbstractIngredient.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import com.google.gson.JsonElement; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.tags.TagKey; @@ -19,18 +19,15 @@ import java.util.stream.Stream; /** * Extension of {@link Ingredient} which makes most methods custom ingredients need to implement abstract, and removes the static constructors * Mods are encouraged to extend this class for their custom ingredients - */ -public abstract class AbstractIngredient extends Ingredient -{ - /** Empty constructor, for the sake of dynamic ingredients */ - protected AbstractIngredient() - { + * / +public abstract class AbstractIngredient extends Ingredient { + /** Empty constructor, for the sake of dynamic ingredients * / + protected AbstractIngredient() { super(Stream.of()); } - /** Value constructor, for ingredients that have some vanilla representation */ - protected AbstractIngredient(Stream values) - { + /** Value constructor, for ingredients that have some vanilla representation * / + protected AbstractIngredient(Stream values) { super(values); } @@ -41,64 +38,57 @@ public abstract class AbstractIngredient extends Ingredient public abstract IIngredientSerializer getSerializer(); @Override - public abstract JsonElement toJson(); + public abstract JsonElement toJson(boolean allowEmpty); - /* Hide vanilla ingredient static constructors to reduce errors with constructing custom ingredients */ + /* Hide vanilla ingredient static constructors to reduce errors with constructing custom ingredients * / - /** @deprecated use {@link Ingredient#fromValues(Stream)} */ + /** @deprecated use {@link Ingredient#fromValues(Stream)} * / @Deprecated - public static Ingredient fromValues(Stream values) - { + public static Ingredient fromValues(Stream values) { throw new UnsupportedOperationException("Use Ingredient.fromValues()"); } - /** @deprecated use {@link Ingredient#of()} */ + /** @deprecated use {@link Ingredient#of()} * / @Deprecated - public static Ingredient of() - { + public static Ingredient of() { throw new UnsupportedOperationException("Use Ingredient.of()"); } - /** @deprecated use {@link Ingredient#of(ItemLike...)} (Stream)} */ + /** @deprecated use {@link Ingredient#of(ItemLike...)} (Stream)} * / @Deprecated - public static Ingredient of(ItemLike... items) - { + public static Ingredient of(ItemLike... items) { throw new UnsupportedOperationException("Use Ingredient.of()"); } - /** @deprecated use {@link Ingredient#of(ItemStack...)} (Stream)} */ + /** @deprecated use {@link Ingredient#of(ItemStack...)} (Stream)} * / @Deprecated - public static Ingredient of(ItemStack... stacks) - { + public static Ingredient of(ItemStack... stacks) { throw new UnsupportedOperationException("Use Ingredient.of()"); } - /** @deprecated use {@link Ingredient#of(Stream)} (Stream)} */ + /** @deprecated use {@link Ingredient#of(Stream)} (Stream)} * / @Deprecated - public static Ingredient of(Stream stacks) - { + public static Ingredient of(Stream stacks) { throw new UnsupportedOperationException("Use Ingredient.of()"); } - /** @deprecated use {@link Ingredient#of(TagKey)} (Stream)} */ + /** @deprecated use {@link Ingredient#of(TagKey)} (Stream)} * / @Deprecated - public static Ingredient of(TagKey tag) - { + public static Ingredient of(TagKey tag) { throw new UnsupportedOperationException("Use Ingredient.of()"); } - /** @deprecated use {@link Ingredient#fromNetwork(FriendlyByteBuf)} */ + /** @deprecated use {@link Ingredient#fromNetwork(FriendlyByteBuf)} * / @Deprecated - public static Ingredient fromNetwork(FriendlyByteBuf buffer) - { + public static Ingredient fromNetwork(FriendlyByteBuf buffer) { throw new UnsupportedOperationException("Use Ingredient.fromNetwork()"); } - /** @deprecated use {@link Ingredient#fromJson(JsonElement)} (Stream)} */ + /** @deprecated use {@link Ingredient#fromJson(JsonElement)} (Stream)} * / @Deprecated - public static Ingredient fromJson(@Nullable JsonElement json) - { + public static Ingredient fromJson(@Nullable JsonElement json) { throw new UnsupportedOperationException("Use Ingredient.fromJson()"); } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java b/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java index 8ac505fe09..edff16b5bd 100644 --- a/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/CompoundIngredient.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -27,7 +27,7 @@ import net.minecraft.network.FriendlyByteBuf; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -/** Ingredient that matches if any of the child ingredients match */ +/** Ingredient that matches if any of the child ingredients match * / public class CompoundIngredient extends AbstractIngredient { private List children; @@ -41,7 +41,7 @@ public class CompoundIngredient extends AbstractIngredient this.isSimple = children.stream().allMatch(Ingredient::isSimple); } - /** Creates a compound ingredient from the given list of ingredients */ + /** Creates a compound ingredient from the given list of ingredients * / public static Ingredient of(Ingredient... children) { // if 0 or 1 ingredient, can save effort @@ -182,3 +182,4 @@ public class CompoundIngredient extends AbstractIngredient } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java index eb61e0ef8e..bdd93903ae 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; @@ -32,7 +32,7 @@ public class ConditionalAdvancement * Processes the conditional advancement during loading. * @param json The incoming json from the advancement file. * @return The advancement that passed the conditions, or null if none did. - */ + * / @Nullable public static JsonObject processConditional(JsonObject json, ICondition.IContext context) { JsonArray entries = GsonHelper.getAsJsonArray(json, "advancements", null); @@ -128,3 +128,4 @@ public class ConditionalAdvancement } } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java index 948232c35c..12d1abedc7 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalRecipe.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* TODO: Conditional Recipes import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; @@ -14,6 +14,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; +import net.minecraft.advancements.AdvancementHolder; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; @@ -153,6 +154,7 @@ public class ConditionalRecipe } } + private static class Finished implements FinishedRecipe { private final ResourceLocation id; @@ -189,19 +191,21 @@ public class ConditionalRecipe } @Override - public ResourceLocation getId() { + public ResourceLocation id() { return id; } @Override - public RecipeSerializer getType() + public RecipeSerializer type() { return SERIALZIER; } - + @Nullable @Override - public JsonObject serializeAdvancement() { - return adv == null ? null : adv.write(); + public AdvancementHolder advancement() { + if (adv == null) + return null; + return new AdvancementHolder(advId, adv.) } @Override @@ -210,3 +214,4 @@ public class ConditionalRecipe } } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java index e20e30983e..63a88b2976 100644 --- a/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java +++ b/src/main/java/net/minecraftforge/common/crafting/CraftingHelper.java @@ -6,13 +6,9 @@ package net.minecraftforge.common.crafting; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; @@ -24,12 +20,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.IConditionSerializer; import net.minecraft.nbt.TagParser; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.util.GsonHelper; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; @@ -38,28 +32,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import org.jetbrains.annotations.Nullable; -public class CraftingHelper -{ +public class CraftingHelper { @SuppressWarnings("unused") private static final Logger LOGGER = LogManager.getLogger(); @SuppressWarnings("unused") private static final Marker CRAFTHELPER = MarkerManager.getMarker("CRAFTHELPER"); private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - private static final Map> conditions = new HashMap<>(); + /* TODO: Custom Ingredients private static final BiMap> ingredients = HashBiMap.create(); - public static IConditionSerializer register(IConditionSerializer serializer) - { - ResourceLocation key = serializer.getID(); - if (conditions.containsKey(key)) - throw new IllegalStateException("Duplicate recipe condition serializer: " + key); - conditions.put(key, serializer); - return serializer; - } - public static IIngredientSerializer register(ResourceLocation key, IIngredientSerializer serializer) - { + + public static IIngredientSerializer register(ResourceLocation key, IIngredientSerializer serializer) { if (ingredients.containsKey(key)) throw new IllegalStateException("Duplicate recipe ingredient serializer: " + key); if (ingredients.containsValue(serializer)) @@ -67,45 +51,40 @@ public class CraftingHelper ingredients.put(key, serializer); return serializer; } + @Nullable - public static ResourceLocation getID(IIngredientSerializer serializer) - { + public static ResourceLocation getID(IIngredientSerializer serializer) { return ingredients.inverse().get(serializer); } - public static void write(FriendlyByteBuf buffer, T ingredient) - { + + public static void write(FriendlyByteBuf buffer, T ingredient) { @SuppressWarnings("unchecked") //I wonder if there is a better way generic wise... IIngredientSerializer serializer = (IIngredientSerializer)ingredient.getSerializer(); ResourceLocation key = ingredients.inverse().get(serializer); if (key == null) throw new IllegalArgumentException("Tried to serialize unregistered Ingredient: " + ingredient + " " + serializer); - if (serializer != VanillaIngredientSerializer.INSTANCE) - { + if (serializer != VanillaIngredientSerializer.INSTANCE) { buffer.writeVarInt(-1); //Marker to know there is a custom ingredient buffer.writeResourceLocation(key); } serializer.write(buffer, ingredient); } - public static Ingredient getIngredient(ResourceLocation type, FriendlyByteBuf buffer) - { + public static Ingredient getIngredient(ResourceLocation type, FriendlyByteBuf buffer) { IIngredientSerializer serializer = ingredients.get(type); if (serializer == null) throw new IllegalArgumentException("Can not deserialize unknown Ingredient type: " + type); return serializer.parse(buffer); } - public static Ingredient getIngredient(JsonElement json, boolean allowEmpty) - { + public static Ingredient getIngredient(JsonElement json, boolean allowEmpty) { if (json == null || json.isJsonNull()) throw new JsonSyntaxException("Json cannot be null"); - if (json.isJsonArray()) - { + if (json.isJsonArray()) { List ingredients = Lists.newArrayList(); List vanilla = Lists.newArrayList(); - json.getAsJsonArray().forEach((ele) -> - { + json.getAsJsonArray().forEach((ele) -> { Ingredient ing = CraftingHelper.getIngredient(ele, allowEmpty); if (ing.getClass() == Ingredient.class) //Vanilla, Due to how we read it splits each itemstack, so we pull out to re-merge later @@ -117,12 +96,9 @@ public class CraftingHelper if (!vanilla.isEmpty()) ingredients.add(Ingredient.merge(vanilla)); - if (ingredients.size() == 0) - { + if (ingredients.size() == 0) { if (allowEmpty) - { return Ingredient.EMPTY; - } throw new JsonSyntaxException("Item array cannot be empty, at least one item must be defined"); } @@ -147,14 +123,13 @@ public class CraftingHelper return serializer.parse(obj); } + */ - public static ItemStack getItemStack(JsonObject json, boolean readNBT) - { + public static ItemStack getItemStack(JsonObject json, boolean readNBT) { return getItemStack(json, readNBT, false); } - public static Item getItem(String itemName, boolean disallowsAirInRecipe) - { + public static Item getItem(String itemName, boolean disallowsAirInRecipe) { ResourceLocation itemKey = new ResourceLocation(itemName); if (!ForgeRegistries.ITEMS.containsKey(itemKey)) throw new JsonSyntaxException("Unknown item '" + itemName + "'"); @@ -165,31 +140,24 @@ public class CraftingHelper return Objects.requireNonNull(item); } - public static CompoundTag getNBT(JsonElement element) - { - try - { + public static CompoundTag getNBT(JsonElement element) { + try { if (element.isJsonObject()) return TagParser.parseTag(GSON.toJson(element)); else return TagParser.parseTag(GsonHelper.convertToString(element, "nbt")); - } - catch (CommandSyntaxException e) - { + } catch (CommandSyntaxException e) { throw new JsonSyntaxException("Invalid NBT Entry: " + e); } } - public static ItemStack getItemStack(JsonObject json, boolean readNBT, boolean disallowsAirInRecipe) - { + public static ItemStack getItemStack(JsonObject json, boolean readNBT, boolean disallowsAirInRecipe) { String itemName = GsonHelper.getAsString(json, "item"); Item item = getItem(itemName, disallowsAirInRecipe); - if (readNBT && json.has("nbt")) - { + if (readNBT && json.has("nbt")) { CompoundTag nbt = getNBT(json.get("nbt")); CompoundTag tmp = new CompoundTag(); - if (nbt.contains("ForgeCaps")) - { + if (nbt.contains("ForgeCaps")) { tmp.put("ForgeCaps", nbt.get("ForgeCaps")); nbt.remove("ForgeCaps"); } @@ -204,13 +172,21 @@ public class CraftingHelper return new ItemStack(item, GsonHelper.getAsInt(json, "count", 1)); } - public static boolean processConditions(JsonObject json, String memberName, ICondition.IContext context) - { + // CONDITIONS + private static final Map> conditions = new HashMap<>(); + public static IConditionSerializer register(IConditionSerializer serializer) { + ResourceLocation key = serializer.getID(); + if (conditions.containsKey(key)) + throw new IllegalStateException("Duplicate recipe condition serializer: " + key); + conditions.put(key, serializer); + return serializer; + } + + public static boolean processConditions(JsonObject json, String memberName, ICondition.IContext context) { return !json.has(memberName) || processConditions(GsonHelper.getAsJsonArray(json, memberName), context); } - public static boolean processConditions(JsonArray conditions, ICondition.IContext context) - { + public static boolean processConditions(JsonArray conditions, ICondition.IContext context) { for (int x = 0; x < conditions.size(); x++) { if (!conditions.get(x).isJsonObject()) @@ -223,8 +199,7 @@ public class CraftingHelper return true; } - public static ICondition getCondition(JsonObject json) - { + public static ICondition getCondition(JsonObject json) { ResourceLocation type = new ResourceLocation(GsonHelper.getAsString(json, "type")); IConditionSerializer serializer = conditions.get(type); if (serializer == null) @@ -232,8 +207,7 @@ public class CraftingHelper return serializer.read(json); } - public static JsonObject serialize(T condition) - { + public static JsonObject serialize(T condition) { @SuppressWarnings("unchecked") IConditionSerializer serializer = (IConditionSerializer)conditions.get(condition.getID()); if (serializer == null) @@ -241,13 +215,10 @@ public class CraftingHelper return serializer.getJson(condition); } - public static JsonArray serialize(ICondition... conditions) - { + public static JsonArray serialize(ICondition... conditions) { JsonArray arr = new JsonArray(); for(ICondition iCond : conditions) - { arr.add(serialize(iCond)); - } return arr; } } diff --git a/src/main/java/net/minecraftforge/common/crafting/DifferenceIngredient.java b/src/main/java/net/minecraftforge/common/crafting/DifferenceIngredient.java index 85f70012f1..4d8a7b6e4d 100644 --- a/src/main/java/net/minecraftforge/common/crafting/DifferenceIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/DifferenceIngredient.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import com.google.gson.JsonElement; import com.google.gson.JsonObject; import it.unimi.dsi.fastutil.ints.IntArrayList; @@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; -/** Ingredient that matches everything from the first ingredient that is not included in the second ingredient */ +/** Ingredient that matches everything from the first ingredient that is not included in the second ingredient * / public class DifferenceIngredient extends AbstractIngredient { private final Ingredient base; @@ -37,7 +37,7 @@ public class DifferenceIngredient extends AbstractIngredient * @param base Ingredient the item must match * @param subtracted Ingredient the item must not match * @return Ingredient that {@code base} anything in base that is not in {@code subtracted} - */ + * / public static DifferenceIngredient of(Ingredient base, Ingredient subtracted) { return new DifferenceIngredient(base, subtracted); @@ -98,12 +98,12 @@ public class DifferenceIngredient extends AbstractIngredient } @Override - public JsonElement toJson() + public JsonElement toJson(boolean allowEmpty) { JsonObject json = new JsonObject(); json.addProperty("type", CraftingHelper.getID(Serializer.INSTANCE).toString()); - json.add("base", base.toJson()); - json.add("subtracted", subtracted.toJson()); + json.add("base", base.toJson(allowEmpty)); + json.add("subtracted", subtracted.toJson(allowEmpty)); return json; } @@ -113,8 +113,7 @@ public class DifferenceIngredient extends AbstractIngredient return Serializer.INSTANCE; } - public static class Serializer implements IIngredientSerializer - { + public static class Serializer implements IIngredientSerializer { public static final IIngredientSerializer INSTANCE = new Serializer(); @Override @@ -141,3 +140,4 @@ public class DifferenceIngredient extends AbstractIngredient } } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java b/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java index 41612e414e..5bc1dd5d46 100644 --- a/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java +++ b/src/main/java/net/minecraftforge/common/crafting/IIngredientSerializer.java @@ -5,16 +5,18 @@ package net.minecraftforge.common.crafting; +// TODO: Ingredient Serializers +/* import com.google.gson.JsonObject; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.network.FriendlyByteBuf; -public interface IIngredientSerializer -{ +public interface IIngredientSerializer { T parse(FriendlyByteBuf buffer); T parse(JsonObject json); void write(FriendlyByteBuf buffer, T ingredient); } +*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java b/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java index 4c2cd6f2e8..aa4d4d50b6 100644 --- a/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java +++ b/src/main/java/net/minecraftforge/common/crafting/IRecipeContainer.java @@ -15,8 +15,7 @@ import net.minecraft.world.inventory.CraftingContainer; * For GUIs with recipe books, this allows their containers to have * recipe completion and ghost recipes in their craft matrices. */ -public interface IRecipeContainer -{ +public interface IRecipeContainer { /** * The crafting result slot of your container, where you take out the crafted item. * The equivalent for {@link CraftingMenu} is {@code CraftingMenu#resultSlots}. diff --git a/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java b/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java index 738ee0d598..9eace6a3d2 100644 --- a/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java +++ b/src/main/java/net/minecraftforge/common/crafting/IShapedRecipe.java @@ -13,8 +13,7 @@ import net.minecraft.world.item.crafting.Recipe; * book and auto crafting picks the correct shape. * Note: These methods can't be named 'getHeight' or 'getWidth' due to obfusication issues. */ -public interface IShapedRecipe extends Recipe -{ +public interface IShapedRecipe extends Recipe { int getRecipeWidth(); int getRecipeHeight(); } diff --git a/src/main/java/net/minecraftforge/common/crafting/IntersectionIngredient.java b/src/main/java/net/minecraftforge/common/crafting/IntersectionIngredient.java index ab01f217d3..6ede3869dc 100644 --- a/src/main/java/net/minecraftforge/common/crafting/IntersectionIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/IntersectionIngredient.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -25,7 +25,7 @@ import java.util.List; import java.util.stream.IntStream; import java.util.stream.Stream; -/** Ingredient that matches if all child ingredients match */ +/** Ingredient that matches if all child ingredients match * / public class IntersectionIngredient extends AbstractIngredient { private final List children; @@ -44,7 +44,7 @@ public class IntersectionIngredient extends AbstractIngredient * Gets an intersection ingredient * @param ingredients List of ingredients to match * @return Ingredient that only matches if all the passed ingredients match - */ + * / public static Ingredient of(Ingredient... ingredients) { if (ingredients.length == 0) @@ -175,3 +175,4 @@ public class IntersectionIngredient extends AbstractIngredient } } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/MultiItemValue.java b/src/main/java/net/minecraftforge/common/crafting/MultiItemValue.java index c0fb22707e..db242478e4 100644 --- a/src/main/java/net/minecraftforge/common/crafting/MultiItemValue.java +++ b/src/main/java/net/minecraftforge/common/crafting/MultiItemValue.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import java.util.Collection; import java.util.Collections; @@ -54,3 +54,4 @@ public class MultiItemValue implements Value } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/PartialNBTIngredient.java b/src/main/java/net/minecraftforge/common/crafting/PartialNBTIngredient.java index 9300b1fa34..6f0d18af57 100644 --- a/src/main/java/net/minecraftforge/common/crafting/PartialNBTIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/PartialNBTIngredient.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import com.google.common.collect.ImmutableSet; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -28,7 +28,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT */ +/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT * / public class PartialNBTIngredient extends AbstractIngredient { private final Set items; @@ -52,13 +52,13 @@ public class PartialNBTIngredient extends AbstractIngredient this.predicate = new NbtPredicate(nbt); } - /** Creates a new ingredient matching any item from the list, containing the given NBT */ + /** Creates a new ingredient matching any item from the list, containing the given NBT * / public static PartialNBTIngredient of(CompoundTag nbt, ItemLike... items) { return new PartialNBTIngredient(Arrays.stream(items).map(ItemLike::asItem).collect(Collectors.toSet()), nbt); } - /** Creates a new ingredient matching the given item, containing the given NBT */ + /** Creates a new ingredient matching the given item, containing the given NBT * / public static PartialNBTIngredient of(ItemLike item, CompoundTag nbt) { return new PartialNBTIngredient(Set.of(item.asItem()), nbt); @@ -154,3 +154,4 @@ public class PartialNBTIngredient extends AbstractIngredient } } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/StrictNBTIngredient.java b/src/main/java/net/minecraftforge/common/crafting/StrictNBTIngredient.java index e65fb93683..f9d836ff4d 100644 --- a/src/main/java/net/minecraftforge/common/crafting/StrictNBTIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/StrictNBTIngredient.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import java.util.stream.Stream; import com.google.gson.JsonElement; @@ -16,7 +16,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; -/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. */ +/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. * / public class StrictNBTIngredient extends AbstractIngredient { private final ItemStack stack; @@ -26,7 +26,7 @@ public class StrictNBTIngredient extends AbstractIngredient this.stack = stack; } - /** Creates a new ingredient matching the given stack and tag */ + /** Creates a new ingredient matching the given stack and tag * / public static StrictNBTIngredient of(ItemStack stack) { return new StrictNBTIngredient(stack); @@ -85,3 +85,4 @@ public class StrictNBTIngredient extends AbstractIngredient } } } +*/ diff --git a/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java b/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java index bb1ce09399..7fe2419111 100644 --- a/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java +++ b/src/main/java/net/minecraftforge/common/crafting/VanillaIngredientSerializer.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.crafting; - +/* import java.util.stream.Stream; import com.google.gson.JsonObject; @@ -36,3 +36,4 @@ public class VanillaIngredientSerializer implements IIngredientSerializer registries, ExistingFileHelper existingFileHelper, List subProviders) - { + public ForgeAdvancementProvider(PackOutput output, CompletableFuture registries, ExistingFileHelper existingFileHelper, List subProviders) { super(output, registries, subProviders.stream().map(generator -> generator.toSubProvider(existingFileHelper)).toList()); } @@ -42,8 +41,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider * * @see AdvancementSubProvider */ - public interface AdvancementGenerator - { + public interface AdvancementGenerator { /** * A method used to generate advancements for a mod. Advancements should be * built via {@link net.minecraftforge.common.extensions.IForgeAdvancementBuilder#save(Consumer, ResourceLocation, ExistingFileHelper)}. @@ -52,7 +50,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider * @param saver a consumer used to write advancements to a file * @param existingFileHelper a helper used to find whether a file exists */ - void generate(HolderLookup.Provider registries, Consumer saver, ExistingFileHelper existingFileHelper); + void generate(HolderLookup.Provider registries, Consumer saver, ExistingFileHelper existingFileHelper); /** * Creates an {@link AdvancementSubProvider} from this generator. @@ -60,8 +58,7 @@ public class ForgeAdvancementProvider extends AdvancementProvider * @param existingFileHelper a helper used to find whether a file exists * @return a sub provider wrapping this generator */ - default AdvancementSubProvider toSubProvider(ExistingFileHelper existingFileHelper) - { + default AdvancementSubProvider toSubProvider(ExistingFileHelper existingFileHelper) { return (registries, saver) -> this.generate(registries, saver, existingFileHelper); } } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java index b4e5a4de2c..c12a9b39da 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.data; - +/* import net.minecraft.advancements.critereon.ItemPredicate; import net.minecraft.data.PackOutput; import net.minecraft.data.loot.LootTableProvider; @@ -35,7 +35,7 @@ import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; /** * Currently used only for replacing shears item to shears_dig tool action - */ + * / public final class ForgeLootTableProvider extends LootTableProvider { public ForgeLootTableProvider(PackOutput packOutput) { super(packOutput, Set.of(), VanillaLootTableProvider.create(packOutput).getTables()); @@ -184,3 +184,4 @@ public final class ForgeLootTableProvider extends LootTableProvider { return items != null && items.contains(expected); } } +*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java index 2c6733106d..b6b1cf585d 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeRecipeProvider.java @@ -6,10 +6,12 @@ package net.minecraftforge.common.data; import com.google.gson.JsonObject; -import net.minecraft.advancements.Advancement; +import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.advancements.Advancement.Builder; import net.minecraft.data.CachedOutput; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.ShapedRecipeBuilder; import net.minecraft.data.recipes.ShapelessRecipeBuilder; import net.minecraft.data.recipes.packs.VanillaRecipeProvider; @@ -36,7 +38,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.function.Consumer; public final class ForgeRecipeProvider extends VanillaRecipeProvider { private final Map> replacements = new HashMap<>(); @@ -59,7 +60,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { } @Override - protected void buildRecipes(Consumer consumer) { + protected void buildRecipes(RecipeOutput consumer) { replace(Items.STICK, Tags.Items.RODS_WOODEN); replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD); replace(Items.IRON_INGOT, Tags.Items.INGOTS_IRON); @@ -92,10 +93,18 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { exclude(Blocks.COBBLED_DEEPSLATE_SLAB); exclude(Blocks.COBBLED_DEEPSLATE_WALL); - super.buildRecipes(vanilla -> { - FinishedRecipe modified = enhance(vanilla); - if (modified != null) - consumer.accept(modified); + super.buildRecipes(new RecipeOutput() { + @Override + public void accept(FinishedRecipe vanilla) { + var modified = enhance(vanilla); + if (modified != null) + consumer.accept(modified); + } + + @Override + public Builder advancement() { + return consumer.advancement(); + } }); } @@ -113,7 +122,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { List ingredients = getField(ShapelessRecipeBuilder.Result.class, vanilla, 4); boolean modified = false; for (int x = 0; x < ingredients.size(); x++) { - Ingredient ing = enhance(vanilla.getId(), ingredients.get(x)); + Ingredient ing = enhance(vanilla.id(), ingredients.get(x)); if (ing != null) { ingredients.set(x, ing); modified = true; @@ -124,13 +133,13 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { @Nullable @Override - protected CompletableFuture saveAdvancement(CachedOutput output, FinishedRecipe recipe, JsonObject json) { + protected CompletableFuture saveAdvancement(CachedOutput output, JsonObject advancementJson, AdvancementHolder holder, FinishedRecipe finishedRecipe) { // NOOP - We don't replace any of the advancement things yet... return null; } @Override - protected CompletableFuture buildAdvancement(CachedOutput output, ResourceLocation name, Advancement.Builder builder) { + protected CompletableFuture buildAdvancement(CachedOutput p_253674_, AdvancementHolder p_297687_) { // NOOP - We don't replace any of the advancement things yet... return CompletableFuture.allOf(); } @@ -140,7 +149,7 @@ public final class ForgeRecipeProvider extends VanillaRecipeProvider { Map ingredients = getField(ShapedRecipeBuilder.Result.class, vanilla, 5); boolean modified = false; for (Character x : ingredients.keySet()) { - Ingredient ing = enhance(vanilla.getId(), ingredients.get(x)); + Ingredient ing = enhance(vanilla.id(), ingredients.get(x)); if (ing != null) { ingredients.put(x, ing); modified = true; diff --git a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java index bc63f6115c..e533e77e3a 100644 --- a/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java +++ b/src/main/java/net/minecraftforge/common/data/GlobalLootModifierProvider.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.data; - +/* import com.google.common.collect.ImmutableList; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -31,7 +31,7 @@ import java.util.stream.Collectors; * Provider for forge's GlobalLootModifier system. See {@link LootModifier} * * This provider only requires implementing {@link #start()} and calling {@link #add} from it. - */ + * / public abstract class GlobalLootModifierProvider implements DataProvider { private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); @@ -48,7 +48,7 @@ public abstract class GlobalLootModifierProvider implements DataProvider /** * Sets the "replace" key in global_loot_modifiers to true. - */ + * / protected void replacing() { this.replace = true; @@ -56,7 +56,7 @@ public abstract class GlobalLootModifierProvider implements DataProvider /** * Call {@link #add} here, which will pass in the necessary information to write the jsons. - */ + * / protected abstract void start(); @Override @@ -91,7 +91,7 @@ public abstract class GlobalLootModifierProvider implements DataProvider * * @param modifier The name of the modifier, which will be the file name. * @param instance The instance to serialize - */ + * / public void add(String modifier, T instance) { JsonElement json = IGlobalLootModifier.DIRECT_CODEC.encodeStart(JsonOps.INSTANCE, instance).getOrThrow(false, s -> {}); @@ -104,3 +104,4 @@ public abstract class GlobalLootModifierProvider implements DataProvider return "Global Loot Modifiers : " + modid; } } +*/ diff --git a/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java b/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java index 1a10db2ec1..c93364847b 100644 --- a/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java +++ b/src/main/java/net/minecraftforge/common/data/JsonCodecProvider.java @@ -7,7 +7,6 @@ package net.minecraftforge.common.data; import com.google.common.collect.ImmutableList; import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import com.mojang.logging.LogUtils; import com.mojang.serialization.Codec; import com.mojang.serialization.DynamicOps; @@ -18,21 +17,14 @@ import java.util.Collections; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; -import net.minecraft.resources.RegistryDataLoader; -import net.minecraft.resources.RegistryOps; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; -import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.data.ExistingFileHelper.ResourceType; -import net.minecraftforge.registries.DataPackRegistriesHooks; import org.slf4j.Logger; /** @@ -96,6 +88,7 @@ public class JsonCodecProvider implements DataProvider final Path path = outputFolder.resolve(id.getNamespace()).resolve(this.directory).resolve(id.getPath() + ".json"); JsonElement encoded = this.codec.encodeStart(this.dynamicOps, value) .getOrThrow(false, msg -> LOGGER.error("Failed to encode {}: {}", path, msg)); + /* TODO: Conditional JSONS ICondition[] conditions = this.conditions.get(id); if (conditions != null && conditions.length > 0) { @@ -108,6 +101,7 @@ public class JsonCodecProvider implements DataProvider LOGGER.error("Attempted to apply conditions to a type that is not a JsonObject! - Path: {}", path); } } + */ futuresBuilder.add(DataProvider.saveStable(cache, encoded, path)); })); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeAdvancementBuilder.java b/src/main/java/net/minecraftforge/common/extensions/IForgeAdvancementBuilder.java deleted file mode 100644 index c823020068..0000000000 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeAdvancementBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common.extensions; - -import com.google.common.collect.Maps; -import net.minecraft.advancements.Advancement; -import net.minecraft.advancements.AdvancementRewards; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.PackType; -import net.minecraftforge.common.data.ExistingFileHelper; - -import java.util.function.Consumer; - -public interface IForgeAdvancementBuilder -{ - - private Advancement.Builder self() - { - return (Advancement.Builder) this; - } - - /** - * Saves this builder with the given id using the {@link ExistingFileHelper} to check if the parent is already known. - * - * @param saver a {@link Consumer} which saves any advancements provided - * @param id the {@link ResourceLocation} id for the new advancement - * @param fileHelper the {@link ExistingFileHelper} where all known advancements are registered - * @return the built advancement - * @throws IllegalStateException if the parent of the advancement is not known - */ - default Advancement save(Consumer saver, ResourceLocation id, ExistingFileHelper fileHelper) - { - boolean canBuild = self().canBuild((advancementId) -> - { - if (fileHelper.exists(advancementId, PackType.SERVER_DATA, ".json", "advancements")) - { - return new Advancement(advancementId, null, null, AdvancementRewards.EMPTY, Maps.newHashMap(), new String[0][0], false); - } - return null; - }); - if (!canBuild) - { - throw new IllegalStateException("Tried to build Advancement without valid Parent!"); - } - - Advancement advancement = self().build(id); - saver.accept(advancement); - return advancement; - } -} diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java index f4a44c1fca..f249d53759 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeCommandSourceStack.java @@ -5,7 +5,7 @@ package net.minecraftforge.common.extensions; -import net.minecraft.advancements.Advancement; +import net.minecraft.advancements.AdvancementHolder; import net.minecraft.commands.CommandSourceStack; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.RecipeManager; @@ -15,44 +15,36 @@ import net.minecraft.world.scores.Scoreboard; /** * Additional methods for {@link CommandSourceStack} so that commands and arguments can access various things without directly referencing using server specific classes */ -public interface IForgeCommandSourceStack -{ - - private CommandSourceStack self() - { +public interface IForgeCommandSourceStack { + private CommandSourceStack self() { return (CommandSourceStack) this; } /** * @return the scoreboard */ - default Scoreboard getScoreboard() - { + default Scoreboard getScoreboard() { return self().getServer().getScoreboard(); } /** * @return the advancement from the id */ - default Advancement getAdvancement(ResourceLocation id) - { - return self().getServer().getAdvancements().getAdvancement(id); + default AdvancementHolder getAdvancement(ResourceLocation id) { + return self().getServer().getAdvancements().get(id); } /** * @return the recipe manager */ - default RecipeManager getRecipeManager() - { + default RecipeManager getRecipeManager() { return self().getServer().getRecipeManager(); } /** * @return the level but without being specifically the server side level */ - default Level getUnsidedLevel() - { + default Level getUnsidedLevel() { return self().getLevel(); } - } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeRecipeSerializer.java b/src/main/java/net/minecraftforge/common/extensions/IForgeRecipeSerializer.java deleted file mode 100644 index 6f901ecc08..0000000000 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeRecipeSerializer.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.common.extensions; - -import com.google.gson.JsonObject; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraftforge.common.crafting.conditions.ICondition; - -public interface IForgeRecipeSerializer> -{ - private RecipeSerializer self() - { - return (RecipeSerializer) this; - } - - default T fromJson(ResourceLocation recipeLoc, JsonObject recipeJson, ICondition.IContext context) - { - return self().fromJson(recipeLoc, recipeJson); - } -} diff --git a/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java b/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java index 789a05bf09..3deec52fe6 100644 --- a/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java +++ b/src/main/java/net/minecraftforge/common/loot/CanToolPerformAction.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.loot; - +/* import com.google.common.collect.ImmutableSet; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; @@ -22,7 +22,7 @@ import java.util.Set; /** * This LootItemCondition "forge:can_tool_perform_action" can be used to check if a tool can perform a given ToolAction. - */ + * / public class CanToolPerformAction implements LootItemCondition { public static final LootItemConditionType LOOT_CONDITION_TYPE = new LootItemConditionType(new CanToolPerformAction.Serializer()); @@ -64,3 +64,4 @@ public class CanToolPerformAction implements LootItemCondition { } } +*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java b/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java index 72f70d5598..12b12ea6ba 100644 --- a/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java +++ b/src/main/java/net/minecraftforge/common/loot/IGlobalLootModifier.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.loot; - +/* import com.google.gson.JsonElement; import com.google.gson.JsonSyntaxException; import com.mojang.serialization.Codec; @@ -26,7 +26,7 @@ import java.util.function.Function; * {@link LootModifier} Supplies base functionality; most modders should only need to extend that.
* Requires a {@link Codec} to be registered: {@link ForgeRegistries#GLOBAL_LOOT_MODIFIER_SERIALIZERS}, and returned in {@link #codec()} * Individual instances of modifiers must be registered via json, see forge:loot_modifiers/global_loot_modifiers - */ + * / public interface IGlobalLootModifier { Codec DIRECT_CODEC = ExtraCodecs.lazyInitializedCodec(() -> ForgeRegistries.GLOBAL_LOOT_MODIFIER_SERIALIZERS.get().getCodec()) .dispatch(IGlobalLootModifier::codec, Function.identity()); @@ -74,12 +74,13 @@ public interface IGlobalLootModifier { * @param generatedLoot the list of ItemStacks that will be dropped, generated by loot tables * @param context the LootContext, identical to what is passed to loot tables * @return modified loot drops - */ + * / @NotNull ObjectArrayList apply(ObjectArrayList generatedLoot, LootContext context); /** * Returns the registered codec for this modifier - */ + * / Codec codec(); } +*/ diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifier.java b/src/main/java/net/minecraftforge/common/loot/LootModifier.java index fafc014795..3e136973c5 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifier.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifier.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.loot; - +/* import java.util.function.Predicate; import com.mojang.datafixers.Products; @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull; /** * A base implementation of a Global Loot Modifier for modders to extend. * Takes care of ILootCondition matching and comes with the base codec to extend. - */ + * / public abstract class LootModifier implements IGlobalLootModifier { protected final LootItemCondition[] conditions; @@ -35,7 +35,7 @@ public abstract class LootModifier implements IGlobalLootModifier *

* Otherwise can follow this with #and() to add more fields. * Examples: Forge Test Subclasses or {@link BendingTrunkPlacer#CODEC} - */ + * / protected static Products.P1, LootItemCondition[]> codecStart(RecordCodecBuilder.Instance instance) { return instance.group(LOOT_CONDITIONS_CODEC.fieldOf("conditions").forGetter(lm -> lm.conditions)); @@ -44,7 +44,7 @@ public abstract class LootModifier implements IGlobalLootModifier /** * Constructs a LootModifier. * @param conditionsIn the ILootConditions that need to be matched before the loot is modified. - */ + * / protected LootModifier(LootItemCondition[] conditionsIn) { this.conditions = conditionsIn; @@ -64,7 +64,8 @@ public abstract class LootModifier implements IGlobalLootModifier * @param generatedLoot the list of ItemStacks that will be dropped, generated by loot tables * @param context the LootContext, identical to what is passed to loot tables * @return modified loot drops - */ + * / @NotNull protected abstract ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context); } +*/ diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java index d928ddc696..e80737a560 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.loot; - +/* import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -16,7 +16,6 @@ import java.util.*; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; -import net.minecraft.world.level.storage.loot.Deserializers; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -87,9 +86,10 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener { /** * An immutable collection of the registered loot modifiers in layered order. - */ + * / public Collection getAllLootMods() { return registeredLootModifiers.values(); } } +*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java b/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java index 69e788d527..9d68402911 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java +++ b/src/main/java/net/minecraftforge/common/loot/LootTableIdCondition.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.common.loot; - +/* import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; @@ -77,3 +77,4 @@ public class LootTableIdCondition implements LootItemCondition } } } +*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayer.java b/src/main/java/net/minecraftforge/common/util/FakePlayer.java index ca605b4859..6bdaf259c9 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayer.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayer.java @@ -15,6 +15,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; +import net.minecraft.network.protocol.common.ServerboundClientInformationPacket; import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket; import net.minecraft.network.protocol.game.ServerboundBlockEntityTagQuery; @@ -24,17 +25,14 @@ import net.minecraft.network.protocol.game.ServerboundChatCommandPacket; import net.minecraft.network.protocol.game.ServerboundChatPacket; import net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket; import net.minecraft.network.protocol.game.ServerboundClientCommandPacket; -import net.minecraft.network.protocol.game.ServerboundClientInformationPacket; import net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket; import net.minecraft.network.protocol.game.ServerboundContainerButtonClickPacket; import net.minecraft.network.protocol.game.ServerboundContainerClickPacket; import net.minecraft.network.protocol.game.ServerboundContainerClosePacket; -import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket; import net.minecraft.network.protocol.game.ServerboundEditBookPacket; import net.minecraft.network.protocol.game.ServerboundEntityTagQuery; import net.minecraft.network.protocol.game.ServerboundInteractPacket; import net.minecraft.network.protocol.game.ServerboundJigsawGeneratePacket; -import net.minecraft.network.protocol.game.ServerboundKeepAlivePacket; import net.minecraft.network.protocol.game.ServerboundLockDifficultyPacket; import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; @@ -48,7 +46,6 @@ import net.minecraft.network.protocol.game.ServerboundPlayerInputPacket; import net.minecraft.network.protocol.game.ServerboundRecipeBookChangeSettingsPacket; import net.minecraft.network.protocol.game.ServerboundRecipeBookSeenRecipePacket; import net.minecraft.network.protocol.game.ServerboundRenameItemPacket; -import net.minecraft.network.protocol.game.ServerboundResourcePackPacket; import net.minecraft.network.protocol.game.ServerboundSeenAdvancementsPacket; import net.minecraft.network.protocol.game.ServerboundSelectTradePacket; import net.minecraft.network.protocol.game.ServerboundSetBeaconPacket; @@ -64,8 +61,10 @@ import net.minecraft.network.protocol.game.ServerboundTeleportToEntityPacket; import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; import net.minecraft.network.protocol.game.ServerboundUseItemPacket; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.stats.Stat; import net.minecraft.world.damagesource.DamageSource; @@ -77,12 +76,10 @@ import org.jetbrains.annotations.Nullable; /** * A basic fake server player implementation that can be used to simulate player actions. */ -public class FakePlayer extends ServerPlayer -{ - public FakePlayer(ServerLevel level, GameProfile name) - { - super(level.getServer(), level, name); - this.connection = new FakePlayerNetHandler(level.getServer(), this); +@Deprecated // TODO: Re-write this whole system to be less hacky. Use until we get a good replacement. +public class FakePlayer extends ServerPlayer { + protected FakePlayer(ServerLevel level, GameProfile name, ClientInformation info) { + super(level.getServer(), level, name, info); } @Override public void displayClientMessage(Component chatComponent, boolean actionBar) { } @@ -91,15 +88,14 @@ public class FakePlayer extends ServerPlayer @Override public boolean canHarmPlayer(Player player) { return false; } @Override public void die(DamageSource source) { } @Override public void tick() { } - @Override public void updateOptions(ServerboundClientInformationPacket packet) { } @Override @Nullable public MinecraftServer getServer() { return ServerLifecycleHooks.getCurrentServer(); } @ParametersAreNonnullByDefault - private static class FakePlayerNetHandler extends ServerGamePacketListenerImpl { + static class NetHandler extends ServerGamePacketListenerImpl { private static final Connection DUMMY_CONNECTION = new Connection(PacketFlow.CLIENTBOUND); - public FakePlayerNetHandler(MinecraftServer server, ServerPlayer player) { - super(server, DUMMY_CONNECTION, player); + NetHandler(MinecraftServer server, ServerPlayer player, CommonListenerCookie cookie) { + super(server, DUMMY_CONNECTION, player, cookie); } @Override public void tick() { } @@ -130,7 +126,6 @@ public class FakePlayer extends ServerPlayer @Override public void handleUseItemOn(ServerboundUseItemOnPacket packet) { } @Override public void handleUseItem(ServerboundUseItemPacket packet) { } @Override public void handleTeleportToEntityPacket(ServerboundTeleportToEntityPacket packet) { } - @Override public void handleResourcePackResponse(ServerboundResourcePackPacket packet) { } @Override public void handlePaddleBoat(ServerboundPaddleBoatPacket packet) { } @Override public void onDisconnect(Component message) { } @Override public void send(Packet packet) { } @@ -147,10 +142,7 @@ public class FakePlayer extends ServerPlayer @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { } @Override public void handleSetCreativeModeSlot(ServerboundSetCreativeModeSlotPacket packet) { } @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { } - @Override public void handleKeepAlive(ServerboundKeepAlivePacket packet) { } @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { } - @Override public void handleClientInformation(ServerboundClientInformationPacket packet) { } - @Override public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { } @Override public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) { } @Override public void handleLockDifficulty(ServerboundLockDifficultyPacket packet) { } @Override public void teleport(double x, double y, double z, float yaw, float pitch, Set relativeSet) { } diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java index d9adf843f4..f2c2bce581 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java @@ -12,8 +12,10 @@ import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.network.CommonListenerCookie; -//To be expanded for generic Mod fake players? + +@Deprecated // TODO: Re-write this whole system to be less hacky. Use until we get a good replacement. public class FakePlayerFactory { private static final GameProfile MINECRAFT = new GameProfile(UUID.fromString("41C82C87-7AfB-4024-BA57-13D2C99CAE77"), "[Minecraft]"); @@ -35,11 +37,18 @@ public class FakePlayerFactory public static FakePlayer get(ServerLevel level, GameProfile username) { FakePlayerKey key = new FakePlayerKey(level, username); - return fakePlayers.computeIfAbsent(key, k -> new FakePlayer(k.level(), k.username())); + return fakePlayers.computeIfAbsent(key, FakePlayerFactory::create); } public static void unloadLevel(ServerLevel level) { fakePlayers.entrySet().removeIf(entry -> entry.getValue().level() == level); } + + private static FakePlayer create(FakePlayerKey key) { + var cookie = CommonListenerCookie.createInitial(key.username()); + var ret = new FakePlayer(key.level(), cookie.gameProfile(), cookie.clientInformation()); + new FakePlayer.NetHandler(key.level().getServer(), ret, cookie); + return ret; + } } diff --git a/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java b/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java index 6d8674f98d..64ecb868ac 100644 --- a/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java +++ b/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java @@ -6,58 +6,63 @@ package net.minecraftforge.common.util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.datafix.DataFixTypes; import net.minecraft.world.level.saveddata.SavedData; +import net.minecraft.world.level.storage.DimensionDataStorage; + import org.jetbrains.annotations.Nullable; -public class LevelCapabilityData extends SavedData -{ +public class LevelCapabilityData extends SavedData { public static final String ID = "capabilities"; private INBTSerializable serializable; private CompoundTag capNBT = null; - public LevelCapabilityData(@Nullable INBTSerializable serializable) - { + public LevelCapabilityData(@Nullable INBTSerializable serializable) { this.serializable = serializable; } - public static LevelCapabilityData load(CompoundTag tag, @Nullable INBTSerializable serializable) { - LevelCapabilityData data = new LevelCapabilityData(serializable); - data.read(tag); - return data; - } - - public void read(CompoundTag nbt) - { + public void read(CompoundTag nbt) { this.capNBT = nbt; - if (serializable != null) - { + if (serializable != null) { serializable.deserializeNBT(this.capNBT); this.capNBT = null; } } @Override - public CompoundTag save(CompoundTag nbt) - { + public CompoundTag save(CompoundTag nbt) { if (serializable != null) nbt = serializable.serializeNBT(); return nbt; } @Override - public boolean isDirty() - { + public boolean isDirty() { return true; } - public void setCapabilities(INBTSerializable capabilities) - { + public void setCapabilities(INBTSerializable capabilities) { this.serializable = capabilities; - if (this.capNBT != null && serializable != null) - { + if (this.capNBT != null && serializable != null) { serializable.deserializeNBT(this.capNBT); this.capNBT = null; } } + + public static LevelCapabilityData compute(DimensionDataStorage data, @Nullable INBTSerializable caps) { + var factory = new Factory<>( + () -> new LevelCapabilityData(caps), + (tag) -> { + var ret = new LevelCapabilityData(caps); + ret.read(tag); + return ret; + }, + DataFixTypes.SAVED_DATA_COMMAND_STORAGE //TODO: Hook this for our own types? + ); + + var ret = data.computeIfAbsent(factory, ID); + ret.setCapabilities(caps); + return ret; + } } diff --git a/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java index fa21a1f5cf..586374db24 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java @@ -62,7 +62,7 @@ public class ForgeChunkManager */ public static boolean hasForcedChunks(ServerLevel level) { - ForcedChunksSavedData data = level.getDataStorage().get(ForcedChunksSavedData::load, "chunks"); + ForcedChunksSavedData data = level.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks"); if (data == null) return false; return !data.getChunks().isEmpty() || !data.getBlockForcedChunks().isEmpty() || !data.getEntityForcedChunks().isEmpty(); } @@ -115,7 +115,7 @@ public class ForgeChunkManager LOGGER.warn("A mod attempted to force a chunk for an unloaded mod of id: {}", modId); return false; } - ForcedChunksSavedData saveData = level.getDataStorage().computeIfAbsent(ForcedChunksSavedData::load, ForcedChunksSavedData::new, "chunks"); + ForcedChunksSavedData saveData = level.getDataStorage().computeIfAbsent(ForcedChunksSavedData.factory(), "chunks"); ChunkPos pos = new ChunkPos(chunkX, chunkZ); long chunk = pos.toLong(); TicketTracker tickets = ticketGetter.apply(saveData); diff --git a/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java b/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java index d637c53869..5f5b0d4391 100644 --- a/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java +++ b/src/main/java/net/minecraftforge/event/AddPackFindersEvent.java @@ -16,13 +16,11 @@ import java.util.function.Consumer; /** * Fired on {@link PackRepository} creation to allow mods to add new pack finders. */ -public class AddPackFindersEvent extends Event implements IModBusEvent -{ +public class AddPackFindersEvent extends Event implements IModBusEvent { private final PackType packType; private final Consumer sources; - public AddPackFindersEvent(PackType packType, Consumer sources) - { + public AddPackFindersEvent(PackType packType, Consumer sources) { this.packType = packType; this.sources = sources; } @@ -31,16 +29,14 @@ public class AddPackFindersEvent extends Event implements IModBusEvent * Adds a new source to the list of pack finders. * @param source the pack finder */ - public void addRepositorySource(RepositorySource source) - { + public void addRepositorySource(RepositorySource source) { sources.accept(source); } /** * @return the {@link PackType} of the pack repository being constructed. */ - public PackType getPackType() - { + public PackType getPackType() { return packType; } } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index de47ee886e..f09ae09731 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -11,11 +11,16 @@ import java.util.function.BooleanSupplier; import java.util.function.Consumer; import com.mojang.authlib.GameProfile; - +import com.mojang.blaze3d.platform.Window; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.advancements.Advancement; +import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementProgress; +import net.minecraft.client.MouseHandler; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererProvider.Context; +import net.minecraft.client.resources.PlayerSkin.Model; import net.minecraft.commands.CommandBuildContext; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; @@ -30,8 +35,10 @@ import net.minecraft.world.DifficultyInstance; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.LevelSimulatedReader; import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.portal.PortalShape; @@ -40,13 +47,10 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.SpawnGroupData; -import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobSpawnType; -import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LightningBolt; import net.minecraft.world.entity.item.ItemEntity; @@ -84,6 +88,9 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.PlayerDataStorage; import net.minecraft.world.phys.Vec3; +import net.minecraftforge.client.event.EntityRenderersEvent; +import net.minecraftforge.client.event.InputEvent; +import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.ToolAction; import net.minecraftforge.common.capabilities.CapabilityDispatcher; @@ -91,11 +98,13 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.event.brewing.PlayerBrewedPotionEvent; import net.minecraftforge.event.brewing.PotionBrewEvent; +import net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityMobGriefingEvent; import net.minecraftforge.event.entity.EntityMountEvent; import net.minecraftforge.event.entity.EntityStruckByLightningEvent; import net.minecraftforge.event.entity.EntityTeleportEvent; +import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.event.entity.item.ItemExpireEvent; import net.minecraftforge.event.entity.living.AnimalTameEvent; @@ -120,6 +129,7 @@ import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.event.entity.player.FillBucketEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.PermissionsChangedEvent; +import net.minecraftforge.event.entity.player.PlayerContainerEvent; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerFlyableFallEvent; @@ -134,8 +144,9 @@ import net.minecraftforge.event.level.BlockEvent; import net.minecraftforge.event.level.BlockEvent.BlockToolModificationEvent; import net.minecraftforge.event.level.BlockEvent.CreateFluidSourceEvent; import net.minecraftforge.event.level.BlockEvent.EntityMultiPlaceEvent; -import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent; import net.minecraftforge.event.level.BlockEvent.NeighborNotifyEvent; +import net.minecraftforge.event.level.ChunkDataEvent; +import net.minecraftforge.event.level.ChunkEvent; import net.minecraftforge.event.level.ChunkTicketLevelUpdatedEvent; import net.minecraftforge.event.level.ChunkWatchEvent; import net.minecraftforge.event.level.ExplosionEvent; @@ -146,64 +157,56 @@ import net.minecraftforge.event.level.LevelEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.fml.LogicalSide; +import net.minecraftforge.fml.ModLoader; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class ForgeEventFactory -{ - - public static boolean onMultiBlockPlace(@Nullable Entity entity, List blockSnapshots, Direction direction) - { - BlockSnapshot snap = blockSnapshots.get(0); - BlockState placedAgainst = snap.getLevel().getBlockState(snap.getPos().relative(direction.getOpposite())); - EntityMultiPlaceEvent event = new EntityMultiPlaceEvent(blockSnapshots, placedAgainst, entity); - return MinecraftForge.EVENT_BUS.post(event); +@ApiStatus.Internal +public class ForgeEventFactory { + private static boolean post(Event e) { + return MinecraftForge.EVENT_BUS.post(e); } - public static boolean onBlockPlace(@Nullable Entity entity, @NotNull BlockSnapshot blockSnapshot, @NotNull Direction direction) - { - BlockState placedAgainst = blockSnapshot.getLevel().getBlockState(blockSnapshot.getPos().relative(direction.getOpposite())); - EntityPlaceEvent event = new BlockEvent.EntityPlaceEvent(blockSnapshot, placedAgainst, entity); - return MinecraftForge.EVENT_BUS.post(event); + private static E fire(E e) { + MinecraftForge.EVENT_BUS.post(e); + return e; } - public static NeighborNotifyEvent onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) - { - NeighborNotifyEvent event = new NeighborNotifyEvent(level, pos, state, notifiedSides, forceRedstoneUpdate); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static boolean onMultiBlockPlace(@Nullable Entity entity, List blockSnapshots, Direction direction) { + var snap = blockSnapshots.get(0); + var placedAgainst = snap.getLevel().getBlockState(snap.getPos().relative(direction.getOpposite())); + var event = new EntityMultiPlaceEvent(blockSnapshots, placedAgainst, entity); + return post(event); } - public static boolean doPlayerHarvestCheck(Player player, BlockState state, boolean success) - { - PlayerEvent.HarvestCheck event = new PlayerEvent.HarvestCheck(player, state, success); - MinecraftForge.EVENT_BUS.post(event); - return event.canHarvest(); + public static boolean onBlockPlace(@Nullable Entity entity, @NotNull BlockSnapshot blockSnapshot, @NotNull Direction direction) { + var placedAgainst = blockSnapshot.getLevel().getBlockState(blockSnapshot.getPos().relative(direction.getOpposite())); + var event = new BlockEvent.EntityPlaceEvent(blockSnapshot, placedAgainst, entity); + return post(event); } - public static float getBreakSpeed(Player player, BlockState state, float original, BlockPos pos) - { - PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, state, original, pos); - return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getNewSpeed()); + public static NeighborNotifyEvent onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet notifiedSides, boolean forceRedstoneUpdate) { + return fire(new NeighborNotifyEvent(level, pos, state, notifiedSides, forceRedstoneUpdate)); } - public static void onPlayerDestroyItem(Player player, @NotNull ItemStack stack, @Nullable InteractionHand hand) - { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand)); + public static boolean doPlayerHarvestCheck(Player player, BlockState state, boolean success) { + return fire(new PlayerEvent.HarvestCheck(player, state, success)).canHarvest(); } - /** - * Internal, should only be called via {@link SpawnPlacements#checkSpawnRules}. - * @see SpawnPlacementCheck - */ - @ApiStatus.Internal - public static boolean checkSpawnPlacements(EntityType entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) - { - var event = new SpawnPlacementCheck(entityType, level, spawnType, pos, random, defaultResult); - MinecraftForge.EVENT_BUS.post(event); - return event.getResult() == Result.DEFAULT ? defaultResult : event.getResult() == Result.ALLOW; + public static float getBreakSpeed(Player player, BlockState state, float original, BlockPos pos) { + var event = new PlayerEvent.BreakSpeed(player, state, original, pos); + return (post(event) ? -1 : event.getNewSpeed()); + } + + public static void onPlayerDestroyItem(Player player, @NotNull ItemStack stack, @Nullable InteractionHand hand) { + post(new PlayerDestroyItemEvent(player, stack, hand)); + } + + public static boolean checkSpawnPlacements(EntityType entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) { + var result = fire(new SpawnPlacementCheck(entityType, level, spawnType, pos, random, defaultResult)).getResult(); + return result == Result.DEFAULT ? defaultResult : result == Result.ALLOW; } /** @@ -215,15 +218,11 @@ public class ForgeEventFactory * @return True, if the position is valid, as determined by the contract of {@link PositionCheck}. * @see PositionCheck */ - public static boolean checkSpawnPosition(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType) - { - var event = new PositionCheck(mob, level, spawnType, null); - MinecraftForge.EVENT_BUS.post(event); - if (event.getResult() == Result.DEFAULT) - { + public static boolean checkSpawnPosition(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType) { + var result = fire(new PositionCheck(mob, level, spawnType, null)).getResult(); + if (result == Result.DEFAULT) return mob.checkSpawnRules(level, spawnType) && mob.checkSpawnObstruction(level); - } - return event.getResult() == Result.ALLOW; + return result == Result.ALLOW; } /** @@ -231,16 +230,13 @@ public class ForgeEventFactory * @see #CheckSpawnPosition * @implNote See in-line comments about custom spawn rules. */ - public static boolean checkSpawnPositionSpawner(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, SpawnData spawnData, BaseSpawner spawner) - { - var event = new PositionCheck(mob, level, spawnType, null); - MinecraftForge.EVENT_BUS.post(event); - if (event.getResult() == Result.DEFAULT) - { + public static boolean checkSpawnPositionSpawner(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, SpawnData spawnData, BaseSpawner spawner) { + var result = fire(new PositionCheck(mob, level, spawnType, null)).getResult(); + if (result == Result.DEFAULT) { // Spawners do not evaluate Mob#checkSpawnRules if any custom rules are present. This is despite the fact that these two methods do not check the same things. return (spawnData.getCustomSpawnRules().isPresent() || mob.checkSpawnRules(level, spawnType)) && mob.checkSpawnObstruction(level); } - return event.getResult() == Result.ALLOW; + return result == Result.ALLOW; } /** @@ -275,15 +271,12 @@ public class ForgeEventFactory */ @Nullable @SuppressWarnings("deprecation") // Call to deprecated Mob#finalizeSpawn is expected. - public static SpawnGroupData onFinalizeSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag) - { + public static SpawnGroupData onFinalizeSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag) { var event = new MobSpawnEvent.FinalizeSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), difficulty, spawnType, spawnData, spawnTag, null); - boolean cancel = MinecraftForge.EVENT_BUS.post(event); + boolean cancel = post(event); if (!cancel) - { mob.finalizeSpawn(level, event.getDifficulty(), event.getSpawnType(), event.getSpawnData(), event.getSpawnTag()); - } return cancel ? null : event.getSpawnData(); } @@ -295,146 +288,104 @@ public class ForgeEventFactory * @see #onFinalizeSpawn */ @Nullable - public static MobSpawnEvent.FinalizeSpawn onFinalizeSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag, BaseSpawner spawner) - { + public static MobSpawnEvent.FinalizeSpawn onFinalizeSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag, BaseSpawner spawner) { var event = new MobSpawnEvent.FinalizeSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), difficulty, MobSpawnType.SPAWNER, spawnData, spawnTag, spawner); - boolean cancel = MinecraftForge.EVENT_BUS.post(event); + boolean cancel = post(event); return cancel ? null : event; } - public static Result canEntityDespawn(Mob entity, ServerLevelAccessor level) - { - AllowDespawn event = new AllowDespawn(entity, level); - MinecraftForge.EVENT_BUS.post(event); - return event.getResult(); + public static Result canEntityDespawn(Mob entity, ServerLevelAccessor level) { + return fire(new AllowDespawn(entity, level)).getResult(); } - public static int getItemBurnTime(@NotNull ItemStack itemStack, int burnTime, @Nullable RecipeType recipeType) - { - FurnaceFuelBurnTimeEvent event = new FurnaceFuelBurnTimeEvent(itemStack, burnTime, recipeType); - MinecraftForge.EVENT_BUS.post(event); - return event.getBurnTime(); + public static int getItemBurnTime(@NotNull ItemStack itemStack, int burnTime, @Nullable RecipeType recipeType) { + return fire(new FurnaceFuelBurnTimeEvent(itemStack, burnTime, recipeType)).getBurnTime(); } - public static int getExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) - { - LivingExperienceDropEvent event = new LivingExperienceDropEvent(entity, attackingPlayer, originalExperience); - if (MinecraftForge.EVENT_BUS.post(event)) - { + public static int getExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) { + var event = new LivingExperienceDropEvent(entity, attackingPlayer, originalExperience); + if (post(event)) return 0; - } return event.getDroppedExperience(); } - public static int getMaxSpawnPackSize(Mob entity) - { - LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity); - MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent); + public static int getMaxSpawnPackSize(Mob entity) { + var maxCanSpawnEvent = fire(new LivingPackSizeEvent(entity)); return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnClusterSize(); } - public static Component getPlayerDisplayName(Player player, Component username) - { - PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username); - MinecraftForge.EVENT_BUS.post(event); - return event.getDisplayname(); + public static Component getPlayerDisplayName(Player player, Component username) { + return fire(new PlayerEvent.NameFormat(player, username)).getDisplayname(); } - public static Component getPlayerTabListDisplayName(Player player) - { - PlayerEvent.TabListNameFormat event = new PlayerEvent.TabListNameFormat(player); - MinecraftForge.EVENT_BUS.post(event); - return event.getDisplayName(); + public static Component getPlayerTabListDisplayName(Player player) { + return fire(new PlayerEvent.TabListNameFormat(player)).getDisplayName(); } - public static BlockState fireFluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) - { - BlockEvent.FluidPlaceBlockEvent event = new BlockEvent.FluidPlaceBlockEvent(level, pos, liquidPos, state); - MinecraftForge.EVENT_BUS.post(event); - return event.getNewState(); + public static BlockState fireFluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) { + return fire(new BlockEvent.FluidPlaceBlockEvent(level, pos, liquidPos, state)).getNewState(); } - public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List list, TooltipFlag flags) - { - ItemTooltipEvent event = new ItemTooltipEvent(itemStack, entityPlayer, list, flags); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List list, TooltipFlag flags) { + return fire(new ItemTooltipEvent(itemStack, entityPlayer, list, flags)); } - public static SummonAidEvent fireZombieSummonAid(Zombie zombie, Level level, int x, int y, int z, LivingEntity attacker, double summonChance) - { - SummonAidEvent summonEvent = new SummonAidEvent(zombie, level, x, y, z, attacker, summonChance); - MinecraftForge.EVENT_BUS.post(summonEvent); - return summonEvent; + public static SummonAidEvent fireZombieSummonAid(Zombie zombie, Level level, int x, int y, int z, LivingEntity attacker, double summonChance) { + return fire(new SummonAidEvent(zombie, level, x, y, z, attacker, summonChance)); } - public static boolean onEntityStruckByLightning(Entity entity, LightningBolt bolt) - { - return MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, bolt)); + public static boolean onEntityStruckByLightning(Entity entity, LightningBolt bolt) { + return post(new EntityStruckByLightningEvent(entity, bolt)); } - public static int onItemUseStart(LivingEntity entity, ItemStack item, int duration) - { - LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Start(entity, item, duration); - return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration(); + public static int onItemUseStart(LivingEntity entity, ItemStack item, int duration) { + var event = new LivingEntityUseItemEvent.Start(entity, item, duration); + return post(event) ? -1 : event.getDuration(); } - public static int onItemUseTick(LivingEntity entity, ItemStack item, int duration) - { - LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Tick(entity, item, duration); - return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration(); + public static int onItemUseTick(LivingEntity entity, ItemStack item, int duration) { + var event = new LivingEntityUseItemEvent.Tick(entity, item, duration); + return post(event) ? -1 : event.getDuration(); } - public static boolean onUseItemStop(LivingEntity entity, ItemStack item, int duration) - { - return MinecraftForge.EVENT_BUS.post(new LivingEntityUseItemEvent.Stop(entity, item, duration)); + public static boolean onUseItemStop(LivingEntity entity, ItemStack item, int duration) { + return post(new LivingEntityUseItemEvent.Stop(entity, item, duration)); } - public static ItemStack onItemUseFinish(LivingEntity entity, ItemStack item, int duration, ItemStack result) - { - LivingEntityUseItemEvent.Finish event = new LivingEntityUseItemEvent.Finish(entity, item, duration, result); - MinecraftForge.EVENT_BUS.post(event); - return event.getResultStack(); + public static ItemStack onItemUseFinish(LivingEntity entity, ItemStack item, int duration, ItemStack result) { + return fire(new LivingEntityUseItemEvent.Finish(entity, item, duration, result)).getResultStack(); } - public static void onStartEntityTracking(Entity entity, Player player) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.StartTracking(player, entity)); + public static void onStartEntityTracking(Entity entity, Player player) { + post(new PlayerEvent.StartTracking(player, entity)); } - public static void onStopEntityTracking(Entity entity, Player player) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.StopTracking(player, entity)); + public static void onStopEntityTracking(Entity entity, Player player) { + post(new PlayerEvent.StopTracking(player, entity)); } - public static void firePlayerLoadingEvent(Player player, File playerDirectory, String uuidString) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, playerDirectory, uuidString)); + public static void firePlayerLoadingEvent(Player player, File playerDirectory, String uuidString) { + post(new PlayerEvent.LoadFromFile(player, playerDirectory, uuidString)); } - public static void firePlayerSavingEvent(Player player, File playerDirectory, String uuidString) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.SaveToFile(player, playerDirectory, uuidString)); + public static void firePlayerSavingEvent(Player player, File playerDirectory, String uuidString) { + post(new PlayerEvent.SaveToFile(player, playerDirectory, uuidString)); } - public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, playerFileData.getPlayerDataFolder(), uuidString)); + public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) { + post(new PlayerEvent.LoadFromFile(player, playerFileData.getPlayerDataFolder(), uuidString)); } @Nullable - public static BlockState onToolUse(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) - { - BlockToolModificationEvent event = new BlockToolModificationEvent(originalState, context, toolAction, simulate); - return MinecraftForge.EVENT_BUS.post(event) ? null : event.getFinalState(); + public static BlockState onToolUse(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) { + var event = new BlockToolModificationEvent(originalState, context, toolAction, simulate); + return post(event) ? null : event.getFinalState(); } - public static int onApplyBonemeal(@NotNull Player player, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ItemStack stack) - { - BonemealEvent event = new BonemealEvent(player, level, pos, state, stack); - if (MinecraftForge.EVENT_BUS.post(event)) return -1; - if (event.getResult() == Result.ALLOW) - { + public static int onApplyBonemeal(@NotNull Player player, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ItemStack stack) { + var event = new BonemealEvent(player, level, pos, state, stack); + if (post(event)) return -1; + if (event.getResult() == Result.ALLOW) { if (!level.isClientSide) stack.shrink(1); return 1; @@ -443,13 +394,12 @@ public class ForgeEventFactory } @Nullable - public static InteractionResultHolder onBucketUse(@NotNull Player player, @NotNull Level level, @NotNull ItemStack stack, @Nullable HitResult target) - { - FillBucketEvent event = new FillBucketEvent(player, stack, level, target); - if (MinecraftForge.EVENT_BUS.post(event)) return new InteractionResultHolder(InteractionResult.FAIL, stack); + public static InteractionResultHolder onBucketUse(@NotNull Player player, @NotNull Level level, @NotNull ItemStack stack, @Nullable HitResult target) { + var event = new FillBucketEvent(player, stack, level, target); + if (post(event)) + return new InteractionResultHolder(InteractionResult.FAIL, stack); - if (event.getResult() == Result.ALLOW) - { + if (event.getResult() == Result.ALLOW) { if (player.getAbilities().instabuild) return new InteractionResultHolder(InteractionResult.SUCCESS, stack); @@ -465,125 +415,87 @@ public class ForgeEventFactory return null; } - public static PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(Entity entity, Holder name, SoundSource category, float volume, float pitch) - { - PlayLevelSoundEvent.AtEntity event = new PlayLevelSoundEvent.AtEntity(entity, name, category, volume, pitch); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(Entity entity, Holder name, SoundSource category, float volume, float pitch) { + return fire(new PlayLevelSoundEvent.AtEntity(entity, name, category, volume, pitch)); } - - public static PlayLevelSoundEvent.AtPosition onPlaySoundAtPosition(Level level, double x, double y, double z, Holder name, SoundSource category, float volume, float pitch) - { - PlayLevelSoundEvent.AtPosition event = new PlayLevelSoundEvent.AtPosition(level, new Vec3(x, y, z), name, category, volume, pitch); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static PlayLevelSoundEvent.AtPosition onPlaySoundAtPosition(Level level, double x, double y, double z, Holder name, SoundSource category, float volume, float pitch) { + return fire(new PlayLevelSoundEvent.AtPosition(level, new Vec3(x, y, z), name, category, volume, pitch)); } - public static int onItemExpire(ItemEntity entity, @NotNull ItemStack item) - { + public static int onItemExpire(ItemEntity entity, @NotNull ItemStack item) { if (item.isEmpty()) return -1; - ItemExpireEvent event = new ItemExpireEvent(entity, (item.isEmpty() ? 6000 : item.getItem().getEntityLifespan(item, entity.level()))); - if (!MinecraftForge.EVENT_BUS.post(event)) return -1; + var event = new ItemExpireEvent(entity, (item.isEmpty() ? 6000 : item.getItem().getEntityLifespan(item, entity.level()))); + if (!post(event)) return -1; return event.getExtraLife(); } - public static int onItemPickup(ItemEntity entityItem, Player player) - { - Event event = new EntityItemPickupEvent(player, entityItem); - if (MinecraftForge.EVENT_BUS.post(event)) return -1; + public static int onItemPickup(ItemEntity entityItem, Player player) { + var event = new EntityItemPickupEvent(player, entityItem); + if (post(event)) return -1; return event.getResult() == Result.ALLOW ? 1 : 0; } - public static boolean canMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting) - { - boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.level(), isMounting)); + public static boolean canMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting) { + boolean isCanceled = post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.level(), isMounting)); - if(isCanceled) - { + if(isCanceled) { entityMounting.absMoveTo(entityMounting.getX(), entityMounting.getY(), entityMounting.getZ(), entityMounting.yRotO, entityMounting.xRotO); return false; - } - else + } else return true; } - public static boolean onAnimalTame(Animal animal, Player tamer) - { - return MinecraftForge.EVENT_BUS.post(new AnimalTameEvent(animal, tamer)); + public static boolean onAnimalTame(Animal animal, Player tamer) { + return post(new AnimalTameEvent(animal, tamer)); } - public static Player.BedSleepingProblem onPlayerSleepInBed(Player player, Optional pos) - { - PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos); - MinecraftForge.EVENT_BUS.post(event); - return event.getResultStatus(); + public static Player.BedSleepingProblem onPlayerSleepInBed(Player player, Optional pos) { + return fire(new PlayerSleepInBedEvent(player, pos)).getResultStatus(); } - public static void onPlayerWakeup(Player player, boolean wakeImmediately, boolean updateLevel) - { - MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player, wakeImmediately, updateLevel)); + public static void onPlayerWakeup(Player player, boolean wakeImmediately, boolean updateLevel) { + post(new PlayerWakeUpEvent(player, wakeImmediately, updateLevel)); } - public static void onPlayerFall(Player player, float distance, float multiplier) - { - MinecraftForge.EVENT_BUS.post(new PlayerFlyableFallEvent(player, distance, multiplier)); + public static void onPlayerFall(Player player, float distance, float multiplier) { + post(new PlayerFlyableFallEvent(player, distance, multiplier)); } - public static boolean onPlayerSpawnSet(Player player, ResourceKey levelKey, BlockPos pos, boolean forced) - { - return MinecraftForge.EVENT_BUS.post(new PlayerSetSpawnEvent(player, levelKey, pos, forced)); + public static boolean onPlayerSpawnSet(Player player, ResourceKey levelKey, BlockPos pos, boolean forced) { + return post(new PlayerSetSpawnEvent(player, levelKey, pos, forced)); } - public static void onPlayerClone(Player player, Player oldPlayer, boolean wasDeath) - { - MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerEvent.Clone(player, oldPlayer, wasDeath)); + public static void onPlayerClone(Player player, Player oldPlayer, boolean wasDeath) { + post(new PlayerEvent.Clone(player, oldPlayer, wasDeath)); } - public static boolean onExplosionStart(Level level, Explosion explosion) - { - return MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Start(level, explosion)); + public static boolean onExplosionStart(Level level, Explosion explosion) { + return post(new ExplosionEvent.Start(level, explosion)); } - public static void onExplosionDetonate(Level level, Explosion explosion, List list, double diameter) - { - //Filter entities to only those who are effected, to prevent modders from seeing more then will be hurt. - /* Enable this if we get issues with modders looping to much. - Iterator itr = list.iterator(); - Vec3 p = explosion.getPosition(); - while (itr.hasNext()) - { - Entity e = itr.next(); - double dist = e.getDistance(p.xCoord, p.yCoord, p.zCoord) / diameter; - if (e.isImmuneToExplosions() || dist > 1.0F) itr.remove(); - } - */ - MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(level, explosion, list)); + public static void onExplosionDetonate(Level level, Explosion explosion, List list, double diameter) { + post(new ExplosionEvent.Detonate(level, explosion, list)); } - public static boolean onCreateWorldSpawn(Level level, ServerLevelData settings) - { - return MinecraftForge.EVENT_BUS.post(new LevelEvent.CreateSpawnPosition(level, settings)); + public static boolean onCreateWorldSpawn(Level level, ServerLevelData settings) { + return post(new LevelEvent.CreateSpawnPosition(level, settings)); } - public static float onLivingHeal(LivingEntity entity, float amount) - { - LivingHealEvent event = new LivingHealEvent(entity, amount); - return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount()); + public static float onLivingHeal(LivingEntity entity, float amount) { + var event = new LivingHealEvent(entity, amount); + return (post(event) ? 0 : event.getAmount()); } - public static boolean onPotionAttemptBrew(NonNullList stacks) - { - NonNullList tmp = NonNullList.withSize(stacks.size(), ItemStack.EMPTY); + public static boolean onPotionAttemptBrew(NonNullList stacks) { + var tmp = NonNullList.withSize(stacks.size(), ItemStack.EMPTY); for (int x = 0; x < tmp.size(); x++) tmp.set(x, stacks.get(x).copy()); - PotionBrewEvent.Pre event = new PotionBrewEvent.Pre(tmp); - if (MinecraftForge.EVENT_BUS.post(event)) - { + var event = new PotionBrewEvent.Pre(tmp); + if (post(event)) { boolean changed = false; - for (int x = 0; x < stacks.size(); x++) - { + for (int x = 0; x < stacks.size(); x++) { changed |= ItemStack.matches(tmp.get(x), stacks.get(x)); stacks.set(x, event.getItem(x)); } @@ -594,379 +506,363 @@ public class ForgeEventFactory return false; } - public static void onPotionBrewed(NonNullList brewingItemStacks) - { - MinecraftForge.EVENT_BUS.post(new PotionBrewEvent.Post(brewingItemStacks)); + public static void onPotionBrewed(NonNullList brewingItemStacks) { + post(new PotionBrewEvent.Post(brewingItemStacks)); } - public static void onPlayerBrewedPotion(Player player, ItemStack stack) - { - MinecraftForge.EVENT_BUS.post(new PlayerBrewedPotionEvent(player, stack)); + public static void onPlayerBrewedPotion(Player player, ItemStack stack) { + post(new PlayerBrewedPotionEvent(player, stack)); } @Nullable - public static CapabilityDispatcher gatherCapabilities(Class type, T provider) - { + public static CapabilityDispatcher gatherCapabilities(Class type, T provider) { return gatherCapabilities(type, provider, null); } @SuppressWarnings("unchecked") @Nullable - public static CapabilityDispatcher gatherCapabilities(Class type, T provider, @Nullable ICapabilityProvider parent) - { + public static CapabilityDispatcher gatherCapabilities(Class type, T provider, @Nullable ICapabilityProvider parent) { return gatherCapabilities(new AttachCapabilitiesEvent((Class) type, provider), parent); } @Nullable - private static CapabilityDispatcher gatherCapabilities(AttachCapabilitiesEvent event, @Nullable ICapabilityProvider parent) - { - MinecraftForge.EVENT_BUS.post(event); + private static CapabilityDispatcher gatherCapabilities(AttachCapabilitiesEvent event, @Nullable ICapabilityProvider parent) { + post(event); return event.getCapabilities().size() > 0 || parent != null ? new CapabilityDispatcher(event.getCapabilities(), event.getListeners(), parent) : null; } - public static boolean fireSleepingLocationCheck(LivingEntity player, BlockPos sleepingLocation) - { - SleepingLocationCheckEvent evt = new SleepingLocationCheckEvent(player, sleepingLocation); - MinecraftForge.EVENT_BUS.post(evt); + public static boolean fireSleepingLocationCheck(LivingEntity player, BlockPos sleepingLocation) { + var evt = new SleepingLocationCheckEvent(player, sleepingLocation); + post(evt); Result canContinueSleep = evt.getResult(); if (canContinueSleep == Result.DEFAULT) - { - return player.getSleepingPos().map(pos-> { - BlockState state = player.level().getBlockState(pos); - return state.getBlock().isBed(state, player.level(), pos, player); - }).orElse(false); - } + return player.getSleepingPos().map(pos -> player.level().getBlockState(pos).isBed(player.level(), pos, player)).orElse(false); else return canContinueSleep == Result.ALLOW; } - public static boolean fireSleepingTimeCheck(Player player, Optional sleepingLocation) - { - SleepingTimeCheckEvent evt = new SleepingTimeCheckEvent(player, sleepingLocation); - MinecraftForge.EVENT_BUS.post(evt); + public static boolean onSleepingTimeCheck(Player player, Optional sleepingLocation) { + var evt = new SleepingTimeCheckEvent(player, sleepingLocation); + post(evt); - Result canContinueSleep = evt.getResult(); + var canContinueSleep = evt.getResult(); if (canContinueSleep == Result.DEFAULT) return !player.level().isDay(); else return canContinueSleep == Result.ALLOW; } - public static InteractionResultHolder onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) - { - ArrowNockEvent event = new ArrowNockEvent(player, item, hand, level, hasAmmo); - if (MinecraftForge.EVENT_BUS.post(event)) + public static InteractionResultHolder onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) { + var event = new ArrowNockEvent(player, item, hand, level, hasAmmo); + if (post(event)) return new InteractionResultHolder(InteractionResult.FAIL, item); return event.getAction(); } - public static int onArrowLoose(ItemStack stack, Level level, Player player, int charge, boolean hasAmmo) - { - ArrowLooseEvent event = new ArrowLooseEvent(player, stack, level, charge, hasAmmo); - if (MinecraftForge.EVENT_BUS.post(event)) + public static int onArrowLoose(ItemStack stack, Level level, Player player, int charge, boolean hasAmmo) { + var event = new ArrowLooseEvent(player, stack, level, charge, hasAmmo); + if (post(event)) return -1; return event.getCharge(); } - public static ProjectileImpactEvent.ImpactResult onProjectileImpactResult(Projectile projectile, HitResult ray) - { - ProjectileImpactEvent event = new ProjectileImpactEvent(projectile, ray); - - // Remove this when the event is no longer cancelable - if (MinecraftForge.EVENT_BUS.post(event)) - return ProjectileImpactEvent.ImpactResult.SKIP_ENTITY; - - return event.getImpactResult(); + public static ProjectileImpactEvent.ImpactResult onProjectileImpactResult(Projectile projectile, HitResult ray) { + return fire(new ProjectileImpactEvent(projectile, ray)).getImpactResult(); } - public static boolean onProjectileImpact(Projectile projectile, HitResult ray) - { + public static boolean onProjectileImpact(Projectile projectile, HitResult ray) { return onProjectileImpactResult(projectile, ray) != ProjectileImpactEvent.ImpactResult.DEFAULT; } - public static LootTable loadLootTable(ResourceLocation name, LootTable table) - { - LootTableLoadEvent event = new LootTableLoadEvent(name, table); - if (MinecraftForge.EVENT_BUS.post(event)) + public static LootTable loadLootTable(ResourceLocation name, LootTable table) { + var event = new LootTableLoadEvent(name, table); + if (post(event)) return LootTable.EMPTY; return event.getTable(); } - public static boolean canCreateFluidSource(Level level, BlockPos pos, BlockState state, boolean def) - { - CreateFluidSourceEvent evt = new CreateFluidSourceEvent(level, pos, state); - MinecraftForge.EVENT_BUS.post(evt); - - Result result = evt.getResult(); + public static boolean canCreateFluidSource(Level level, BlockPos pos, BlockState state, boolean def) { + var result = fire(new CreateFluidSourceEvent(level, pos, state)).getResult(); return result == Result.DEFAULT ? def : result == Result.ALLOW; } - public static Optional onTrySpawnPortal(LevelAccessor level, BlockPos pos, Optional size) - { + public static Optional onTrySpawnPortal(LevelAccessor level, BlockPos pos, Optional size) { if (!size.isPresent()) return size; - return !MinecraftForge.EVENT_BUS.post(new BlockEvent.PortalSpawnEvent(level, pos, level.getBlockState(pos), size.get())) ? size : Optional.empty(); + return !post(new BlockEvent.PortalSpawnEvent(level, pos, level.getBlockState(pos), size.get())) ? size : Optional.empty(); } - public static int onEnchantmentLevelSet(Level level, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int enchantmentLevel) - { - net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent e = new net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent(level, pos, enchantRow, power, itemStack, enchantmentLevel); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e); - return e.getEnchantLevel(); + public static int onEnchantmentLevelSet(Level level, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int enchantmentLevel) { + return fire(new EnchantmentLevelSetEvent(level, pos, enchantRow, power, itemStack, enchantmentLevel)).getEnchantLevel(); } - public static boolean onEntityDestroyBlock(LivingEntity entity, BlockPos pos, BlockState state) - { - return !MinecraftForge.EVENT_BUS.post(new LivingDestroyBlockEvent(entity, pos, state)); + public static boolean onEntityDestroyBlock(LivingEntity entity, BlockPos pos, BlockState state) { + return !post(new LivingDestroyBlockEvent(entity, pos, state)); } - public static boolean getMobGriefingEvent(Level level, @Nullable Entity entity) - { + public static boolean getMobGriefingEvent(Level level, @Nullable Entity entity) { if (entity == null) return level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); - EntityMobGriefingEvent event = new EntityMobGriefingEvent(entity); - MinecraftForge.EVENT_BUS.post(event); - - Result result = event.getResult(); + var result = fire(new EntityMobGriefingEvent(entity)).getResult(); return result == Result.DEFAULT ? level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW; } - public static SaplingGrowTreeEvent blockGrowFeature(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder> holder) - { - SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(level, randomSource, pos, holder); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static SaplingGrowTreeEvent blockGrowFeature(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder> holder) { + return fire(new SaplingGrowTreeEvent(level, randomSource, pos, holder)); } - public static BlockState alterGround(LevelSimulatedReader level, RandomSource random, BlockPos pos, BlockState altered) - { - AlterGroundEvent event = new AlterGroundEvent(level, random, pos, altered); - MinecraftForge.EVENT_BUS.post(event); - return event.getNewAlteredState(); + public static BlockState alterGround(LevelSimulatedReader level, RandomSource random, BlockPos pos, BlockState altered) { + return fire(new AlterGroundEvent(level, random, pos, altered)).getNewAlteredState(); } - public static void fireChunkTicketLevelUpdated(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder) - { + public static void fireChunkTicketLevelUpdated(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder) { if (oldTicketLevel != newTicketLevel) - MinecraftForge.EVENT_BUS.post(new ChunkTicketLevelUpdatedEvent(level, chunkPos, oldTicketLevel, newTicketLevel, chunkHolder)); + post(new ChunkTicketLevelUpdatedEvent(level, chunkPos, oldTicketLevel, newTicketLevel, chunkHolder)); } - public static void fireChunkWatch(ServerPlayer entity, LevelChunk chunk, ServerLevel level) - { - MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(entity, chunk, level)); + public static void fireChunkWatch(ServerPlayer entity, LevelChunk chunk, ServerLevel level) { + post(new ChunkWatchEvent.Watch(entity, chunk, level)); } - public static void fireChunkUnWatch(ServerPlayer entity, ChunkPos chunkpos, ServerLevel level) - { - MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(entity, chunkpos, level)); + public static void fireChunkUnWatch(ServerPlayer entity, ChunkPos chunkpos, ServerLevel level) { + post(new ChunkWatchEvent.UnWatch(entity, chunkpos, level)); } - public static boolean onPistonMovePre(Level level, BlockPos pos, Direction direction, boolean extending) - { - return MinecraftForge.EVENT_BUS.post(new PistonEvent.Pre(level, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT)); + public static boolean onPistonMovePre(Level level, BlockPos pos, Direction direction, boolean extending) { + return post(new PistonEvent.Pre(level, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT)); } - public static boolean onPistonMovePost(Level level, BlockPos pos, Direction direction, boolean extending) - { - return MinecraftForge.EVENT_BUS.post(new PistonEvent.Post(level, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT)); + public static boolean onPistonMovePost(Level level, BlockPos pos, Direction direction, boolean extending) { + return post(new PistonEvent.Post(level, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT)); } - public static long onSleepFinished(ServerLevel level, long newTime, long minTime) - { - SleepFinishedTimeEvent event = new SleepFinishedTimeEvent(level, newTime, minTime); - MinecraftForge.EVENT_BUS.post(event); - return event.getNewTime(); + public static long onSleepFinished(ServerLevel level, long newTime, long minTime) { + return fire(new SleepFinishedTimeEvent(level, newTime, minTime)).getNewTime(); } - public static List onResourceReload(ReloadableServerResources serverResources, RegistryAccess registryAccess) - { - AddReloadListenerEvent event = new AddReloadListenerEvent(serverResources, registryAccess); - MinecraftForge.EVENT_BUS.post(event); - return event.getListeners(); + public static List onResourceReload(ReloadableServerResources serverResources, RegistryAccess registryAccess) { + return fire(new AddReloadListenerEvent(serverResources, registryAccess)).getListeners(); } - public static void onCommandRegister(CommandDispatcher dispatcher, Commands.CommandSelection environment, CommandBuildContext context) - { - RegisterCommandsEvent event = new RegisterCommandsEvent(dispatcher, environment, context); - MinecraftForge.EVENT_BUS.post(event); + public static void onCommandRegister(CommandDispatcher dispatcher, Commands.CommandSelection environment, CommandBuildContext context) { + post(new RegisterCommandsEvent(dispatcher, environment, context)); } - @Deprecated(forRemoval = true, since = "1.20.1") // Remove Entity Eye/Size hooks, as they need to be redesigned - public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) - { - var evt = new EntityEvent.Size(entity, pose, size, eyeHeight); - MinecraftForge.EVENT_BUS.post(evt); - return evt; + public static boolean canLivingConvert(LivingEntity entity, EntityType outcome, Consumer timer) { + return !post(new LivingConversionEvent.Pre(entity, outcome, timer)); } - @Deprecated(forRemoval = true, since = "1.20.1") // Remove Entity Eye/Size hooks, as they need to be redesigned - public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight) - { - var evt = new EntityEvent.Size(entity, pose, oldSize, newSize, entity.getEyeHeight(), newEyeHeight); - MinecraftForge.EVENT_BUS.post(evt); - return evt; + public static void onLivingConvert(LivingEntity entity, LivingEntity outcome) { + post(new LivingConversionEvent.Post(entity, outcome)); } - public static boolean canLivingConvert(LivingEntity entity, EntityType outcome, Consumer timer) - { - return !MinecraftForge.EVENT_BUS.post(new LivingConversionEvent.Pre(entity, outcome, timer)); + public static EntityTeleportEvent.TeleportCommand onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) { + return fire(new EntityTeleportEvent.TeleportCommand(entity, targetX, targetY, targetZ)); } - public static void onLivingConvert(LivingEntity entity, LivingEntity outcome) - { - MinecraftForge.EVENT_BUS.post(new LivingConversionEvent.Post(entity, outcome)); + public static EntityTeleportEvent.SpreadPlayersCommand onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) { + return fire(new EntityTeleportEvent.SpreadPlayersCommand(entity, targetX, targetY, targetZ)); } - public static EntityTeleportEvent.TeleportCommand onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) - { - EntityTeleportEvent.TeleportCommand event = new EntityTeleportEvent.TeleportCommand(entity, targetX, targetY, targetZ); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static EntityTeleportEvent.EnderEntity onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) { + return fire(new EntityTeleportEvent.EnderEntity(entity, targetX, targetY, targetZ)); } - public static EntityTeleportEvent.SpreadPlayersCommand onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) - { - EntityTeleportEvent.SpreadPlayersCommand event = new EntityTeleportEvent.SpreadPlayersCommand(entity, targetX, targetY, targetZ); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult) { + return fire(new EntityTeleportEvent.EnderPearl(entity, targetX, targetY, targetZ, pearlEntity, attackDamage, hitResult)); } - public static EntityTeleportEvent.EnderEntity onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) - { - EntityTeleportEvent.EnderEntity event = new EntityTeleportEvent.EnderEntity(entity, targetX, targetY, targetZ); - MinecraftForge.EVENT_BUS.post(event); - return event; + public static EntityTeleportEvent.ChorusFruit onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) { + return fire(new EntityTeleportEvent.ChorusFruit(entity, targetX, targetY, targetZ)); } - @ApiStatus.Internal - public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult) - { - EntityTeleportEvent.EnderPearl event = new EntityTeleportEvent.EnderPearl(entity, targetX, targetY, targetZ, pearlEntity, attackDamage, hitResult); - MinecraftForge.EVENT_BUS.post(event); - return event; - } - - public static EntityTeleportEvent.ChorusFruit onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) - { - EntityTeleportEvent.ChorusFruit event = new EntityTeleportEvent.ChorusFruit(entity, targetX, targetY, targetZ); - MinecraftForge.EVENT_BUS.post(event); - return event; - } - - public static boolean onPermissionChanged(GameProfile gameProfile, int newLevel, PlayerList playerList) - { - int oldLevel = playerList.getServer().getProfilePermissions(gameProfile); - ServerPlayer player = playerList.getPlayer(gameProfile.getId()); + public static boolean onPermissionChanged(GameProfile gameProfile, int newLevel, PlayerList playerList) { + var oldLevel = playerList.getServer().getProfilePermissions(gameProfile); + var player = playerList.getPlayer(gameProfile.getId()); if (newLevel != oldLevel && player != null) - { - return MinecraftForge.EVENT_BUS.post(new PermissionsChangedEvent(player, newLevel, oldLevel)); - } + return post(new PermissionsChangedEvent(player, newLevel, oldLevel)); return false; } - public static void firePlayerChangedDimensionEvent(Player player, ResourceKey fromDim, ResourceKey toDim) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim)); + public static void onPlayerChangedDimension(Player player, ResourceKey fromDim, ResourceKey toDim) { + post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim)); } - public static void firePlayerLoggedIn(Player player) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedInEvent(player)); + public static void firePlayerLoggedIn(Player player) { + post(new PlayerEvent.PlayerLoggedInEvent(player)); } - public static void firePlayerLoggedOut(Player player) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedOutEvent(player)); + public static void firePlayerLoggedOut(Player player) { + post(new PlayerEvent.PlayerLoggedOutEvent(player)); } - public static void firePlayerRespawnEvent(Player player, boolean endConquered) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerRespawnEvent(player, endConquered)); + public static void firePlayerRespawnEvent(Player player, boolean endConquered) { + post(new PlayerEvent.PlayerRespawnEvent(player, endConquered)); } - public static void firePlayerItemPickupEvent(Player player, ItemEntity item, ItemStack clone) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemPickupEvent(player, item, clone)); + public static void firePlayerItemPickupEvent(Player player, ItemEntity item, ItemStack clone) { + post(new PlayerEvent.ItemPickupEvent(player, item, clone)); } - public static void firePlayerCraftingEvent(Player player, ItemStack crafted, Container craftMatrix) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix)); + public static void firePlayerCraftingEvent(Player player, ItemStack crafted, Container craftMatrix) { + post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix)); } - public static void firePlayerSmeltedEvent(Player player, ItemStack smelted) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); + public static void firePlayerSmeltedEvent(Player player, ItemStack smelted) { + post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); } - public static void onRenderTickStart(float timer) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.RenderTickEvent(TickEvent.Phase.START, timer)); + public static void onRenderTickStart(float timer) { + post(new TickEvent.RenderTickEvent(TickEvent.Phase.START, timer)); } - public static void onRenderTickEnd(float timer) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.RenderTickEvent(TickEvent.Phase.END, timer)); + public static void onRenderTickEnd(float timer) { + post(new TickEvent.RenderTickEvent(TickEvent.Phase.END, timer)); } - public static void onPlayerPreTick(Player player) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.START, player)); + public static void onPlayerPreTick(Player player) { + post(new TickEvent.PlayerTickEvent(TickEvent.Phase.START, player)); } - public static void onPlayerPostTick(Player player) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.END, player)); + public static void onPlayerPostTick(Player player) { + post(new TickEvent.PlayerTickEvent(TickEvent.Phase.END, player)); } - public static void onPreLevelTick(Level level, BooleanSupplier haveTime) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.LevelTickEvent(level.isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER, TickEvent.Phase.START, level, haveTime)); + public static void onPreLevelTick(Level level, BooleanSupplier haveTime) { + post(new TickEvent.LevelTickEvent(level.isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER, TickEvent.Phase.START, level, haveTime)); } - public static void onPostLevelTick(Level level, BooleanSupplier haveTime) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.LevelTickEvent(level.isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER, TickEvent.Phase.END, level, haveTime)); + public static void onPostLevelTick(Level level, BooleanSupplier haveTime) { + post(new TickEvent.LevelTickEvent(level.isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER, TickEvent.Phase.END, level, haveTime)); } - public static void onPreClientTick() - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ClientTickEvent(TickEvent.Phase.START)); + public static void onPreClientTick() { + post(new TickEvent.ClientTickEvent(TickEvent.Phase.START)); } - public static void onPostClientTick() - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ClientTickEvent(TickEvent.Phase.END)); + public static void onPostClientTick() { + post(new TickEvent.ClientTickEvent(TickEvent.Phase.END)); } - public static void onPreServerTick(BooleanSupplier haveTime, MinecraftServer server) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ServerTickEvent(TickEvent.Phase.START, haveTime, server)); + public static void onPreServerTick(BooleanSupplier haveTime, MinecraftServer server) { + post(new TickEvent.ServerTickEvent(TickEvent.Phase.START, haveTime, server)); } - public static void onPostServerTick(BooleanSupplier haveTime, MinecraftServer server) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ServerTickEvent(TickEvent.Phase.END, haveTime, server)); + public static void onPostServerTick(BooleanSupplier haveTime, MinecraftServer server) { + post(new TickEvent.ServerTickEvent(TickEvent.Phase.END, haveTime, server)); } - public static WeightedRandomList getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList oldList) - { + public static WeightedRandomList getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList oldList) { LevelEvent.PotentialSpawns event = new LevelEvent.PotentialSpawns(level, category, pos, oldList); - if (MinecraftForge.EVENT_BUS.post(event)) + if (post(event)) return WeightedRandomList.create(); return WeightedRandomList.create(event.getSpawnerDataList()); } - @ApiStatus.Internal - public static void onAdvancementEarnedEvent(Player player, Advancement earned) - { - MinecraftForge.EVENT_BUS.post(new AdvancementEarnEvent(player, earned)); + public static void onAdvancementEarned(Player player, AdvancementHolder holder) { + post(new AdvancementEarnEvent(player, holder)); } - @ApiStatus.Internal - public static void onAdvancementProgressedEvent(Player player, Advancement progressed, AdvancementProgress advancementProgress, String criterion, ProgressType progressType) - { - MinecraftForge.EVENT_BUS.post(new AdvancementProgressEvent(player, progressed, advancementProgress, criterion, progressType)); + public static void onAdvancementGrant(Player player, AdvancementHolder holder, AdvancementProgress advancementProgress, String criterion) { + post(new AdvancementProgressEvent(player, holder, advancementProgress, criterion, ProgressType.GRANT)); + } + + public static void onAdvancementRevoke(Player player, AdvancementHolder holder, AdvancementProgress advancementProgress, String criterion) { + post(new AdvancementProgressEvent(player, holder, advancementProgress, criterion, ProgressType.REVOKE)); + } + + public static void onEntityConstructing(Entity entity) { + post(new EntityEvent.EntityConstructing(entity)); + } + + public static void onPlayerOpenContainer(ServerPlayer player, AbstractContainerMenu menu) { + post(new PlayerContainerEvent.Open(player, menu)); + } + + public static void onPlayerCloseContainer(ServerPlayer player, AbstractContainerMenu menu) { + post(new PlayerContainerEvent.Close(player, menu)); + } + + public static boolean onTravelToDimension(Entity entity, ResourceKey dimension) { + return post(new EntityTravelToDimensionEvent(entity, dimension)); + } + + public static void onChunkUnload(ChunkAccess chunk) { + post(new ChunkEvent.Unload(chunk)); + } + + public static void onChunkLoad(ChunkAccess chunk, boolean newChunk) { + post(new ChunkEvent.Load(chunk, newChunk)); + } + + public static void onChunkDataSave(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { + post(new ChunkDataEvent.Save(chunk, world, data)); + } + + public static void gatherLayers(Map, EntityRenderer> renderers, Map> playerRenderers, Context context) { + // TODO: Why is this a ModLoader event... + ModLoader.get().postEvent(new EntityRenderersEvent.AddLayers(renderers, playerRenderers, context)); + } + + public static boolean onScreenMouseReleasedPre(Screen guiScreen, double mouseX, double mouseY, int button) { + return post(new ScreenEvent.MouseButtonReleased.Pre(guiScreen, mouseX, mouseY, button)); + } + + public static boolean onScreenMouseReleasedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) { + var result = fire(new ScreenEvent.MouseButtonReleased.Post(guiScreen, mouseX, mouseY, button, handled)).getResult(); + return result == Event.Result.DEFAULT ? handled : result == Event.Result.ALLOW; + } + + public static boolean onScreenMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button) { + return post(new ScreenEvent.MouseButtonPressed.Pre(guiScreen, mouseX, mouseY, button)); + } + + public static boolean onScreenMouseClickedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) { + var result = fire(new ScreenEvent.MouseButtonPressed.Post(guiScreen, mouseX, mouseY, button, handled)).getResult(); + return result == Event.Result.DEFAULT ? handled : result == Event.Result.ALLOW; + } + + public static boolean onMouseButtonPre(int button, int action, int mods) { + return post(new InputEvent.MouseButton.Pre(button, action, mods)); + } + + public static void onMouseButtonPost(int button, int action, int mods) { + post(new InputEvent.MouseButton.Post(button, action, mods)); + } + + public static boolean onScreenMouseScrollPre(Screen guiScreen, double mouseX, double mouseY, double deltaX, double deltaY) { + return post(new ScreenEvent.MouseScrolled.Pre(guiScreen, mouseX, mouseY, deltaX, deltaY)); + } + + public static void onScreenMouseScrollPost(Screen guiScreen, double mouseX, double mouseY, double deltaX, double deltaY) { + post(new ScreenEvent.MouseScrolled.Post(guiScreen, mouseX, mouseY, deltaX, deltaY)); + } + + public static boolean onMouseScroll(MouseHandler mouseHelper, double deltaX, double deltaY) { + return post(new InputEvent.MouseScrollingEvent(deltaX, deltaY, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos())); + } + + public static boolean onScreenMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { + return post(new ScreenEvent.MouseDragged.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY)); + } + + public static void onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { + post(new ScreenEvent.MouseDragged.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY)); + } + + public static @Nullable Screen onScreenOpening(Screen old, Screen screen) { + var event = new ScreenEvent.Opening(old, screen); + if (post(event)) + return null; + return event.getNewScreen(); + } + + public static void onScreenClose(Screen screen) { + post(new ScreenEvent.Closing(screen)); + } + + public static void onGameShuttingDown() { + post(new GameShuttingDownEvent()); } } diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java index 4a029628e2..7738eced2d 100644 --- a/src/main/java/net/minecraftforge/event/ServerChatEvent.java +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -26,16 +26,14 @@ import org.jetbrains.annotations.ApiStatus; * only on the {@linkplain LogicalSide#SERVER logical server}. **/ @Cancelable -public class ServerChatEvent extends Event -{ +public class ServerChatEvent extends Event { private final ServerPlayer player; private final String username; private final String rawText; private Component message; @ApiStatus.Internal - public ServerChatEvent(ServerPlayer player, String rawText, Component message) - { + public ServerChatEvent(ServerPlayer player, String rawText, Component message) { this.player = player; this.username = player.getGameProfile().getName(); this.rawText = rawText; @@ -45,40 +43,35 @@ public class ServerChatEvent extends Event /** * {@return the player who initiated the chat action} */ - public ServerPlayer getPlayer() - { + public ServerPlayer getPlayer() { return this.player; } /** * {@return the username of the player who initiated the chat action} */ - public String getUsername() - { + public String getUsername() { return this.username; } /** * {@return the original raw text of the player chat message} */ - public String getRawText() - { + public String getRawText() { return this.rawText; } /** * Set the message to be sent to the relevant clients. */ - public void setMessage(Component message) - { + public void setMessage(Component message) { this.message = Objects.requireNonNull(message); } /** * {@return the message that will be sent to the relevant clients, if the event is not cancelled} */ - public Component getMessage() - { + public Component getMessage() { return this.message; } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java index 8a56a3c2cf..c3ef704e4c 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java @@ -7,11 +7,7 @@ package net.minecraftforge.event.entity; import net.minecraft.core.SectionPos; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityDimensions; -import net.minecraft.world.entity.Pose; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.extensions.IForgeEntity; -import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; /** @@ -23,17 +19,14 @@ import net.minecraftforge.eventbus.api.Event; *
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/ -public class EntityEvent extends Event -{ +public class EntityEvent extends Event { private final Entity entity; - public EntityEvent(Entity entity) - { + public EntityEvent(Entity entity) { this.entity = entity; } - public Entity getEntity() - { + public Entity getEntity() { return entity; } @@ -47,10 +40,8 @@ public class EntityEvent extends Event *
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/ - public static class EntityConstructing extends EntityEvent - { - public EntityConstructing(Entity entity) - { + public static class EntityConstructing extends EntityEvent { + public EntityConstructing(Entity entity) { super(entity); } } @@ -67,14 +58,11 @@ public class EntityEvent extends Event *
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
**/ - public static class EnteringSection extends EntityEvent - { - + public static class EnteringSection extends EntityEvent { private final long packedOldPos; private final long packedNewPos; - public EnteringSection(Entity entity, long packedOldPos, long packedNewPos) - { + public EnteringSection(Entity entity, long packedOldPos, long packedNewPos) { super(entity); this.packedOldPos = packedOldPos; this.packedNewPos = packedNewPos; @@ -85,8 +73,7 @@ public class EntityEvent extends Event * such as {@link SectionPos#of(long)} or {@link SectionPos#x(long)} to avoid allocation. * @return the packed position of the old section */ - public long getPackedOldPos() - { + public long getPackedOldPos() { return packedOldPos; } @@ -95,24 +82,21 @@ public class EntityEvent extends Event * such as {@link SectionPos#of(long)} or {@link SectionPos#x(long)} to avoid allocation. * @return the packed position of the new section */ - public long getPackedNewPos() - { + public long getPackedNewPos() { return packedNewPos; } /** * @return the position of the old section */ - public SectionPos getOldPos() - { + public SectionPos getOldPos() { return SectionPos.of(packedOldPos); } /** * @return the position of the new section */ - public SectionPos getNewPos() - { + public SectionPos getNewPos() { return SectionPos.of(packedNewPos); } @@ -120,87 +104,8 @@ public class EntityEvent extends Event * Whether the chunk has changed as part of this event. If this method returns false, only the Y position of the * section has changed. */ - public boolean didChunkChange() - { + public boolean didChunkChange() { return SectionPos.x(packedOldPos) != SectionPos.x(packedNewPos) || SectionPos.z(packedOldPos) != SectionPos.z(packedNewPos); } - - } - - /** - * CAREFUL: This is also fired in the Entity constructor. Therefore, the entity (subclass) might not be fully initialized. Check {@link Entity#isAddedToWorld()} or {@code !Entity.firstUpdate}.
- * If you change the player's size, you probably want to set the eye height accordingly as well
- *
- * This event is not {@link Cancelable}.
- *
- * This event does not have a result. {@link HasResult} - *
- * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
- **/ - @Deprecated(forRemoval = true, since = "1.20.1") // Remove Entity Eye/Size hooks, as they need to be redesigned - public static class Size extends EntityEvent { - private final Pose pose; - private final EntityDimensions originalSize; - private EntityDimensions newSize; - private final float oldEyeHeight; - private float newEyeHeight; - - public Size(Entity entity, Pose pose, EntityDimensions size) { - this(entity, pose, size, 1.0f); // Eye height doesn't matter this is just for binary compatibility. - } - - public Size(Entity entity, Pose pose, EntityDimensions size, float defaultEyeHeight) { - this(entity, pose, size, size, defaultEyeHeight, defaultEyeHeight); - } - - public Size(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float oldEyeHeight, float newEyeHeight) { - super(entity); - this.pose = pose; - this.originalSize = oldSize; - this.newSize = newSize; - this.oldEyeHeight = oldEyeHeight; - this.newEyeHeight = newEyeHeight; - } - - public Pose getPose() { return pose; } - public EntityDimensions getOldSize() { return this.getOriginalSize(); } - public EntityDimensions getOriginalSize() { return originalSize; } - public EntityDimensions getNewSize() { return newSize; } - public void setNewSize(EntityDimensions size) { this.newSize = size; } - - public void setNewSize(EntityDimensions size, boolean updateEyeHeight) { - this.setNewSize(size); - if (updateEyeHeight) { - this.newEyeHeight = this.getEntity().getEyeHeightAccess(this.getPose(), this.newSize); - } - } - public float getOldEyeHeight() { return oldEyeHeight; } - public float getNewEyeHeight() { return newEyeHeight; } - public void setNewEyeHeight(float eyeHeight) { this.newEyeHeight = eyeHeight; } - } - - /** - *Remove Entity Eye/Size hooks, as they need to be redesigned, this is no longer fired in any forge/vanilla code. - **/ - @Deprecated(forRemoval = true, since = "1.20.1") - public static class EyeHeight extends EntityEvent { - private final Pose pose; - private final EntityDimensions size; - private final float originalEyeHeight; - private float newEyeHeight; - - public EyeHeight(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) { - super(entity); - this.pose = pose; - this.size = size; - this.originalEyeHeight = eyeHeight; - this.newEyeHeight = eyeHeight; - } - - public Pose getPose() { return pose; } - public EntityDimensions getSize() { return size; } - public float getOriginalEyeHeight() { return originalEyeHeight; } - public float getNewEyeHeight() { return newEyeHeight; } - public void setNewEyeHeight(float newEyeHeight) { this.newEyeHeight = newEyeHeight; } } } diff --git a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java index f8e327a4d1..d2ed1bc1c9 100644 --- a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java @@ -9,7 +9,6 @@ import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.phys.HitResult; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.eventbus.api.Cancelable; import org.jetbrains.annotations.NotNull; import java.util.Objects; @@ -20,58 +19,38 @@ import java.util.Objects; * This event is fired via {@link ForgeEventFactory#onProjectileImpact(Projectile, HitResult)} * This event is fired for all vanilla projectiles by Forge, * custom projectiles should fire this event and check the result in a similar fashion. - * This event is cancelable. When canceled, the impact will not be processed and the projectile will continue flying. - * Killing or other handling of the entity after event cancellation is up to the modder. * You can also directly set the {@link ImpactResult} to change the impact behaviour. * @see #setImpactResult(ImpactResult) */ -@Cancelable -public class ProjectileImpactEvent extends EntityEvent -{ +public class ProjectileImpactEvent extends EntityEvent { private final HitResult ray; private final Projectile projectile; private ImpactResult result = ImpactResult.DEFAULT; - public ProjectileImpactEvent(Projectile projectile, HitResult ray) - { + public ProjectileImpactEvent(Projectile projectile, HitResult ray) { super(projectile); this.ray = ray; this.projectile = projectile; } - /** - * {@inheritDoc} - * @deprecated Use {@link #setImpactResult(ImpactResult)} instead. - */ - @Deprecated(forRemoval = true, since = "1.20.1") - public void setCanceled(boolean cancel) - { - super.setCanceled(cancel); - } - - public HitResult getRayTraceResult() - { + public HitResult getRayTraceResult() { return ray; } - public Projectile getProjectile() - { + public Projectile getProjectile() { return projectile; } - public void setImpactResult(@NotNull ImpactResult newResult) - { + public void setImpactResult(@NotNull ImpactResult newResult) { this.result = Objects.requireNonNull(newResult, "ImpactResult cannot be null"); } - public ImpactResult getImpactResult() - { + public ImpactResult getImpactResult() { return result; } - public enum ImpactResult - { + public enum ImpactResult { /** * The default behaviour, the projectile will be destroyed and the hit will be processed. */ diff --git a/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java index 091bcd16c9..cebb46186b 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java @@ -6,6 +6,7 @@ package net.minecraftforge.event.entity.player; import net.minecraft.advancements.Advancement; +import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementProgress; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.MinecraftForge; @@ -15,18 +16,15 @@ import net.minecraftforge.common.MinecraftForge; * @see AdvancementEarnEvent * @see AdvancementProgressEvent */ -public class AdvancementEvent extends PlayerEvent -{ - private final Advancement advancement; +public class AdvancementEvent extends PlayerEvent { + private final AdvancementHolder advancement; - public AdvancementEvent(Player player, Advancement advancement) - { + public AdvancementEvent(Player player, AdvancementHolder advancement) { super(player); this.advancement = advancement; } - public Advancement getAdvancement() - { + public AdvancementHolder getAdvancement() { return advancement; } @@ -43,23 +41,10 @@ public class AdvancementEvent extends PlayerEvent * * @see AdvancementProgress#isDone() */ - public static class AdvancementEarnEvent extends AdvancementEvent - { - - public AdvancementEarnEvent(Player player, Advancement earned) - { + public static class AdvancementEarnEvent extends AdvancementEvent { + public AdvancementEarnEvent(Player player, AdvancementHolder earned) { super(player, earned); } - - /** - * - * {@return the advancement that was earned} - */ - @Override - public Advancement getAdvancement() - { - return super.getAdvancement(); - } } /** @@ -74,56 +59,40 @@ public class AdvancementEvent extends PlayerEvent * @see net.minecraft.server.PlayerAdvancements#award(Advancement, String) * @see net.minecraft.server.PlayerAdvancements#revoke(Advancement, String) */ - public static class AdvancementProgressEvent extends AdvancementEvent - { + public static class AdvancementProgressEvent extends AdvancementEvent { private final AdvancementProgress advancementProgress; private final String criterionName; private final AdvancementEvent.AdvancementProgressEvent.ProgressType progressType; - public AdvancementProgressEvent(Player player, Advancement progressed, AdvancementProgress advancementProgress, String criterionName, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) - { + public AdvancementProgressEvent(Player player, AdvancementHolder progressed, AdvancementProgress advancementProgress, String criterionName, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) { super(player, progressed); this.advancementProgress = advancementProgress; this.criterionName = criterionName; this.progressType = progressType; } - /** - * - * {@return The advancement that was progressed} - */ - @Override - public Advancement getAdvancement() - { - return super.getAdvancement(); - } - /** * {@return the progress of the advancement} */ - public AdvancementProgress getAdvancementProgress() - { + public AdvancementProgress getAdvancementProgress() { return advancementProgress; } /** * {@return name of the criterion that was progressed} */ - public String getCriterionName() - { + public String getCriterionName() { return criterionName; } /** * {@return The type of progress for the criterion in this event} */ - public ProgressType getProgressType() - { + public ProgressType getProgressType() { return progressType; } - public enum ProgressType - { + public enum ProgressType { GRANT, REVOKE } } diff --git a/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java b/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java index 8557451efd..bcd5c56515 100644 --- a/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java +++ b/src/main/java/net/minecraftforge/event/level/ChunkDataEvent.java @@ -26,24 +26,20 @@ import net.minecraftforge.eventbus.api.Event; *
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/ -public class ChunkDataEvent extends ChunkEvent -{ +public class ChunkDataEvent extends ChunkEvent { private final CompoundTag data; - public ChunkDataEvent(ChunkAccess chunk, CompoundTag data) - { + public ChunkDataEvent(ChunkAccess chunk, CompoundTag data) { super(chunk); this.data = data; } - public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, CompoundTag data) - { + public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { super(chunk, world); this.data = data; } - public CompoundTag getData() - { + public CompoundTag getData() { return data; } @@ -58,18 +54,15 @@ public class ChunkDataEvent extends ChunkEvent *
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/ - public static class Load extends ChunkDataEvent - { + public static class Load extends ChunkDataEvent { private ChunkStatus.ChunkType status; - public Load(ChunkAccess chunk, CompoundTag data, ChunkStatus.ChunkType status) - { + public Load(ChunkAccess chunk, CompoundTag data, ChunkStatus.ChunkType status) { super(chunk, data); this.status = status; } - public ChunkStatus.ChunkType getStatus() - { + public ChunkStatus.ChunkType getStatus() { return this.status; } } @@ -85,10 +78,8 @@ public class ChunkDataEvent extends ChunkEvent *
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/ - public static class Save extends ChunkDataEvent - { - public Save(ChunkAccess chunk, LevelAccessor world, CompoundTag data) - { + public static class Save extends ChunkDataEvent { + public Save(ChunkAccess chunk, LevelAccessor world, CompoundTag data) { super(chunk, world, data); } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidUtil.java b/src/main/java/net/minecraftforge/fluids/FluidUtil.java index 9f91541dee..6ec56e7901 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidUtil.java +++ b/src/main/java/net/minecraftforge/fluids/FluidUtil.java @@ -573,7 +573,7 @@ public class FluidUtil BlockState destBlockState = level.getBlockState(pos); boolean isDestNonSolid = !destBlockState.isSolid(); boolean isDestReplaceable = destBlockState.canBeReplaced(context); - boolean canDestContainFluid = destBlockState.getBlock() instanceof LiquidBlockContainer && ((LiquidBlockContainer) destBlockState.getBlock()).canPlaceLiquid(level, pos, destBlockState, fluid); + boolean canDestContainFluid = destBlockState.getBlock() instanceof LiquidBlockContainer && ((LiquidBlockContainer) destBlockState.getBlock()).canPlaceLiquid(player, level, pos, destBlockState, fluid); if (!level.isEmptyBlock(pos) && !isDestNonSolid && !isDestReplaceable && !canDestContainFluid) { return false; // Non-air, solid, unreplacable block. We can't put fluid here. diff --git a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BlockWrapper.java b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BlockWrapper.java index f59ce76181..6384faeb73 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BlockWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BlockWrapper.java @@ -20,61 +20,50 @@ import net.minecraftforge.fluids.capability.templates.VoidFluidHandler; * If the block in question inherits from the Forge implementations, * consider using {@link FluidBlockWrapper}. */ -public class BlockWrapper extends VoidFluidHandler -{ +public class BlockWrapper extends VoidFluidHandler { protected final BlockState state; protected final Level world; protected final BlockPos blockPos; - public BlockWrapper(BlockState state, Level world, BlockPos blockPos) - { + public BlockWrapper(BlockState state, Level world, BlockPos blockPos) { this.state = state; this.world = world; this.blockPos = blockPos; } @Override - public int fill(FluidStack resource, FluidAction action) - { + public int fill(FluidStack resource, FluidAction action) { // NOTE: "Filling" means placement in this context! if (resource.getAmount() < FluidType.BUCKET_VOLUME) - { return 0; - } - if (action.execute()) - { + + if (action.execute()) { FluidUtil.destroyBlockOnFluidPlacement(world, blockPos); world.setBlock(blockPos, state, Block.UPDATE_ALL_IMMEDIATE); } + return FluidType.BUCKET_VOLUME; } - public static class LiquidContainerBlockWrapper extends VoidFluidHandler - { + public static class LiquidContainerBlockWrapper extends VoidFluidHandler { protected final LiquidBlockContainer liquidContainer; protected final Level world; protected final BlockPos blockPos; - public LiquidContainerBlockWrapper(LiquidBlockContainer liquidContainer, Level world, BlockPos blockPos) - { + public LiquidContainerBlockWrapper(LiquidBlockContainer liquidContainer, Level world, BlockPos blockPos) { this.liquidContainer = liquidContainer; this.world = world; this.blockPos = blockPos; } @Override - public int fill(FluidStack resource, FluidAction action) - { + public int fill(FluidStack resource, FluidAction action) { // NOTE: "Filling" means placement in this context! - if (resource.getAmount() >= FluidType.BUCKET_VOLUME) - { + if (resource.getAmount() >= FluidType.BUCKET_VOLUME) { BlockState state = world.getBlockState(blockPos); - if (liquidContainer.canPlaceLiquid(world, blockPos, state, resource.getFluid())) - { + if (liquidContainer.canPlaceLiquid(null, world, blockPos, state, resource.getFluid())) { if (action.execute()) - { liquidContainer.placeLiquid(world, blockPos, state, resource.getFluid().getFluidType().getStateForPlacement(world, blockPos, resource)); - } return FluidType.BUCKET_VOLUME; } } diff --git a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java index 7e3eac2386..303e393f7a 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java +++ b/src/main/java/net/minecraftforge/fluids/capability/wrappers/BucketPickupHandlerWrapper.java @@ -85,7 +85,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler { if (action.execute()) { - ItemStack itemStack = bucketPickupHandler.pickupBlock(world, blockPos, world.getBlockState(blockPos)); + ItemStack itemStack = bucketPickupHandler.pickupBlock(null, world, blockPos, world.getBlockState(blockPos)); if (itemStack != ItemStack.EMPTY && itemStack.getItem() instanceof BucketItem bucket) { FluidStack extracted = new FluidStack(bucket.getFluid(), FluidType.BUCKET_VOLUME); @@ -126,7 +126,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler { return new FluidStack(fluidState.getType(), FluidType.BUCKET_VOLUME); } - ItemStack itemStack = bucketPickupHandler.pickupBlock(world, blockPos, world.getBlockState(blockPos)); + ItemStack itemStack = bucketPickupHandler.pickupBlock(null, world, blockPos, world.getBlockState(blockPos)); if (itemStack != ItemStack.EMPTY && itemStack.getItem() instanceof BucketItem bucket) { return new FluidStack(bucket.getFluid(), FluidType.BUCKET_VOLUME); diff --git a/src/main/java/net/minecraftforge/network/ConnectionType.java b/src/main/java/net/minecraftforge/network/ConnectionType.java index 170985fdcd..32a2c995ff 100644 --- a/src/main/java/net/minecraftforge/network/ConnectionType.java +++ b/src/main/java/net/minecraftforge/network/ConnectionType.java @@ -7,30 +7,28 @@ package net.minecraftforge.network; import java.util.function.Function; -public enum ConnectionType -{ - MODDED(s->Integer.valueOf(s.substring(NetworkConstants.FMLNETMARKER.length()))), VANILLA(s->0); +import org.jetbrains.annotations.ApiStatus; + +@SuppressWarnings("unused") +public enum ConnectionType { + MODDED(s -> Integer.valueOf(s.substring(NetworkConstants.FMLNETMARKER.length()))), + VANILLA(s ->0); private final Function versionExtractor; - ConnectionType(Function versionExtractor) - { + ConnectionType(Function versionExtractor) { this.versionExtractor = versionExtractor; } - public static ConnectionType forVersionFlag(String vers) - { + public static ConnectionType forVersionFlag(String vers) { return vers.startsWith(NetworkConstants.FMLNETMARKER) ? MODDED : VANILLA; } - public int getFMLVersionNumber(final String fmlVersion) - { + public int getFMLVersionNumber(final String fmlVersion) { return versionExtractor.apply(fmlVersion); } - public boolean isVanilla() - { + public boolean isVanilla() { return this == VANILLA; } - } diff --git a/src/main/java/net/minecraftforge/network/HandshakeHandler.java b/src/main/java/net/minecraftforge/network/HandshakeHandler.java index b1365dc069..921632e19e 100644 --- a/src/main/java/net/minecraftforge/network/HandshakeHandler.java +++ b/src/main/java/net/minecraftforge/network/HandshakeHandler.java @@ -13,7 +13,6 @@ import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.handshake.ClientIntentionPacket; import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket; -import net.minecraft.network.protocol.login.ServerboundCustomQueryPacket; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.network.ServerLoginPacketListenerImpl; @@ -341,7 +340,7 @@ public class HandshakeHandler public boolean tickServer() { if (!negotiationStarted) { - GameProfile profile = ((ServerLoginPacketListenerImpl) manager.getPacketListener()).gameProfile; + GameProfile profile = ((ServerLoginPacketListenerImpl) manager.getPacketListener()).getAuthenticatedProfile(); PlayerNegotiationEvent event = new PlayerNegotiationEvent(manager, profile, pendingFutures); MinecraftForge.EVENT_BUS.post(event); negotiationStarted = true; diff --git a/src/main/java/net/minecraftforge/network/NetworkDirection.java b/src/main/java/net/minecraftforge/network/NetworkDirection.java index 9d0b6d34d1..574e48043f 100644 --- a/src/main/java/net/minecraftforge/network/NetworkDirection.java +++ b/src/main/java/net/minecraftforge/network/NetworkDirection.java @@ -7,11 +7,14 @@ package net.minecraftforge.network; import it.unimi.dsi.fastutil.objects.Reference2ReferenceArrayMap; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; +import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; +import net.minecraft.network.protocol.common.custom.DiscardedPayload; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.protocol.login.ServerboundCustomQueryPacket; import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket; -import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket; -import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; +import net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket; +import net.minecraft.network.protocol.login.custom.DiscardedQueryAnswerPayload; +import net.minecraft.network.protocol.login.custom.DiscardedQueryPayload; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.LogicalSide; import org.apache.commons.lang3.tuple.Pair; @@ -22,12 +25,11 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -public enum NetworkDirection -{ - PLAY_TO_SERVER(NetworkEvent.ClientCustomPayloadEvent::new, LogicalSide.CLIENT, ServerboundCustomPayloadPacket.class, 1, (d, i, n) -> new ServerboundCustomPayloadPacket(n, d)), - PLAY_TO_CLIENT(NetworkEvent.ServerCustomPayloadEvent::new, LogicalSide.SERVER, ClientboundCustomPayloadPacket.class, 0, (d, i, n) -> new ClientboundCustomPayloadPacket(n, d)), - LOGIN_TO_SERVER(NetworkEvent.ClientCustomPayloadLoginEvent::new, LogicalSide.CLIENT, ServerboundCustomQueryPacket.class, 3, (d, i, n) -> new ServerboundCustomQueryPacket(i, d)), - LOGIN_TO_CLIENT(NetworkEvent.ServerCustomPayloadLoginEvent::new, LogicalSide.SERVER, ClientboundCustomQueryPacket.class, 2, (d, i, n) -> new ClientboundCustomQueryPacket(i, n, d)); +public enum NetworkDirection { + PLAY_TO_SERVER(NetworkEvent.ClientCustomPayloadEvent::new, LogicalSide.CLIENT, ServerboundCustomPayloadPacket.class, 1, NetworkDirection::playServerbound), + PLAY_TO_CLIENT(NetworkEvent.ServerCustomPayloadEvent::new, LogicalSide.SERVER, ClientboundCustomPayloadPacket.class, 0, NetworkDirection::playClientbound), + LOGIN_TO_SERVER(NetworkEvent.ClientCustomPayloadLoginEvent::new, LogicalSide.CLIENT, ServerboundCustomQueryAnswerPacket.class, 3, NetworkDirection::loginServerbound), + LOGIN_TO_CLIENT(NetworkEvent.ServerCustomPayloadLoginEvent::new, LogicalSide.SERVER, ClientboundCustomQueryPacket.class, 2, NetworkDirection::loginClientbound); private final BiFunction, Supplier, NetworkEvent> eventSupplier; private final LogicalSide logicalSide; @@ -42,8 +44,7 @@ public enum NetworkDirection collect(Collectors.toMap(NetworkDirection::getPacketClass, Function.identity(), (m1,m2)->m1, Reference2ReferenceArrayMap::new)); } - private NetworkDirection(BiFunction, Supplier, NetworkEvent> eventSupplier, LogicalSide logicalSide, Class clazz, int i, Factory factory) - { + private NetworkDirection(BiFunction, Supplier, NetworkEvent> eventSupplier, LogicalSide logicalSide, Class clazz, int i, Factory factory) { this.eventSupplier = eventSupplier; this.logicalSide = logicalSide; this.packetClass = clazz; @@ -54,32 +55,47 @@ public enum NetworkDirection private Class getPacketClass() { return packetClass; } - public static > NetworkDirection directionFor(Class customPacket) - { + + public static > NetworkDirection directionFor(Class customPacket) { return packetLookup.get(customPacket); } public NetworkDirection reply() { return NetworkDirection.values()[this.otherWay]; } + public NetworkEvent getEvent(final ICustomPacket buffer, final Supplier manager) { return this.eventSupplier.apply(buffer, manager); } - public LogicalSide getOriginationSide() - { + public LogicalSide getOriginationSide() { return logicalSide; } public LogicalSide getReceptionSide() { return reply().logicalSide; }; @SuppressWarnings("unchecked") - public > ICustomPacket buildPacket(Pair packetData, ResourceLocation channelName) - { + public > ICustomPacket buildPacket(Pair packetData, ResourceLocation channelName) { return this.factory.create(packetData.getLeft(), packetData.getRight(), channelName); } private interface Factory> { ICustomPacket create(FriendlyByteBuf data, Integer index, ResourceLocation channelName); } + + private static ServerboundCustomPayloadPacket playServerbound(FriendlyByteBuf data, Integer index, ResourceLocation channelName) { + return new ServerboundCustomPayloadPacket(new DiscardedPayload(channelName, data)); + } + + private static ClientboundCustomPayloadPacket playClientbound(FriendlyByteBuf data, Integer index, ResourceLocation channelName) { + return new ClientboundCustomPayloadPacket(new DiscardedPayload(channelName, data)); + } + + private static ServerboundCustomQueryAnswerPacket loginServerbound(FriendlyByteBuf data, Integer index, ResourceLocation channelName) { + return new ServerboundCustomQueryAnswerPacket(index, new DiscardedQueryAnswerPayload(data)); + } + + private static ClientboundCustomQueryPacket loginClientbound(FriendlyByteBuf data, Integer index, ResourceLocation channelName) { + return new ClientboundCustomQueryPacket(index, new DiscardedQueryPayload(channelName, data)); + } } diff --git a/src/main/java/net/minecraftforge/network/NetworkHooks.java b/src/main/java/net/minecraftforge/network/NetworkHooks.java index 5cd7eeb7cb..8639d094d2 100644 --- a/src/main/java/net/minecraftforge/network/NetworkHooks.java +++ b/src/main/java/net/minecraftforge/network/NetworkHooks.java @@ -41,35 +41,41 @@ import net.minecraft.core.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerContainerEvent; import net.minecraftforge.fml.config.ConfigTracker; + +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -public class NetworkHooks -{ +@ApiStatus.Internal +public class NetworkHooks { private static final Logger LOGGER = LogManager.getLogger(); - public static String getFMLVersion(final String ip) - { - return ip.contains("\0") ? Objects.equals(ip.split("\0")[1], NetworkConstants.NETVERSION) ? NetworkConstants.NETVERSION : ip.split("\0")[1] : NetworkConstants.NOVERSION; + public static String getFMLVersion(final String ip) { + int idx = ip.indexOf('\0'); + if (idx == -1) + return NetworkConstants.NOVERSION; + + for (var pt : ip.split("\0")) { + if (pt.startsWith("FML")) + return pt; + } + + return NetworkConstants.NOVERSION; } - public static ConnectionType getConnectionType(final Supplier connection) - { + public static ConnectionType getConnectionType(final Supplier connection) { return getConnectionType(connection.get().channel()); } - public static ConnectionType getConnectionType(ChannelHandlerContext context) - { + public static ConnectionType getConnectionType(ChannelHandlerContext context) { return getConnectionType(context.channel()); } - private static ConnectionType getConnectionType(Channel channel) - { + private static ConnectionType getConnectionType(Channel channel) { return ConnectionType.forVersionFlag(channel.attr(NetworkConstants.FML_NETVERSION).get()); } @SuppressWarnings("unchecked") - public static Packet getEntitySpawningPacket(Entity entity) - { + public static Packet getEntitySpawningPacket(Entity entity) { // ClientboundCustomPayloadPacket is an instance of Packet return (Packet) NetworkConstants.playChannel.toVanillaPacket(new PlayMessages.SpawnEntity(entity), NetworkDirection.PLAY_TO_CLIENT); } @@ -94,14 +100,13 @@ public class NetworkHooks throw new IllegalStateException("Invalid packet received, aborting connection"); } } - public static void registerServerLoginChannel(Connection manager, ClientIntentionPacket packet) - { - manager.channel().attr(NetworkConstants.FML_NETVERSION).set(packet.getFMLVersion()); + + public static void registerServerLoginChannel(Connection manager, ClientIntentionPacket packet) { + manager.channel().attr(NetworkConstants.FML_NETVERSION).set(NetworkHooks.getFMLVersion(packet.hostName())); HandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_CLIENT); } - public synchronized static void registerClientLoginChannel(Connection manager) - { + public synchronized static void registerClientLoginChannel(Connection manager) { manager.channel().attr(NetworkConstants.FML_NETVERSION).set(NetworkConstants.NOVERSION); HandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_SERVER); } @@ -115,17 +120,7 @@ public class NetworkHooks MCRegisterPacketHandler.INSTANCE.sendRegistry(manager, NetworkDirection.valueOf(direction)); } - //TODO Dimensions.. -/* public synchronized static void sendDimensionDataPacket(NetworkManager manager, ServerPlayerEntity player) { - // don't send vanilla dims - if (player.dimension.isVanilla()) return; - // don't sent to local - we already have a valid dim registry locally - if (manager.isLocalChannel()) return; - FMLNetworkConstants.playChannel.sendTo(new FMLPlayMessages.DimensionInfoMessage(player.dimension), manager, NetworkDirection.PLAY_TO_CLIENT); - }*/ - - public static boolean isVanillaConnection(Connection manager) - { + public static boolean isVanillaConnection(Connection manager) { if (manager == null || manager.channel() == null) throw new NullPointerException("ARGH! Network Manager is null (" + manager != null ? "CHANNEL" : "MANAGER"+")" ); return getConnectionType(() -> manager) == ConnectionType.VANILLA; } @@ -139,9 +134,8 @@ public class NetworkHooks } } - public static boolean tickNegotiation(ServerLoginPacketListenerImpl netHandlerLoginServer, Connection networkManager, ServerPlayer player) - { - return HandshakeHandler.tickLogin(networkManager); + public static boolean tickNegotiation(Connection manager) { + return HandshakeHandler.tickLogin(manager); } /** @@ -153,8 +147,7 @@ public class NetworkHooks * @param player The player to open the GUI for * @param containerSupplier A supplier of container properties including the registry name of the container */ - public static void openScreen(ServerPlayer player, MenuProvider containerSupplier) - { + public static void openScreen(ServerPlayer player, MenuProvider containerSupplier) { openScreen(player, containerSupplier, buf -> {}); } @@ -168,10 +161,10 @@ public class NetworkHooks * @param containerSupplier A supplier of container properties including the registry name of the container * @param pos A block pos, which will be encoded into the auxillary data for this request */ - public static void openScreen(ServerPlayer player, MenuProvider containerSupplier, BlockPos pos) - { + public static void openScreen(ServerPlayer player, MenuProvider containerSupplier, BlockPos pos) { openScreen(player, containerSupplier, buf -> buf.writeBlockPos(pos)); } + /** * Request to open a GUI on the client, from the server * @@ -184,8 +177,7 @@ public class NetworkHooks * @param containerSupplier A supplier of container properties including the registry name of the container * @param extraDataWriter Consumer to write any additional data the GUI needs */ - public static void openScreen(ServerPlayer player, MenuProvider containerSupplier, Consumer extraDataWriter) - { + public static void openScreen(ServerPlayer player, MenuProvider containerSupplier, Consumer extraDataWriter) { if (player.level().isClientSide) return; player.doCloseContainer(); player.nextContainerCounter(); @@ -206,7 +198,7 @@ public class NetworkHooks return; MenuType type = c.getType(); PlayMessages.OpenContainer msg = new PlayMessages.OpenContainer(type, openContainerId, containerSupplier.getDisplayName(), output); - NetworkConstants.playChannel.sendTo(msg, player.connection.connection, NetworkDirection.PLAY_TO_CLIENT); + NetworkConstants.playChannel.sendTo(msg, player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT); player.containerMenu = c; player.initMenu(player.containerMenu); @@ -217,8 +209,7 @@ public class NetworkHooks * Updates the current ConnectionData instance with new mod or channel data if the old instance did not have either of these yet, * or creates a new ConnectionData instance with the new data if the current ConnectionData instance doesn't exist yet. */ - static void appendConnectionData(Connection mgr, Map> modData, Map channels) - { + static void appendConnectionData(Connection mgr, Map> modData, Map channels) { ConnectionData oldData = mgr.channel().attr(NetworkConstants.FML_CONNECTION_DATA).get(); oldData = oldData != null ? new ConnectionData(oldData.getModData().isEmpty() ? modData : oldData.getModData(), oldData.getChannels().isEmpty() ? channels : oldData.getChannels()) : new ConnectionData(modData, channels); @@ -226,20 +217,17 @@ public class NetworkHooks } @Nullable - public static ConnectionData getConnectionData(Connection mgr) - { + public static ConnectionData getConnectionData(Connection mgr) { return mgr.channel().attr(NetworkConstants.FML_CONNECTION_DATA).get(); } @Nullable - public static ModMismatchData getModMismatchData(Connection mgr) - { + public static ModMismatchData getModMismatchData(Connection mgr) { return mgr.channel().attr(NetworkConstants.FML_MOD_MISMATCH_DATA).get(); } @Nullable - public static MCRegisterPacketHandler.ChannelList getChannelList(Connection mgr) - { + public static MCRegisterPacketHandler.ChannelList getChannelList(Connection mgr) { return mgr.channel().attr(NetworkConstants.FML_MC_REGISTRY).get(); } } diff --git a/src/main/java/net/minecraftforge/network/PacketDistributor.java b/src/main/java/net/minecraftforge/network/PacketDistributor.java index 23e55e1d32..b6874491d0 100644 --- a/src/main/java/net/minecraftforge/network/PacketDistributor.java +++ b/src/main/java/net/minecraftforge/network/PacketDistributor.java @@ -200,7 +200,7 @@ public class PacketDistributor { } private Consumer> playerConsumer(final Supplier entityPlayerMPSupplier) { - return p -> entityPlayerMPSupplier.get().connection.connection.send(p); + return p -> entityPlayerMPSupplier.get().connection.getConnection().send(p); } private Consumer> playerListDimConsumer(final Supplier> dimensionTypeSupplier) { return p->getServer().getPlayerList().broadcastAll(p, dimensionTypeSupplier.get()); diff --git a/src/main/java/net/minecraftforge/network/filters/ForgeConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/filters/ForgeConnectionNetworkFilter.java index fce8e9c27e..763ecd3296 100644 --- a/src/main/java/net/minecraftforge/network/filters/ForgeConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/ForgeConnectionNetworkFilter.java @@ -5,6 +5,7 @@ package net.minecraftforge.network.filters; +/* import java.util.List; import java.util.Map; import java.util.function.BiConsumer; @@ -24,7 +25,7 @@ import org.jetbrains.annotations.Nullable; /** * Network filter for forge-forge connections. - */ + * / @ChannelHandler.Sharable public class ForgeConnectionNetworkFilter extends VanillaPacketFilter { @@ -65,3 +66,4 @@ public class ForgeConnectionNetworkFilter extends VanillaPacketFilter } } +*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/network/filters/NetworkFilters.java b/src/main/java/net/minecraftforge/network/filters/NetworkFilters.java index 509c98128b..d215281a14 100644 --- a/src/main/java/net/minecraftforge/network/filters/NetworkFilters.java +++ b/src/main/java/net/minecraftforge/network/filters/NetworkFilters.java @@ -22,8 +22,8 @@ public class NetworkFilters private static final Logger LOGGER = LogManager.getLogger(); private static final Map> instances = ImmutableMap.of( - "forge:vanilla_filter", manager -> new VanillaConnectionNetworkFilter(), - "forge:forge_fixes", ForgeConnectionNetworkFilter::new + "forge:vanilla_filter", manager -> new VanillaConnectionNetworkFilter()/*, + "forge:forge_fixes", ForgeConnectionNetworkFilter::new*/ ); public static void injectIfNecessary(Connection manager) diff --git a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java index 5ce436e0c4..4b97b25c55 100644 --- a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java @@ -7,18 +7,13 @@ package net.minecraftforge.network.filters; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.function.BiConsumer; -import java.util.stream.Collectors; - import io.netty.channel.ChannelHandler; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.Commands; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.gametest.framework.TestClassNameArgument; @@ -27,18 +22,11 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundCommandsPacket; import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket; -import net.minecraft.network.protocol.game.ClientboundUpdateTagsPacket; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tags.TagNetworkSerialization; -import net.minecraft.world.flag.FeatureFlagSet; -import net.minecraft.world.flag.FeatureFlags; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryManager; -import net.minecraftforge.server.ServerLifecycleHooks; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -61,7 +49,8 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter ImmutableMap.>, BiConsumer, List>>>builder() .put(handler(ClientboundUpdateAttributesPacket.class, VanillaConnectionNetworkFilter::filterEntityProperties)) .put(handler(ClientboundCommandsPacket.class, VanillaConnectionNetworkFilter::filterCommandList)) - .put(handler(ClientboundUpdateTagsPacket.class, VanillaConnectionNetworkFilter::filterCustomTagTypes)) + // TODO Filter tags + //.put(handler(ClientboundUpdateTagsPacket.class, VanillaConnectionNetworkFilter::filterCustomTagTypes)) .build() ); } @@ -113,12 +102,14 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter * Filters out custom tag types that the vanilla client won't recognize. * It prevents a rare error from logging and reduces the packet size */ + /* private static ClientboundUpdateTagsPacket filterCustomTagTypes(ClientboundUpdateTagsPacket packet) { Map>, TagNetworkSerialization.NetworkPayload> tags = packet.getTags() .entrySet().stream().filter(e -> isVanillaRegistry(e.getKey().location())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return new ClientboundUpdateTagsPacket(tags); } + */ private static boolean isVanillaRegistry(ResourceLocation location) { diff --git a/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java b/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java index ea6ee42fab..5a04228958 100644 --- a/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.network.filters; - +/* import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; @@ -14,7 +14,6 @@ import io.netty.buffer.Unpooled; import net.minecraft.network.*; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; -import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.*; import net.minecraftforge.network.event.EventNetworkChannel; @@ -25,9 +24,8 @@ import org.apache.logging.log4j.Logger; /** * A custom payload channel that allows sending vanilla server-to-client packets, even if they would normally * be too large for the vanilla protocol. This is achieved by splitting them into multiple custom payload packets. - */ -public class VanillaPacketSplitter -{ + * / +public class VanillaPacketSplitter { private static final Logger LOGGER = LogManager.getLogger(); @@ -43,8 +41,7 @@ public class VanillaPacketSplitter private static final byte STATE_FIRST = 1; private static final byte STATE_LAST = 2; - public static void register() - { + public static void register() { Predicate versionCheck = NetworkRegistry.acceptMissingOr(VERSION); EventNetworkChannel channel = NetworkRegistry.newEventChannel(CHANNEL, () -> VERSION, versionCheck, versionCheck); channel.addListener(VanillaPacketSplitter::onClientPacket); @@ -53,43 +50,29 @@ public class VanillaPacketSplitter /** * Append the given packet to the given list. If the packet needs to be split, multiple packets will be appened. * Otherwise only the packet itself. - */ - public static void appendPackets(ConnectionProtocol protocol, PacketFlow direction, Packet packet, List> out) - { - if (heuristicIsDefinitelySmallEnough(packet)) - { + * / + public static void appendPackets(ConnectionProtocol protocol, PacketFlow direction, Packet packet, List> out) { + if (heuristicIsDefinitelySmallEnough(packet)) { out.add(packet); - } - else - { + } else { FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); packet.write(buf); - if (buf.readableBytes() <= PROTOCOL_MAX) - { + if (buf.readableBytes() <= PROTOCOL_MAX) { buf.release(); out.add(packet); - } - else - { + } else { int parts = (int)Math.ceil(((double)buf.readableBytes()) / PART_SIZE); - if (parts == 1) - { + if (parts == 1) { buf.release(); out.add(packet); - } - else - { - for (int part = 0; part < parts; part++) - { + } else { + for (int part = 0; part < parts; part++) { ByteBuf partPrefix; - if (part == 0) - { + if (part == 0) { partPrefix = Unpooled.buffer(5); partPrefix.writeByte(STATE_FIRST); new FriendlyByteBuf(partPrefix).writeVarInt(protocol.getPacketId(direction, packet)); - } - else - { + } else { partPrefix = Unpooled.buffer(1); partPrefix.writeByte(part == parts - 1 ? STATE_LAST : 0); } @@ -108,15 +91,13 @@ public class VanillaPacketSplitter } } - private static boolean heuristicIsDefinitelySmallEnough(Packet packet) - { + private static boolean heuristicIsDefinitelySmallEnough(Packet packet) { return false; } private static final List receivedBuffers = new ArrayList<>(); - private static void onClientPacket(NetworkEvent.ServerCustomPayloadEvent event) - { + private static void onClientPacket(NetworkEvent.ServerCustomPayloadEvent event) { NetworkEvent.Context ctx = event.getSource().get(); PacketFlow direction = ctx.getDirection() == NetworkDirection.PLAY_TO_CLIENT ? PacketFlow.CLIENTBOUND : PacketFlow.SERVERBOUND; ConnectionProtocol protocol = ConnectionProtocol.PLAY; @@ -126,27 +107,21 @@ public class VanillaPacketSplitter FriendlyByteBuf buf = event.getPayload(); byte state = buf.readByte(); - if (state == STATE_FIRST) - { - if (!receivedBuffers.isEmpty()) - { + if (state == STATE_FIRST) { + if (!receivedBuffers.isEmpty()) { LOGGER.warn("forge:split received out of order - inbound buffer not empty when receiving first"); receivedBuffers.clear(); } } buf.retain(); // retain the buffer, it is released after this handler otherwise receivedBuffers.add(buf); - if (state == STATE_LAST) - { + if (state == STATE_LAST) { FriendlyByteBuf full = new FriendlyByteBuf(Unpooled.wrappedBuffer(receivedBuffers.toArray(new FriendlyByteBuf[0]))); int packetId = full.readVarInt(); Packet packet = protocol.createPacket(direction, packetId, full); - if (packet == null) - { + if (packet == null) { LOGGER.error("Received invalid packet ID {} in forge:split", packetId); - } - else - { + } else { receivedBuffers.clear(); full.release(); ctx.enqueueWork(() -> genericsFtw(packet, event.getSource().get().getNetworkManager().getPacketListener())); @@ -155,32 +130,25 @@ public class VanillaPacketSplitter } @SuppressWarnings("unchecked") - private static void genericsFtw(Packet pkt, Object listener) - { + private static void genericsFtw(Packet pkt, Object listener) { pkt.handle((T) listener); } - public enum RemoteCompatibility - { + public enum RemoteCompatibility { ABSENT, PRESENT } - public static RemoteCompatibility getRemoteCompatibility(Connection manager) - { + public static RemoteCompatibility getRemoteCompatibility(Connection manager) { ConnectionData connectionData = NetworkHooks.getConnectionData(manager); if (connectionData != null && connectionData.getChannels().containsKey(CHANNEL)) - { return RemoteCompatibility.PRESENT; - } else - { return RemoteCompatibility.ABSENT; - } } - public static boolean isRemoteCompatible(Connection manager) - { + public static boolean isRemoteCompatible(Connection manager) { return getRemoteCompatibility(manager) != RemoteCompatibility.ABSENT; } } +*/ \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java b/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java index d006ea684d..f95f467317 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java +++ b/src/main/java/net/minecraftforge/registries/ForgeDeferredRegistriesSetup.java @@ -25,7 +25,7 @@ public class ForgeDeferredRegistriesSetup } ForgeRegistries.DEFERRED_ENTITY_DATA_SERIALIZERS.register(modEventBus); - ForgeRegistries.DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus); + //ForgeRegistries.DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus); ForgeRegistries.DEFERRED_BIOME_MODIFIER_SERIALIZERS.register(modEventBus); ForgeRegistries.DEFERRED_FLUID_TYPES.register(modEventBus); ForgeRegistries.DEFERRED_STRUCTURE_MODIFIER_SERIALIZERS.register(modEventBus); diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java index 2e14b2bd90..66d10b424a 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java @@ -43,15 +43,10 @@ import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraftforge.common.Tags; -import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.world.BiomeModifier; import net.minecraftforge.fluids.FluidType; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.holdersets.HolderSetType; -import java.util.Arrays; -import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.function.Supplier; import net.minecraftforge.common.world.StructureModifier; @@ -109,12 +104,12 @@ public class ForgeRegistries * Use {@link Keys#ENTITY_DATA_SERIALIZERS} to create a {@link DeferredRegister}. */ public static final Supplier>> ENTITY_DATA_SERIALIZERS = DEFERRED_ENTITY_DATA_SERIALIZERS.makeRegistry(GameData::getDataSerializersRegistryBuilder); - static final DeferredRegister> DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS.location().getNamespace()); + //static final DeferredRegister> DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS.location().getNamespace()); /** * Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned. * Use {@link Keys#GLOBAL_LOOT_MODIFIER_SERIALIZERS} to create a {@link DeferredRegister}. */ - public static final Supplier>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.makeRegistry(GameData::getGLMSerializersRegistryBuilder); + //public static final Supplier>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.makeRegistry(GameData::getGLMSerializersRegistryBuilder); static final DeferredRegister> DEFERRED_BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.BIOME_MODIFIER_SERIALIZERS, Keys.BIOME_MODIFIER_SERIALIZERS.location().getNamespace()); /** * Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned. @@ -184,7 +179,7 @@ public class ForgeRegistries // Forge public static final ResourceKey>> ENTITY_DATA_SERIALIZERS = key("forge:entity_data_serializers"); - public static final ResourceKey>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = key("forge:global_loot_modifier_serializers"); + //public static final ResourceKey>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = key("forge:global_loot_modifier_serializers"); public static final ResourceKey>> BIOME_MODIFIER_SERIALIZERS = key("forge:biome_modifier_serializers"); public static final ResourceKey>> STRUCTURE_MODIFIER_SERIALIZERS = key("forge:structure_modifier_serializers"); public static final ResourceKey> FLUID_TYPES = key("forge:fluid_type"); diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index 2f806d19fa..8c3fddf442 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -30,6 +30,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.effect.MobEffect; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.entity.ai.attributes.Attribute; @@ -38,7 +39,10 @@ import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.levelgen.DebugLevelSource; @@ -46,7 +50,6 @@ import net.minecraft.world.level.material.Fluid; import net.minecraftforge.common.CreativeModeTabRegistry; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.common.util.LogMessageAdapter; import net.minecraftforge.common.world.BiomeModifier; import net.minecraftforge.common.world.StructureModifier; @@ -103,12 +106,12 @@ public class GameData makeRegistry(Keys.BLOCKS, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").intrusiveHolderCallback(Block::builtInRegistryHolder).create(); makeRegistry(Keys.FLUIDS, "empty").intrusiveHolderCallback(Fluid::builtInRegistryHolder).create(); makeRegistry(Keys.ITEMS, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").intrusiveHolderCallback(Item::builtInRegistryHolder).create(); - makeRegistry(Keys.MOB_EFFECTS).legacyName("potions").create(); + makeRegistry(Keys.MOB_EFFECTS).legacyName("potions").intrusiveHolderCallback(MobEffect::builtInRegistryHolder).create(); makeRegistry(Keys.SOUND_EVENTS).legacyName("soundevents").create(); - makeRegistry(Keys.POTIONS, "empty").legacyName("potiontypes").create(); - makeRegistry(Keys.ENCHANTMENTS).legacyName("enchantments").create(); + makeRegistry(Keys.POTIONS, "empty").legacyName("potiontypes").intrusiveHolderCallback(Potion::builtInRegistryHolder).create(); + makeRegistry(Keys.ENCHANTMENTS).legacyName("enchantments").intrusiveHolderCallback(Enchantment::builtInRegistryHolder).create(); makeRegistry(Keys.ENTITY_TYPES, "pig").legacyName("entities").intrusiveHolderCallback(EntityType::builtInRegistryHolder).create(); - makeRegistry(Keys.BLOCK_ENTITY_TYPES).disableSaving().legacyName("blockentities").create(); + makeRegistry(Keys.BLOCK_ENTITY_TYPES).disableSaving().legacyName("blockentities").intrusiveHolderCallback(BlockEntityType::builtInRegistryHolder).create(); makeRegistry(Keys.PARTICLE_TYPES).disableSaving().create(); makeRegistry(Keys.MENU_TYPES).disableSaving().create(); makeRegistry(Keys.PAINTING_VARIANTS, "kebab").create(); @@ -143,10 +146,12 @@ public class GameData return makeRegistry(Keys.ENTITY_DATA_SERIALIZERS, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides(); } + /* static RegistryBuilder> getGLMSerializersRegistryBuilder() { return makeRegistry(Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS).disableSaving().disableSync(); } + */ static RegistryBuilder> getBiomeModifierSerializersRegistryBuilder() { diff --git a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java index aa56259254..96f410d546 100644 --- a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java +++ b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java @@ -22,6 +22,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTestServer; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.repository.PackSource; import net.minecraft.server.packs.repository.RepositorySource; @@ -52,6 +53,7 @@ import net.minecraft.network.ConnectionProtocol; import net.minecraft.network.protocol.handshake.ClientIntentionPacket; import net.minecraft.network.protocol.login.ClientboundLoginDisconnectPacket; import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.Pack.Info; import net.minecraft.server.MinecraftServer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; @@ -159,9 +161,10 @@ public class ServerLifecycleHooks return false; } - if (packet.getIntention() == ConnectionProtocol.LOGIN) { - final ConnectionType connectionType = ConnectionType.forVersionFlag(packet.getFMLVersion()); - final int versionNumber = connectionType.getFMLVersionNumber(packet.getFMLVersion()); + if (packet.nextProtocol() == ConnectionProtocol.LOGIN) { + var fmlVersion = NetworkHooks.getFMLVersion(packet.hostName()); + final ConnectionType connectionType = ConnectionType.forVersionFlag(fmlVersion); + final int versionNumber = connectionType.getFMLVersionNumber(fmlVersion); if (connectionType == ConnectionType.MODDED && versionNumber != NetworkConstants.FMLNETVERSION) { rejectConnection(manager, connectionType, "This modded server is not impl compatible with your modded client. Please verify your Forge version closely matches the server. Got net version " + versionNumber + " this server is net version " + NetworkConstants.FMLNETVERSION); @@ -174,7 +177,7 @@ public class ServerLifecycleHooks } } - if (packet.getIntention() == ConnectionProtocol.STATUS) return true; + if (packet.nextProtocol() == ConnectionProtocol.STATUS) return true; NetworkHooks.registerServerLoginChannel(manager, packet); return true; @@ -182,11 +185,8 @@ public class ServerLifecycleHooks } private static void rejectConnection(final Connection manager, ConnectionType type, String message) { - manager.setProtocol(ConnectionProtocol.LOGIN); - String ip = "local"; - if (manager.getRemoteAddress() != null) - ip = manager.getRemoteAddress().toString(); - LOGGER.info(SERVERHOOKS, "[{}] Disconnecting {} connection attempt: {}", ip, type, message); + //manager.setProtocol(ConnectionProtocol.LOGIN); Pretty sure things auto swap in ProtocolSwapHandler + LOGGER.info(SERVERHOOKS, "[{}] Disconnecting {} connection attempt: {}", manager.getLoggableAddress(true), type, message); // TODO: Respect logIP setting MutableComponent text = Component.literal(message); manager.send(new ClientboundLoginDisconnectPacket(text)); manager.disconnect(text); @@ -208,7 +208,21 @@ public class ServerLifecycleHooks IModInfo mod = e.getKey().getModInfos().get(0); if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod" final String name = "mod:" + mod.getModId(); - final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, id -> e.getValue(), PackType.SERVER_DATA, Pack.Position.BOTTOM, PackSource.DEFAULT); + + var supplier = new Pack.ResourcesSupplier() { + @Override + public PackResources openPrimary(String path) { + return e.getValue(); + } + + @Override + public PackResources openFull(String path, Info info) { + return e.getValue(); // TODO: composite + } + + }; + + final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, supplier, PackType.SERVER_DATA, Pack.Position.BOTTOM, PackSource.DEFAULT); if (modPack == null) { // Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey())); diff --git a/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java b/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java index 9734713a68..557ad55d2b 100644 --- a/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java +++ b/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java @@ -13,34 +13,25 @@ import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.locale.Language; import net.minecraftforge.network.ConnectionType; import net.minecraftforge.network.NetworkHooks; -import org.spongepowered.asm.mixin.Mutable; - import java.util.Locale; -public class TextComponentHelper -{ +public class TextComponentHelper { private TextComponentHelper() {} /** * Detects when sending to a vanilla client and falls back to sending english, * since they don't have the lang data necessary to translate on the client. */ - public static MutableComponent createComponentTranslation(CommandSource source, final String translation, final Object... args) - { + public static MutableComponent createComponentTranslation(CommandSource source, final String translation, final Object... args) { if (isVanillaClient(source)) - { return Component.literal(String.format(Locale.ENGLISH, Language.getInstance().getOrDefault(translation), args)); - } return Component.translatable(translation, args); } - private static boolean isVanillaClient(CommandSource sender) - { - if (sender instanceof ServerPlayer) - { - ServerPlayer playerMP = (ServerPlayer) sender; + private static boolean isVanillaClient(CommandSource sender) { + if (sender instanceof ServerPlayer playerMP) { ServerGamePacketListenerImpl channel = playerMP.connection; - return NetworkHooks.getConnectionType(()->channel.connection) == ConnectionType.VANILLA; + return NetworkHooks.getConnectionType(channel::getConnection) == ConnectionType.VANILLA; } return false; } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 779205ed00..cb6e4cf848 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,4 +1,3 @@ -public net.minecraft.advancements.CriteriaTriggers m_10595_(Lnet/minecraft/advancements/CriterionTrigger;)Lnet/minecraft/advancements/CriterionTrigger; # register default net.minecraft.client.KeyMapping f_90817_ # isDown public net.minecraft.client.Minecraft f_90987_ # textureManager public net.minecraft.client.Minecraft m_91271_()V # createSearchTrees @@ -21,7 +20,38 @@ protected net.minecraft.client.gui.Gui f_193829_ # lastAutosaveIndicatorValue protected net.minecraft.client.gui.Gui f_193830_ # SAVING_TEXT protected net.minecraft.client.gui.Gui f_193831_ # AUTOSAVE_FADE_SPEED_FACTOR protected net.minecraft.client.gui.Gui f_238167_ # chatDisabledByPlayerShown -protected net.minecraft.client.gui.Gui f_279580_ # GUI_ICONS_LOCATION +protected net.minecraft.client.gui.Gui f_290334_ # HEART_VEHICLE_HALF_SPRITE +protected net.minecraft.client.gui.Gui f_290366_ # FOOD_FULL_HUNGER_SPRITE +protected net.minecraft.client.gui.Gui f_290368_ # HOTBAR_SELECTION_SPRITE +protected net.minecraft.client.gui.Gui f_290436_ # ARMOR_FULL_SPRITE +protected net.minecraft.client.gui.Gui f_290513_ # EFFECT_BACKGROUND_SPRITE +protected net.minecraft.client.gui.Gui f_290694_ # FOOD_EMPTY_SPRITE +protected net.minecraft.client.gui.Gui f_290711_ # CROSSHAIR_ATTACK_INDICATOR_PROGRESS_SPRITE +protected net.minecraft.client.gui.Gui f_290833_ # HOTBAR_ATTACK_INDICATOR_BACKGROUND_SPRITE +protected net.minecraft.client.gui.Gui f_290939_ # HEART_VEHICLE_CONTAINER_SPRITE +protected net.minecraft.client.gui.Gui f_291002_ # FOOD_HALF_SPRITE +protected net.minecraft.client.gui.Gui f_291104_ # JUMP_BAR_COOLDOWN_SPRITE +protected net.minecraft.client.gui.Gui f_291149_ # HOTBAR_SPRITE +protected net.minecraft.client.gui.Gui f_291256_ # HEART_VEHICLE_FULL_SPRITE +protected net.minecraft.client.gui.Gui f_291301_ # HOTBAR_ATTACK_INDICATOR_PROGRESS_SPRITE +protected net.minecraft.client.gui.Gui f_291320_ # debugOverlay +protected net.minecraft.client.gui.Gui f_291322_ # HOTBAR_OFFHAND_LEFT_SPRITE +protected net.minecraft.client.gui.Gui f_291360_ # CROSSHAIR_ATTACK_INDICATOR_BACKGROUND_SPRITE +protected net.minecraft.client.gui.Gui f_291363_ # CROSSHAIR_ATTACK_INDICATOR_FULL_SPRITE +protected net.minecraft.client.gui.Gui f_291473_ # EFFECT_BACKGROUND_AMBIENT_SPRITE +protected net.minecraft.client.gui.Gui f_291483_ # JUMP_BAR_BACKGROUND_SPRITE +protected net.minecraft.client.gui.Gui f_291486_ # FOOD_EMPTY_HUNGER_SPRITE +protected net.minecraft.client.gui.Gui f_291491_ # EXPERIENCE_BAR_PROGRESS_SPRITE +protected net.minecraft.client.gui.Gui f_291577_ # FOOD_HALF_HUNGER_SPRITE +protected net.minecraft.client.gui.Gui f_291609_ # AIR_BURSTING_SPRITE +protected net.minecraft.client.gui.Gui f_291650_ # FOOD_FULL_SPRITE +protected net.minecraft.client.gui.Gui f_291741_ # EXPERIENCE_BAR_BACKGROUND_SPRITE +protected net.minecraft.client.gui.Gui f_291785_ # ARMOR_HALF_SPRITE +protected net.minecraft.client.gui.Gui f_291820_ # JUMP_BAR_PROGRESS_SPRITE +protected net.minecraft.client.gui.Gui f_291829_ # CROSSHAIR_SPRITE +protected net.minecraft.client.gui.Gui f_291833_ # AIR_SPRITE +protected net.minecraft.client.gui.Gui f_291864_ # HOTBAR_OFFHAND_RIGHT_SPRITE +protected net.minecraft.client.gui.Gui f_291879_ # ARMOR_EMPTY_SPRITE protected net.minecraft.client.gui.Gui f_92970_ # titleFadeInTime protected net.minecraft.client.gui.Gui f_92971_ # titleStayTime protected net.minecraft.client.gui.Gui f_92972_ # titleFadeOutTime @@ -32,7 +62,6 @@ protected net.minecraft.client.gui.Gui f_92976_ # healthBlinkTime protected net.minecraft.client.gui.Gui f_92977_ # screenWidth protected net.minecraft.client.gui.Gui f_92978_ # screenHeight protected net.minecraft.client.gui.Gui f_92981_ # VIGNETTE_LOCATION -protected net.minecraft.client.gui.Gui f_92982_ # WIDGETS_LOCATION protected net.minecraft.client.gui.Gui f_92983_ # PUMPKIN_BLUR_LOCATION protected net.minecraft.client.gui.Gui f_92984_ # DEMO_EXPIRED_TEXT protected net.minecraft.client.gui.Gui f_92985_ # random @@ -45,7 +74,6 @@ protected net.minecraft.client.gui.Gui f_92991_ # overlayMessageTime protected net.minecraft.client.gui.Gui f_92992_ # animateOverlayMessageColor protected net.minecraft.client.gui.Gui f_92993_ # toolHighlightTimer protected net.minecraft.client.gui.Gui f_92994_ # lastToolHighlight -protected net.minecraft.client.gui.Gui f_92995_ # debugScreen protected net.minecraft.client.gui.Gui f_92996_ # subtitleOverlay protected net.minecraft.client.gui.Gui f_92997_ # spectatorGui protected net.minecraft.client.gui.Gui f_92998_ # tabList @@ -64,10 +92,10 @@ protected net.minecraft.client.gui.Gui m_280379_(Lnet/minecraft/client/gui/GuiGr public net.minecraft.client.gui.Gui m_280518_(FLnet/minecraft/client/gui/GuiGraphics;)V # renderHotbar public net.minecraft.client.gui.Gui m_280523_(Lnet/minecraft/client/gui/GuiGraphics;)V # renderEffects protected net.minecraft.client.gui.Gui m_93039_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Font;III)V # drawBackdrop +protected net.minecraft.client.gui.components.AbstractButton f_290895_ # SPRITES protected net.minecraft.client.gui.components.AbstractSelectionList$Entry f_93521_ # list -public net.minecraft.client.gui.components.AbstractSliderButton f_263683_ # SLIDER_LOCATION -protected net.minecraft.client.gui.components.AbstractSliderButton m_264270_()I # getHandleTextureY -protected net.minecraft.client.gui.components.AbstractSliderButton m_264355_()I # getTextureY +protected net.minecraft.client.gui.components.AbstractSliderButton m_293290_()Lnet/minecraft/resources/ResourceLocation; # getHandleSprite +protected net.minecraft.client.gui.components.AbstractSliderButton m_293389_()Lnet/minecraft/resources/ResourceLocation; # getSprite protected net.minecraft.client.gui.components.DebugScreenOverlay f_94032_ # block protected net.minecraft.client.gui.components.DebugScreenOverlay f_94033_ # liquid public net.minecraft.client.gui.screens.MenuScreens m_96206_(Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/gui/screens/MenuScreens$ScreenConstructor;)V # register @@ -170,23 +198,16 @@ protected net.minecraft.data.loot.BlockLootSubProvider m_246900_(Lnet/minecraft/ protected net.minecraft.data.loot.EntityLootSubProvider m_245552_(Lnet/minecraft/world/entity/EntityType;)Z # canHaveLootTable protected net.minecraft.data.recipes.RecipeProvider f_236355_ # recipePathProvider protected net.minecraft.data.recipes.RecipeProvider f_236356_ # advancementPathProvider -protected net.minecraft.data.recipes.RecipeProvider m_125979_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/advancements/critereon/EnterBlockTrigger$TriggerInstance; # insideOf -protected net.minecraft.data.recipes.RecipeProvider m_126011_([Lnet/minecraft/advancements/critereon/ItemPredicate;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # inventoryTrigger -protected net.minecraft.data.recipes.RecipeProvider m_176520_(Lnet/minecraft/advancements/critereon/MinMaxBounds$Ints;Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/advancements/critereon/InventoryChangeTrigger$TriggerInstance; # has protected net.minecraft.data.recipes.RecipeProvider m_176523_(Lnet/minecraft/data/BlockFamily;Lnet/minecraft/data/BlockFamily$Variant;)Lnet/minecraft/world/level/block/Block; # getBaseBlock protected net.minecraft.data.recipes.RecipeProvider m_176658_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # buttonBuilder protected net.minecraft.data.recipes.RecipeProvider m_176678_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # fenceBuilder protected net.minecraft.data.recipes.RecipeProvider m_176684_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # fenceGateBuilder protected net.minecraft.data.recipes.RecipeProvider m_176720_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # trapdoorBuilder protected net.minecraft.data.recipes.RecipeProvider m_176726_(Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # signBuilder -protected net.minecraft.data.recipes.RecipeProvider m_176739_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # smeltingResultFromBase protected net.minecraft.data.recipes.RecipeProvider m_245792_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/ShapedRecipeBuilder; # cutBuilder -protected net.minecraft.data.recipes.RecipeProvider m_245809_(Ljava/util/function/Consumer;Lnet/minecraft/world/item/crafting/RecipeSerializer;Ljava/util/List;Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;FILjava/lang/String;Ljava/lang/String;)V # oreCooking protected net.minecraft.data.recipes.RecipeProvider m_245864_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # wallBuilder protected net.minecraft.data.recipes.RecipeProvider m_247174_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # polishedBuilder protected net.minecraft.data.recipes.RecipeProvider m_247347_(Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/item/crafting/Ingredient;)Lnet/minecraft/data/recipes/RecipeBuilder; # pressurePlateBuilder -protected net.minecraft.data.recipes.RecipeProvider m_247368_(Ljava/util/function/Consumer;Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/data/recipes/RecipeCategory;Lnet/minecraft/world/level/ItemLike;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V # nineBlockStorageRecipes -protected net.minecraft.data.recipes.RecipeProvider m_247434_(Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/world/item/crafting/RecipeSerializer;ILnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;F)V # simpleCookingRecipe public net.minecraft.data.recipes.ShapedRecipeBuilder$Result public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_243671_ # COAL_SMELTABLES public net.minecraft.data.recipes.packs.VanillaRecipeProvider f_243779_ # IRON_SMELTABLES @@ -213,8 +234,6 @@ public net.minecraft.server.level.ServerLevel m_142646_()Lnet/minecraft/world/le public net.minecraft.server.level.ServerPlayer f_8940_ # containerCounter public net.minecraft.server.level.ServerPlayer m_143399_(Lnet/minecraft/world/inventory/AbstractContainerMenu;)V # initMenu public net.minecraft.server.level.ServerPlayer m_9217_()V # nextContainerCounter -public net.minecraft.server.network.ServerGamePacketListenerImpl f_9742_ # connection -public net.minecraft.server.network.ServerLoginPacketListenerImpl f_10021_ # gameProfile public net.minecraft.server.packs.repository.ServerPacksSource m_246173_()Lnet/minecraft/server/packs/VanillaPackResources; # createVanillaPackSource public net.minecraft.server.packs.resources.FallbackResourceManager f_10599_ # fallbacks public net.minecraft.util.ExtraCodecs$EitherCodec @@ -276,7 +295,6 @@ public net.minecraft.world.item.context.BlockPlaceContext (Lnet/minecraft/ public net.minecraft.world.item.context.UseOnContext (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V # constructor public-f net.minecraft.world.item.crafting.Ingredient protected net.minecraft.world.item.crafting.Ingredient (Ljava/util/stream/Stream;)V # constructor -public net.minecraft.world.item.crafting.Ingredient m_43919_(Lcom/google/gson/JsonObject;)Lnet/minecraft/world/item/crafting/Ingredient$Value; # valueFromJson public+f net.minecraft.world.item.crafting.Ingredient m_43923_(Lnet/minecraft/network/FriendlyByteBuf;)V # toNetwork public net.minecraft.world.item.crafting.Ingredient m_43938_(Ljava/util/stream/Stream;)Lnet/minecraft/world/item/crafting/Ingredient; # fromValues public net.minecraft.world.item.crafting.Ingredient$ItemValue diff --git a/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java b/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java index 90734b8489..d2d24272d4 100644 --- a/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java +++ b/src/test/java/net/minecraftforge/debug/AddPackFinderEventTest.java @@ -7,8 +7,7 @@ package net.minecraftforge.debug; import net.minecraft.network.chat.Component; import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.PathPackResources; -import net.minecraft.server.packs.metadata.pack.PackMetadataSection; +import net.minecraft.server.packs.PathPackResources.PathResourcesSupplier; import net.minecraft.server.packs.repository.Pack; import net.minecraft.server.packs.repository.PackSource; import net.minecraftforge.event.AddPackFindersEvent; @@ -17,11 +16,8 @@ import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import java.io.IOException; - @Mod(AddPackFinderEventTest.MODID) -public class AddPackFinderEventTest -{ +public class AddPackFinderEventTest { private static final boolean ENABLE = false; public static final String MODID = "add_pack_finders_test"; @@ -33,13 +29,11 @@ public class AddPackFinderEventTest } @SubscribeEvent - public void addPackFinders(AddPackFindersEvent event) - { - if (event.getPackType() == PackType.CLIENT_RESOURCES) - { + public void addPackFinders(AddPackFindersEvent event) { + if (event.getPackType() == PackType.CLIENT_RESOURCES) { var resourcePath = ModList.get().getModFileById(MODID).getFile().findResource("test_nested_resource_pack"); - var pack = Pack.readMetaAndCreate("builtin/add_pack_finders_test", Component.literal("display name"), false, - (path) -> new PathPackResources(path, resourcePath, false), PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.BUILT_IN); + var supplier = new PathResourcesSupplier(resourcePath, false); + var pack = Pack.readMetaAndCreate("builtin/add_pack_finders_test", Component.literal("display name"), false, supplier, PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.BUILT_IN); event.addRepositorySource((packConsumer) -> packConsumer.accept(pack)); } } diff --git a/src/test/java/net/minecraftforge/debug/CreativeModeTabTest.java b/src/test/java/net/minecraftforge/debug/CreativeModeTabTest.java index 642adea4a5..a181ee9998 100644 --- a/src/test/java/net/minecraftforge/debug/CreativeModeTabTest.java +++ b/src/test/java/net/minecraftforge/debug/CreativeModeTabTest.java @@ -97,12 +97,12 @@ public class CreativeModeTabTest ); } - final ResourceLocation custom_tabs_image = new ResourceLocation(MOD_ID, "textures/gui/container/creative_inventory/custom_tabs.png"); + //final ResourceLocation custom_tabs_image = new ResourceLocation(MOD_ID, "textures/gui/container/creative_inventory/custom_tabs.png"); helper.register(new ResourceLocation(MOD_ID, "with_tabs_image"), CreativeModeTab.builder() .title(Component.translatable("itemGroup.with_tabs_image")) .icon(() -> new ItemStack(Blocks.BRICKS)) .displayItems((params, output) -> output.accept(Blocks.BRICKS)) - .withTabsImage(custom_tabs_image) + //.withTabsImage(custom_tabs_image) .build()); }); } diff --git a/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java b/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java index 3259ff0751..9d9937e3a6 100644 --- a/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java +++ b/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.debug; - +/* import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -1110,7 +1110,8 @@ public class DataGeneratorTest false) .addCriterion("get_cobbleStone", InventoryChangeTrigger.Instance.hasItems(Items.COBBLESTONE)) .parent(new ResourceLocation("not_there/not_here")) - .save(consumer, new ResourceLocation("illegal_parent"), fileHelper);*/ + .save(consumer, new ResourceLocation("illegal_parent"), fileHelper); +* / Advancement.Builder.advancement().display(Blocks.COBBLESTONE, Component.translatable(Items.COBBLESTONE.getDescriptionId()), @@ -1265,3 +1266,4 @@ public class DataGeneratorTest return model.replaceAll("^\\w+:", "minecraft:"); } } +*/ diff --git a/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java b/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java index f3a4fe9aa5..0457657f3c 100644 --- a/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java +++ b/src/test/java/net/minecraftforge/debug/ManyMobEffectsTest.java @@ -10,7 +10,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectCategory; -import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.animal.MushroomCow; import net.minecraft.world.item.CreativeModeTab; @@ -18,6 +17,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.SuspiciousStewItem; import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.level.block.SuspiciousEffectHolder; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.IEventBus; @@ -44,9 +44,7 @@ import java.util.List; * it again using an empty hand before and after reloading the world. */ @Mod(ManyMobEffectsTest.MODID) -public class ManyMobEffectsTest -{ - +public class ManyMobEffectsTest { static final String MODID = "many_mob_effects_test"; private static final boolean ENABLED = true; @@ -56,26 +54,21 @@ public class ManyMobEffectsTest private static final DeferredRegister MOB_EFFECTS = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, MODID); private static final RegistryObject LAST_EFFECT; - static - { + static { RegistryObject effect = null; - for (int i = 0; i < 255; i++) - { + for (int i = 0; i < 255; i++) { final var index = i; - effect = MOB_EFFECTS.register("effect_" + i, () -> new MobEffect(MobEffectCategory.NEUTRAL, 0xFF0000) - { + effect = MOB_EFFECTS.register("effect_" + i, () -> new MobEffect(MobEffectCategory.NEUTRAL, 0xFF0000) { + @SuppressWarnings("resource") @Override - public void applyEffectTick(LivingEntity entity, int amplifier) - { - if (entity.level().isClientSide) - { + public void applyEffectTick(LivingEntity entity, int amplifier) { + if (entity.level().isClientSide) { LOGGER.info("Effect Tick for {} on the client", index); } } @Override - public boolean isDurationEffectTick(int duration, int amplifier) - { + public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) { return true; } }); @@ -83,8 +76,7 @@ public class ManyMobEffectsTest LAST_EFFECT = effect; } - public ManyMobEffectsTest() - { + public ManyMobEffectsTest() { if (!ENABLED) return; IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); MOB_EFFECTS.register(modBus); @@ -93,36 +85,30 @@ public class ManyMobEffectsTest helper.register(new ResourceLocation(MODID, "many_mob_effects_test"), CreativeModeTab.builder().withSearchBar() .icon(() -> new ItemStack(Items.POTION)) .displayItems((params, output) -> { + var effect = new SuspiciousEffectHolder.EffectEntry(LAST_EFFECT.get(), 1000); var stack = new ItemStack(Items.POTION); - PotionUtils.setCustomEffects(stack, List.of(new MobEffectInstance(LAST_EFFECT.get(), 1000))); + PotionUtils.setCustomEffects(stack, List.of(effect.createEffectInstance())); output.accept(stack); stack = new ItemStack(Items.SUSPICIOUS_STEW); - SuspiciousStewItem.saveMobEffect(stack, LAST_EFFECT.get(), 1000); + SuspiciousStewItem.saveMobEffects(stack, List.of(effect)); output.accept(stack); }) .build()))); } - private static void mobInteract(PlayerInteractEvent.EntityInteract event) - { - if (!event.getTarget().level().isClientSide() && event.getTarget() instanceof MushroomCow cow) - { + private static void mobInteract(PlayerInteractEvent.EntityInteract event) { + if (!event.getTarget().level().isClientSide() && event.getTarget() instanceof MushroomCow cow) { var heldItem = event.getEntity().getItemInHand(event.getHand()); - if (heldItem.is(Items.POTION)) - { + if (heldItem.is(Items.POTION)) { var effects = PotionUtils.getMobEffects(heldItem); - if (!effects.isEmpty()) - { + if (!effects.isEmpty()) { ObfuscationReflectionHelper.setPrivateValue(MushroomCow.class, cow, effects.get(0).getEffect(), "f_289" + "09_"); ObfuscationReflectionHelper.setPrivateValue(MushroomCow.class, cow, effects.get(0).getDuration(), "f_289" + "10_"); } - } - else if (heldItem.isEmpty()) - { + } else if (heldItem.isEmpty()) { var effect = ((MobEffect) ObfuscationReflectionHelper.getPrivateValue(MushroomCow.class, cow, "f_289" + "09_")); - if (effect != null) - { + if (effect != null) { event.getEntity().sendSystemMessage(Component.literal(String.valueOf(ForgeRegistries.MOB_EFFECTS.getKey(effect)))); } } diff --git a/src/test/java/net/minecraftforge/debug/chat/ClientCommandTest.java b/src/test/java/net/minecraftforge/debug/chat/ClientCommandTest.java index 5d095e0215..96af5a755a 100644 --- a/src/test/java/net/minecraftforge/debug/chat/ClientCommandTest.java +++ b/src/test/java/net/minecraftforge/debug/chat/ClientCommandTest.java @@ -73,7 +73,7 @@ public class ClientCommandTest .then(Commands.literal("get_advancement") .then(Commands.argument("advancement", ResourceLocationArgument.id()) .executes((context) -> { - final Component msg = ResourceLocationArgument.getAdvancement(context, "advancement").getChatComponent(); + final Component msg = ResourceLocationArgument.getAdvancement(context, "advancement").value().name().get(); context.getSource().sendSuccess(() -> msg, false); return 1; }))) @@ -81,7 +81,7 @@ public class ClientCommandTest .then(Commands.literal("get_recipe") .then(Commands.argument("recipe", ResourceLocationArgument.id()) .executes((context) -> { - final Component msg = ResourceLocationArgument.getRecipe(context, "recipe").getResultItem(context.getSource().registryAccess()).getDisplayName(); + final Component msg = ResourceLocationArgument.getRecipe(context, "recipe").value().getResultItem(context.getSource().registryAccess()).getDisplayName(); context.getSource() .sendSuccess(() -> msg, false); return 1; diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java index 62745711d8..9eb77d8c48 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java @@ -9,11 +9,10 @@ import java.util.Random; import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.client.renderer.texture.*; -import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection; import net.minecraft.client.resources.metadata.animation.FrameSize; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.ResourceMetadata; import net.minecraft.world.item.Item; import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent; import net.minecraftforge.client.textures.ForgeTextureMetadata; @@ -28,38 +27,31 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @Mod(CustomTASTest.MOD_ID) -public class CustomTASTest -{ +public class CustomTASTest { private static final boolean ENABLED = true; static final String MOD_ID = "custom_tas_test"; private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); private static final RegistryObject TEST_ITEM = ITEMS.register("test_item", () -> new Item(new Item.Properties())); - public CustomTASTest() - { - if (ENABLED) - { + public CustomTASTest() { + if (ENABLED) { if (FMLLoader.getDist().isClient()) - { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerTextureAtlasSpriteLoaders); - } ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); } } - private void registerTextureAtlasSpriteLoaders(RegisterTextureAtlasSpriteLoadersEvent event) - { + private void registerTextureAtlasSpriteLoaders(RegisterTextureAtlasSpriteLoadersEvent event) { event.register("tas_loader", new TasLoader()); } - private static class TasLoader implements ITextureAtlasSpriteLoader - { + private static class TasLoader implements ITextureAtlasSpriteLoader { @Override - public SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, AnimationMetadataSection animationMeta, ForgeTextureMetadata forgeMeta) { + public SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, ResourceMetadata meta, ForgeTextureMetadata forgeMeta) { final class TASSpriteContents extends SpriteContents { - public TASSpriteContents(ResourceLocation p_249787_, FrameSize p_251031_, NativeImage p_252131_, AnimationMetadataSection p_250432_, @Nullable ForgeTextureMetadata forgeMeta) { - super(p_249787_, p_251031_, p_252131_, p_250432_, forgeMeta); + public TASSpriteContents(ResourceLocation name, FrameSize size, NativeImage image, ResourceMetadata meta, @Nullable ForgeTextureMetadata forgeMeta) { + super(name, size, image, meta, forgeMeta); } @Override @@ -68,13 +60,12 @@ public class CustomTASTest } class Ticker implements SpriteTicker { - final Random random = new Random(); @Override - public void tickAndUpload(int p_248847_, int p_250486_) { + public void tickAndUpload(int x, int y) { TASSpriteContents.this.byMipLevel[0].fillRect(0, 0, 16, 16, 0xFF000000 | random.nextInt(0xFFFFFF)); - TASSpriteContents.this.uploadFirstFrame(p_248847_, p_250486_); + TASSpriteContents.this.uploadFirstFrame(x, y); } @Override @@ -84,15 +75,14 @@ public class CustomTASTest } } - return new TASSpriteContents(name, frameSize, image, animationMeta, forgeMeta); + return new TASSpriteContents(name, frameSize, image, meta, forgeMeta); } @Override public @NotNull TextureAtlasSprite makeSprite(ResourceLocation atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel) { final class TASSprite extends TextureAtlasSprite { - - public TASSprite(ResourceLocation p_250211_, SpriteContents p_248526_, int p_248950_, int p_249741_, int p_248672_, int p_248637_) { - super(p_250211_, p_248526_, p_248950_, p_249741_, p_248672_, p_248637_); + public TASSprite(ResourceLocation atlasName, SpriteContents contents, int width, int height, int x, int y) { + super(atlasName, contents, width, height, x, y); } } diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java index 1b6c3cadef..8257a43505 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java @@ -46,21 +46,17 @@ import java.util.Map; import java.util.Optional; @Mod(CustomTooltipTest.ID) -public class CustomTooltipTest -{ +public class CustomTooltipTest { static final boolean ENABLED = true; static final String ID = "custom_tooltip_test"; private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ID); static final RegistryObject CUSTOM_ITEM = ITEMS.register("test_item", () -> new CustomItemWithTooltip(new Item.Properties())); - public CustomTooltipTest() - { - if (ENABLED) - { + public CustomTooltipTest() { + if (ENABLED) { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - if (FMLEnvironment.dist.isClient()) - { + if (FMLEnvironment.dist.isClient()) { MinecraftForge.EVENT_BUS.register(ClientEventHandler.class); modEventBus.register(ClientModBusEventHandler.class); } @@ -69,96 +65,74 @@ public class CustomTooltipTest } } - private void addCreative(BuildCreativeModeTabContentsEvent event) - { + private void addCreative(BuildCreativeModeTabContentsEvent event) { if (event.getTabKey() == CreativeModeTabs.INGREDIENTS) event.accept(CUSTOM_ITEM); } record CustomTooltip(int color) implements TooltipComponent {} - record CustomClientTooltip(CustomTooltip tooltip) implements ClientTooltipComponent - { + record CustomClientTooltip(CustomTooltip tooltip) implements ClientTooltipComponent { @Override - public int getHeight() - { + public int getHeight() { return 10; } @Override - public int getWidth(Font font) - { + public int getWidth(Font font) { return 10; } @Override - public void renderImage(Font font, int x, int y, GuiGraphics graphics) - { + public void renderImage(Font font, int x, int y, GuiGraphics graphics) { graphics.fill(x, y, x + 10, y + 10,tooltip.color); } } - static class CustomItemWithTooltip extends Item - { - public CustomItemWithTooltip(Properties properties) - { + static class CustomItemWithTooltip extends Item { + public CustomItemWithTooltip(Properties properties) { super(properties); } @Override - public void appendHoverText(ItemStack stack, @Nullable Level level, List components, TooltipFlag flag) - { + public void appendHoverText(ItemStack stack, @Nullable Level level, List components, TooltipFlag flag) { super.appendHoverText(stack, level, components, flag); components.add(Component.literal("This is a very very very very very very long hover text that should really really be split across multiple lines.").withStyle(ChatFormatting.YELLOW)); } @Override - public InteractionResultHolder use(Level level, Player player, InteractionHand hand) - { + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { if (level.isClientSide) - { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> TooltipTestScreen::show); - } return InteractionResultHolder.success(player.getItemInHand(hand)); } @Override - public Optional getTooltipImage(ItemStack stack) - { + public Optional getTooltipImage(ItemStack stack) { return Optional.of(new CustomTooltip(0xFFFF0000)); } } - private static class ClientModBusEventHandler - { + private static class ClientModBusEventHandler { @SubscribeEvent - public static void onRegisterClientTooltipComponentFactories(RegisterClientTooltipComponentFactoriesEvent event) - { + public static void onRegisterClientTooltipComponentFactories(RegisterClientTooltipComponentFactoriesEvent event) { event.register(CustomTooltip.class, CustomClientTooltip::new); } } - private static class ClientEventHandler - { + private static class ClientEventHandler { @SubscribeEvent - public static void gatherTooltips(RenderTooltipEvent.GatherComponents event) - { + public static void gatherTooltips(RenderTooltipEvent.GatherComponents event) { if (event.getItemStack().getItem() == Items.STICK) - { event.getTooltipElements().add(Either.right(new CustomTooltip(0xFF0000FF))); - } if (event.getItemStack().getItem() == Items.CLOCK) - { event.setMaxWidth(30); - } } @SubscribeEvent - public static void preTooltip(RenderTooltipEvent.Color event) - { - if (event.getItemStack().getItem() == Items.APPLE) - { + public static void preTooltip(RenderTooltipEvent.Color event) { + if (event.getItemStack().getItem() == Items.APPLE) { event.setBackgroundStart(0xFF0000FF); event.setBackgroundEnd(0xFFFFFF00); event.setBorderStart(0xFFFF0000); @@ -167,32 +141,27 @@ public class CustomTooltipTest } } - static class TooltipTestScreen extends Screen - { + static class TooltipTestScreen extends Screen { private ItemStack testStack = ItemStack.EMPTY; private boolean testFont = false; - protected TooltipTestScreen() - { + protected TooltipTestScreen() { super(Component.literal("TooltipMethodTest")); } - static void show() - { + static void show() { Minecraft.getInstance().setScreen(new TooltipTestScreen()); } @Override - public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - { - this.renderBackground(graphics); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(graphics, mouseX, mouseY, partialTicks); super.render(graphics, mouseX, mouseY, partialTicks); graphics.drawString(font, "* must have Stack, # must have custom font", 0, 0, 0xFFFFFF); } @Override - protected void init() - { + protected void init() { addRenderableWidget(Button.builder(Component.literal("Toggle Stack: EMPTY"), button -> { this.testStack = this.testStack.isEmpty() ? new ItemStack(Items.APPLE) : ItemStack.EMPTY; button.setMessage(Component.literal("Toggle Stack: " + (testStack.isEmpty() ? "EMPTY" : "Apple"))); @@ -205,30 +174,28 @@ public class CustomTooltipTest // * must have stack context // # must have custom font List> tooltipTests = Arrays.asList( - Map.entry(" 1 * ", this::test1), - Map.entry(" 2 * ", this::test2), - Map.entry(" 3 #", this::test3), - Map.entry(" 4 *#", this::test4), - Map.entry(" 5 ", this::test5), - Map.entry(" 6 ", this::test6), - Map.entry(" 7 * ", this::test7), - Map.entry(" 8 #", this::test8), - Map.entry(" 9 *#", this::test9), - Map.entry("10 ", this::test10), - Map.entry("11 ", this::test11), - Map.entry("12 #", this::test12), - Map.entry("13 #", this::test13), - Map.entry("14 #", this::test14) + Map.entry(" 1 * ", this::test1), + Map.entry(" 2 * ", this::test2), + Map.entry(" 3 #", this::test3), + Map.entry(" 4 *#", this::test4), + Map.entry(" 5 ", this::test5), + Map.entry(" 6 ", this::test6), + Map.entry(" 7 * ", this::test7), + Map.entry(" 8 #", this::test8), + Map.entry(" 9 *#", this::test9), + Map.entry("10 ", this::test10), + Map.entry("11 ", this::test11), + Map.entry("12 #", this::test12), + Map.entry("13 #", this::test13), + Map.entry("14 #", this::test14) ); int x = 50; int y = 50; - for (var test : tooltipTests) - { + for (var test : tooltipTests) { addRenderableWidget(new Button.Builder(Component.literal(test.getKey()), button -> {}) .bounds(x, y, 100, 20).build(b -> new Button(b) { @Override - public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) - { + public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) { super.renderWidget(graphics, mouseX, mouseY, partialTick); boolean showTooltip = this.isHovered || this.isFocused() && Minecraft.getInstance().getLastInputType().isKeyboard(); @@ -237,92 +204,76 @@ public class CustomTooltipTest } })); y+= 22; - if (y >= height - 50) - { + if (y >= height - 50) { y = 50; x += 110; } } } - private Component getTestComponent(boolean testFont) - { + private Component getTestComponent(boolean testFont) { return Component.literal("test").withStyle(s -> s.withFont(testFont ? Minecraft.UNIFORM_FONT : Minecraft.DEFAULT_FONT)); } - private void test1(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test1(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, this.testStack, mouseX, mouseY); } // renderTooltip with List and all combinations of ItemStack/Font - private void test2(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test2(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, List.of(this.getTestComponent(false)), Optional.empty(), mouseX, mouseY); } - private void test3(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test3(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont)), Optional.empty(), mouseX, mouseY); } - private void test4(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test4(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont)), Optional.empty(), mouseX, mouseY); } - private void test5(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test5(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, List.of(this.getTestComponent(false)), Optional.empty(), mouseX, mouseY); } // renderTooltip with just Component - private void test6(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test6(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, this.getTestComponent(false), mouseX, mouseY); } // renderComponentTooltip with all combinations of ItemStack/Font - private void test7(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test7(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(false)), mouseX, mouseY); } - private void test8(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test8(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(this.testFont)), mouseX, mouseY); } - private void test9(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test9(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(this.testFont)), mouseX, mouseY); } - private void test10(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test10(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(false)), mouseX, mouseY); } // renderTooltip with list of FormattedCharSequence - private void test11(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test11(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, List.of(this.getTestComponent(false).getVisualOrderText()), mouseX, mouseY); } // renderTooltip with list of FormattedCharSequence and Font - private void test12(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test12(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont).getVisualOrderText()), mouseX, mouseY); } // legacy ToolTip methods - private void test13(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test13(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont).getVisualOrderText()), mouseX, mouseY); } - private void test14(GuiGraphics graphics, int mouseX, int mouseY) - { + private void test14(GuiGraphics graphics, int mouseX, int mouseY) { graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(this.testFont)), mouseX, mouseY); } } diff --git a/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java b/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java index c7a65ae821..f620ac0e9b 100644 --- a/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java +++ b/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java @@ -5,7 +5,6 @@ package net.minecraftforge.debug.client; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; @@ -23,21 +22,18 @@ import net.minecraftforge.fml.common.Mod; import java.util.Random; @Mod(GuiLayeringTest.MODID) -public class GuiLayeringTest -{ +public class GuiLayeringTest { private static final boolean ENABLED = false; private static final Random RANDOM = new Random(); public static final String MODID = "gui_layer_test"; @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) - public static class ClientEvents - { + public static class ClientEvents { + @SuppressWarnings("unused") @SubscribeEvent - public static void guiOpen(ScreenEvent.Init event) - { - if (event.getScreen() instanceof AbstractContainerScreen && ENABLED) - { + public static void guiOpen(ScreenEvent.Init event) { + if (event.getScreen() instanceof AbstractContainerScreen && ENABLED) { event.addListener(Button.builder(Component.literal("Test Gui Layering"), btn -> { Minecraft.getInstance().pushGuiLayer(new TestLayer(Component.literal("LayerScreen"))); }).pos(2,2).size(150, 20).build()); @@ -48,24 +44,20 @@ public class GuiLayeringTest } } - public static class TestLayer extends Screen - { - protected TestLayer(Component titleIn) - { + public static class TestLayer extends Screen { + protected TestLayer(Component titleIn) { super(titleIn); } @Override - public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - { - this.renderBackground(graphics); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(graphics, mouseX, mouseY, partialTicks); graphics.drawString(this.font, this.title, this.width / 2, 15, 0xFFFFFF); super.render(graphics, mouseX, mouseY, partialTicks); } @Override - protected void init() - { + protected void init() { int buttonWidth = 150; int buttonHeight = 30; int buttonGap = 4; @@ -86,18 +78,15 @@ public class GuiLayeringTest this.addRenderableWidget(new ForgeSlider(xoff, yoff + buttonSpacing * cnt, 50, 25, Component.literal("Val: ").withStyle(ChatFormatting.GOLD), Component.literal("some text which will be cut off"), 5, 55, 6, true)); } - private void closeStack(Button button) - { + private void closeStack(Button button) { this.minecraft.setScreen(null); } - private void popLayerButton(Button button) - { + private void popLayerButton(Button button) { this.minecraft.popGuiLayer(); } - private void pushLayerButton(Button button) - { + private void pushLayerButton(Button button) { this.minecraft.pushGuiLayer(new TestLayer(Component.literal("LayerScreen"))); } } diff --git a/src/test/java/net/minecraftforge/debug/client/TestScreen.java b/src/test/java/net/minecraftforge/debug/client/TestScreen.java index 124ec8a894..2648cd4792 100644 --- a/src/test/java/net/minecraftforge/debug/client/TestScreen.java +++ b/src/test/java/net/minecraftforge/debug/client/TestScreen.java @@ -5,29 +5,24 @@ package net.minecraftforge.debug.client; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.brigadier.Command; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -public class TestScreen extends Screen -{ - public static int open() - { +public class TestScreen extends Screen { + public static int open() { Minecraft.getInstance().setScreen(new TestScreen()); return Command.SINGLE_SUCCESS; } - public TestScreen() - { + public TestScreen() { super(Component.literal("testscreen")); } @Override - public void render(GuiGraphics graphics, int MouseX, int MouseY, float PartialTick) - { - renderBackground(graphics); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + renderBackground(graphics, mouseX, mouseY, partialTicks); } } diff --git a/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java index b03dbefa14..5feda5b099 100644 --- a/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/GravityAttributeTest.java @@ -114,7 +114,7 @@ public class GravityAttributeTest else if (!inPlains && grav.hasModifier(REDUCED_GRAVITY)) { logger.info("Removed low gravity from Entity: {}", liv); - grav.removeModifier(REDUCED_GRAVITY); + grav.removeModifier(REDUCED_GRAVITY.getId()); } } } diff --git a/src/test/java/net/minecraftforge/debug/entity/player/AdvancementEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/AdvancementEventTest.java index 6ef08ae611..96a0e73414 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/AdvancementEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/AdvancementEventTest.java @@ -5,7 +5,6 @@ package net.minecraftforge.debug.entity.player; -import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementProgress; import net.minecraft.world.entity.player.Player; import net.minecraftforge.common.MinecraftForge; @@ -20,45 +19,36 @@ import org.slf4j.Logger; import com.mojang.logging.LogUtils; @Mod(AdvancementEventTest.MOD_ID) -public class AdvancementEventTest -{ +public class AdvancementEventTest { static final String MOD_ID = "advancement_event_test"; private static final boolean ENABLED = false; private static final Logger LOGGER = LogUtils.getLogger(); - public AdvancementEventTest() - { - if (ENABLED) - { + public AdvancementEventTest() { + if (ENABLED) { MinecraftForge.EVENT_BUS.addListener(this::onAdvancementEarnEvent); MinecraftForge.EVENT_BUS.addListener(this::onAdvancementProgressEvent); } } - public void onAdvancementEarnEvent(AdvancementEarnEvent event) - { - Advancement advancement = event.getAdvancement(); + public void onAdvancementEarnEvent(AdvancementEarnEvent event) { + var advancement = event.getAdvancement(); Player player = event.getEntity(); - LOGGER.info("Player {} earned advancement {} and was awarded {}", player, advancement.getId(), advancement.getRewards().toString()); + LOGGER.info("Player {} earned advancement {} and was awarded {}", player, advancement.id(), advancement.value().rewards().toString()); } - public void onAdvancementProgressEvent(AdvancementProgressEvent event) - { - Advancement advancement = event.getAdvancement(); + public void onAdvancementProgressEvent(AdvancementProgressEvent event) { + var advancement = event.getAdvancement(); Player player = event.getEntity(); AdvancementProgress advancementProgress = event.getAdvancementProgress(); String criterionName = event.getCriterionName(); AdvancementEvent.AdvancementProgressEvent.ProgressType progressType = event.getProgressType(); String action; if (progressType == ProgressType.GRANT) - { action = "granted"; - } else - { action = "revoked"; - } LOGGER.info("Player {} progressed advancement {}. They were {} progress on {}. They have completed {}% of the achievement", - player, advancement.getId(), action, criterionName, advancementProgress.getPercent()*100); + player, advancement.id(), action, criterionName, advancementProgress.getPercent()*100); } } diff --git a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java index fc2ce286c2..aad2b68f6c 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.debug.fluid; - +/* import net.minecraft.world.item.*; import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.FluidState; @@ -46,8 +46,7 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; @Mod(NewFluidTest.MODID) -public class NewFluidTest -{ +public class NewFluidTest { public static final boolean ENABLE = false; // TODO fix public static final String MODID = "new_fluid_test"; @@ -200,15 +199,14 @@ public class NewFluidTest if (state.getValue(FLUIDLOGGED)) { worldIn.setBlock(pos, state.setValue(FLUIDLOGGED, false), 3); return new ItemStack(TEST_FLUID_BUCKET.get()); - } else { + } else return ItemStack.EMPTY; - } } @Override - public FluidState getFluidState(BlockState state) - { + public FluidState getFluidState(BlockState state) { return state.getValue(FLUIDLOGGED) ? test_fluid.get().defaultFluidState() : Fluids.EMPTY.defaultFluidState(); } } } +*/ \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java index e9d4164170..e73d325402 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.debug.gameplay.loot; - +/* import com.google.common.base.Suppliers; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -133,7 +133,7 @@ public class GlobalLootModifiersTest { /** * The smelting enchantment causes this modifier to be invoked, via the smelting loot_modifier json * - */ + * / private static class SmeltingEnchantmentModifier extends LootModifier { public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(inst -> codecStart(inst).apply(inst, SmeltingEnchantmentModifier::new))); @@ -150,11 +150,15 @@ public class GlobalLootModifiersTest { } private static ItemStack smelt(ItemStack stack, LootContext context) { - return context.getLevel().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SimpleContainer(stack), context.getLevel()) - .map(smeltingRecipe -> smeltingRecipe.getResultItem(context.getLevel().registryAccess())) - .filter(itemStack -> !itemStack.isEmpty()) - .map(itemStack -> ItemHandlerHelper.copyStackWithSize(itemStack, stack.getCount() * itemStack.getCount())) - .orElse(stack); + var mgr = context.getLevel().getRecipeManager(); + var reg = context.getLevel().registryAccess(); + return mgr + .getRecipeFor(RecipeType.SMELTING, new SimpleContainer(stack), context.getLevel()) + .map(holder -> holder.value()) + .map(recipe -> recipe.getResultItem(reg)) + .filter(itemStack -> !itemStack.isEmpty()) + .map(itemStack -> ItemHandlerHelper.copyStackWithSize(itemStack, stack.getCount() * itemStack.getCount())) + .orElse(stack); } @Override @@ -166,7 +170,7 @@ public class GlobalLootModifiersTest { /** * When harvesting blocks with bamboo, this modifier is invoked, via the silk_touch_bamboo loot_modifier json * - */ + * / private static class SilkTouchTestModifier extends LootModifier { public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(inst -> codecStart(inst).apply(inst, SilkTouchTestModifier::new))); @@ -198,7 +202,7 @@ public class GlobalLootModifiersTest { * When harvesting wheat with shears, this modifier is invoked via the wheat_harvest loot_modifier json
* This modifier checks how many seeds were harvested and turns X seeds into Y wheat (3:1) * - */ + * / private static class WheatSeedsConverterModifier extends LootModifier { public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(inst -> codecStart(inst).and( inst.group( @@ -273,3 +277,4 @@ public class GlobalLootModifiersTest { } } } +*/ \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionClientHelper.java b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionClientHelper.java index f12a4bcf7c..a5eb4ee38d 100644 --- a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionClientHelper.java +++ b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionClientHelper.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.debug.recipe.recipebook; - +/* import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import net.minecraft.client.Minecraft; @@ -15,21 +15,19 @@ import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent; import java.util.function.Supplier; -public class RecipeBookExtensionClientHelper -{ +public class RecipeBookExtensionClientHelper { public static final Supplier TESTING_SEARCH = Suppliers.memoize(() -> RecipeBookCategories.create("TESTING_SEARCH", new ItemStack(Items.COMPASS))); public static final Supplier TESTING_CAT_1 = Suppliers.memoize(() -> RecipeBookCategories.create("TESTING_CAT_1", new ItemStack(Items.DIAMOND))); public static final Supplier TESTING_CAT_2 = Suppliers.memoize(() -> RecipeBookCategories.create("TESTING_CAT_2", new ItemStack(Items.NETHERITE_INGOT))); - public static void init(RegisterRecipeBookCategoriesEvent event) - { + public static void init(RegisterRecipeBookCategoriesEvent event) { event.registerBookCategories(RecipeBookExtensionTest.TEST_TYPE, ImmutableList.of(TESTING_SEARCH.get(), TESTING_CAT_1.get(), TESTING_CAT_2.get())); event.registerAggregateCategory(TESTING_SEARCH.get(), ImmutableList.of(TESTING_CAT_1.get(), TESTING_CAT_2.get())); - event.registerRecipeCategoryFinder(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), r -> - { + event.registerRecipeCategoryFinder(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), r -> { if (r.getResultItem(Minecraft.getInstance().level.registryAccess()).getItem() == Items.DIAMOND_BLOCK) return TESTING_CAT_1.get(); else return TESTING_CAT_2.get(); }); } } +*/ diff --git a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionTest.java b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionTest.java index b8879edc57..c584701fb5 100644 --- a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionTest.java +++ b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookExtensionTest.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.debug.recipe.recipebook; - +/* import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -33,8 +33,7 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; @Mod(RecipeBookExtensionTest.MOD_ID) -public class RecipeBookExtensionTest -{ +public class RecipeBookExtensionTest { public static final boolean ENABLED = false; public static final String MOD_ID = "recipe_book_extension_test"; @@ -42,7 +41,7 @@ public class RecipeBookExtensionTest public static final DeferredRegister> RECIPE_SERIALIZER = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MOD_ID); public static final RegistryObject> RECIPE_BOOK_TEST_RECIPE_SERIALIZER = - RECIPE_SERIALIZER.register("test_recipe", RecipeBookTestRecipeSerializer::new); + RECIPE_SERIALIZER.register("test_recipe", RecipeBookTestRecipe.Serializer::new); public static final DeferredRegister> MENU_TYPE = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MOD_ID); public static final RegistryObject> RECIPE_BOOK_TEST_MENU_TYPE = @@ -51,8 +50,7 @@ public class RecipeBookExtensionTest public static final DeferredRegister> RECIPE_TYPE = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, MOD_ID); public static final RegistryObject> RECIPE_BOOK_TEST_RECIPE_TYPE = RECIPE_TYPE.register("test_recipe", () -> RecipeType.simple(getId("test_recipe"))); - public RecipeBookExtensionTest() - { + public RecipeBookExtensionTest() { if (!ENABLED) return; @@ -64,46 +62,40 @@ public class RecipeBookExtensionTest MinecraftForge.EVENT_BUS.addListener(this::onRightClick); } - private void onRightClick(PlayerInteractEvent.RightClickBlock event) - { + private void onRightClick(PlayerInteractEvent.RightClickBlock event) { if (event.getLevel().isClientSide) return; if (event.getLevel().getBlockState(event.getPos()).getBlock() == Blocks.GRASS_BLOCK) NetworkHooks.openScreen((ServerPlayer) event.getEntity(), new SimpleMenuProvider((id, inv, p) -> new RecipeBookTestMenu(id, inv, ContainerLevelAccess.create(event.getLevel(), event.getPos())), Component.literal("Test"))); } - public static ResourceLocation getId(String name) - { + public static ResourceLocation getId(String name) { return new ResourceLocation(MOD_ID, name); } @Mod.EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) - public static class ClientHandler - { + public static class ClientHandler { @SubscribeEvent - public static void clientSetup(FMLClientSetupEvent event) - { + public static void clientSetup(FMLClientSetupEvent event) { if (!ENABLED) return; - event.enqueueWork(() -> - { + event.enqueueWork(() -> { MenuScreens.register(RECIPE_BOOK_TEST_MENU_TYPE.get(), RecipeBookTestScreen::new); }); } + @SubscribeEvent - public static void onRegisterRecipeBookCategories(RegisterRecipeBookCategoriesEvent event) - { + public static void onRegisterRecipeBookCategories(RegisterRecipeBookCategoriesEvent event) { if (!ENABLED) return; RecipeBookExtensionClientHelper.init(event); } } - public static class RecipeBookTestContainer extends SimpleContainer - { - public RecipeBookTestContainer() - { + public static class RecipeBookTestContainer extends SimpleContainer { + public RecipeBookTestContainer() { super(8); } } } +*/ diff --git a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestMenu.java b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestMenu.java index a9543e2b06..5a901c2e5e 100644 --- a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestMenu.java +++ b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestMenu.java @@ -4,7 +4,7 @@ */ package net.minecraftforge.debug.recipe.recipebook; - +/* import net.minecraft.core.NonNullList; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; @@ -15,119 +15,102 @@ import net.minecraft.world.entity.player.StackedContents; import net.minecraft.world.inventory.*; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.debug.recipe.recipebook.RecipeBookExtensionTest.RecipeBookTestContainer; import java.util.List; import java.util.Optional; -public class RecipeBookTestMenu extends RecipeBookMenu -{ +public class RecipeBookTestMenu extends RecipeBookMenu { private final RecipeBookTestContainer container = new RecipeBookTestContainer(); private final ResultContainer resultContainer = new ResultContainer(); private final Slot resultSlot; private final ContainerLevelAccess access; private final Player player; - public RecipeBookTestMenu(int id, Inventory inv, FriendlyByteBuf extraData) - { + public RecipeBookTestMenu(int id, Inventory inv, FriendlyByteBuf extraData) { this(id, inv, ContainerLevelAccess.NULL); } - public RecipeBookTestMenu(int id, Inventory inv, ContainerLevelAccess access) - { + public RecipeBookTestMenu(int id, Inventory inv, ContainerLevelAccess access) { super(RecipeBookExtensionTest.RECIPE_BOOK_TEST_MENU_TYPE.get(), id); this.access = access; this.container.addListener(this::slotsChanged); this.player = inv.player; - /** - * Copied from {@link ResultSlot} but not limited to {@link CraftingContainer} - */ - this.resultSlot = new Slot(this.resultContainer, 0, 144, 35) - { + // Copied from {@link ResultSlot} but not limited to {@link CraftingContainer} + this.resultSlot = new Slot(this.resultContainer, 0, 144, 35) { private int removeCount; @Override - public boolean mayPlace(ItemStack stack) - { + public boolean mayPlace(ItemStack stack) { return false; } @Override - public void onTake(Player player, ItemStack stack) - { + public void onTake(Player player, ItemStack stack) { this.checkTakeAchievements(stack); Container craftingContainer = RecipeBookTestMenu.this.container; NonNullList remainders = player.level() .getRecipeManager().getRemainingItemsFor(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), RecipeBookTestMenu.this.container, player.level()); - for (int i = 0; i < remainders.size(); ++i) - { + for (int i = 0; i < remainders.size(); ++i) { ItemStack toRemove = craftingContainer.getItem(i); ItemStack toReplace = remainders.get(i); - if (!toRemove.isEmpty()) - { + if (!toRemove.isEmpty()) { craftingContainer.removeItem(i, 1); toRemove = craftingContainer.getItem(i); } - if (!toReplace.isEmpty()) - { + if (!toReplace.isEmpty()) { if (toRemove.isEmpty()) craftingContainer.setItem(i, toRemove); - else if (ItemStack.isSameItemSameTags(toRemove, toReplace)) - { + else if (ItemStack.isSameItemSameTags(toRemove, toReplace)) { toReplace.grow(toRemove.getCount()); craftingContainer.setItem(i, toReplace); - } - else if (!player.getInventory().add(toReplace)) + } else if (!player.getInventory().add(toReplace)) player.drop(toReplace, false); } } } + @Override - public ItemStack remove(int amount) - { + public ItemStack remove(int amount) { if (this.hasItem()) this.removeCount += Math.min(amount, this.getItem().getCount()); return super.remove(amount); } @Override - public void onQuickCraft(ItemStack output, int amount) - { + public void onQuickCraft(ItemStack output, int amount) { this.removeCount += amount; this.checkTakeAchievements(output); } @Override - protected void onSwapCraft(int amount) - { + protected void onSwapCraft(int amount) { this.removeCount = amount; } @Override - protected void checkTakeAchievements(ItemStack stack) - { + protected void checkTakeAchievements(ItemStack stack) { if (this.removeCount > 0) stack.onCraftedBy(RecipeBookTestMenu.this.player.level(), RecipeBookTestMenu.this.player, this.removeCount); - if (this.container instanceof RecipeHolder recipeHolder) - recipeHolder.awardUsedRecipes(RecipeBookTestMenu.this.player, List.of()); + if (this.container instanceof RecipeCraftingHolder holder) + holder.awardUsedRecipes(RecipeBookTestMenu.this.player, List.of()); this.removeCount = 0; } }; this.addSlot(this.resultSlot); //slot 0 //slots 1 - 8 - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { for (int j = 0; j < 2; ++j) this.addSlot(new Slot(this.container, j + i * 2, 30 + j * 18, 61 - i * 18)); } //slots 9 to 35 - for(int i = 0; i < 3; ++i) - { + for(int i = 0; i < 3; ++i) { for(int j = 0; j < 9; ++j) this.addSlot(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } @@ -138,37 +121,31 @@ public class RecipeBookTestMenu extends RecipeBookMenu } @Override - public boolean stillValid(Player player) - { + public boolean stillValid(Player player) { return stillValid(this.access, player, Blocks.GRASS_BLOCK); } @Override - public void removed(Player player) - { + public void removed(Player player) { super.removed(player); this.access.execute((level, pos) -> this.clearContainer(player, this.container)); } @Override - public boolean canTakeItemForPickAll(ItemStack stack, Slot slot) - { + public boolean canTakeItemForPickAll(ItemStack stack, Slot slot) { return slot != resultSlot; } @Override - public void slotsChanged(Container container) - { - this.access.execute((level, pos) -> - { - if (container == this.container) - { - Optional recipe = level.getRecipeManager() + public void slotsChanged(Container container) { + this.access.execute((level, pos) -> { + if (container == this.container) { + Optional> recipe = level.getRecipeManager() .getRecipeFor(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), this.container, level); if (recipe.isEmpty()) this.resultContainer.setItem(0, ItemStack.EMPTY); else if (player instanceof ServerPlayer sp && this.resultContainer.setRecipeUsed(level, sp, recipe.get())) { - ItemStack stack = recipe.get().assemble(this.container, level.registryAccess()); + ItemStack stack = recipe.get().value().assemble(this.container, level.registryAccess()); this.resultContainer.setItem(0, stack); } } @@ -184,11 +161,8 @@ public class RecipeBookTestMenu extends RecipeBookMenu private static final int INVENTORY_STOP = 44; private static final int HOTBAR_START = 36; - /** - * Mostly copied from {@link CraftingMenu#quickMoveStack} - */ - public ItemStack quickMoveStack(Player player, int idx) - { + // Mostly copied from {@link CraftingMenu#quickMoveStack} + public ItemStack quickMoveStack(Player player, int idx) { ItemStack ret = ItemStack.EMPTY; Slot slot = this.slots.get(idx); if (!slot.hasItem()) @@ -197,23 +171,17 @@ public class RecipeBookTestMenu extends RecipeBookMenu ItemStack item = slot.getItem(); ret = item.copy(); - if (idx == RESULT_SLOT) - { + if (idx == RESULT_SLOT) { if (!this.moveItemStackTo(item, INVENTORY_START, INVENTORY_STOP + 1, true)) return ItemStack.EMPTY; slot.onQuickCraft(item, ret); - } - else if (idx >= INVENTORY_START && idx < INVENTORY_STOP + 1) - { - if (!this.moveItemStackTo(item, CRAFTING_START, CRAFTING_STOP + 1, false)) - { - if (idx < HOTBAR_START) - { + } else if (idx >= INVENTORY_START && idx < INVENTORY_STOP + 1) { + if (!this.moveItemStackTo(item, CRAFTING_START, CRAFTING_STOP + 1, false)) { + if (idx < HOTBAR_START) { if (!this.moveItemStackTo(item, HOTBAR_START, INVENTORY_STOP + 1, false)) return ItemStack.EMPTY; - } - else if (!this.moveItemStackTo(item, INVENTORY_START, HOTBAR_START, false)) + } else if (!this.moveItemStackTo(item, INVENTORY_START, HOTBAR_START, false)) return ItemStack.EMPTY; } } @@ -237,57 +205,49 @@ public class RecipeBookTestMenu extends RecipeBookMenu //RecipeBook stuff @Override - public void fillCraftSlotsStackedContents(StackedContents contents) - { + public void fillCraftSlotsStackedContents(StackedContents contents) { this.container.fillStackedContents(contents); } @Override - public void clearCraftingContent() - { + public void clearCraftingContent() { this.container.clearContent(); this.resultContainer.clearContent(); } @Override - public boolean recipeMatches(Recipe recipe) - { - return recipe.matches(this.container, this.player.level()); + public boolean recipeMatches(RecipeHolder> recipe) { + return recipe.value().matches(this.container, this.player.level()); } @Override - public int getResultSlotIndex() - { + public int getResultSlotIndex() { return RESULT_SLOT; } @Override - public int getGridWidth() - { + public int getGridWidth() { return 2; } @Override - public int getGridHeight() - { + public int getGridHeight() { return 4; } @Override - public int getSize() - { + public int getSize() { return 9; } @Override - public RecipeBookType getRecipeBookType() - { + public RecipeBookType getRecipeBookType() { return RecipeBookExtensionTest.TEST_TYPE; } @Override - public boolean shouldMoveToInventory(int slotIdx) - { + public boolean shouldMoveToInventory(int slotIdx) { return slotIdx != RESULT_SLOT; } } +*/ diff --git a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestRecipe.java b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestRecipe.java index f4f5207d23..f65339d024 100644 --- a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestRecipe.java +++ b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestRecipe.java @@ -5,6 +5,7 @@ package net.minecraftforge.debug.recipe.recipebook; +/* import com.google.common.collect.ImmutableList; import com.google.gson.JsonElement; import com.mojang.serialization.Codec; @@ -14,6 +15,8 @@ import com.mojang.serialization.JsonOps; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.NonNullList; import net.minecraft.core.RegistryAccess; +import net.minecraft.nbt.NbtOps; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -24,6 +27,7 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.debug.recipe.recipebook.RecipeBookTestRecipe.Ingredients; import java.util.*; import java.util.function.Function; @@ -31,17 +35,15 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -public class RecipeBookTestRecipe implements Recipe -{ - public final ResourceLocation id; +import org.jetbrains.annotations.Nullable; + +public class RecipeBookTestRecipe implements Recipe { public final Ingredients ingredients; private final int width; private final int height; private final NonNullList items; - public RecipeBookTestRecipe(ResourceLocation id, Ingredients ingredients) - { - this.id = id; + public RecipeBookTestRecipe(Ingredients ingredients) { this.ingredients = ingredients; this.width = ingredients.pattern.get(0).length(); this.height = ingredients.pattern.size(); @@ -55,35 +57,25 @@ public class RecipeBookTestRecipe implements Recipe= 0 && curY >= 0 && curX < this.width && curY < this.height) - { + + if (curX >= 0 && curY >= 0 && curX < this.width && curY < this.height) { int idx = mirror ? this.width - curX - 1 + curY * this.width : curX + curY * this.width; ingredient = this.items.get(idx); } @@ -97,56 +89,42 @@ public class RecipeBookTestRecipe implements Recipe getSerializer() - { + public RecipeSerializer getSerializer() { return RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_SERIALIZER.get(); } @Override - public RecipeType getType() - { + public RecipeType getType() { return RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(); } @Override - public String getGroup() - { + public String getGroup() { return this.ingredients.group; } @Override - public NonNullList getIngredients() - { + public NonNullList getIngredients() { return this.items; } @Override - public boolean isIncomplete() - { + public boolean isIncomplete() { return this.getIngredients().isEmpty() || this.getIngredients().stream() .filter((ingredient) -> !ingredient.isEmpty()) @@ -154,37 +132,31 @@ public class RecipeBookTestRecipe implements Recipe pattern, Map recipe, ItemStack result) - { - private static final Function> VERIFY_LENGTH_2 = s -> s.length() == 2 ? DataResult.success(s) : - DataResult.error(() -> "Key row length must be of 2!"); - private static final Function, DataResult>> VERIFY_SIZE = l -> - { - if (l.size() <= 4 && l.size() >= 1) - { + public record Ingredients(String group, List pattern, Map recipe, ItemStack result) { + private static final Function> VERIFY_LENGTH_1 = + s -> s.length() == 1 ? DataResult.success(s) : DataResult.error(() -> "Key must be a single character!"); + + private static final Function> VERIFY_LENGTH_2 = + s -> s.length() == 2 ? DataResult.success(s) : DataResult.error(() -> "Key row length must be of 2!"); + + private static final Function, DataResult>> VERIFY_SIZE = l -> { + if (l.size() <= 4 && l.size() >= 1) { List temp = new ArrayList<>(l); Collections.reverse(temp); //reverse so the first row is at the bottom in the json. return DataResult.success(ImmutableList.copyOf(temp)); } return DataResult.error(() -> "Pattern must have between 1 and 4 rows of keys"); }; - private static final Function> VERIFY_LENGTH_1 = s -> s.length() == 1 ? DataResult.success(s) : - DataResult.error(() -> "Key must be a single character!"); - public static final Codec INGREDIENT_CODEC = Codec.PASSTHROUGH.comapFlatMap(obj -> - { + public static final Codec INGREDIENT_CODEC = Codec.PASSTHROUGH.comapFlatMap(obj -> { JsonElement json = obj.convert(JsonOps.INSTANCE).getValue(); - try - { + try { return DataResult.success(Ingredient.fromJson(json)); - } - catch (Exception e) - { + } catch (Exception e) { return DataResult.error(() -> "Failed to parse ingredient: " + e.getMessage()); } }, ingredient -> new Dynamic<>(JsonOps.INSTANCE, ingredient.toJson())); @@ -198,4 +170,23 @@ public class RecipeBookTestRecipe implements Recipe { + @Override + public void toNetwork(FriendlyByteBuf buffer, RecipeBookTestRecipe recipe) { + buffer.writeWithCodec(NbtOps.INSTANCE, Ingredients.CODEC, recipe.ingredients); + } + + @Override + public Codec codec() { + return CODEC; + } + + @Override + public @Nullable RecipeBookTestRecipe fromNetwork(FriendlyByteBuf buf) { + Ingredients ingredients = buf.readWithCodec(NbtOps.INSTANCE, Ingredients.CODEC); + return new RecipeBookTestRecipe(ingredients); + } + } } +*/ \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestRecipeSerializer.java b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestRecipeSerializer.java deleted file mode 100644 index d589925536..0000000000 --- a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestRecipeSerializer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.debug.recipe.recipebook; - -import com.google.gson.JsonObject; -import com.mojang.serialization.JsonOps; -import net.minecraft.nbt.NbtOps; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraftforge.debug.recipe.recipebook.RecipeBookTestRecipe.Ingredients; -import org.jetbrains.annotations.Nullable; - -public class RecipeBookTestRecipeSerializer implements RecipeSerializer -{ - @Override - public RecipeBookTestRecipe fromJson(ResourceLocation id, JsonObject json) - { - Ingredients ingredients = Ingredients.CODEC.parse(JsonOps.INSTANCE, json).getOrThrow(false, s->{}); - return new RecipeBookTestRecipe(id, ingredients); - } - - @Nullable - @Override - public RecipeBookTestRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) - { - Ingredients ingredients = buf.readWithCodec(NbtOps.INSTANCE, Ingredients.CODEC); - return new RecipeBookTestRecipe(id, ingredients); - } - - @Override - public void toNetwork(FriendlyByteBuf buffer, RecipeBookTestRecipe recipe) - { - buffer.writeWithCodec(NbtOps.INSTANCE, Ingredients.CODEC, recipe.ingredients); - } -} diff --git a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java index 6395ceb02b..9de3cd8a48 100644 --- a/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java +++ b/src/test/java/net/minecraftforge/debug/recipe/recipebook/RecipeBookTestScreen.java @@ -4,9 +4,8 @@ */ package net.minecraftforge.debug.recipe.recipebook; - +/* import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -21,57 +20,45 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.ClickType; import net.minecraft.world.inventory.Slot; -/** - * Mostly copied from {@link CraftingScreen} - */ -public class RecipeBookTestScreen extends AbstractContainerScreen implements RecipeUpdateListener -{ +// Mostly copied from {@link CraftingScreen} +public class RecipeBookTestScreen extends AbstractContainerScreen implements RecipeUpdateListener { private static final ResourceLocation TEXTURE = RecipeBookExtensionTest.getId("textures/gui/container/recipe_book_test.png"); - private static final ResourceLocation RECIPE_BUTTON_LOCATION = new ResourceLocation("textures/gui/recipe_button.png"); private final RecipeBookComponent recipeBookComponent = new RecipeBookComponent(); private boolean widthTooNarrow; - public RecipeBookTestScreen(RecipeBookTestMenu menu, Inventory inv, Component title) - { + public RecipeBookTestScreen(RecipeBookTestMenu menu, Inventory inv, Component title) { super(menu, inv, title); } @Override - protected void init() - { + protected void init() { super.init(); this.widthTooNarrow = this.width < 379; this.titleLabelX = this.imageWidth - this.font.width(Language.getInstance().getVisualOrder(this.title)) - 5; this.recipeBookComponent.init(this.width, this.height, this.minecraft, this.widthTooNarrow, this.menu); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - this.addRenderableWidget(new ImageButton(this.leftPos + 5, this.height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_LOCATION, (button) -> - { + this.addRenderableWidget(new ImageButton(this.leftPos + 5, this.height / 2 - 49, 20, 18, RecipeBookComponent.RECIPE_BUTTON_SPRITES, (button) -> { this.recipeBookComponent.toggleVisibility(); this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth); - ((ImageButton)button).setPosition(this.leftPos + 5, this.height / 2 - 49); + button.setPosition(this.leftPos + 5, this.height / 2 - 49); })); this.addWidget(this.recipeBookComponent); this.setInitialFocus(this.recipeBookComponent); } @Override - protected void containerTick() - { + protected void containerTick() { super.containerTick(); this.recipeBookComponent.tick(); } @Override - public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - { - this.renderBackground(graphics); - if (this.recipeBookComponent.isVisible() && this.widthTooNarrow) - { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(graphics, mouseX, mouseY, partialTicks); + if (this.recipeBookComponent.isVisible() && this.widthTooNarrow) { this.renderBg(graphics, partialTicks, mouseX, mouseY); this.recipeBookComponent.render(graphics, mouseX, mouseY, partialTicks); - } - else - { + } else { this.recipeBookComponent.render(graphics, mouseX, mouseY, partialTicks); super.render(graphics, mouseX, mouseY, partialTicks); this.recipeBookComponent.renderGhostRecipe(graphics, this.leftPos, this.topPos, true, partialTicks); @@ -81,59 +68,49 @@ public class RecipeBookTestScreen extends AbstractContainerScreen= (double)(x + this.imageWidth) || mouseY >= (double)(y + this.imageHeight); return flag && this.recipeBookComponent.hasClickedOutside(mouseX, mouseY, this.leftPos, this.topPos, this.imageWidth, this.imageHeight, buttonIdx); } - protected void slotClicked(Slot slot, int mouseX, int mouseY, ClickType clickType) - { + protected void slotClicked(Slot slot, int mouseX, int mouseY, ClickType clickType) { super.slotClicked(slot, mouseX, mouseY, clickType); this.recipeBookComponent.slotClicked(slot); } @Override - public void recipesUpdated() - { + public void recipesUpdated() { this.recipeBookComponent.recipesUpdated(); } @Override - public RecipeBookComponent getRecipeBookComponent() - { + public RecipeBookComponent getRecipeBookComponent() { return this.recipeBookComponent; } } +*/ diff --git a/src/test/java/net/minecraftforge/debug/world/LoginPacketSplitTest.java b/src/test/java/net/minecraftforge/debug/world/LoginPacketSplitTest.java index a608c05d6f..2d3b3a1ac8 100644 --- a/src/test/java/net/minecraftforge/debug/world/LoginPacketSplitTest.java +++ b/src/test/java/net/minecraftforge/debug/world/LoginPacketSplitTest.java @@ -19,7 +19,6 @@ import net.minecraft.commands.Commands; import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; import net.minecraft.core.RegistryCodecs; -import net.minecraft.nbt.NbtOps; import net.minecraft.network.CompressionDecoder; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -29,6 +28,7 @@ import net.minecraft.server.packs.PackResources; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.metadata.MetadataSectionSerializer; import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.Pack.Info; import net.minecraft.server.packs.repository.PackSource; import net.minecraft.server.packs.resources.IoSupplier; import net.minecraft.util.GsonHelper; @@ -87,12 +87,23 @@ public class LoginPacketSplitTest if (event.getPackType() == PackType.SERVER_DATA) { final InMemoryResourcePack pack = new InMemoryResourcePack("virtual_bigdata"); + final var supplier = new Pack.ResourcesSupplier() { + @Override + public PackResources openPrimary(String p_298664_) { + return pack; + } + + @Override + public PackResources openFull(String p_251717_, Info p_298253_) { + return pack; + } + }; generateEntries(pack); event.addRepositorySource(packs -> packs.accept(Pack.readMetaAndCreate( pack.id, Component.literal("Pack containing big datapack registries"), true, - s -> pack, + supplier, PackType.SERVER_DATA, Pack.Position.TOP, PackSource.BUILT_IN diff --git a/src/test/java/net/minecraftforge/mdk/MdkDatagen.java b/src/test/java/net/minecraftforge/mdk/MdkDatagen.java index 1c90b08351..63f820bfd7 100644 --- a/src/test/java/net/minecraftforge/mdk/MdkDatagen.java +++ b/src/test/java/net/minecraftforge/mdk/MdkDatagen.java @@ -14,9 +14,7 @@ import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import java.util.Arrays; -import java.util.function.Function; -import java.util.stream.Collectors; +import java.util.Optional; @Mod(MdkDatagen.MOD_ID) public class MdkDatagen @@ -33,11 +31,11 @@ public class MdkDatagen var gen = event.getGenerator(); var packOutput = gen.getPackOutput(); gen.addProvider(true, new PackMetadataGenerator(packOutput) - .add(PackMetadataSection.TYPE, new PackMetadataSection( - Component.literal("${mod_id} resources"), - DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES), - Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion)) - )) + .add(PackMetadataSection.TYPE, new PackMetadataSection( + Component.literal("${mod_id} resources"), + DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES), + Optional.empty() + )) ); } }